-// Searches for the closest airport whose Manhattan distance to
-// @lat,@lon is inferior to @min_manhattan_distance (expressed in
-// degrees) and for which @test_airport returns true. Returns NULL if
-// no airport was found.
-template <class C>
-static const FGAirport *
-get_closest_airport (double lat,
- double lon,
- double min_manhattan_distance,
- C &obj,
- bool (C::*test_airport) (const FGAirport *))
-{
- const FGAirport *airport = NULL;
- const airport_list *airport_list = globals->get_airports()->getAirportList();
-
- for (size_t i = 0; i < airport_list->size(); i++)
- {
- const FGAirport *a = (*airport_list)[i];
- double dist = fabs(lat - a->getLatitude()) + fabs(lon - a->getLongitude());
- if (dist < min_manhattan_distance && (obj.*test_airport)(a))
- {
- airport = a;
- min_manhattan_distance = dist;
- }
- }
-
- return airport;
-}
-