X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Frunways.cxx;h=3eb853823e4d39f0927fcba599c71f3d08750217;hb=8b57675aef4930245a964816469be922e3004287;hp=cc2c350150c232212b220a9d0f431b5dea109776;hpb=aa78341698c0ede62bd45d864c1e866d309b420d;p=flightgear.git diff --git a/src/Airports/runways.cxx b/src/Airports/runways.cxx index cc2c35015..3eb853823 100644 --- a/src/Airports/runways.cxx +++ b/src/Airports/runways.cxx @@ -25,28 +25,19 @@ # include #endif -#include // fabs() #include // sprintf() #include // atoi() #include -#include -#include
+ +#include #include -#include #include "runways.hxx" -using std::istream; -using std::multimap; using std::string; -static FGPositioned::Type runwayTypeFromNumber(const std::string& aRwyNo) -{ - return (aRwyNo[0] == 'x') ? FGPositioned::TAXIWAY : FGPositioned::RUNWAY; -} - static std::string cleanRunwayNo(const std::string& aRwyNo) { if (aRwyNo[0] == 'x') { @@ -70,29 +61,22 @@ static std::string cleanRunwayNo(const std::string& aRwyNo) return result; } -FGRunway::FGRunway(FGAirport* aAirport, const string& rwy_no, - const double longitude, const double latitude, +FGRunway::FGRunway(FGAirport* 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) : - FGPositioned(runwayTypeFromNumber(rwy_no), cleanRunwayNo(rwy_no), latitude, longitude, 0.0), + FGRunwayBase(RUNWAY, cleanRunwayNo(aIdent), aGeod, heading, length, width, surface_code, true), _airport(aAirport), - _reciprocal(reciprocal) + _isReciprocal(reciprocal), + _reciprocal(NULL), + _displ_thresh(displ_thresh), + _stopway(stopway), + _ils(NULL) { - _rwy_no = ident(); - - _lon = longitude; - _lat = latitude; - _heading = heading; - _length = length; - _width = width; - _displ_thresh = displ_thresh; - _stopway = stopway; - - _surface_code = surface_code; } string FGRunway::reverseIdent(const string& aRunwayIdent) @@ -140,34 +124,46 @@ double FGRunway::score(double aLengthWt, double aWidthWt, double aSurfaceWt) con return _length * aLengthWt + _width * aWidthWt + surface * aSurfaceWt + 1e-20; } -bool FGRunway::isTaxiway() const -{ - return (type() == TAXIWAY); -} - -SGGeod FGRunway::threshold() const +SGGeod FGRunway::begin() const { return pointOnCenterline(0.0); } -SGGeod FGRunway::reverseThreshold() const +SGGeod FGRunway::end() const { return pointOnCenterline(lengthM()); } -SGGeod FGRunway::displacedThreshold() const +SGGeod FGRunway::threshold() const { return pointOnCenterline(_displ_thresh * SG_FEET_TO_METER); } -SGGeod FGRunway::pointOnCenterline(double aOffset) const +void FGRunway::processThreshold(SGPropertyNode* aThreshold) { - SGGeod result; - double dummyAz2; - double halfLengthMetres = lengthM() * 0.5; + assert(ident() == aThreshold->getStringValue("rwy")); - SGGeodesy::direct(mPosition, _heading, - aOffset - halfLengthMetres, - result, dummyAz2); - return result; + 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; + + // 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)); + + _reciprocal = other; } +