This patch should fix the problem with src/Navaids/navlist.cxx  choosing
the wrong localizer on a runway with localizers at each end on the same
frequency. [There seems to be quite a few in the UK like this, EGLL,
EGLC, EGSS]. Selecting the autopilot 'LOC' without this patch causes
planes to turn round and flu away from the intended destination. 

I have arbitrarily chosen a +/- 30 degree window for selection because
this seems reasonable if in reality its smaller then OK. 

-- 
Ed Sirett <[EMAIL PROTECTED]>


21c21
< // $Id: navlist.cxx,v 1.6 2004/06/20 18:58:45 curt Exp $
---
> // $Id: navlist.cxx,v 1.5 2004/05/28 05:24:54 curt Exp $
185,186c185,187
<     double dist;
<     double min_dist = FG_NAV_MAX_RANGE * SG_NM_TO_METER;
---
>     double d2;
>     double min_dist = FG_NAV_MAX_RANGE*SG_NM_TO_METER *
FG_NAV_MAX_RANGE*SG_NM_TO_METER ; 
>                               
188c189
<     // find the closest station within a sensible range
(FG_NAV_MAX_RANGE)
---
>     // check if any of the remaining stations are closer
195c196
<       dist = aircraft.distance3D( station );
---
>       d2 = aircraft.distance3Dsquared( station );
201,202c202,221
<         if ( dist < min_dist ) {
<             min_dist = dist;
---
>         // LOC or ILS must point substantially toward the aircraft
>       // This is to stop finding the nearer LOC/ILS transmitter which is
facing away from the a/c
>       // make this expensive check only when needed 
>       if ( d2 < min_dist && (stations[i]->get_type() == 4 ||
stations[i]->get_type() == 5)) {
>               double az1=0.0, az2=0.0, s=0.0;
>               double elev=0.0, lati=0.0, longi=0.0;
>               double xyz[3] = {aircraft.x(), aircraft.y(), aircraft.z()};
>               sgCartToGeod(xyz, &lati, &longi, &elev);
>               geo_inverse_wgs_84(elev, lati * SG_RADIANS_TO_DEGREES, longi *
SG_RADIANS_TO_DEGREES,
>                                  stations[i]->get_lat() , stations[i]->get_lon() ,
>                                  &az1, &az2, &s);      
>               az1 = az1-stations[i]->get_multiuse();
>               while (az1>  180.0) az1 -= 360.0;
>               while (az1< -180.0) az1 += 360.0;
>               // make d2 fail test if not pointing the right way.
>               if (fabs(az1) > 30.0 ) d2 = min_dist+1.0;
>               }
> 
>         if ( d2 < min_dist ) {
>             min_dist = d2;
206d224
< 




_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to