Convert the only remaining user of FGFixList to use an FGPositioned query,
and hence remove the query code from fix-list. The only remaining code deals with parsing fix.dat.
This commit is contained in:
parent
d6277068f5
commit
059f2e6a8e
5 changed files with 11 additions and 155 deletions
|
@ -939,11 +939,10 @@ static bool fgSetPosFromCarrier( const string& carrier, const string& posid ) {
|
|||
// Set current_options lon/lat given an airport id and heading (degrees)
|
||||
static bool fgSetPosFromFix( const string& id )
|
||||
{
|
||||
FGFix* fix;
|
||||
|
||||
// set initial position from runway and heading
|
||||
if ( !globals->get_fixlist()->query( id.c_str(), fix ) ) {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate NAV = " << id );
|
||||
FGPositioned::TypeFilter fixFilter(FGPositioned::FIX);
|
||||
FGPositioned* fix = FGPositioned::findNextWithPartialId(NULL, id, &fixFilter);
|
||||
if (!fix) {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate fix = " << id );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -951,7 +950,6 @@ static bool fgSetPosFromFix( const string& id )
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize vor/ndb/ils/fix list management and query systems (as
|
||||
* well as simple airport db list)
|
||||
|
@ -1000,7 +998,6 @@ fgInitNav ()
|
|||
p_fix.append( "Navaids/fix.dat" );
|
||||
FGFixList *fixlist = new FGFixList;
|
||||
fixlist->init( p_fix );
|
||||
globals->set_fixlist( fixlist );
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, " Airways");
|
||||
SGPath p_awy( globals->get_fg_root() );
|
||||
|
|
|
@ -108,7 +108,6 @@ FGGlobals::FGGlobals() :
|
|||
tacanlist( NULL ),
|
||||
carrierlist( NULL ),
|
||||
channellist( NULL ),
|
||||
fixlist( NULL ),
|
||||
airwaynet( NULL ),
|
||||
multiplayer_mgr( NULL )
|
||||
{
|
||||
|
@ -160,7 +159,6 @@ FGGlobals::~FGGlobals()
|
|||
delete tacanlist;
|
||||
delete carrierlist;
|
||||
delete channellist;
|
||||
delete fixlist;
|
||||
delete airwaynet;
|
||||
delete multiplayer_mgr;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@ class FGIO;
|
|||
class FGNavList;
|
||||
class FGAirwayNetwork;
|
||||
class FGTACANList;
|
||||
class FGFixList;
|
||||
class FGLight;
|
||||
class FGModelMgr;
|
||||
class FGRouteMgr;
|
||||
|
@ -188,7 +187,6 @@ private:
|
|||
FGNavList *tacanlist;
|
||||
FGNavList *carrierlist;
|
||||
FGTACANList *channellist;
|
||||
FGFixList *fixlist;
|
||||
FGAirwayNetwork *airwaynet;
|
||||
|
||||
//Mulitplayer managers
|
||||
|
@ -335,8 +333,6 @@ public:
|
|||
inline void set_carrierlist( FGNavList *n ) { carrierlist = n; }
|
||||
inline FGNavList *get_mkrlist() const { return mkrlist; }
|
||||
inline void set_mkrlist( FGNavList *n ) { mkrlist = n; }
|
||||
inline FGFixList *get_fixlist() const { return fixlist; }
|
||||
inline void set_fixlist( FGFixList *f ) { fixlist = f; }
|
||||
inline FGTACANList *get_channellist() const { return channellist; }
|
||||
inline void set_channellist( FGTACANList *c ) { channellist = c; }
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/sgstream.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
|
||||
#include "fixlist.hxx"
|
||||
|
@ -51,9 +52,7 @@ FGFixList::~FGFixList( void ) {
|
|||
|
||||
|
||||
// load the navaids and build the map
|
||||
bool FGFixList::init( SGPath path ) {
|
||||
fixlist.erase( fixlist.begin(), fixlist.end() );
|
||||
|
||||
bool FGFixList::init(const SGPath& path ) {
|
||||
sg_gzifstream in( path.str() );
|
||||
if ( !in.is_open() ) {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << path.str() );
|
||||
|
@ -71,106 +70,10 @@ bool FGFixList::init( SGPath path ) {
|
|||
in >> lat >> lon >> ident;
|
||||
if (lat > 95) break;
|
||||
|
||||
FGFix* fix = new FGFix(ident, SGGeod::fromDeg(lon, lat));
|
||||
fixlist.insert(std::make_pair(fix->ident(), fix));
|
||||
// fix gets added to the FGPositioned spatial indices, so we don't need
|
||||
// to hold onto it here.
|
||||
new FGFix(ident, SGGeod::fromDeg(lon, lat));
|
||||
in >> skipcomment;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// query the database for the specified fix, lon and lat are in
|
||||
// degrees, elev is in meters
|
||||
bool FGFixList::query( const string& ident, FGFix* &fix ) {
|
||||
fix_map_const_iterator it = fixlist.find(ident);
|
||||
if ( it != fixlist.end() ) {
|
||||
fix = it->second;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// query the database for the specified fix, lon and lat are in
|
||||
// degrees, elev is in meters
|
||||
bool FGFixList::query_and_offset( const string& ident, double lon, double lat,
|
||||
double elev, FGFix* &fix, double *heading,
|
||||
double *dist )
|
||||
{
|
||||
std::pair<fix_map_const_iterator, fix_map_const_iterator> range = fixlist.equal_range(ident);
|
||||
|
||||
if (range.first == range.second) {
|
||||
return false;
|
||||
}
|
||||
|
||||
double min_s = -1.0;
|
||||
for (fix_map_const_iterator current = range.first; current != range.second; ++current) {
|
||||
double az1, az2, s;
|
||||
geo_inverse_wgs_84( elev, lat, lon,
|
||||
current->second->get_lat(), current->second->get_lon(),
|
||||
&az1, &az2, &s );
|
||||
// cout << " dist = " << s << endl;
|
||||
if (min_s < 0 || s < min_s) {
|
||||
*heading = az2;
|
||||
*dist = s;
|
||||
min_s = s;
|
||||
fix = current->second;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const FGFix* FGFixList::search(const string& ident)
|
||||
{
|
||||
fix_map_iterator itr = fixlist.find(ident);
|
||||
if (itr == fixlist.end()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
class orderingFunctor
|
||||
{
|
||||
public:
|
||||
orderingFunctor(FGIdentOrdering* aOrder) :
|
||||
mOrdering(aOrder)
|
||||
{ assert(aOrder); }
|
||||
|
||||
bool operator()(const fix_map_type::value_type& aA, const std::string& aB) const
|
||||
{
|
||||
return mOrdering->compare(aA.first,aB);
|
||||
}
|
||||
|
||||
bool operator()(const std::string& aA, const fix_map_type::value_type& aB) const
|
||||
{
|
||||
return mOrdering->compare(aA, aB.first);
|
||||
}
|
||||
|
||||
bool operator()(const fix_map_type::value_type& aA, const fix_map_type::value_type& aB) const
|
||||
{
|
||||
return mOrdering->compare(aA.first, aB.first);
|
||||
}
|
||||
|
||||
private:
|
||||
FGIdentOrdering* mOrdering;
|
||||
};
|
||||
|
||||
const FGFix* FGFixList::findFirstByIdent( const string& ident, FGIdentOrdering* aOrder)
|
||||
{
|
||||
fix_map_iterator itr;
|
||||
if (aOrder) {
|
||||
orderingFunctor func(aOrder);
|
||||
itr = std::lower_bound(fixlist.begin(),fixlist.end(), ident, func);
|
||||
} else {
|
||||
itr = fixlist.lower_bound(ident);
|
||||
}
|
||||
|
||||
if (itr == fixlist.end()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return itr->second;
|
||||
}
|
||||
|
|
|
@ -26,56 +26,18 @@
|
|||
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class FGFix;
|
||||
|
||||
using std::multimap;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
// fix names may be globally non-unique. Allow for this.
|
||||
typedef multimap < string, FGFix* > fix_map_type;
|
||||
typedef fix_map_type::iterator fix_map_iterator;
|
||||
typedef fix_map_type::const_iterator fix_map_const_iterator;
|
||||
|
||||
class FGIdentOrdering; // FIXME, currently declared in Airports/simple.hxx
|
||||
class SGPath;
|
||||
|
||||
class FGFixList {
|
||||
|
||||
fix_map_type fixlist;
|
||||
|
||||
public:
|
||||
|
||||
FGFixList();
|
||||
~FGFixList();
|
||||
|
||||
// load the navaids and build the map
|
||||
bool init( SGPath path );
|
||||
|
||||
// query the database for the specified fix
|
||||
bool query( const string& ident, FGFix* &f );
|
||||
|
||||
const FGFix* search(const string& ident);
|
||||
|
||||
// Find fix of requested type with closest exact or following ident
|
||||
// (by ACSII values) to that supplied (ie. a lower-bound lookup).
|
||||
// Supplying true for exact forces only exact matches to be returned (similar to above function)
|
||||
// Returns NULL if no match found.
|
||||
const FGFix* findFirstByIdent( const string& ident, FGIdentOrdering* aOrder = NULL);
|
||||
|
||||
// query the database for the specified fix, lon and lat are
|
||||
// in degrees, elev is in meters
|
||||
bool query_and_offset( const string& ident, double lon, double lat,
|
||||
double elev, FGFix* &f, double *heading,
|
||||
double *dist );
|
||||
|
||||
// Return a pointer to the master fixlist
|
||||
// inline const fix_map_type* getFixList() { return(&fixlist); }
|
||||
bool init(const SGPath& path);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue