        velocity_filter.update(locationd_velocity.getValue()[0]);
      }
    }
  
    // TODO should check a valid/status flag
    if (sm.updated("gnssMeasurements") && sm["gnssMeasurements"].getGnssMeasurements().getGpsWeek() > 0){
      auto laikad_location = sm["gnssMeasurements"].getGnssMeasurements();
      auto laikad_pos = laikad_location.getPositionECEF();
      auto laikad_pos_ecef = laikad_pos.getValue();
      auto laikad_pos_std = laikad_pos.getStd();
      auto laikad_velocity_ecef = laikad_location.getVelocityECEF().getValue();
  
      laikad_valid = laikad_pos.getValid() && Eigen::Vector3d(laikad_pos_std[0], laikad_pos_std[1], laikad_pos_std[2]).norm() < VALID_POS_STD;
  
      if (laikad_valid && !locationd_valid) {
        ECEF ecef = {.x = laikad_pos_ecef[0], .y = laikad_pos_ecef[1], .z = laikad_pos_ecef[2]};
        Geodetic laikad_pos_geodetic = ecef2geodetic(ecef);
        last_position = QMapbox::Coordinate(laikad_pos_geodetic.lat, laikad_pos_geodetic.lon);
  
        // Compute NED velocity
        LocalCoord converter(ecef);
        ECEF next_ecef = {.x = ecef.x + laikad_velocity_ecef[0], .y = ecef.y + laikad_velocity_ecef[1], .z = ecef.z + laikad_velocity_ecef[2]};
        Eigen::VectorXd ned_vel = converter.ecef2ned(next_ecef).to_vector() - converter.ecef2ned(ecef).to_vector();
  
        float velocity = ned_vel.norm();
        velocity_filter.update(velocity);
  
        // Convert NED velocity to angle
        if (velocity > 1.0) {
          float new_bearing = fmod(RAD2DEG(atan2(ned_vel[1], ned_vel[0])) + 360.0, 360.0);
          if (last_bearing) {
            float delta = 0.1 * angle_difference(*last_bearing, new_bearing); // Smooth heading
            last_bearing = fmod(*last_bearing + delta + 360.0, 360.0);
          } else {
            last_bearing = new_bearing;
          }
        }
      }
    }
  
    if (sm.updated("navRoute") && sm["navRoute"].getNavRoute().getCoordinates().size()) {
      qWarning() << "Got new navRoute from navd. Opening map:" << allow_open;
  
      // Only open the map on setting destination the first time
      if (allow_open) {
 
</s> remove const float VALID_POS_STD = 50.0; // m

 </s> add  </s> remove     "wideRoadCameraState", "managerState", "navInstruction", "navRoute", "gnssMeasurements",
    "uiPlan",
 </s> add     "wideRoadCameraState", "managerState", "navInstruction", "navRoute", "uiPlan",
        velocity_filter.update(locationd_velocity.getValue()[0]);
      }
    }
  




































    if (sm.updated("navRoute") && sm["navRoute"].getNavRoute().getCoordinates().size()) {
      qWarning() << "Got new navRoute from navd. Opening map:" << allow_open;
  
      // Only open the map on setting destination the first time
      if (allow_open) {
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Only trust locationd for nav (#27579)

* Only trust locationd for nav

* unused var 
selfdrive/ui/qt/maps/map.cc