1
0
Fork 0

When searching for nav records ignore stations > 300nm away.

This commit is contained in:
curt 2004-06-20 18:58:44 +00:00
parent 2bcec1fbbc
commit 258cd292c6
3 changed files with 13 additions and 18 deletions

View file

@ -613,9 +613,9 @@ void FGNavCom::search()
gs = globals->get_gslist()->findByFreq(nav_freq, lon, lat, elev); gs = globals->get_gslist()->findByFreq(nav_freq, lon, lat, elev);
} }
if ( loc != NULL ) { if ( loc != NULL ) {
nav_id = loc->get_ident(); nav_id = loc->get_ident();
// cout << "localizer = " << nav_id << endl;
nav_valid = true; nav_valid = true;
if ( last_nav_id != nav_id || last_nav_vor ) { if ( last_nav_id != nav_id || last_nav_vor ) {
nav_trans_ident = loc->get_trans_ident(); nav_trans_ident = loc->get_trans_ident();
@ -701,6 +701,7 @@ void FGNavCom::search()
} }
} else if ( nav != NULL ) { } else if ( nav != NULL ) {
nav_id = nav->get_ident(); nav_id = nav->get_ident();
// cout << "nav = " << nav_id << endl;
nav_valid = true; nav_valid = true;
if ( last_nav_id != nav_id || !last_nav_vor ) { if ( last_nav_id != nav_id || !last_nav_vor ) {
last_nav_id = nav_id; last_nav_id = nav_id;

View file

@ -182,31 +182,24 @@ FGNavRecord *FGNavList::findNavFromList( const Point3D &aircraft,
{ {
FGNavRecord *nav = NULL; FGNavRecord *nav = NULL;
Point3D station; Point3D station;
double d2; double dist;
double min_dist = 999999999.0; double min_dist = FG_NAV_MAX_RANGE * SG_NM_TO_METER;
// prime the pump with info from stations[0] // find the closest station within a sensible range (FG_NAV_MAX_RANGE)
if ( stations.size() > 0 ) { for ( unsigned int i = 0; i < stations.size(); ++i ) {
nav = stations[0];
station = Point3D( nav->get_x(), nav->get_y(), nav->get_z());
min_dist = aircraft.distance3Dsquared( station );
}
// check if any of the remaining stations are closer
for ( unsigned int i = 1; i < stations.size(); ++i ) {
// cout << "testing " << current->get_ident() << endl; // cout << "testing " << current->get_ident() << endl;
station = Point3D( stations[i]->get_x(), station = Point3D( stations[i]->get_x(),
stations[i]->get_y(), stations[i]->get_y(),
stations[i]->get_z() ); stations[i]->get_z() );
d2 = aircraft.distance3Dsquared( station ); dist = aircraft.distance3D( station );
// cout << " dist = " << sqrt(d) // cout << " dist = " << sqrt(d)
// << " range = " << current->get_range() * SG_NM_TO_METER // << " range = " << current->get_range() * SG_NM_TO_METER
// << endl; // << endl;
if ( d2 < min_dist ) { if ( dist < min_dist ) {
min_dist = d2; min_dist = dist;
nav = stations[i]; nav = stations[i];
} }
} }

View file

@ -43,9 +43,10 @@
SG_USING_STD(istream); SG_USING_STD(istream);
#define FG_NAV_DEFAULT_RANGE 50 #define FG_NAV_DEFAULT_RANGE 50 // nm
#define FG_LOC_DEFAULT_RANGE 18 #define FG_LOC_DEFAULT_RANGE 18 // nm
#define FG_DME_DEFAULT_RANGE 50 #define FG_DME_DEFAULT_RANGE 50 // nm
#define FG_NAV_MAX_RANGE 300 // nm
class FGNavRecord { class FGNavRecord {