From 39cba9139c1fba14989b8f31775614307a3b493d Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 15 Apr 2002 17:53:05 +0000 Subject: [PATCH] Of all the ILS stations that match the specified frequency and are in range, return the one that is pointed most directly at us. --- src/Navaids/ilslist.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Navaids/ilslist.cxx b/src/Navaids/ilslist.cxx index 840195051..151c87b89 100644 --- a/src/Navaids/ilslist.cxx +++ b/src/Navaids/ilslist.cxx @@ -130,6 +130,9 @@ bool FGILSList::query( double lon, double lat, double elev, double freq, ils_list_iterator current = stations.begin(); ils_list_iterator last = stations.end(); + double best_angle = 362.0; + bool found_one = false; + // double az1, az2, s; Point3D aircraft = sgGeodToCart( Point3D(lon, lat, elev) ); Point3D station; @@ -155,9 +158,8 @@ bool FGILSList::query( double lon, double lat, double elev, double freq, if ( d < (2* FG_ILS_DEFAULT_RANGE * SG_NM_TO_METER * 2 * FG_ILS_DEFAULT_RANGE * SG_NM_TO_METER) ) { - *ils = *current; - return true; -#if 0 + found_one = true; + // Get our bearing from this station. double reciprocal_bearing, dummy; double a_lat_deg = lat * SGD_RADIANS_TO_DEGREES; @@ -174,13 +176,12 @@ bool FGILSList::query( double lon, double lat, double elev, double freq, 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 ) { + if ( angle_to_beam_deg <= best_angle ) { *ils = *current; - return true; + best_angle = angle_to_beam_deg; } -#endif } } - return false; + return found_one; } -- 2.39.5