]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/airport.cxx
Interim windows build fix
[flightgear.git] / src / Airports / airport.cxx
index ce8fd1a39edf8586b6bc3f746d50ec2af94f01dd..f284fb55ad50bc38874416311814665192ba10df 100644 (file)
@@ -46,8 +46,9 @@
 #include <Main/fg_props.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/pavement.hxx>
-#include <Airports/dynamics.hxx>
 #include <Airports/xmlloader.hxx>
+#include <Airports/dynamics.hxx>
+#include <Airports/airportdynamicsmanager.hxx>
 #include <Navaids/procedure.hxx>
 #include <Navaids/waypoint.hxx>
 #include <ATC/CommStation.hxx>
@@ -74,7 +75,6 @@ FGAirport::FGAirport( PositionedID aGuid,
     FGPositioned(aGuid, aType, id, location),
     _name(name),
     _has_metar(has_metar),
-    _dynamics(0),
     mTowerDataLoaded(false),
     mHasTower(false),
     mRunwaysLoaded(false),
@@ -84,12 +84,12 @@ FGAirport::FGAirport( PositionedID aGuid,
     mThresholdDataLoaded(false),
     mILSDataLoaded(false)
 {
+    mIsClosed = (name.find("[x]") != std::string::npos);
 }
 
 
 FGAirport::~FGAirport()
 {
-    delete _dynamics;
 }
 
 bool FGAirport::isAirport() const
@@ -116,23 +116,6 @@ bool FGAirport::isAirportType(FGPositioned* pos)
     return (pos->type() >= AIRPORT) && (pos->type() <= SEAPORT);
 }
 
-FGAirportDynamics * FGAirport::getDynamics()
-{
-    if (_dynamics) {
-        return _dynamics;
-    }
-    
-    _dynamics = new FGAirportDynamics(this);
-    XMLLoader::load(_dynamics);
-    _dynamics->init();
-  
-    FGRunwayPreference rwyPrefs(this);
-    XMLLoader::load(&rwyPrefs);
-    _dynamics->setRwyUse(rwyPrefs);
-    
-    return _dynamics;
-}
-
 //------------------------------------------------------------------------------
 unsigned int FGAirport::numRunways() const
 {
@@ -680,6 +663,17 @@ void FGAirport::validateTowerData() const
   if (towers.empty()) {
     mHasTower = false;
     mTowerPosition = geod(); // use airport position
+
+    // offset the tower position away from the runway centerline, if
+    // airport has a single runway. Offset by eight times the runway width,
+    // an entirely guessed figure.
+    int runwayCount = numRunways();
+    if ((runwayCount > 0) && (runwayCount <= 2)) {
+        FGRunway* runway = getRunwayByIndex(0);
+        double hdg = runway->headingDeg() + 90;
+        mTowerPosition = SGGeodesy::direct(geod(), hdg, runway->widthM() * 8);
+    }
+
     // increase tower elevation by 20 metres above the field elevation
     mTowerPosition.setElevationM(geod().getElevationM() + 20.0);
   } else {
@@ -970,6 +964,11 @@ void FGAirport::sortBySize(FGPositionedList& airportList)
     }
 }
 
+FGAirportDynamicsRef FGAirport::getDynamics() const
+{
+    return flightgear::AirportDynamicsManager::find(const_cast<FGAirport*>(this));
+}
+
 // get airport elevation
 double fgGetAirportElev( const std::string& id )
 {