]> git.mxchange.org Git - flightgear.git/commitdiff
metar: make unknown station-id's work again
authorTorsten Dreyer <Torsten@t3r.de>
Wed, 15 Dec 2010 16:57:05 +0000 (17:57 +0100)
committerTorsten Dreyer <Torsten@t3r.de>
Wed, 15 Dec 2010 16:57:05 +0000 (17:57 +0100)
Restore old feature where unknown station id's like XXXX were
substituted by the metar station closest to the current position.

src/Environment/metarproperties.cxx

index ba9ff65ea1df15f8f7fd4f18a694ae5b08330eed..6a147c9f525f280b8b89068ce71e7930efa9c36a 100644 (file)
@@ -28,6 +28,7 @@
 #include "fgmetar.hxx"
 #include "environment.hxx"
 #include "atmosphere.hxx"
+#include "metarairportfilter.hxx"
 #include <simgear/scene/sky/cloud.hxx>
 #include <simgear/structure/exception.hxx>
 #include <Main/fg_props.hxx>
@@ -161,13 +162,15 @@ void MetarProperties::set_metar( const char * metar )
     {
         // 1. check the id given in the metar
         FGAirport* a = FGAirport::findByIdent(m->getId());
-/*
+
         // 2. if unknown, find closest airport with metar to current position
         if( a == NULL ) {
-            SGGeod pos = SGGeod::fromDeg(_longitude_n->getDoubleValue(), _latitude_n->getDoubleValue());
-            a = FGAirport::findClosest(pos, 10000.0, &_airportWithMetarFilter);
+            SGGeod pos = SGGeod::fromDeg(
+                fgGetDouble( "/position/longitude-deg", 0.0 ),
+                fgGetDouble( "/position/latitude-deg", 0.0 ) );
+            a = FGAirport::findClosest(pos, 10000.0, MetarAirportFilter::instance() );
         }
-*/
+
         // 3. otherwise use ground elevation
         if( a != NULL ) {
             _station_elevation = a->getElevation();
@@ -176,12 +179,10 @@ void MetarProperties::set_metar( const char * metar )
             _station_longitude = towerPosition.getLongitudeDeg();
             _station_id = a->ident();
         } else {
-            _station_elevation = 0.0;
-            _station_latitude = 0.0;
-            _station_longitude = 0.0;
+            _station_elevation = fgGetDouble("/position/ground-elev-m", 0.0 ) * SG_METER_TO_FEET;
+            _station_latitude = fgGetDouble( "/position/latitude-deg", 0.0 );
+            _station_longitude = fgGetDouble( "/position/longitude-deg", 0.0 );
             _station_id = "XXXX";
-//            station_elevation_ft = _ground_elevation_n->getDoubleValue() * SG_METER_TO_FEET;
-//            _station_id = m->getId();
         }
     }