X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FScripting%2FNasalPositioned.cxx;h=eb572973e015316121a883eff935ee3a0ae49017;hb=22a1c9b2af9fd6c4c2758d095c3004da28e83b85;hp=f4eeb84440f00030b24c5bcee004668dc2ebe390;hpb=45e3b7e2d19e7b0d1201f849c852bae5b6b3005b;p=flightgear.git diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx index f4eeb8444..eb572973e 100644 --- a/src/Scripting/NasalPositioned.cxx +++ b/src/Scripting/NasalPositioned.cxx @@ -983,49 +983,6 @@ static naRef f_geodinfo(naContext c, naRef me, int argc, naRef* args) } -class AirportInfoFilter : public FGAirport::AirportFilter -{ -public: - AirportInfoFilter() : type(FGPositioned::AIRPORT) { - minRunwayLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft", 0.0); - } - - bool fromArg(naRef arg) - { - const char *s = naStr_data(arg); - if(!strcmp(s, "airport")) type = FGPositioned::AIRPORT; - else if(!strcmp(s, "seaport")) type = FGPositioned::SEAPORT; - else if(!strcmp(s, "heliport")) type = FGPositioned::HELIPORT; - else - return false; - - return true; - } - - virtual FGPositioned::Type minType() const { - return type; - } - - 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 // on error. // @@ -1046,12 +1003,12 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args) double maxRange = 10000.0; // expose this? or pick a smaller value? - AirportInfoFilter filter; // defaults to airports only + FGAirport::TypeRunwayFilter filter; // defaults to airports only if(argc == 0) { // fall through and use AIRPORT } else if(argc == 1 && naIsString(args[0])) { - if (filter.fromArg(args[0])) { + if (filter.fromTypeString(naStr_data(args[0]))) { // done! } else { // user provided an , hopefully @@ -1086,10 +1043,10 @@ static naRef f_findAirportsWithinRange(naContext c, naRef me, int argc, naRef* a naRuntimeError(c, "findAirportsWithinRange expected range (in nm) as arg %d", argOffset); } - AirportInfoFilter filter; // defaults to airports only + FGAirport::TypeRunwayFilter filter; // defaults to airports only double rangeNm = args[argOffset++].num; if (argOffset < argc) { - filter.fromArg(args[argOffset++]); + filter.fromTypeString(naStr_data(args[argOffset++])); } naRef r = naNewVector(c); @@ -1113,9 +1070,9 @@ static naRef f_findAirportsByICAO(naContext c, naRef me, int argc, naRef* args) int argOffset = 0; std::string prefix(naStr_data(args[argOffset++])); - AirportInfoFilter filter; // defaults to airports only + FGAirport::TypeRunwayFilter filter; // defaults to airports only if (argOffset < argc) { - filter.fromArg(args[argOffset++]); + filter.fromTypeString(naStr_data(args[argOffset++])); } naRef r = naNewVector(c);