- const FGAirport* a = globals->get_airports()
- ->search( longitude->getDoubleValue(),
- latitude->getDoubleValue(),
- 360.0,
- metar_only );
- if ( a ) {
- FGMetarResult result = fetch_data( a->getId() );
- if ( result.m != NULL ) {
- SG_LOG( SG_GENERAL, SG_INFO, "closest station w/ metar = "
- << a->getId());
- last_apt = a;
- _icao = a->getId();
- search_elapsed = 0.0;
- fetch_elapsed = 0.0;
- update_metar_properties( result.m );
- update_env_config();
- env->init();
- found_metar = true;
- } else {
- // mark as no metar so it doesn't show up in subsequent
- // searches.
- SG_LOG( SG_GENERAL, SG_INFO, "no metar at metar = "
- << a->getId() );
- globals->get_airports()->no_metar( a->getId() );
- }
+ AirportWithMetar filter;
+ FGAirport* a = FGAirport::findClosest(pos, 10000.0, &filter);
+ if (!a) {
+ break;