FlightGear next
flightgear::NavDataCache Class Reference

#include <NavDataCache.hxx>

Classes

struct  DatFilesGroupInfo
 
class  NavDataCachePrivate
 
struct  SceneryLocation
 
class  ThreadedGUISearch
 
class  Transaction
 

Public Types

enum  DatFileType {
  DATFILETYPE_APT = 0 , DATFILETYPE_METAR , DATFILETYPE_AWY , DATFILETYPE_NAV ,
  DATFILETYPE_FIX , DATFILETYPE_POI , DATFILETYPE_CARRIER , DATFILETYPE_TACAN_FREQ ,
  DATFILETYPE_LAST
}
 
enum  RebuildPhase {
  REBUILD_UNKNOWN = 0 , REBUILD_READING_APT_DAT_FILES , REBUILD_LOADING_AIRPORTS , REBUILD_NAVAIDS ,
  REBUILD_FIXES , REBUILD_POIS , REBUILD_DONE
}
 
using SceneryLocationList = std::vector<SceneryLocation>
 

Public Member Functions

 ~NavDataCache ()
 
SGPath path () const
 
void updateListsOfDatFiles ()
 
const DatFilesGroupInfogetDatFilesInfo (DatFileType datFileType) const
 
bool isRebuildRequired ()
 predicate - check if the cache needs to be rebuilt.
 
RebuildPhase rebuild ()
 run the cache rebuild - returns the current phase or 'done'
 
unsigned int rebuildPhaseCompletionPercentage () const
 
void setRebuildPhaseProgress (RebuildPhase ph, unsigned int percent=0)
 
bool isCachedFileModified (const SGPath &path) const
 
void stampCacheFile (const SGPath &path, const std::string &sha={})
 
int readIntProperty (const std::string &key)
 
double readDoubleProperty (const std::string &key)
 
std::string readStringProperty (const std::string &key)
 
void writeIntProperty (const std::string &key, int value)
 
void writeStringProperty (const std::string &key, const std::string &value)
 
void writeDoubleProperty (const std::string &key, const double &value)
 
string_list readStringListProperty (const std::string &key)
 
void writeStringListProperty (const std::string &key, const string_list &values)
 
string_list readOrderedStringListProperty (const std::string &key, const char *separator)
 
void writeOrderedStringListProperty (const std::string &key, const string_list &values, const char *separator)
 
FGPositionedRef loadById (PositionedID guid)
 retrieve an FGPositioned from the cache.
 
PositionedID insertAirport (FGPositioned::Type ty, const std::string &ident, const std::string &name, const SGPath &sceneryPath)
 
void insertTower (PositionedID airportId, const SGGeod &pos)
 
PositionedID insertRunway (FGPositioned::Type ty, const std::string &ident, const SGGeod &pos, PositionedID apt, double heading, double length, double width, double displacedThreshold, double stopway, int markings, int approach, int tdz, int reil, int surfaceCode, int shoulder_code, float smoothness, int center_lights, int edge_lights, int distance_remaining)
 
PositionedID insertRunway (FGPositioned::Type ty, const std::string &ident, const SGGeod &pos, PositionedID apt, double heading, double length, double width, double displacedThreshold, double stopway, int surfaceCode)
 
void setRunwayReciprocal (PositionedID runway, PositionedID recip)
 
void setRunwayILS (PositionedID runway, PositionedID ils)
 
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 setNavaidColocated (PositionedID navaid, PositionedID colocatedDME)
 
PositionedID insertCommStation (FGPositioned::Type ty, const std::string &name, const SGGeod &pos, int freq, int range, PositionedID apt)
 
PositionedID createPOI (FGPositioned::Type ty, const std::string &ident, const SGGeod &aPos, const std::string &aName, bool transient)
 
bool removePOI (FGPositionedRef wpt)
 
void setAirportMetar (const std::string &icao, bool hasMetar)
 update the metar flag associated with an airport
 
void updatePosition (PositionedID item, const SGGeod &pos)
 Modify the position of an existing item.
 
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)
 
