X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Frunways.cxx;h=84205a27620a9de91f27cf0e6c69170aa31d6bc7;hb=81cd33e2fa9b5930784d3aed920eea0e3038e7f7;hp=f97cd14e83aee82c4c4dde7e078d2a77362ba50d;hpb=2dee4ef14ff449381d11ef2d55d07b2e199677af;p=flightgear.git diff --git a/src/Airports/runways.cxx b/src/Airports/runways.cxx index f97cd14e8..84205a276 100644 --- a/src/Airports/runways.cxx +++ b/src/Airports/runways.cxx @@ -27,6 +27,7 @@ #include // sprintf() #include // atoi() +#include #include @@ -36,45 +37,28 @@ #include "runways.hxx" -using std::string; +#include +#include +#include +#include -static std::string cleanRunwayNo(const std::string& aRwyNo) -{ - if (aRwyNo[0] == 'x') { - return std::string(); // no ident for taxiways - } - - string result(aRwyNo); - // canonicalise runway ident - if ((aRwyNo.size() == 1) || !isdigit(aRwyNo[1])) { - result = "0" + aRwyNo; - } - - // trim off trailing garbage - if (result.size() > 2) { - char suffix = toupper(result[2]); - if (suffix == 'X') { - result = result.substr(0, 2); - } - } - - return result; -} +using std::string; -FGRunway::FGRunway(FGAirport* aAirport, const string& aIdent, +FGRunway::FGRunway(PositionedID aGuid, + PositionedID aAirport, const string& aIdent, const SGGeod& aGeod, const double heading, const double length, const double width, const double displ_thresh, const double stopway, - const int surface_code, - bool reciprocal) : - FGRunwayBase(RUNWAY, cleanRunwayNo(aIdent), aGeod, heading, length, width, surface_code, true), + const int surface_code) : + FGRunwayBase(aGuid, RUNWAY, aIdent, aGeod, + heading, length, width, surface_code), _airport(aAirport), - _reciprocal(reciprocal), + _reciprocal(0), _displ_thresh(displ_thresh), _stopway(stopway), - _ils(NULL) + _ils(0) { } @@ -135,26 +119,98 @@ SGGeod FGRunway::end() const SGGeod FGRunway::threshold() const { - return pointOnCenterline(_displ_thresh * SG_FEET_TO_METER); + return pointOnCenterline(_displ_thresh); +} + +void FGRunway::setReciprocalRunway(PositionedID other) +{ + assert(_reciprocal==0); + _reciprocal = other; +} + +FGAirport* FGRunway::airport() const +{ + return loadById(_airport); +} + +FGRunway* FGRunway::reciprocalRunway() const +{ + return loadById(_reciprocal); +} + +FGNavRecord* FGRunway::ILS() const +{ + if (_ils == 0) { + return NULL; + } + + return loadById(_ils); +} + +FGNavRecord* FGRunway::glideslope() const +{ + flightgear::NavDataCache* cache = flightgear::NavDataCache::instance(); + PositionedID gsId = cache->findNavaidForRunway(guid(), FGPositioned::GS); + if (gsId == 0) { + return NULL; + } + + return loadById(gsId); } -void FGRunway::processThreshold(SGPropertyNode* aThreshold) +flightgear::SIDList FGRunway::getSIDs() const { - assert(ident() == aThreshold->getStringValue("rwy")); + FGAirport* apt = airport(); + flightgear::SIDList result; + for (unsigned int i=0; inumSIDs(); ++i) { + flightgear::SID* s = apt->getSIDByIndex(i); + if (s->isForRunway(this)) { + result.push_back(s); + } + } // of SIDs at the airport iteration - double lon = aThreshold->getDoubleValue("lon"), - lat = aThreshold->getDoubleValue("lat"); - SGGeod newThreshold(SGGeod::fromDegM(lon, lat, mPosition.getElevationM())); + return result; +} + +flightgear::STARList FGRunway::getSTARs() const +{ + FGAirport* apt = airport(); + flightgear::STARList result; + for (unsigned int i=0; inumSTARs(); ++i) { + flightgear::STAR* s = apt->getSTARByIndex(i); + if (s->isForRunway(this)) { + result.push_back(s); + } + } // of STARs at the airport iteration - _heading = aThreshold->getDoubleValue("hdg-deg"); - _displ_thresh = aThreshold->getDoubleValue("displ-m") * SG_METER_TO_FEET; - _stopway = aThreshold->getDoubleValue("stopw-m") * SG_METER_TO_FEET; + return result; +} + +flightgear::ApproachList +FGRunway::getApproaches(flightgear::ProcedureType type) const +{ + FGAirport* apt = airport(); + flightgear::ApproachList result; + for (unsigned int i=0; inumApproaches(); ++i) + { + flightgear::Approach* s = apt->getApproachByIndex(i); + if( s->runway() == this + && (type == flightgear::PROCEDURE_INVALID || type == s->type()) ) + { + result.push_back(s); + } + } // of approaches at the airport iteration - // compute the new runway center, based on the threshold lat/lon, length, - // and any displaced threshold. - double offsetFt = (0.5 * _length) - _displ_thresh; - SGGeod newCenter; - double dummy; - SGGeodesy::direct(newThreshold, _heading, offsetFt * SG_FEET_TO_METER, newCenter, dummy); - mPosition = newCenter; -} + return result; +} + +FGHelipad::FGHelipad(PositionedID aGuid, + PositionedID aAirport, const string& aIdent, + const SGGeod& aGeod, + const double heading, const double length, + const double width, + const int surface_code) : + FGRunwayBase(aGuid, RUNWAY, aIdent, aGeod, + heading, length, width, surface_code) +{ +}