diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index 356b8dcc2..02d7025b8 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -249,13 +249,9 @@ FGAirport::HardSurfaceFilter::HardSurfaceFilter(double minLengthFt) : { } -bool FGAirport::HardSurfaceFilter::pass(FGPositioned* aPos) const +bool FGAirport::HardSurfaceFilter::passAirport(FGAirport* aApt) const { - if (aPos->type() != AIRPORT) { - return false; // exclude seaports and heliports as well, we need a runways - } - - return static_cast(aPos)->hasHardRunwayOfLengthFt(mMinLengthFt); + return aApt->hasHardRunwayOfLengthFt(mMinLengthFt); } FGAirport* FGAirport::findByIdent(const std::string& aIdent) diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx index 0a25f8d46..dc4d7c319 100644 --- a/src/Airports/simple.hxx +++ b/src/Airports/simple.hxx @@ -104,17 +104,32 @@ public: { public: virtual bool pass(FGPositioned* aPos) const { - Type ty(aPos->type()); - return (ty >= AIRPORT) && (ty <= SEAPORT); + return passAirport(static_cast(aPos)); + } + + virtual Type minType() const { + return AIRPORT; + } + + virtual Type maxType() const { + return SEAPORT; + } + + virtual bool passAirport(FGAirport* aApt) const { + return true; } }; - class HardSurfaceFilter : public Filter + class HardSurfaceFilter : public AirportFilter { public: HardSurfaceFilter(double minLengthFt); - virtual bool pass(FGPositioned* aPos) const; + virtual bool passAirport(FGAirport* aApt) const; + + virtual Type maxType() const { + return AIRPORT; + } private: double mMinLengthFt; }; diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx index 1331a2c32..72f6f0979 100644 --- a/src/Environment/environment_ctrl.cxx +++ b/src/Environment/environment_ctrl.cxx @@ -40,17 +40,12 @@ using std::sort; -class AirportWithMetar : public FGPositioned::Filter +class AirportWithMetar : public FGAirport::AirportFilter { public: - virtual bool pass(FGPositioned* aPos) const + virtual bool passAirport(FGAirport* aApt) const { - if ((aPos->type() < FGPositioned::AIRPORT) || (aPos->type() > FGPositioned::SEAPORT)) { - return false; - } - - FGAirport* apt = static_cast(aPos); - return apt->getMetar(); + return aApt->getMetar(); } }; diff --git a/src/Instrumentation/marker_beacon.cxx b/src/Instrumentation/marker_beacon.cxx index e636704fb..3662fcd16 100644 --- a/src/Instrumentation/marker_beacon.cxx +++ b/src/Instrumentation/marker_beacon.cxx @@ -250,11 +250,15 @@ static bool check_beacon_range( const SGGeod& pos, class BeaconFilter : public FGPositioned::Filter { -public: - virtual bool pass(FGPositioned* aPos) const - { - return (aPos->type() >= FGPositioned::OM) && (aPos->type() <= FGPositioned::IM); +public: + virtual FGPositioned::Type minType() const { + return FGPositioned::OM; } + + virtual FGPositioned::Type maxType() const { + return FGPositioned::IM; + } + }; // Update current nav/adf radio stations based on current postition diff --git a/src/Instrumentation/mk_viii.cxx b/src/Instrumentation/mk_viii.cxx index 50e1df1a7..3bbdc4235 100755 --- a/src/Instrumentation/mk_viii.cxx +++ b/src/Instrumentation/mk_viii.cxx @@ -4254,13 +4254,9 @@ MK_VIII::Mode6Handler::test_airport (const FGAirport *airport) return false; } -bool MK_VIII::Mode6Handler::AirportFilter::pass(FGPositioned* a) const +bool MK_VIII::Mode6Handler::AirportFilter::passAirport(FGAirport* a) const { - if (a->type() != FGPositioned::AIRPORT) { - return false; - } - - bool ok = self->test_airport(static_cast(a)); + bool ok = self->test_airport(a); return ok; } @@ -4497,14 +4493,9 @@ MK_VIII::TCFHandler::select_runway (const FGAirport *airport) return _runway; } -bool MK_VIII::TCFHandler::AirportFilter::pass(FGPositioned* aPos) const +bool MK_VIII::TCFHandler::AirportFilter::passAirport(FGAirport* aApt) const { - if (aPos->type() != FGPositioned::AIRPORT) { - return false; - } - - FGAirport* apt = static_cast(aPos); - return apt->hasHardRunwayOfLengthFt(mk->conf.runway_database); + return aApt->hasHardRunwayOfLengthFt(mk->conf.runway_database); } void diff --git a/src/Instrumentation/mk_viii.hxx b/src/Instrumentation/mk_viii.hxx index 249bdf023..4db4b45ce 100755 --- a/src/Instrumentation/mk_viii.hxx +++ b/src/Instrumentation/mk_viii.hxx @@ -1505,13 +1505,17 @@ private: unsigned int get_bank_angle_alerts (); void update_bank_angle (); - class AirportFilter : public FGPositioned::Filter + class AirportFilter : public FGAirport::AirportFilter { public: AirportFilter(Mode6Handler *s) : self(s) {} - virtual bool pass(FGPositioned *a) const; + virtual bool passAirport(FGAirport *a) const; + + virtual FGPositioned::Type maxType() const { + return FGPositioned::AIRPORT; + } private: Mode6Handler* self; @@ -1578,14 +1582,17 @@ private: bool is_tcf (); bool is_rfcf (); - class AirportFilter : public FGPositioned::Filter + class AirportFilter : public FGAirport::AirportFilter { public: AirportFilter(MK_VIII *device) : mk(device) {} - virtual bool pass(FGPositioned *a) const; + virtual bool passAirport(FGAirport *a) const; + virtual FGPositioned::Type maxType() const { + return FGPositioned::AIRPORT; + } private: MK_VIII* mk; }; diff --git a/src/Navaids/navlist.cxx b/src/Navaids/navlist.cxx index 66d990d5c..f49052125 100644 --- a/src/Navaids/navlist.cxx +++ b/src/Navaids/navlist.cxx @@ -74,9 +74,12 @@ FGNavRecord *FGNavList::findByFreq( double freq, const SGGeod& position) class VORNDBFilter : public FGPositioned::Filter { public: - virtual bool pass(FGPositioned* aPos) const - { - return (aPos->type() == FGPositioned::VOR) || (aPos->type() == FGPositioned::NDB); + virtual FGPositioned::Type minType() const { + return FGPositioned::VOR; + } + + virtual FGPositioned::Type maxType() const { + return FGPositioned::NDB; } }; diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index af2d51c66..1941712ec 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -497,19 +497,22 @@ static naRef f_geodinfo(naContext c, naRef me, int argc, naRef* args) #undef HASHSET } -class AirportInfoFilter : public FGPositioned::Filter +class AirportInfoFilter : public FGAirport::AirportFilter { public: AirportInfoFilter() : type(FGPositioned::AIRPORT) { } - virtual bool pass(FGPositioned* aPos) const - { - return (aPos->type() == type); + virtual FGPositioned::Type minType() const { + return type; } - FGPositioned::Type type; + virtual FGPositioned::Type maxType() const { + return type; + } + + FGPositioned::Type type; }; // Returns data hash for particular or nearest airport of a , or nil