char ** searchAirportNamesAndIdents (const std::string &aFilter)
 Helper to implement the AirportSearch widget.
 
FGPositionedRef findCommByFreq (int freqKhz, const SGGeod &pos, FGPositioned::Filter *filt)
 Find the closest matching comm-station on a frequency, to a position.
 
PositionedIDVec findCommsByFreq (int freqKhz, const SGGeod &pos, FGPositioned::Filter *filt)
 Find all on a frequency, sorted by distance from a position The filter with be used for both type ranging and to validate the result candidates.
 
PositionedIDVec airportItemsOfType (PositionedID apt, FGPositioned::Type ty, FGPositioned::Type maxTy=FGPositioned::INVALID)
 find all items of a specified type (or range of types) at an airport
 
PositionedID airportItemWithIdent (PositionedID apt, FGPositioned::Type ty, const std::string &ident)
 find the first match item of the specified type and ident, at an airport
 
PositionedIDVec findNavaidsByFreq (int freqKhz, const SGGeod &pos, FGPositioned::Filter *filt)
 Find all navaids matching a particular frequency, sorted by range from the supplied position.
 
PositionedIDVec findNavaidsByFreq (int freqKhz, FGPositioned::Filter *filt)
 overload version of the above that does not consider positioned when returning results.
 
PositionedID findNavaidForRunway (PositionedID runway, FGPositioned::Type ty)
 Given a runway and type, find the corresponding navaid (ILS / GS / OM)
 
AirportRunwayPair findAirportRunway (const std::string &name)
 given a navaid name (or similar) from apt.dat / nav.dat, find the corresponding airport and runway IDs.
 
PositionedID findILS (PositionedID airport, const std::string &runway, const std::string &navIdent)
 Given an airport, and runway and ILS identifier, find the corresponding cache entry.
 
int getOctreeBranchChildren (int64_t octreeNodeId)
 Given an Octree node ID, return a bit-mask defining which of the child nodes exist.
 
void defineOctreeNode (Octree::Branch *pr, Octree::Node *nd)
 
TypedPositionedVec getOctreeLeafChildren (int64_t octreeNodeId)
 given an octree leaf, return all its child positioned items and their types
 
int findAirway (int network, const std::string &aName, bool create)
 
int findAirway (const std::string &aName)
 
void insertEdge (int network, int airwayID, PositionedID from, PositionedID to)
 insert an edge between two positioned nodes, into the network.
 
bool isInAirwayNetwork (int network, PositionedID pos)
 is the specified positioned a node on the network?
 
AirwayEdgeVec airwayEdgesFrom (int network, PositionedID pos)
 retrive all the destination points reachable from a positioned in an airway
 
AirwayRef loadAirway (int airwayID)
 
PositionedIDVec airwayWaypts (int id)
 Waypoints on the airway.
 
bool isReadOnly () const
 
void clearDynamicPositioneds ()
 
PositionedID createTransientID ()
 

Static Public Member Functions

static NavDataCacheinstance ()
 
static NavDataCachecreateInstance ()
 
static void shutdown ()
 
static bool isAnotherProcessRebuilding ()
 

Static Public Attributes

static const std::string datTypeStr []
 
static const std::string defaultDatFile []
 

Friends

class RebuildThread
 
class Transaction
 

Detailed Description

Definition at line 43 of file NavDataCache.hxx.

Member Typedef Documentation

◆ SceneryLocationList

Definition at line 75 of file NavDataCache.hxx.

Member Enumeration Documentation

◆ DatFileType

Enumerator
DATFILETYPE_APT 
DATFILETYPE_METAR 
DATFILETYPE_AWY 
DATFILETYPE_NAV 
DATFILETYPE_FIX 
DATFILETYPE_POI 
DATFILETYPE_CARRIER 
DATFILETYPE_TACAN_FREQ 
DATFILETYPE_LAST 

Definition at line 58 of file NavDataCache.hxx.

◆ RebuildPhase

