true_hdg_deg->setDoubleValue( wp_course );
double target_alt = wp.get_target_alt();
- // activate altitude lock only once per route (this can't be done in
- // new_waypoint() because the first wp might not have an altitude defined at all)
- if (!altitude_set && target_alt > -9990) {
+ if ( !altitude_set && target_alt > -9990 ) {
target_altitude_ft->setDoubleValue( target_alt * SG_METER_TO_FEET );
- altitude_lock->setStringValue( "altitude-hold" );
altitude_set = true;
+
+ if ( !on_ground() )
+ altitude_lock->setStringValue( "altitude-hold" );
}
if ( wp_distance < 200.0 ) {
void FGRouteMgr::add_waypoint( const SGWayPoint& wp, int n ) {
+ if ( n == 0 || !route->size() )
+ altitude_set = false;
+
route->add_waypoint( wp, n );
update_mirror();
}
wp0_eta->setStringValue( "" );
}
+ if ( n == 0 && route->size() )
+ altitude_set = false;
+
update_mirror();
return wp;
}
}
-
int FGRouteMgr::new_waypoint( const string& Tgt_Alt, int n ) {
string target = Tgt_Alt;
int type = make_waypoint( &wp, target );
if (wp) {
- fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
add_waypoint( *wp, n );
delete wp;
+
+ if ( !on_ground() )
+ fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
}
return type;
}
-
int FGRouteMgr::make_waypoint(SGWayPoint **wp, string& target) {
double alt = -9999.0;
}
// check for lon,lat
- pos = target.find(',');
+ pos = target.find( ',' );
if ( pos != string::npos ) {
double lon = atof( target.substr(0, pos).c_str());
double lat = atof( target.c_str() + pos + 1);
return 4;
}
- // target not identified
+ // unknown target
return 0;
}
}
+bool FGRouteMgr::on_ground() {
+ SGPropertyNode *gear = fgGetNode( "/gear/gear/wow", false );
+ if ( !gear || gear->getType() == SGPropertyNode::NONE )
+ return fgGetBool( "/sim/presets/onground", true );
+
+ return gear->getBoolValue();
+}
+
+
// command interface /autopilot/route-manager/input:
//
// @clear ... clear route