- if ( ! globals->get_runways()->search( id, (int)tgt_hdg, &r ) ) {
- SG_LOG( SG_GENERAL, SG_ALERT,
- "Failed to find a good runway for " << id << '\n' );
- return false;
- }
- fgSetString("/sim/atc/runway", r._rwy_no.c_str());
-
- double lat2, lon2, az2;
- double heading = r._heading;
- double azimuth = heading + 180.0;
- while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
-
- SG_LOG( SG_GENERAL, SG_INFO,
- "runway = " << r._lon << ", " << r._lat
- << " length = " << r._length * SG_FEET_TO_METER
- << " heading = " << azimuth );
-
- geo_direct_wgs_84 ( 0, r._lat, r._lon, azimuth, r._length * SG_FEET_TO_METER * 0.5
- - fgGetDouble("/sim/airport/runways/start-offset-m", 5.0),
- &lat2, &lon2, &az2 );
-
- if ( fabs( fgGetDouble("/sim/presets/offset-distance-nm") ) > SG_EPSILON ) {
- double olat, olon;
- double odist = fgGetDouble("/sim/presets/offset-distance-nm");
- odist *= SG_NM_TO_METER;
- double oaz = azimuth;
- if ( fabs(fgGetDouble("/sim/presets/offset-azimuth-deg")) > SG_EPSILON ) {
- oaz = fgGetDouble("/sim/presets/offset-azimuth-deg") + 180;
- heading = tgt_hdg;
- }
- while ( oaz >= 360.0 ) { oaz -= 360.0; }
- geo_direct_wgs_84 ( 0, lat2, lon2, oaz, odist, &olat, &olon, &az2 );
- lat2=olat;
- lon2=olon;
- }
-
- // presets
- fgSetDouble("/sim/presets/longitude-deg", lon2 );
- fgSetDouble("/sim/presets/latitude-deg", lat2 );
- fgSetDouble("/sim/presets/heading-deg", heading );
-
- // other code depends on the actual values being set ...
- fgSetDouble("/position/longitude-deg", lon2 );
- fgSetDouble("/position/latitude-deg", lat2 );
- fgSetDouble("/orientation/heading-deg", heading );