Enumerator
REBUILD_UNKNOWN 
REBUILD_READING_APT_DAT_FILES 
REBUILD_LOADING_AIRPORTS 
REBUILD_NAVAIDS 
REBUILD_FIXES 
REBUILD_POIS 
REBUILD_DONE 

Definition at line 107 of file NavDataCache.hxx.

Constructor & Destructor Documentation

◆ ~NavDataCache()

flightgear::NavDataCache::~NavDataCache ( )

Definition at line 1403 of file NavDataCache.cxx.

Member Function Documentation

◆ airportItemsOfType()

PositionedIDVec flightgear::NavDataCache::airportItemsOfType ( PositionedID apt,
FGPositioned::Type ty,
FGPositioned::Type maxTy = FGPositioned::INVALID )

find all items of a specified type (or range of types) at an airport

Definition at line 2607 of file NavDataCache.cxx.

◆ airportItemWithIdent()

PositionedID flightgear::NavDataCache::airportItemWithIdent ( PositionedID apt,
FGPositioned::Type ty,
const std::string & ident )

find the first match item of the specified type and ident, at an airport

Definition at line 2622 of file NavDataCache.cxx.

◆ airwayEdgesFrom()

AirwayEdgeVec flightgear::NavDataCache::airwayEdgesFrom ( int network,
PositionedID pos )

retrive all the destination points reachable from a positioned in an airway

Definition at line 2743 of file NavDataCache.cxx.

◆ airwayWaypts()

PositionedIDVec flightgear::NavDataCache::airwayWaypts ( int id)

Waypoints on the airway.

Definition at line 2789 of file NavDataCache.cxx.

◆ clearDynamicPositioneds()

void flightgear::NavDataCache::clearDynamicPositioneds ( )

Definition at line 2058 of file NavDataCache.cxx.

◆ createInstance()

NavDataCache * flightgear::NavDataCache::createInstance ( )
static

Definition at line 1426 of file NavDataCache.cxx.

◆ createPOI()

PositionedID flightgear::NavDataCache::createPOI ( FGPositioned::Type ty,
const std::string & ident,
const SGGeod & aPos,
const std::string & aName,
bool transient )

Definition at line 2303 of file NavDataCache.cxx.

◆ createTransientID()

PositionedID flightgear::NavDataCache::createTransientID ( )

Definition at line 2926 of file NavDataCache.cxx.

◆ defineOctreeNode()

void flightgear::NavDataCache::defineOctreeNode ( Octree::Branch * pr,
Octree::Node * nd )

Definition at line 2408 of file NavDataCache.cxx.

◆ findAirportRunway()

AirportRunwayPair flightgear::NavDataCache::findAirportRunway ( const std::string & name)

given a navaid name (or similar) from apt.dat / nav.dat, find the corresponding airport and runway IDs.

Such names look like: 'LHBP 31L DME-ILS' or 'UEEE 23L MM'

Definition at line 2639 of file NavDataCache.cxx.

◆ findAirway() [1/2]

int flightgear::NavDataCache::findAirway ( const std::string & aName)

◆ findAirway() [2/2]

int flightgear::NavDataCache::findAirway ( int network,
const std::string & aName,
bool create )

◆ findAllWithIdent()

FGPositionedList flightgear::NavDataCache::findAllWithIdent ( const std::string & ident,
FGPositioned::Filter * filter,
bool exact )

Definition at line 2341 of file NavDataCache.cxx.

◆ findAllWithName()

FGPositionedList flightgear::NavDataCache::findAllWithName ( const std::string & ident,
FGPositioned::Filter * filter,
bool exact )

Definition at line 2349 of file NavDataCache.cxx.

◆ findClosestWithIdent()

FGPositionedRef flightgear::NavDataCache::findClosestWithIdent ( const std::string & aIdent,
const SGGeod & aPos,
FGPositioned::Filter * aFilter )

Definition at line 2357 of file NavDataCache.cxx.

◆ findCommByFreq()

FGPositionedRef flightgear::NavDataCache::findCommByFreq ( int freqKhz,
const SGGeod & pos,
FGPositioned::Filter * filt )

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.

