X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNavaids%2FNavDataCache.hxx;h=e5d9e7c06f3a01fc1d5ffedd78e2396f6e91abba;hb=5ccc83566785c9b5b75e8d03579dbd1aa45d7237;hp=19edb91d7d4c7e0381598df88ed5d2ff996d35bb;hpb=32248bf576f720789c99c1c5901280be0d4fe3ca;p=flightgear.git diff --git a/src/Navaids/NavDataCache.hxx b/src/Navaids/NavDataCache.hxx index 19edb91d7..e5d9e7c06 100644 --- a/src/Navaids/NavDataCache.hxx +++ b/src/Navaids/NavDataCache.hxx @@ -30,6 +30,7 @@ #include class SGPath; +class FGRunway; namespace flightgear { @@ -63,11 +64,18 @@ public: ** global input files is changed. */ bool isRebuildRequired(); - + + /** + * check if cached scenery paths have changed, and if so, drop scenery- + * dependant data such as ground-nets. + */ + bool dropGroundnetsIfRequired(); + /** - * run the cache rebuild + * run the cache rebuild - returns true if rebuild is complete, + * otherwise keep going. */ - void rebuild(); + bool rebuild(); bool isCachedFileModified(const SGPath& path) const; void stampCacheFile(const SGPath& path); @@ -83,7 +91,12 @@ public: string_list readStringListProperty(const std::string& key); void writeStringListProperty(const std::string& key, const string_list& values); - FGPositioned* loadById(PositionedID guid); + /** + * retrieve an FGPositioned from the cache. + * This may be trivial if the object is previously loaded, or require actual + * disk IO. + */ + FGPositionedRef loadById(PositionedID guid); PositionedID insertAirport(FGPositioned::Type ty, const std::string& ident, const std::string& name); @@ -95,50 +108,103 @@ public: void setRunwayReciprocal(PositionedID runway, PositionedID recip); void setRunwayILS(PositionedID runway, PositionedID ils); - void updateRunwayThreshold(PositionedID runwayID, const SGGeod &aThreshold, - double aHeading, double aDisplacedThreshold, - double aStopway); - PositionedID insertNavaid(FGPositioned::Type ty, const std::string& ident, const std::string& name, const SGGeod& pos, int freq, int range, double multiuse, PositionedID apt, PositionedID runway); - void updateILS(PositionedID ils, const SGGeod& newPos, double aHdg); + + // Assign colocated DME to a navaid + void setNavaidColocated(PositionedID navaid, PositionedID colocatedDME); PositionedID insertCommStation(FGPositioned::Type ty, const std::string& name, const SGGeod& pos, int freq, int range, PositionedID apt); PositionedID insertFix(const std::string& ident, const SGGeod& aPos); - PositionedID createUserWaypoint(const std::string& ident, const SGGeod& aPos); + PositionedID createPOI(FGPositioned::Type ty, const std::string& ident, const SGGeod& aPos); + + bool removePOI(FGPositioned::Type ty, const std::string& aIdent); + + void dropGroundnetFor(PositionedID aAirport); + + /** + * Remove all ground-nets globally from the cache. + * This includes parking and taxi-nodes and edges between them. It's useful + * when scenery paths change, since the ground-nets depend on the scenery. + * Using this we can avoid havind to rebuild the entire cache. + */ + void dropAllGroundnets(); + + PositionedID insertParking(const std::string& name, const SGGeod& aPos, + PositionedID aAirport, + double aHeading, int aRadius, const std::string& aAircraftType, + const std::string& aAirlines); + + void setParkingPushBackRoute(PositionedID parking, PositionedID pushBackNode); + PositionedID insertTaxiNode(const SGGeod& aPos, PositionedID aAirport, int aHoldType, bool aOnRunway); + + void insertGroundnetEdge(PositionedID aAirport, PositionedID from, PositionedID to); + + /// update the metar flag associated with an airport void setAirportMetar(const std::string& icao, bool hasMetar); + /** + * Modify the position of an existing item. + */ void updatePosition(PositionedID item, const SGGeod &pos); - FGPositioned::List findAllWithIdent(const std::string& ident, - FGPositioned::Filter* filter, bool exact); - FGPositioned::List findAllWithName(const std::string& ident, - FGPositioned::Filter* filter, bool exact); + FGPositionedList findAllWithIdent( const std::string& ident, + FGPositioned::Filter* filter, + bool exact ); + FGPositionedList findAllWithName( const std::string& ident, + FGPositioned::Filter* filter, + bool exact ); - FGPositionedRef findClosestWithIdent(const std::string& aIdent, - const SGGeod& aPos, FGPositioned::Filter* aFilter); + FGPositionedRef findClosestWithIdent( const std::string& aIdent, + const SGGeod& aPos, + FGPositioned::Filter* aFilter ); + /** + * Helper to implement the AirportSearch widget. Optimised text search of + * airport names and idents, returning a list suitable for passing directly + * to PLIB. + */ char** searchAirportNamesAndIdents(const std::string& aFilter); + /** + * Find the closest matching comm-station on a frequency, to a position. + * The filter with be used for both type ranging and to validate the result + * candidates. + */ FGPositionedRef findCommByFreq(int freqKhz, const SGGeod& pos, FGPositioned::Filter* filt); + /** + * find all items of a specified type (or range of types) at an airport + */ PositionedIDVec airportItemsOfType(PositionedID apt, FGPositioned::Type ty, FGPositioned::Type maxTy = FGPositioned::INVALID); + /** + * find the first match item of the specified type and ident, at an airport + */ PositionedID airportItemWithIdent(PositionedID apt, FGPositioned::Type ty, const std::string& ident); - + + /** + * Find all navaids matching a particular frequency, sorted by range from the + * supplied position. Type-range will be determined from the filter + */ PositionedIDVec findNavaidsByFreq(int freqKhz, const SGGeod& pos, FGPositioned::Filter* filt); /// overload version of the above that does not consider positioned when /// returning results. Only used by TACAN carrier search PositionedIDVec findNavaidsByFreq(int freqKhz, FGPositioned::Filter* filt); + /** + * Given a runway and type, find the corresponding navaid (ILS / GS / OM) + */ + PositionedID findNavaidForRunway(PositionedID runway, FGPositioned::Type ty); + /** * given a navaid name (or similar) from apt.dat / nav.dat, find the * corresponding airport and runway IDs. @@ -169,8 +235,15 @@ public: // airways int findAirway(int network, const std::string& aName); + /** + * insert an edge between two positioned nodes, into the network. + * The airway identifier will be set accordingly. No reverse edge is created + * by this method - edges are directional so a reverses must be explicitly + * created. + */ void insertEdge(int network, int airwayID, PositionedID from, PositionedID to); + /// is the specified positioned a node on the network? bool isInAirwayNetwork(int network, PositionedID pos); /** @@ -178,8 +251,43 @@ public: * in an airway */ AirwayEdgeVec airwayEdgesFrom(int network, PositionedID pos); + +// ground-network + PositionedIDVec groundNetNodes(PositionedID aAirport, bool onlyPushback); + void markGroundnetAsPushback(PositionedID nodeId); + + PositionedID findGroundNetNode(PositionedID airport, const SGGeod& aPos, + bool onRunway, FGRunway* aRunway = NULL); + PositionedIDVec groundNetEdgesFrom(PositionedID pos, bool onlyPushback); + + PositionedIDVec findAirportParking(PositionedID airport, const std::string& flightType, + int radius); + + + class Transaction + { + public: + Transaction(NavDataCache* cache); + ~Transaction(); + + void commit(); + private: + NavDataCache* _instance; + bool _committed; + }; + + bool isReadOnly() const; private: NavDataCache(); + + friend class RebuildThread; + void doRebuild(); + + friend class Transaction; + + void beginTransaction(); + void commitTransaction(); + void abortTransaction(); class NavDataCachePrivate; std::auto_ptr d;