From fe22475260cfe7a093c2ecf52ee6fc5fcb8dcbc9 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 30 Oct 2001 17:45:11 +0000 Subject: [PATCH] Alasdair Campbell's ILS patch allowing us to fly both ILS approaches if both ends of the same runway share the same frequency. This is probably the best we can do until we impliment some sort of operator interface to manually set which end is active (like is done in real life.) --- src/Navaids/ilslist.cxx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Navaids/ilslist.cxx b/src/Navaids/ilslist.cxx index cf8c9e55f..eb9247f0a 100644 --- a/src/Navaids/ilslist.cxx +++ b/src/Navaids/ilslist.cxx @@ -162,8 +162,27 @@ bool FGILSList::query( double lon, double lat, double elev, double freq, // reduced signal strength if ( d < (2* FG_ILS_DEFAULT_RANGE * SG_NM_TO_METER * 2 * FG_ILS_DEFAULT_RANGE * SG_NM_TO_METER) ) { - *ils = *current; - return true; + + // Get our bearing from this station. + double reciprocal_bearing, dummy; + double a_lat_deg = lat * SGD_RADIANS_TO_DEGREES; + double a_lon_deg = lon * SGD_RADIANS_TO_DEGREES; + // Locator beam direction + double s_ils_deg = current->get_locheading() - 180.0; + if ( s_ils_deg < 0.0 ) { s_ils_deg += 360.0; } + double angle_to_beam_deg; + + // printf("**ALI geting geo_inverse_wgs_84 with elev = %.2f, a.lat = %.2f, a.lon = %.2f, + // s.lat = %.2f, s.lon = %.2f\n", elev,a_lat_deg,a_lon_deg,current->get_loclat(),current->get_loclon()); + + geo_inverse_wgs_84( elev, current->get_loclat(), + current->get_loclon(), a_lat_deg, a_lon_deg, + &reciprocal_bearing, &dummy, &dummy ); + angle_to_beam_deg = fabs(reciprocal_bearing - s_ils_deg); + if ( angle_to_beam_deg < 90.0 ) { + *ils = *current; + return true; + } } } -- 2.39.5