Definition at line 2524 of file NavDataCache.cxx.

◆ findCommsByFreq()

PositionedIDVec flightgear::NavDataCache::findCommsByFreq ( int freqKhz,
const SGGeod & pos,
FGPositioned::Filter * filt )

Find all on a frequency, sorted by distance from a position The filter with be used for both type ranging and to validate the result candidates.

Definition at line 2535 of file NavDataCache.cxx.

◆ findILS()

PositionedID flightgear::NavDataCache::findILS ( PositionedID airport,
const std::string & runway,
const std::string & navIdent )

Given an airport, and runway and ILS identifier, find the corresponding cache entry.

This matches the data we get in the ils.xml files for airports.

Definition at line 2669 of file NavDataCache.cxx.

◆ findNavaidForRunway()

PositionedID flightgear::NavDataCache::findNavaidForRunway ( PositionedID runway,
FGPositioned::Type ty )

Given a runway and type, find the corresponding navaid (ILS / GS / OM)

Definition at line 2902 of file NavDataCache.cxx.

◆ findNavaidsByFreq() [1/2]

PositionedIDVec flightgear::NavDataCache::findNavaidsByFreq ( int freqKhz,
const SGGeod & pos,
FGPositioned::Filter * filt )

Find all navaids matching a particular frequency, sorted by range from the supplied position.

Type-range will be determined from the filter

Definition at line 2572 of file NavDataCache.cxx.

◆ findNavaidsByFreq() [2/2]

PositionedIDVec flightgear::NavDataCache::findNavaidsByFreq ( int freqKhz,
FGPositioned::Filter * filt )

overload version of the above that does not consider positioned when returning results.

Only used by TACAN carrier search

Definition at line 2592 of file NavDataCache.cxx.

◆ getDatFilesInfo()

const NavDataCache::DatFilesGroupInfo & flightgear::NavDataCache::getDatFilesInfo ( DatFileType datFileType) const

Definition at line 1474 of file NavDataCache.cxx.

◆ getOctreeBranchChildren()

int flightgear::NavDataCache::getOctreeBranchChildren ( int64_t octreeNodeId)

Given an Octree node ID, return a bit-mask defining which of the child nodes exist.

In practice this means an 8-bit value be sufficient, but an int works fine too.

Definition at line 2392 of file NavDataCache.cxx.

◆ getOctreeLeafChildren()

TypedPositionedVec flightgear::NavDataCache::getOctreeLeafChildren ( int64_t octreeNodeId)

given an octree leaf, return all its child positioned items and their types

Definition at line 2432 of file NavDataCache.cxx.

◆ insertAirport()

PositionedID flightgear::NavDataCache::insertAirport ( FGPositioned::Type ty,
const std::string & ident,
const std::string & name,
const SGPath & sceneryPath )

Definition at line 2100 of file NavDataCache.cxx.

◆ insertCommStation()

PositionedID flightgear::NavDataCache::insertCommStation ( FGPositioned::Type ty,
const std::string & name,
const SGGeod & pos,
int freq,
int range,
PositionedID apt )

Definition at line 2292 of file NavDataCache.cxx.

◆ insertEdge()

void flightgear::NavDataCache::insertEdge ( int network,
int airwayID,
PositionedID from,
PositionedID to )

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.

Definition at line 2724 of file NavDataCache.cxx.

◆ insertNavaid()

PositionedID flightgear::NavDataCache::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 )

Definition at line 2257 of file NavDataCache.cxx.

◆ insertRunway() [1/2]

PositionedID flightgear::NavDataCache::insertRunway ( FGPositioned::Type ty,
const std::string & ident,
const SGGeod & pos,
PositionedID apt,
double heading,
double length,
double width,
double displacedThreshold,
double stopway,
int markings,
int approach,
int tdz,
int reil,
int surfaceCode,
int shoulder_code,
float smoothness,
int center_lights,
int edge_lights,
int distance_remaining )

◆ insertRunway() [2/2]

