X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNavaids%2Fpositioned.hxx;h=a9f2cd4bf8decd2c1badb65bba405096a870f033;hb=afcdbd3158503773644aa07dd86cd92d67946bd4;hp=1c275dcf4db30ddcefe52340fcd23d5247394dad;hpb=030742fa4ae7d99facb517381da71fa404c4ee2b;p=flightgear.git diff --git a/src/Navaids/positioned.hxx b/src/Navaids/positioned.hxx index 1c275dcf4..a9f2cd4bf 100644 --- a/src/Navaids/positioned.hxx +++ b/src/Navaids/positioned.hxx @@ -21,15 +21,22 @@ #ifndef FG_POSITIONED_HXX #define FG_POSITIONED_HXX +#include #include +#include +#include #include -#include +#include class FGPositioned; - typedef SGSharedPtr FGPositionedRef; +typedef int64_t PositionedID; +typedef std::vector PositionedIDVec; + +namespace flightgear { class NavDataCache; } + class FGPositioned : public SGReferenced { public: @@ -41,23 +48,38 @@ public: SEAPORT, RUNWAY, TAXIWAY, - PARK_STAND, + PAVEMENT, + WAYPOINT, FIX, - VOR, NDB, + VOR, ILS, LOC, GS, OM, MM, IM, +/// important that DME & TACAN are adjacent to keep the TacanFilter +/// efficient - DMEs are proxies for TACAN/VORTAC stations DME, TACAN, + MOBILE_TACAN, OBSTACLE, - WAYPOINT, // user-defined waypoint - FREQ_GND, - FREQ_TWR, +/// an actual airport tower - not a radio comms facility! +/// some airports have multiple towers, eg EHAM, although our data source +/// doesn't necessarily include them + TOWER, + FREQ_GROUND, + FREQ_TOWER, FREQ_ATIS, + FREQ_AWOS, + FREQ_APP_DEP, + FREQ_ENROUTE, + FREQ_CLEARANCE, + FREQ_UNICOM, +// groundnet items + PARKING, ///< parking position - might be a gate, or stand + TAXI_NODE, LAST_TYPE } Type; @@ -81,14 +103,15 @@ public: const SGGeod& geod() const { return mPosition; } + + PositionedID guid() const + { return mGuid; } /** - * Compute the cartesian position associated with this object + * The cartesian position associated with this object */ - SGVec3d cart() const; + const SGVec3d& cart() const; - SGBucket bucket() const; - double latitude() const { return mPosition.getLatitudeDeg(); } @@ -113,6 +136,13 @@ public: virtual bool pass(FGPositioned* aPos) const { return true; } + virtual Type minType() const + { return INVALID; } + + virtual Type maxType() const + { return INVALID; } + + bool operator()(FGPositioned* aPos) const { return pass(aPos); } }; @@ -120,34 +150,42 @@ public: class TypeFilter : public Filter { public: - TypeFilter(Type aTy) : mType(aTy) { ; } - virtual bool pass(FGPositioned* aPos) const - { return (mType == aPos->type()); } + TypeFilter(Type aTy); + virtual bool pass(FGPositioned* aPos) const; + + virtual Type minType() const + { return mMinType; } + + virtual Type maxType() const + { return mMaxType; } + + void addType(Type aTy); private: - const Type mType; + std::vector types; + Type mMinType, mMaxType; }; - + static List findWithinRange(const SGGeod& aPos, double aRangeNm, Filter* aFilter = NULL); static FGPositionedRef findClosestWithIdent(const std::string& aIdent, const SGGeod& aPos, Filter* aFilter = NULL); + + static FGPositionedRef findFirstWithIdent(const std::string& aIdent, Filter* aFilter = NULL); + + /** + * Find all items with the specified ident + * @param aFilter - optional filter on items + */ + static List findAllWithIdent(const std::string& aIdent, Filter* aFilter = NULL, bool aExact = true); /** - * Find the next item with the specified partial ID, after the 'current' item - * Note this function is not hyper-efficient, particular where the partial id - * spans a large number of candidates. - * - * @param aCur - Current item, or NULL to retrieve the first item with partial id - * @param aId - the (partial) id to lookup + * As above, but searches names instead of idents */ - static FGPositionedRef findNextWithPartialId(FGPositionedRef aCur, const std::string& aId, Filter* aFilter = NULL); + static List findAllWithName(const std::string& aName, Filter* aFilter = NULL, bool aExact = true); /** - * Find all items with the specified ident, and return then sorted by - * distance from a position - * - * @param aFilter - optional filter on items + * Sort an FGPositionedList by distance from a position */ - static List findAllWithIdentSortedByRange(const std::string& aIdent, const SGGeod& aPos, Filter* aFilter = NULL); + static void sortByRange(List&, const SGGeod& aPos); /** * Find the closest item to a position, which pass the specified filter @@ -165,28 +203,39 @@ public: * Very large cutoff values will make this slow. * * @result The matches (possibly less than N, depending on the filter and cutoff), - * sorted by distance from the search pos + * sorted by distance from the search pos * @param aN - number of matches to find * @param aCutoffNm - maximum distance to search within, in nautical miles */ static List findClosestN(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter = NULL); - + /** + * Map a candidate type string to a real type. Returns INVALID if the string + * does not correspond to a defined type. + */ + static Type typeFromName(const std::string& aName); /** - * Debug helper, map a type to a human-readable string + * Map a type to a human-readable string */ static const char* nameForType(Type aTy); -protected: - FGPositioned(Type ty, const std::string& aIdent, const SGGeod& aPos, bool aIndex = true); + static FGPositioned* createUserWaypoint(const std::string& aIdent, const SGGeod& aPos); +protected: + friend class flightgear::NavDataCache; - // can't be const right now, navrecord at least needs to fix up the position - // after navaids are parsed - SGGeod mPosition; + FGPositioned(PositionedID aGuid, Type ty, const std::string& aIdent, const SGGeod& aPos); + + void modifyPosition(const SGGeod& newPos); + const PositionedID mGuid; + SGGeod mPosition; + const SGVec3d mCart; const Type mType; const std::string mIdent; + +private: + SG_DISABLE_COPY(FGPositioned); }; #endif // of FG_POSITIONED_HXX