-
-// search for first subsequent alphabetically to supplied id
-const FGAirport* FGAirportList::findFirstById( const string& id, bool exact )
-{
- airport_map_iterator itr;
- if (exact) {
- itr = airports_by_id.find(id);
- } else {
- itr = airports_by_id.lower_bound(id);
- }
- if (itr == airports_by_id.end()) {
- return (NULL);
- } else {
- return (itr->second);
- }
-}
-
-
-// search for the airport nearest the specified position
-FGAirport* FGAirportList::search(double lon_deg, double lat_deg)
-{
- static FGAirportSearchFilter accept_any;
- return search(lon_deg, lat_deg, accept_any);
-}
-
-
-// search for the airport nearest the specified position and
-// passing the filter
-FGAirport* FGAirportList::search(double lon_deg, double lat_deg,
- FGAirportSearchFilter& filter)
-{
- double min_dist = 360.0;
- airport_list_iterator it = airports_array.begin();
- airport_list_iterator end = airports_array.end();
- airport_list_iterator closest = end;
- for (; it != end; ++it) {
- if (!filter.pass(*it))
- continue;
-
- // crude manhatten distance based on lat/lon difference
- double d = fabs(lon_deg - (*it)->getLongitude())
- + fabs(lat_deg - (*it)->getLatitude());
- if (d < min_dist) {
- closest = it;
- min_dist = d;
- }
- }
- return closest != end ? *closest : 0;
-}
-
-