-
- _positionTimeToLive -= dt;
- _requestTimer -= dt;
-
- if( _positionTimeToLive <= 0.0 ) {
- // check nearest airport
- SG_LOG(SG_ENVIRONMENT, SG_INFO, "NoaaMetarRealWxController::update(): (re) checking nearby airport with METAR" );
- _positionTimeToLive = 60.0;
-
- SGGeod pos = SGGeod::fromDeg(_longitude_n->getDoubleValue(), _latitude_n->getDoubleValue());
-
- FGAirport * nearestAirport = FGAirport::findClosest(pos, 10000.0, MetarAirportFilter::instance() );
- if( nearestAirport == NULL ) {
- SG_LOG(SG_ENVIRONMENT,SG_WARN,"RealWxController::update can't find airport with METAR within 10000NM" );
- return;
- }
-
- SG_LOG(SG_ENVIRONMENT, SG_INFO,
- "NoaaMetarRealWxController::update(): nearest airport with METAR is: " << nearestAirport->ident() );
-
- // if it has changed, invalidate the associated METAR
- if( _metarProperties[0]->getStationId() != nearestAirport->ident() ) {
- SG_LOG(SG_ENVIRONMENT, SG_INFO,
- "NoaaMetarRealWxController::update(): nearest airport with METAR has changed. Old: '" <<
- _metarProperties[0]->getStationId() <<
- "', new: '" << nearestAirport->ident() << "'" );
- _metarProperties[0]->setStationId( nearestAirport->ident() );
- _metarProperties[0]->setTimeToLive( 0.0 );
- }
- }
-
- if( _requestTimer <= 0.0 ) {
- _requestTimer = 10.0;
-
- BOOST_FOREACH(LiveMetarProperties* p, _metarProperties) {
- if( p->getTimeToLive() > 0.0 ) continue;
- const std::string & stationId = p->getStationId();
- if( stationId.empty() ) continue;
-
- SG_LOG(SG_ENVIRONMENT, SG_INFO,
- "NoaaMetarRealWxController::update(): spawning load request for station-id '" << stationId << "'" );
-
- _http.makeRequest(new MetarGetRequest(this, stationId));
- } // of MetarProperties iteration
- }