When searching for nav records ignore stations > 300nm away.
This commit is contained in:
parent
2bcec1fbbc
commit
258cd292c6
3 changed files with 13 additions and 18 deletions
|
@ -613,9 +613,9 @@ void FGNavCom::search()
|
|||
gs = globals->get_gslist()->findByFreq(nav_freq, lon, lat, elev);
|
||||
}
|
||||
|
||||
|
||||
if ( loc != NULL ) {
|
||||
nav_id = loc->get_ident();
|
||||
// cout << "localizer = " << nav_id << endl;
|
||||
nav_valid = true;
|
||||
if ( last_nav_id != nav_id || last_nav_vor ) {
|
||||
nav_trans_ident = loc->get_trans_ident();
|
||||
|
@ -701,6 +701,7 @@ void FGNavCom::search()
|
|||
}
|
||||
} else if ( nav != NULL ) {
|
||||
nav_id = nav->get_ident();
|
||||
// cout << "nav = " << nav_id << endl;
|
||||
nav_valid = true;
|
||||
if ( last_nav_id != nav_id || !last_nav_vor ) {
|
||||
last_nav_id = nav_id;
|
||||
|
|
|
@ -182,31 +182,24 @@ FGNavRecord *FGNavList::findNavFromList( const Point3D &aircraft,
|
|||
{
|
||||
FGNavRecord *nav = NULL;
|
||||
Point3D station;
|
||||
double d2;
|
||||
double min_dist = 999999999.0;
|
||||
double dist;
|
||||
double min_dist = FG_NAV_MAX_RANGE * SG_NM_TO_METER;
|
||||
|
||||
// prime the pump with info from stations[0]
|
||||
if ( stations.size() > 0 ) {
|
||||
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 ) {
|
||||
// find the closest station within a sensible range (FG_NAV_MAX_RANGE)
|
||||
for ( unsigned int i = 0; i < stations.size(); ++i ) {
|
||||
// cout << "testing " << current->get_ident() << endl;
|
||||
station = Point3D( stations[i]->get_x(),
|
||||
stations[i]->get_y(),
|
||||
stations[i]->get_z() );
|
||||
|
||||
d2 = aircraft.distance3Dsquared( station );
|
||||
dist = aircraft.distance3D( station );
|
||||
|
||||
// cout << " dist = " << sqrt(d)
|
||||
// << " range = " << current->get_range() * SG_NM_TO_METER
|
||||
// << endl;
|
||||
|
||||
if ( d2 < min_dist ) {
|
||||
min_dist = d2;
|
||||
if ( dist < min_dist ) {
|
||||
min_dist = dist;
|
||||
nav = stations[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,9 +43,10 @@
|
|||
SG_USING_STD(istream);
|
||||
|
||||
|
||||
#define FG_NAV_DEFAULT_RANGE 50
|
||||
#define FG_LOC_DEFAULT_RANGE 18
|
||||
#define FG_DME_DEFAULT_RANGE 50
|
||||
#define FG_NAV_DEFAULT_RANGE 50 // nm
|
||||
#define FG_LOC_DEFAULT_RANGE 18 // nm
|
||||
#define FG_DME_DEFAULT_RANGE 50 // nm
|
||||
#define FG_NAV_MAX_RANGE 300 // nm
|
||||
|
||||
|
||||
class FGNavRecord {
|
||||
|
|
Loading…
Reference in a new issue