X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Frunways.cxx;h=9f2291f7ba90f31f10f31da246a4a978975572d4;hb=c068049d840c2f4567c7d07e7fb37247d8e23407;hp=adbd22600cdd3134cdd18fb1cacf111d9962955b;hpb=2d267a578224f5028dbe1a37a9fe122c0d31c9d3;p=flightgear.git diff --git a/src/Airports/runways.cxx b/src/Airports/runways.cxx index adbd22600..9f2291f7b 100644 --- a/src/Airports/runways.cxx +++ b/src/Airports/runways.cxx @@ -37,50 +37,28 @@ #include "runways.hxx" -#include +#include #include #include +#include using std::string; -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; -} - -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), - _isReciprocal(reciprocal), - _reciprocal(NULL), + _reciprocal(0), _displ_thresh(displ_thresh), _stopway(stopway), - _ils(NULL) + _ils(0) { } @@ -118,15 +96,17 @@ string FGRunway::reverseIdent(const string& aRunwayIdent) return buf; } -double FGRunway::score(double aLengthWt, double aWidthWt, double aSurfaceWt) const +double FGRunway::score(double aLengthWt, double aWidthWt, double aSurfaceWt, double aIlsWt) const { int surface = 1; if (_surface_code == 12 || _surface_code == 5) // dry lakebed & gravel surface = 2; else if (_surface_code == 1 || _surface_code == 2) // asphalt & concrete surface = 3; + + int ils = (_ils != 0); - return _length * aLengthWt + _width * aWidthWt + surface * aSurfaceWt + 1e-20; + return _length * aLengthWt + _width * aWidthWt + surface * aSurfaceWt + ils * aIlsWt + 1e-20; } SGGeod FGRunway::begin() const @@ -141,42 +121,51 @@ SGGeod FGRunway::end() const SGGeod FGRunway::threshold() const { - return pointOnCenterline(_displ_thresh * SG_FEET_TO_METER); + return pointOnCenterline(_displ_thresh); } -void FGRunway::processThreshold(SGPropertyNode* aThreshold) +void FGRunway::setReciprocalRunway(PositionedID other) { - assert(ident() == aThreshold->getStringValue("rwy")); - - double lon = aThreshold->getDoubleValue("lon"), - lat = aThreshold->getDoubleValue("lat"); - SGGeod newThreshold(SGGeod::fromDegM(lon, lat, mPosition.getElevationM())); - - _heading = aThreshold->getDoubleValue("hdg-deg"); - _displ_thresh = aThreshold->getDoubleValue("displ-m") * SG_METER_TO_FEET; - _stopway = aThreshold->getDoubleValue("stopw-m") * SG_METER_TO_FEET; + 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; + } - // compute the new runway center, based on the threshold lat/lon and length, - double offsetFt = (0.5 * _length); - SGGeod newCenter; - double dummy; - SGGeodesy::direct(newThreshold, _heading, offsetFt * SG_FEET_TO_METER, newCenter, dummy); - mPosition = newCenter; -} - -void FGRunway::setReciprocalRunway(FGRunway* other) -{ - assert(_reciprocal==NULL); - assert((other->_reciprocal == NULL) || (other->_reciprocal == this)); + 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; + } - _reciprocal = other; + return loadById(gsId); } -std::vector FGRunway::getSIDs() +flightgear::SIDList FGRunway::getSIDs() const { - std::vector result; - for (unsigned int i=0; i<_airport->numSIDs(); ++i) { - flightgear::SID* s = _airport->getSIDByIndex(i); + 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); } @@ -185,11 +174,12 @@ std::vector FGRunway::getSIDs() return result; } -std::vector FGRunway::getSTARs() +flightgear::STARList FGRunway::getSTARs() const { - std::vector result; - for (unsigned int i=0; i<_airport->numSTARs(); ++i) { - flightgear::STAR* s = _airport->getSTARByIndex(i); + 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); } @@ -198,3 +188,41 @@ std::vector FGRunway::getSTARs() 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 + + return result; +} + +void FGRunway::updateThreshold(const SGGeod& newThreshold, double newHeading, + double newDisplacedThreshold, + double newStopway) +{ + modifyPosition(newThreshold); + _heading = newHeading; + _stopway = newStopway; + _displ_thresh = newDisplacedThreshold; +} + +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) +{ +}