X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FNavaids%2Filslist.cxx;h=3bed2ed943f8597653e508a4ab5e0028b9b5ec00;hb=cbaf01548180f2dcaafd04676c4832b7297abc27;hp=8c43d7c647766a0bc503d0879443517e521b8c8b;hpb=8f1c10a746108369cbeb3aad9ac067b765974ce6;p=flightgear.git diff --git a/src/Navaids/ilslist.cxx b/src/Navaids/ilslist.cxx index 8c43d7c64..3bed2ed94 100644 --- a/src/Navaids/ilslist.cxx +++ b/src/Navaids/ilslist.cxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include "ilslist.hxx" @@ -61,10 +61,10 @@ bool FGILSList::init( FGPath path ) { #ifdef __MWERKS__ char c = 0; - while ( in.get(c) && c != '\0' && n.get_ilstype() != '[' ) { + while ( in.get(c) && c != '\0' && ils.get_ilstype() != '[' ) { in.putback(c); in >> ils; - if ( ils.get_type() != '[' ) { + if ( ils.get_ilstype() != '[' ) { ilslist[ils.get_locfreq()].push_back(ils); } in >> skipcomment; @@ -72,6 +72,9 @@ bool FGILSList::init( FGPath path ) { #else + double min = 1000000.0; + double max = 0.0; + while ( ! in.eof() && ils.get_ilstype() != '[' ) { in >> ils; /* cout << "id = " << n.get_ident() << endl; @@ -85,8 +88,18 @@ bool FGILSList::init( FGPath path ) { ilslist[ils.get_locfreq()].push_back(ils); } in >> skipcomment; + + if ( ils.get_locfreq() < min ) { + min = ils.get_locfreq(); + } + if ( ils.get_locfreq() > max ) { + max = ils.get_locfreq(); + } } + // cout << "min freq = " << min << endl; + // cout << "max freq = " << max << endl; + #endif return true; @@ -96,24 +109,35 @@ bool FGILSList::init( FGPath path ) { // query the database for the specified frequency, lon and lat are in // degrees, elev is in meters bool FGILSList::query( double lon, double lat, double elev, double freq, - FGILS *ils, double *heading, double *dist ) + FGILS *ils ) { ils_list_type stations = ilslist[(int)(freq*100.0 + 0.5)]; ils_list_iterator current = stations.begin(); ils_list_iterator last = stations.end(); - double az1, az2, s; + // double az1, az2, s; + Point3D aircraft = sgGeodToCart( Point3D(lon, lat, elev) ); + Point3D station; + double d; for ( ; current != last ; ++current ) { - // cout << "testing " << current->get_ident() << endl; - geo_inverse_wgs_84( elev, lat, lon, - current->get_loclat(), current->get_loclon(), - &az1, &az2, &s ); + // cout << " testing " << current->get_locident() << endl; + station = Point3D(current->get_x(), + current->get_y(), + current->get_z()); + // cout << " aircraft = " << aircraft << " station = " << station + // << endl; + + d = aircraft.distance3Dsquared( station ); + // cout << " distance = " << d << " (" + // << FG_ILS_DEFAULT_RANGE * NM_TO_METER + // * FG_ILS_DEFAULT_RANGE * NM_TO_METER + // << ")" << endl; + // cout << " dist = " << s << endl; - if ( s < ( FG_ILS_DEFAULT_RANGE * NM_TO_METER ) ) { + if ( d < (FG_ILS_DEFAULT_RANGE * NM_TO_METER + * FG_ILS_DEFAULT_RANGE * NM_TO_METER) ) { *ils = *current; - *heading = az2; - *dist = s; return true; } }