-
- double az1, az2, s;
- SGGeodesy::inverse(aGeod, aNav->geod(), az1, az2, s);
- az1 = az1 - hdg_deg;
- SG_NORMALIZE_RANGE(az1, -180.0, 180.0);
- return fabs(az1) > 90.0;
-}
-
-// Given a point and a list of stations, return the closest one to the
-// specified point.
-FGNavRecord *FGNavList::findNavFromList( const SGGeod &aircraft,
- const nav_list_type &stations )
-{
- FGNavRecord *nav = NULL;
- double d2; // in meters squared
- double min_dist
- = FG_NAV_MAX_RANGE*SG_NM_TO_METER*FG_NAV_MAX_RANGE*SG_NM_TO_METER;
- SGVec3d aircraftCart = SGVec3d::fromGeod(aircraft);
-
- nav_list_const_iterator it;
- nav_list_const_iterator end = stations.end();
- // find the closest station within a sensible range (FG_NAV_MAX_RANGE)
- for ( it = stations.begin(); it != end; ++it ) {
- FGNavRecord *station = *it;
- // cout << "testing " << current->get_ident() << endl;
- d2 = distSqr(station->cart(), aircraftCart);
- if ( d2 < min_dist && penaltyForNav(station, aircraft))
- {
- double dist = sqrt(d2);
- d2 = (dist + 5000) * (dist + 5000);
- }
-
- if ( d2 < min_dist ) {
- min_dist = d2;
- nav = station;
- }
+
+ BOOST_FOREACH(PositionedID id, stations) {
+ FGNavRecordRef station = FGPositioned::loadById<FGNavRecord>(id);
+ if (filter->pass(station)) {
+ return station;