X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Fsimple.cxx;h=9df1cb254723f3ffd530f9430b6f2ead28caded5;hb=348ff2ec23298db4db3b3f2b12d301dec73ec8e1;hp=7eceffe5b583dfd2a91b61d82e9838344bf85c60;hpb=58ca6c916f3e9b74ca2a0f3ee2f23f0ece247f4e;p=flightgear.git diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index 7eceffe5b..9df1cb254 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -47,6 +47,8 @@ #include #include #include +#include +#include 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; } @@ -372,7 +372,7 @@ void FGAirport::loadRunways() const } mRunwaysLoaded = true; - loadSceneryDefintions(); + loadSceneryDefinitions(); } void FGAirport::loadTaxiways() const @@ -399,7 +399,7 @@ void FGAirport::loadProcedures() const Route::loadAirportProcedures(path, const_cast(this)); } -void FGAirport::loadSceneryDefintions() const +void FGAirport::loadSceneryDefinitions() const { // allow users to disable the scenery data in the short-term // longer term, this option can probably disappear @@ -456,9 +456,13 @@ void FGAirport::readTowerData(SGPropertyNode* aRoot) SGPropertyNode* twrNode = aRoot->getChild("tower")->getChild("twr"); double lat = twrNode->getDoubleValue("lat"), lon = twrNode->getDoubleValue("lon"), - elevM = twrNode->getDoubleValue("elev-m"); - - _tower_location = SGGeod::fromDegM(lon, lat, elevM); + elevM = twrNode->getDoubleValue("elev-m"); +// tower elevation is AGL, not AMSL. Since we don't want to depend on the +// scenery for a precise terrain elevation, we use the field elevation +// (this is also what the apt.dat code does) + double fieldElevationM = geod().getElevationM(); + + _tower_location = SGGeod::fromDegM(lon, lat, fieldElevationM + elevM); } bool FGAirport::buildApproach(Waypt* aEnroute, STAR* aSTAR, FGRunway* aRwy, WayptVec& aRoute) @@ -658,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; csetAirport(this); + } +} + +CommStationList +FGAirport::commStationsOfType(FGPositioned::Type aTy) const +{ + CommStationList result; + for (unsigned int c=0; ctype() == aTy) { + result.push_back(mCommStations[c]); + } + } + return result; +} + // get airport elevation double fgGetAirportElev( const string& id ) {