]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/simple.cxx
Change tower location to an SGGeod. Include taxiways too.
[flightgear.git] / src / Airports / simple.cxx
index ed80d43afc8b98675654241e368ae03fd3263491..0b9c39097e57e8203f6b592180abc4ff413ede9e 100644 (file)
@@ -50,6 +50,7 @@
 #include STL_STRING
 
 #include "simple.hxx"
+#include "xmlloader.hxx"
 
 SG_USING_STD(sort);
 SG_USING_STD(random_shuffle);
@@ -60,18 +61,16 @@ SG_USING_STD(random_shuffle);
 /***************************************************************************
  * FGAirport
  ***************************************************************************/
-FGAirport::FGAirport() : _longitude(0), _latitude(0), _elevation(0)
+FGAirport::FGAirport()
 {
     dynamics = 0;
 }
 
-
-FGAirport::FGAirport(const string &id, double lon, double lat, double elev, const string &name, bool has_metar)
+FGAirport::FGAirport(const string &id, const SGGeod& location, const SGGeod& tower_location, const string &name, bool has_metar)
 {
     _id = id;
-    _longitude = lon;
-    _latitude  = lat;
-    _elevation = elev;
+    _location = location;
+    _tower_location = tower_location;
     _name      = name;
     _has_metar = has_metar;
     dynamics   = 0;
@@ -89,46 +88,14 @@ FGAirportDynamics * FGAirport::getDynamics()
     if (dynamics != 0) {
         return dynamics;
     } else {
-        FGRunwayPreference rwyPrefs;
         //cerr << "Trying to load dynamics for " << _id << endl;
-        dynamics = new FGAirportDynamics(_latitude, _longitude, _elevation, _id);
-
-        SGPath parkpath( globals->get_fg_root() );
-        parkpath.append( "/AI/Airports/" );
-        parkpath.append(_id);
-        parkpath.append("parking.xml");
-
-        SGPath rwyPrefPath( globals->get_fg_root() );
-        rwyPrefPath.append( "AI/Airports/" );
-        rwyPrefPath.append(_id);
-        rwyPrefPath.append("rwyuse.xml");
-
-        //if (ai_dirs.find(id.c_str()) != ai_dirs.end()
-        //  && parkpath.exists())
-        if (parkpath.exists()) {
-            try {
-                readXML(parkpath.str(),*dynamics);
-               //cerr << "Initializing " << getId() << endl;
-                dynamics->init();
-               dynamics->getGroundNetwork()->setParent(this);
-            } catch (const sg_exception &e) {
-                //cerr << "unable to read " << parkpath.str() << endl;
-            }
-        }
+        dynamics = new FGAirportDynamics(this);
+        XMLLoader::load(dynamics);
 
-        //if (ai_dirs.find(id.c_str()) != ai_dirs.end()
-        //  && rwyPrefPath.exists())
-        if (rwyPrefPath.exists()) {
-            try {
-                readXML(rwyPrefPath.str(), rwyPrefs);
-                dynamics->setRwyUse(rwyPrefs);
-            } catch (const sg_exception &e) {
-                //cerr << "unable to read " << rwyPrefPath.str() << endl;
-                //exit(1);
-            }
-        }
-        //exit(1);
-    }
+        FGRunwayPreference rwyPrefs(this);
+        XMLLoader::load(&rwyPrefs);
+        dynamics->setRwyUse(rwyPrefs);
+   }
     return dynamics;
 }
 
@@ -174,19 +141,17 @@ FGAirportList::~FGAirportList( void )
 
 
 // add an entry to the list
-void FGAirportList::add( const string &id, const double longitude,
-                         const double latitude, const double elevation,
+void FGAirportList::add( const string &id, const SGGeod& location, const SGGeod& tower_location,
                          const string &name, const bool has_metar )
 {
-    FGRunwayPreference rwyPrefs;
-    FGAirport* a = new FGAirport(id, longitude, latitude, elevation, name, has_metar);
-
+    FGAirport* a = new FGAirport(id, location, tower_location, name, has_metar);
     airports_by_id[a->getId()] = a;
     // try and read in an auxilary file
-
     airports_array.push_back( a );
-    SG_LOG( SG_GENERAL, SG_BULK, "Adding " << id << " pos = " << longitude
-            << ", " << latitude << " elev = " << elevation );
+    SG_LOG( SG_GENERAL, SG_BULK, "Adding " << id << " pos = " << location.getLongitudeDeg()
+            << ", " << location.getLatitudeDeg() << " elev = " << location.getElevationFt() );
 }