PositionedID flightgear::NavDataCache::insertRunway ( FGPositioned::Type ty,
const std::string & ident,
const SGGeod & pos,
PositionedID apt,
double heading,
double length,
double width,
double displacedThreshold,
double stopway,
int surfaceCode )

◆ insertTower()

void flightgear::NavDataCache::insertTower ( PositionedID airportId,
const SGGeod & pos )

Definition at line 2179 of file NavDataCache.cxx.

◆ instance()

NavDataCache * flightgear::NavDataCache::instance ( )
static

Definition at line 1433 of file NavDataCache.cxx.

◆ isAnotherProcessRebuilding()

bool flightgear::NavDataCache::isAnotherProcessRebuilding ( )
static

Definition at line 1632 of file NavDataCache.cxx.

◆ isCachedFileModified()

bool flightgear::NavDataCache::isCachedFileModified ( const SGPath & path) const

Definition at line 1965 of file NavDataCache.cxx.

◆ isInAirwayNetwork()

bool flightgear::NavDataCache::isInAirwayNetwork ( int network,
PositionedID pos )

is the specified positioned a node on the network?

Definition at line 2733 of file NavDataCache.cxx.

◆ isReadOnly()

bool flightgear::NavDataCache::isReadOnly ( ) const

Definition at line 2916 of file NavDataCache.cxx.

◆ isRebuildRequired()

bool flightgear::NavDataCache::isRebuildRequired ( )

predicate - check if the cache needs to be rebuilt.

This can happen is the cache file is missing or damaged, or one of the global input files is changed.

Definition at line 1485 of file NavDataCache.cxx.

◆ loadAirway()

AirwayRef flightgear::NavDataCache::loadAirway ( int airwayID)

Definition at line 2775 of file NavDataCache.cxx.

◆ loadById()

FGPositionedRef flightgear::NavDataCache::loadById ( PositionedID guid)

retrieve an FGPositioned from the cache.

This may be trivial if the object is previously loaded, or require actual disk IO.

Definition at line 2068 of file NavDataCache.cxx.

◆ path()

SGPath flightgear::NavDataCache::path ( ) const

Definition at line 2921 of file NavDataCache.cxx.

◆ readDoubleProperty()

double flightgear::NavDataCache::readDoubleProperty ( const std::string & key)

Definition at line 1850 of file NavDataCache.cxx.

◆ readIntProperty()

int flightgear::NavDataCache::readIntProperty ( const std::string & key)

Definition at line 1835 of file NavDataCache.cxx.

◆ readOrderedStringListProperty()

string_list flightgear::NavDataCache::readOrderedStringListProperty ( const std::string & key,
const char * separator )

Definition at line 1933 of file NavDataCache.cxx.

◆ readStringListProperty()

string_list flightgear::NavDataCache::readStringListProperty ( const std::string & key)

Definition at line 1907 of file NavDataCache.cxx.

◆ readStringProperty()

string flightgear::NavDataCache::readStringProperty ( const std::string & key)

Definition at line 1864 of file NavDataCache.cxx.

◆ rebuild()

NavDataCache::RebuildPhase flightgear::NavDataCache::rebuild ( )

run the cache rebuild - returns the current phase or 'done'

Definition at line 1606 of file NavDataCache.cxx.

◆ rebuildPhaseCompletionPercentage()

unsigned int flightgear::NavDataCache::rebuildPhaseCompletionPercentage ( ) const

Definition at line 1693 of file NavDataCache.cxx.

◆ removePOI()

bool flightgear::NavDataCache::removePOI ( FGPositionedRef wpt)

Definition at line 2316 of file NavDataCache.cxx.

◆ searchAirportNamesAndIdents()

char ** flightgear::NavDataCache::searchAirportNamesAndIdents ( const std::string & searchInput)

Helper to implement the AirportSearch widget.

A special purpose helper (used by FGAirport::searchNamesAndIdents) to implement the AirportList dialog.

Optimised text search of airport names and idents, returning a list suitable for passing directly to PLIB.

