]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/simple.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / Airports / simple.cxx
index a085fab57ab7804084100bb8cea4983decb7672a..9df1cb254723f3ffd530f9430b6f2ead28caded5 100644 (file)
@@ -47,6 +47,8 @@
 #include <Airports/xmlloader.hxx>
 #include <Navaids/procedure.hxx>
 #include <Navaids/waypoint.hxx>
+#include <Navaids/PositionedBinding.hxx>
+#include <ATC/CommStation.hxx>
 
 using std::vector;
 using namespace flightgear;
@@ -94,20 +96,18 @@ bool FGAirport::isHeliport() const
 
 FGAirportDynamics * FGAirport::getDynamics()
 {
-    if (_dynamics != 0) {
+    if (_dynamics) {
         return _dynamics;
-    } else {
-        //cerr << "Trying to load dynamics for " << _id << endl;
-        _dynamics = new FGAirportDynamics(this);
-        XMLLoader::load(_dynamics);
-
-        FGRunwayPreference rwyPrefs(this);
-        XMLLoader::load(&rwyPrefs);
-        _dynamics->setRwyUse(rwyPrefs);
+    }
+    
+    _dynamics = new FGAirportDynamics(this);
+    XMLLoader::load(_dynamics);
 
-        //FGSidStar SIDs(this);
-        XMLLoader::load(_dynamics->getSIDs());
-   }
+    FGRunwayPreference rwyPrefs(this);
+    XMLLoader::load(&rwyPrefs);
+    _dynamics->setRwyUse(rwyPrefs);
+    XMLLoader::load(_dynamics->getSIDs());
+    
     return _dynamics;
 }
 
@@ -662,6 +662,61 @@ Approach* FGAirport::getApproachByIndex(unsigned int aIndex) const
   return mApproaches[aIndex];
 }
 
+class AirportNodeListener : public SGPropertyChangeListener
+{
+public:
+    AirportNodeListener()
+    {
+        SGPropertyNode* airports = fgGetNode("/sim/airport");
+        airports->addChangeListener(this, false);
+    }
+
+    virtual void valueChanged(SGPropertyNode*)
+    {
+    }
+
+    virtual void childAdded(SGPropertyNode* pr, SGPropertyNode* child)
+    {
+       FGAirport* apt = FGAirport::findByIdent(child->getName());
+       if (!apt) {
+           return;
+       }
+       
+       flightgear::PositionedBinding::bind(apt, child);
+    }
+};
+    
+void FGAirport::installPropertyListener()
+{
+    new AirportNodeListener;  
+}
+
+flightgear::PositionedBinding*
+FGAirport::createBinding(SGPropertyNode* nd) const
+{
+    return new flightgear::AirportBinding(this, nd);
+}
+
+void FGAirport::setCommStations(CommStationList& comms)
+{
+    mCommStations.swap(comms);
+    for (unsigned int c=0; c<mCommStations.size(); ++c) {
+        mCommStations[c]->setAirport(this);
+    }
+}
+
+CommStationList
+FGAirport::commStationsOfType(FGPositioned::Type aTy) const
+{
+    CommStationList result;
+    for (unsigned int c=0; c<mCommStations.size(); ++c) {
+        if (mCommStations[c]->type() == aTy) {
+            result.push_back(mCommStations[c]);
+        }
+    }
+    return result;
+}
+
 // get airport elevation
 double fgGetAirportElev( const string& id )
 {