- // check for airport id
- const FGAirport *apt = fgFindAirportID( target );
- if (apt) {
- SG_LOG( SG_GENERAL, SG_INFO, "Adding waypoint (airport) = " << target );
- *wp = new SGWayPoint( apt->getLongitude(), apt->getLatitude(), alt, SGWayPoint::WGS84, target );
- return 2;
- }
-
- // check for fix id
- FGFix f;
- if ( globals->get_fixlist()->query( target, &f ) ) {
- SG_LOG( SG_GENERAL, SG_INFO, "Adding waypoint (fix) = " << target );
- *wp = new SGWayPoint( f.get_lon(), f.get_lat(), alt, SGWayPoint::WGS84, target );
- return 3;
- }
-
- // Try finding a nav matching the ID
- double lat, lon;
- // The base lon/lat are determined by the last WP,
- // or the current pos if the WP list is empty.
- const int wps = this->size();
-
- if (wps > 0) {
- SGWayPoint wp = get_waypoint(wps-1);
- lat = wp.get_target_lat();
- lon = wp.get_target_lon();
+ SGGeod basePosition;
+ if (route->size() > 0) {
+ SGWayPoint wp = get_waypoint(route->size()-1);
+ basePosition = SGGeod::fromDeg(wp.get_target_lon(), wp.get_target_lat());