It's unfortunate that it needs to reside here, but for now it's least ugly solution.

Definition at line 2454 of file NavDataCache.cxx.

◆ setAirportMetar()

void flightgear::NavDataCache::setAirportMetar ( const std::string & icao,
bool hasMetar )

update the metar flag associated with an airport

Definition at line 2333 of file NavDataCache.cxx.

◆ setNavaidColocated()

void flightgear::NavDataCache::setNavaidColocated ( PositionedID navaid,
PositionedID colocatedDME )

Definition at line 2278 of file NavDataCache.cxx.

◆ setRebuildPhaseProgress()

void flightgear::NavDataCache::setRebuildPhaseProgress ( RebuildPhase ph,
unsigned int percent = 0 )

Definition at line 1702 of file NavDataCache.cxx.

◆ setRunwayILS()

void flightgear::NavDataCache::setRunwayILS ( PositionedID runway,
PositionedID ils )

Definition at line 2243 of file NavDataCache.cxx.

◆ setRunwayReciprocal()

void flightgear::NavDataCache::setRunwayReciprocal ( PositionedID runway,
PositionedID recip )

Definition at line 2231 of file NavDataCache.cxx.

◆ shutdown()

void flightgear::NavDataCache::shutdown ( )
static

Definition at line 1438 of file NavDataCache.cxx.

◆ stampCacheFile()

void flightgear::NavDataCache::stampCacheFile ( const SGPath & path,
const std::string & sha = {} )

Definition at line 1970 of file NavDataCache.cxx.

◆ updateListsOfDatFiles()

void flightgear::NavDataCache::updateListsOfDatFiles ( )

Definition at line 1447 of file NavDataCache.cxx.

◆ updatePosition()

void flightgear::NavDataCache::updatePosition ( PositionedID item,
const SGGeod & pos )

Modify the position of an existing item.

Definition at line 2119 of file NavDataCache.cxx.

◆ writeDoubleProperty()

void flightgear::NavDataCache::writeDoubleProperty ( const std::string & key,
const double & value )

Definition at line 1895 of file NavDataCache.cxx.

◆ writeIntProperty()

void flightgear::NavDataCache::writeIntProperty ( const std::string & key,
int value )

Definition at line 1878 of file NavDataCache.cxx.

◆ writeOrderedStringListProperty()

void flightgear::NavDataCache::writeOrderedStringListProperty ( const std::string & key,
const string_list & values,
const char * separator )

Definition at line 1944 of file NavDataCache.cxx.

◆ writeStringListProperty()

void flightgear::NavDataCache::writeStringListProperty ( const std::string & key,
const string_list & values )

Definition at line 1919 of file NavDataCache.cxx.

◆ writeStringProperty()

void flightgear::NavDataCache::writeStringProperty ( const std::string & key,
const std::string & value )

Definition at line 1883 of file NavDataCache.cxx.

Friends And Related Symbol Documentation

◆ RebuildThread

friend class RebuildThread
friend

Definition at line 350 of file NavDataCache.hxx.

◆ Transaction

friend class Transaction
friend

Definition at line 359 of file NavDataCache.hxx.

Member Data Documentation

◆ datTypeStr

const string flightgear::NavDataCache::datTypeStr
static
Initial value:
= {
string("apt"),
string("metar"),
string("awy"),
string("nav"),
string("fix"),
string("poi"),
string("carrier"),
string("TACAN_freq")
}

Definition at line 86 of file NavDataCache.hxx.

◆ defaultDatFile

const string flightgear::NavDataCache::defaultDatFile
static
Initial value:
= {
string("Airports/apt.dat.gz"),
string("Airports/metar.dat.gz"),
string("Navaids/awy.dat.gz"),
string("Navaids/nav.dat.gz"),
string("Navaids/fix.dat.gz"),
string("Navaids/poi.dat.gz"),
string("Navaids/carrier.dat.gz"),
string("Navaids/TACAN_freq.dat.gz")
}

Definition at line 90 of file NavDataCache.hxx.


The documentation for this class was generated from the following files: