From 02d1b14c1a4bf20803bc152a25697f684052feda Mon Sep 17 00:00:00 2001 From: jmt Date: Wed, 24 Dec 2008 15:45:35 +0000 Subject: [PATCH] Finish conversion of FGRunway to a real class - all public members are gone. --- src/Airports/runways.cxx | 20 +++++++++++++ src/Airports/runways.hxx | 31 ++++++++++++++------ src/Airports/simple.cxx | 9 ++---- src/Airports/simple.hxx | 2 -- src/Instrumentation/KLN89/kln89_page_apt.cxx | 6 ++-- src/Instrumentation/mk_viii.cxx | 2 +- src/Scripting/NasalSys.cxx | 4 +-- 7 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/Airports/runways.cxx b/src/Airports/runways.cxx index 84c064263..c38d1dc91 100644 --- a/src/Airports/runways.cxx +++ b/src/Airports/runways.cxx @@ -42,6 +42,20 @@ using std::istream; using std::multimap; using std::string; +/* + * surface codes + * 1 - asphalt + * 2 - concrete + * 3 - turf + * 4 - dirt + * 5 - gravel + * 6 - asphalt helipad + * 7 - concrete helipad + * 8 - turf helipad + * 9 - dirt helipad + * 12 - lakebed + */ + static FGPositioned::Type runwayTypeFromNumber(const std::string& aRwyNo) { return (aRwyNo[0] == 'x') ? FGPositioned::TAXIWAY : FGPositioned::RUNWAY; @@ -168,3 +182,9 @@ SGGeod FGRunway::pointOnCenterline(double aOffset) const result, dummyAz2); return result; } + +bool FGRunway::isHardSurface() const +{ + return ((_surface_code == 1) || (_surface_code == 2)); +} + diff --git a/src/Airports/runways.hxx b/src/Airports/runways.hxx index a198f492c..7bb21b6b4 100644 --- a/src/Airports/runways.hxx +++ b/src/Airports/runways.hxx @@ -39,6 +39,13 @@ class FGRunway : public FGPositioned { FGAirport* _airport; ///< owning airport bool _reciprocal; + double _heading; + double _length; + double _width; + double _displ_thresh; + double _stopway; + int _surface_code; + public: FGRunway(FGAirport* aAirport, const std::string& rwy_no, @@ -113,6 +120,12 @@ public: double widthM() const { return _width * SG_FEET_TO_METER; } + double displacedThresholdM() const + { return _displ_thresh * SG_FEET_TO_METER; } + + double stopwayM() const + { return _stopway * SG_FEET_TO_METER; } + /** * Runway heading in degrees. */ @@ -129,17 +142,17 @@ public: void setAirport(FGAirport* aAirport) { _airport = aAirport; } + /** + * Predicate to test if this runway has a hard surface. For the moment, this + * means concrete or asphalt + */ + bool isHardSurface() const; + + /** + * Retrieve runway surface code, as define in Robin Peel's data + */ int surface() const { return _surface_code; } - - double _displ_thresh; - double _stopway; - - double _heading; - double _length; - double _width; - - int _surface_code; }; #endif // _FG_RUNWAYS_HXX diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index f99b963f3..944dfbb80 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -200,13 +200,8 @@ bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const if (rwy->isReciprocal()) { continue; // we only care about lengths, so don't do work twice } - - int surface = rwy->surface(); - if ((surface != 1) && (surface != 2)) { - continue; // no hard surface - } - - if (rwy->lengthFt() >= aLengthFt) { + + if (rwy->isHardSurface() && (rwy->lengthFt() >= aLengthFt)) { return true; // we're done! } } // of runways iteration diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx index eb14d386c..7c7445947 100644 --- a/src/Airports/simple.hxx +++ b/src/Airports/simple.hxx @@ -89,8 +89,6 @@ public: /** * Useful predicate for FMS/GPS/NAV displays and similar - check if this * aiport has a hard-surfaced runway of at least the specified length. - * For the moment, hard means asphalt or concrete, not gravel or a - * lake bed. */ bool hasHardRunwayOfLengthFt(double aLengthFt) const; diff --git a/src/Instrumentation/KLN89/kln89_page_apt.cxx b/src/Instrumentation/KLN89/kln89_page_apt.cxx index e42121519..62031c760 100644 --- a/src/Instrumentation/KLN89/kln89_page_apt.cxx +++ b/src/Instrumentation/KLN89/kln89_page_apt.cxx @@ -204,7 +204,7 @@ void KLN89AptPage::Update(double dt) { // I guess we can make a heuristic guess as to fuel availability from the runway sizes // For now assume that airports with asphalt or concrete runways will have at least 100L, // and that runways over 4000ft will have JET. - if(_aptRwys[0]->_surface_code <= 2) { + if(_aptRwys[0]->surface() <= 2) { if(_aptRwys[0]->lengthFt() >= 4000) { _kln89->DrawText("JET 100L", 2, 0, 1); } else { @@ -235,7 +235,7 @@ void KLN89AptPage::Update(double dt) { _kln89->DrawText((_kln89->_altUnits == GPS_ALT_UNITS_FT ? "ft" : "m"), 2, 5, 2); // Surface // TODO - why not store these strings as an array? - switch(_aptRwys[i]->_surface_code) { + switch(_aptRwys[i]->surface()) { case 1: // Asphalt - fall through case 2: @@ -283,7 +283,7 @@ void KLN89AptPage::Update(double dt) { _kln89->DrawText((_kln89->_altUnits == GPS_ALT_UNITS_FT ? "ft" : "m"), 2, 5, 0); // Surface // TODO - why not store these strings as an array? - switch(_aptRwys[i]->_surface_code) { + switch(_aptRwys[i]->surface()) { case 1: // Asphalt - fall through case 2: diff --git a/src/Instrumentation/mk_viii.cxx b/src/Instrumentation/mk_viii.cxx index 6990d38a3..a310297d6 100755 --- a/src/Instrumentation/mk_viii.cxx +++ b/src/Instrumentation/mk_viii.cxx @@ -4230,7 +4230,7 @@ MK_VIII::Mode6Handler::update_altitude_callouts () bool MK_VIII::Mode6Handler::test_runway (const FGRunway *_runway) { - if (_runway->_length < mk->conf.runway_database) + if (_runway->lengthFt() < mk->conf.runway_database) return false; SGGeod pos( diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 941776b35..0a10317f9 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -569,8 +569,8 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args) HASHSET("heading", 7, naNum(rwy->headingDeg())); HASHSET("length", 6, naNum(rwy->lengthM())); HASHSET("width", 5, naNum(rwy->widthM())); - HASHSET("threshold", 9, naNum(rwy->_displ_thresh * SG_FEET_TO_METER)); - HASHSET("stopway", 7, naNum(rwy->_stopway * SG_FEET_TO_METER)); + HASHSET("threshold", 9, naNum(rwy->displacedThresholdM())); + HASHSET("stopway", 7, naNum(rwy->stopwayM())); #undef HASHSET naHash_set(rwys, rwyid, rwydata); } -- 2.39.5