diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index af3945a61..2065c907e 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -329,6 +329,9 @@ FGAirport* FGAirport::findClosest(const SGGeod& aPos, double aCuttofNm, Filter* FGAirport::HardSurfaceFilter::HardSurfaceFilter(double minLengthFt) : mMinLengthFt(minLengthFt) { + if (minLengthFt < 0.0) { + mMinLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft", 0.0); + } } bool FGAirport::HardSurfaceFilter::passAirport(FGAirport* aApt) const diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx index 6995e6976..dfa836570 100644 --- a/src/Airports/simple.hxx +++ b/src/Airports/simple.hxx @@ -161,7 +161,7 @@ public: class HardSurfaceFilter : public AirportFilter { public: - HardSurfaceFilter(double minLengthFt); + HardSurfaceFilter(double minLengthFt = -1); virtual bool passAirport(FGAirport* aApt) const; diff --git a/src/GUI/MapWidget.cxx b/src/GUI/MapWidget.cxx index 5a53ffe7f..ba4174086 100644 --- a/src/GUI/MapWidget.cxx +++ b/src/GUI/MapWidget.cxx @@ -887,7 +887,7 @@ public: { _heliports = nd->getBoolValue("show-heliports", false); _hardRunwaysOnly = nd->getBoolValue("hard-surfaced-airports", true); - _minLengthFt = nd->getDoubleValue("min-runway-length-ft", 2000.0); + _minLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft", 2000); } virtual FGPositioned::Type maxType() const { diff --git a/src/Instrumentation/NavDisplay.cxx b/src/Instrumentation/NavDisplay.cxx index 2528a7ef4..003b40dc0 100644 --- a/src/Instrumentation/NavDisplay.cxx +++ b/src/Instrumentation/NavDisplay.cxx @@ -947,7 +947,7 @@ void NavDisplay::findItems() { if (!_cachedItemsValid) { Filter filt; - filt.minRunwayLengthFt = 2000; + filt.minRunwayLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft", 2000); _itemsInRange = FGPositioned::findWithinRange(_pos, _rangeNm, &filt); _cachedItemsValid = true; _cachedPos = SGVec3d::fromGeod(_pos); diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 4d7b79b4f..e9a91dcaa 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -201,7 +201,6 @@ GPS::Config::Config() : _turnRate(3.0), // degrees-per-second, so 180 degree turn takes 60 seconds _overflightArmDistance(1.0), _waypointAlertTime(30.0), - _minRunwayLengthFt(0.0), _requireHardSurface(true), _cdiMaxDeflectionNm(3.0), // linear mode, 3nm at the peg _driveAutopilot(true), @@ -215,7 +214,6 @@ void GPS::Config::bind(GPS* aOwner, SGPropertyNode* aCfg) aOwner->tie(aCfg, "turn-rate-deg-sec", SGRawValuePointer(&_turnRate)); aOwner->tie(aCfg, "turn-anticipation", SGRawValuePointer(&_enableTurnAnticipation)); aOwner->tie(aCfg, "wpt-alert-time", SGRawValuePointer(&_waypointAlertTime)); - aOwner->tie(aCfg, "min-runway-length-ft", SGRawValuePointer(&_minRunwayLengthFt)); aOwner->tie(aCfg, "hard-surface-runways-only", SGRawValuePointer(&_requireHardSurface)); aOwner->tie(aCfg, "cdi-max-deflection-nm", SGRawValuePointer(&_cdiMaxDeflectionNm)); aOwner->tie(aCfg, "drive-autopilot", SGRawValuePointer(&_driveAutopilot)); @@ -1439,7 +1437,7 @@ FGPositioned::Type GPS::SearchFilter::maxType() const FGPositioned::Filter* GPS::createFilter(FGPositioned::Type aTy) { if (aTy == FGPositioned::AIRPORT) { - return new FGAirport::HardSurfaceFilter(_config.minRunwayLengthFt()); + return new FGAirport::HardSurfaceFilter(); } // if we were passed INVALID, assume it means 'all types interesting to a GPS' diff --git a/src/Instrumentation/gps.hxx b/src/Instrumentation/gps.hxx index 3ee14100e..21cd46166 100644 --- a/src/Instrumentation/gps.hxx +++ b/src/Instrumentation/gps.hxx @@ -134,8 +134,6 @@ private: bool requireHardSurface() const { return _requireHardSurface; } - double minRunwayLengthFt() const { return _minRunwayLengthFt; } - bool cdiDeflectionIsAngular() const { return (_cdiMaxDeflectionNm <= 0.0); } double cdiDeflectionLinearPeg() const diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx index 53a3a41e7..8f54c14df 100644 --- a/src/Scripting/NasalPositioned.cxx +++ b/src/Scripting/NasalPositioned.cxx @@ -344,8 +344,15 @@ static const char* airportGhostGetMember(naContext c, void* g, naRef field, naRe *out = naNum(apt->getMetar()); } else if (!strcmp(fieldName, "runways")) { *out = naNewHash(c); + double minLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft"); for(unsigned int r=0; rnumRunways(); ++r) { FGRunway* rwy(apt->getRunwayByIndex(r)); + + // ignore unusably short runways + if (rwy->lengthFt() < minLengthFt) { + continue; + } + naRef rwyid = stringToNasal(c, rwy->ident()); naRef rwydata = ghostForRunway(c, rwy); naHash_set(*out, rwyid, rwydata); @@ -918,6 +925,7 @@ class AirportInfoFilter : public FGAirport::AirportFilter { public: AirportInfoFilter() : type(FGPositioned::AIRPORT) { + minRunwayLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft", 0.0); } bool fromArg(naRef arg) @@ -939,8 +947,21 @@ public: virtual FGPositioned::Type maxType() const { return type; } + + virtual bool pass(FGPositioned* aPos) const + { + FGAirport* apt = (FGAirport*) aPos; + if ((apt->type() == FGPositioned::AIRPORT) && + !apt->hasHardRunwayOfLengthFt(minRunwayLengthFt)) + { + return false; + } + + return true; + } FGPositioned::Type type; + double minRunwayLengthFt; }; // Returns data hash for particular or nearest airport of a , or nil