1
0
Fork 0

If a non existant runway is specified with --runway=xxx fall back to

finding the runway that is the closest match to the specified (or default)
heading.
This commit is contained in:
curt 2002-11-17 04:17:27 +00:00
parent 13bb01a70e
commit 8f3a988e0e

View file

@ -752,6 +752,7 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy ) {
FGRunway found_r;
double heading = 0.0;
string runway;
bool match = false;
// standardize input number
string tmp = rwy.substr(1, 1);
@ -785,6 +786,7 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy ) {
if ( r.rwy_no == runway ) {
found_r = r;
heading = r.heading;
match = true;
SG_LOG( SG_GENERAL, SG_INFO,
"Runway " << r.rwy_no << " heading = " << heading );
}
@ -827,6 +829,7 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy ) {
found_r = r;
heading = r.heading + 180;
while ( heading > 360.0 ) { heading -= 360; }
match = true;
SG_LOG( SG_GENERAL, SG_INFO,
"Runway " << r.rwy_no << " heading = " << heading );
}
@ -837,6 +840,7 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy ) {
return false;
}
if ( match ) {
double lat2, lon2, az2;
double azimuth = heading + 180.0;
while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
@ -847,15 +851,18 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy ) {
<< " heading = " << azimuth );
geo_direct_wgs_84 ( 0, found_r.lat, found_r.lon,
azimuth, found_r.length * SG_FEET_TO_METER * 0.5 - 5.0,
azimuth,
found_r.length * SG_FEET_TO_METER * 0.5 - 5.0,
&lat2, &lon2, &az2 );
if ( fabs( fgGetDouble("/sim/presets/offset-distance") ) > SG_EPSILON ) {
if ( fabs( fgGetDouble("/sim/presets/offset-distance") ) > SG_EPSILON )
{
double olat, olon;
double odist = fgGetDouble("/sim/presets/offset-distance");
odist *= SG_NM_TO_METER;
double oaz = azimuth;
if ( fabs(fgGetDouble("/sim/presets/offset-azimuth")) > SG_EPSILON ) {
if ( fabs(fgGetDouble("/sim/presets/offset-azimuth")) > SG_EPSILON )
{
oaz = fgGetDouble("/sim/presets/offset-azimuth") + 180;
}
while ( oaz >= 360.0 ) { oaz -= 360.0; }
@ -881,6 +888,9 @@ static bool fgSetPosFromAirportIDandRwy( const string& id, const string& rwy ) {
<< heading );
return true;
} else {
return false;
}
}