Move navaids and fixes out of "global" name space into the FGGlobals
structure.
This commit is contained in:
parent
88f6b4e23b
commit
78e6d35998
19 changed files with 102 additions and 71 deletions
|
@ -677,7 +677,7 @@ int NewWaypoint( string Tgt_Alt )
|
|||
|
||||
return 1;
|
||||
|
||||
} else if ( current_fixlist->query( TgtAptId, &f ) ) {
|
||||
} else if ( globals->get_fixlist()->query( TgtAptId, &f ) ) {
|
||||
SG_LOG( SG_GENERAL, SG_INFO,
|
||||
"Adding waypoint (fix) = " << TgtAptId );
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ void FGDME::search()
|
|||
FGILS *ils;
|
||||
FGNav *nav;
|
||||
|
||||
if ( (ils = current_ilslist->findByFreq( freq, lon, lat, elev )) != NULL ) {
|
||||
if ( (ils = globals->get_ilslist()->findByFreq( freq, lon, lat, elev )) != NULL ) {
|
||||
if ( ils->get_has_dme() ) {
|
||||
valid = true;
|
||||
lon = ils->get_loclon();
|
||||
|
@ -233,7 +233,7 @@ void FGDME::search()
|
|||
y = ils->get_dme_y();
|
||||
z = ils->get_dme_z();
|
||||
}
|
||||
} else if ( (nav = current_navlist->findByFreq(freq, lon, lat, elev)) != NULL ) {
|
||||
} else if ( (nav = globals->get_navlist()->findByFreq(freq, lon, lat, elev)) != NULL ) {
|
||||
if (nav->get_has_dme()) {
|
||||
valid = true;
|
||||
lon = nav->get_lon();
|
||||
|
|
|
@ -488,7 +488,7 @@ void FGKR_87::search() {
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FGNav *nav
|
||||
= current_navlist->findByFreq(freq, acft_lon, acft_lat, acft_elev);
|
||||
= globals->get_navlist()->findByFreq(freq, acft_lon, acft_lat, acft_elev);
|
||||
|
||||
if ( nav != NULL ) {
|
||||
char sfreq[128];
|
||||
|
|
|
@ -174,8 +174,8 @@ void FGMarkerBeacon::search()
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FGMkrBeacon::fgMkrBeacType beacon_type
|
||||
= current_beacons->query( lon * SGD_RADIANS_TO_DEGREES,
|
||||
lat * SGD_RADIANS_TO_DEGREES, elev );
|
||||
= globals->get_beacons()->query( lon * SGD_RADIANS_TO_DEGREES,
|
||||
lat * SGD_RADIANS_TO_DEGREES, elev );
|
||||
|
||||
outer_marker = middle_marker = inner_marker = false;
|
||||
|
||||
|
|
|
@ -604,7 +604,7 @@ void FGNavCom::search()
|
|||
// Nav.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if ( (ils = current_ilslist->findByFreq(nav_freq, lon, lat, elev)) != NULL ) {
|
||||
if ( (ils = globals->get_ilslist()->findByFreq(nav_freq, lon, lat, elev)) != NULL ) {
|
||||
nav_id = ils->get_locident();
|
||||
nav_valid = true;
|
||||
if ( last_nav_id != nav_id || last_nav_vor ) {
|
||||
|
@ -678,7 +678,7 @@ void FGNavCom::search()
|
|||
// cout << "Found an ils station in range" << endl;
|
||||
// cout << " id = " << ils->get_locident() << endl;
|
||||
}
|
||||
} else if ( (nav = current_navlist->findByFreq(nav_freq, lon, lat, elev)) != NULL ) {
|
||||
} else if ( (nav = globals->get_navlist()->findByFreq(nav_freq, lon, lat, elev)) != NULL ) {
|
||||
nav_id = nav->get_ident();
|
||||
nav_valid = (nav->get_type() == 'V');
|
||||
if ( last_nav_id != nav_id || !last_nav_vor ) {
|
||||
|
|
|
@ -163,9 +163,9 @@ ADF::search (double frequency_khz, double longitude_rad,
|
|||
_time_before_search_sec = 1.0;
|
||||
|
||||
// try the ILS list first
|
||||
FGNav * nav =
|
||||
current_navlist->findByFreq(frequency_khz, longitude_rad,
|
||||
latitude_rad, altitude_m);
|
||||
FGNav *nav =
|
||||
globals->get_navlist()->findByFreq(frequency_khz, longitude_rad,
|
||||
latitude_rad, altitude_m);
|
||||
|
||||
if (nav !=0) {
|
||||
_transmitter_valid = true;
|
||||
|
|
|
@ -149,10 +149,10 @@ DME::search (double frequency_mhz, double longitude_rad,
|
|||
_time_before_search_sec = 1.0;
|
||||
|
||||
// try the ILS list first
|
||||
FGILS * ils = current_ilslist->findByFreq(frequency_mhz,
|
||||
longitude_rad,
|
||||
latitude_rad,
|
||||
altitude_m);
|
||||
FGILS *ils = globals->get_ilslist()->findByFreq(frequency_mhz,
|
||||
longitude_rad,
|
||||
latitude_rad,
|
||||
altitude_m);
|
||||
if (ils !=0 && ils->get_has_dme()) {
|
||||
_transmitter_valid = true;
|
||||
_transmitter = Point3D(ils->get_dme_x(),
|
||||
|
@ -164,10 +164,10 @@ DME::search (double frequency_mhz, double longitude_rad,
|
|||
}
|
||||
|
||||
// try the VORs next
|
||||
FGNav * nav = current_navlist->findByFreq(frequency_mhz,
|
||||
longitude_rad,
|
||||
latitude_rad,
|
||||
altitude_m);
|
||||
FGNav *nav = globals->get_navlist()->findByFreq(frequency_mhz,
|
||||
longitude_rad,
|
||||
latitude_rad,
|
||||
altitude_m);
|
||||
if (nav != 0 && nav->get_has_dme()) {
|
||||
_transmitter_valid = true;
|
||||
_transmitter = Point3D(nav->get_x(),
|
||||
|
|
|
@ -326,10 +326,12 @@ GPS::update (double delta_time_sec)
|
|||
}
|
||||
}
|
||||
else if (waypont_type == "nav") {
|
||||
FGNav * n;
|
||||
if ( (n = current_navlist->findByIdent(wp0_ID.c_str(),
|
||||
longitude_deg,
|
||||
latitude_deg)) != NULL) {
|
||||
FGNav *n;
|
||||
if ( (n = globals->get_navlist()->findByIdent(wp0_ID.c_str(),
|
||||
longitude_deg,
|
||||
latitude_deg))
|
||||
!= NULL)
|
||||
{
|
||||
//cout << "Nav found" << endl;
|
||||
wp0_longitude_deg = n->get_lon();
|
||||
wp0_latitude_deg = n->get_lat();
|
||||
|
@ -338,7 +340,7 @@ GPS::update (double delta_time_sec)
|
|||
}
|
||||
else if (waypont_type == "fix") {
|
||||
FGFix f;
|
||||
if ( current_fixlist->query(wp0_ID, &f) ) {
|
||||
if ( globals->get_fixlist()->query(wp0_ID, &f) ) {
|
||||
//cout << "Fix found" << endl;
|
||||
wp0_longitude_deg = f.get_lon();
|
||||
wp0_latitude_deg = f.get_lat();
|
||||
|
@ -365,9 +367,11 @@ GPS::update (double delta_time_sec)
|
|||
}
|
||||
else if (waypont_type == "nav") {
|
||||
FGNav * n;
|
||||
if ( (n = current_navlist->findByIdent(wp1_ID.c_str(),
|
||||
longitude_deg,
|
||||
latitude_deg)) != NULL) {
|
||||
if ( (n = globals->get_navlist()->findByIdent(wp1_ID.c_str(),
|
||||
longitude_deg,
|
||||
latitude_deg))
|
||||
!= NULL)
|
||||
{
|
||||
//cout << "Nav found" << endl;
|
||||
wp1_longitude_deg = n->get_lon();
|
||||
wp1_latitude_deg = n->get_lat();
|
||||
|
@ -376,7 +380,7 @@ GPS::update (double delta_time_sec)
|
|||
}
|
||||
else if (waypont_type == "fix") {
|
||||
FGFix f;
|
||||
if ( current_fixlist->query(wp1_ID, &f) ) {
|
||||
if ( globals->get_fixlist()->query(wp1_ID, &f) ) {
|
||||
//cout << "Fix found" << endl;
|
||||
wp1_longitude_deg = f.get_lon();
|
||||
wp1_latitude_deg = f.get_lat();
|
||||
|
|
|
@ -906,7 +906,7 @@ static void fgSetDistOrAltFromGlideSlope() {
|
|||
|
||||
// Set current_options lon/lat given an airport id and heading (degrees)
|
||||
static bool fgSetPosFromNAV( const string& id, const double& freq ) {
|
||||
FGNav *nav = current_navlist->findByIdentAndFreq( id.c_str(), freq );
|
||||
FGNav *nav = globals->get_navlist()->findByIdentAndFreq( id.c_str(), freq );
|
||||
|
||||
// set initial position from runway and heading
|
||||
if ( nav != NULL ) {
|
||||
|
@ -958,7 +958,7 @@ static bool fgSetPosFromFix( const string& id ) {
|
|||
FGFix fix;
|
||||
|
||||
// set initial position from runway and heading
|
||||
if ( current_fixlist->query( id.c_str(), &fix ) ) {
|
||||
if ( globals->get_fixlist()->query( id.c_str(), &fix ) ) {
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Attempting to set starting position for "
|
||||
<< id );
|
||||
|
||||
|
@ -1049,24 +1049,28 @@ fgInitNav ()
|
|||
SG_LOG(SG_GENERAL, SG_INFO, "Loading Navaids");
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, " VOR/NDB");
|
||||
current_navlist = new FGNavList;
|
||||
FGNavList *navlist = new FGNavList;
|
||||
SGPath p_nav( globals->get_fg_root() );
|
||||
p_nav.append( "Navaids/default.nav" );
|
||||
current_navlist->init( p_nav );
|
||||
navlist->init( p_nav );
|
||||
globals->set_navlist( navlist );
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, " ILS and Marker Beacons");
|
||||
current_beacons = new FGMarkerBeacons;
|
||||
current_beacons->init();
|
||||
current_ilslist = new FGILSList;
|
||||
FGMarkerBeacons *beacons = new FGMarkerBeacons;
|
||||
beacons->init();
|
||||
globals->set_beacons( beacons );
|
||||
FGILSList *ilslist = new FGILSList;
|
||||
SGPath p_ils( globals->get_fg_root() );
|
||||
p_ils.append( "Navaids/default.ils" );
|
||||
current_ilslist->init( p_ils );
|
||||
ilslist->init( p_ils );
|
||||
globals->set_ilslist( ilslist );
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, " Fixes");
|
||||
current_fixlist = new FGFixList;
|
||||
FGFixList *fixlist = new FGFixList;
|
||||
SGPath p_fix( globals->get_fg_root() );
|
||||
p_fix.append( "Navaids/fix.dat" );
|
||||
current_fixlist->init( p_fix );
|
||||
fixlist->init( p_fix );
|
||||
globals->set_fixlist( fixlist );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,11 @@ FGGlobals::FGGlobals() :
|
|||
initial_waypoints(0),
|
||||
scenery( NULL ),
|
||||
tile_mgr( NULL ),
|
||||
io( new FGIO )
|
||||
io( new FGIO ),
|
||||
navlist( NULL ),
|
||||
fixlist( NULL ),
|
||||
ilslist( NULL ),
|
||||
beacons( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,10 @@ class FGATCDisplay;
|
|||
class FGAircraftModel;
|
||||
class FGControls;
|
||||
class FGIO;
|
||||
class FGNavList;
|
||||
class FGFixList;
|
||||
class FGILSList;
|
||||
class FGMarkerBeacons;
|
||||
class FGLight;
|
||||
class FGModelMgr;
|
||||
class FGRouteMgr;
|
||||
|
@ -191,6 +195,12 @@ private:
|
|||
// Input/Ouput subsystem
|
||||
FGIO *io;
|
||||
|
||||
// Navigational Aids
|
||||
FGNavList *navlist;
|
||||
FGFixList *fixlist;
|
||||
FGILSList *ilslist;
|
||||
FGMarkerBeacons *beacons;
|
||||
|
||||
#ifdef FG_MPLAYER_AS
|
||||
//Mulitplayer managers
|
||||
FGMultiplayTxMgr *multiplayer_tx_mgr;
|
||||
|
@ -347,7 +357,20 @@ public:
|
|||
|
||||
inline FGIO* get_io() const { return io; }
|
||||
|
||||
/**
|
||||
inline FGNavList *get_navlist() const { return navlist; }
|
||||
inline void set_navlist( FGNavList *n ) { navlist = n; }
|
||||
|
||||
inline FGFixList *get_fixlist() const { return fixlist; }
|
||||
inline void set_fixlist( FGFixList *f ) { fixlist = f; }
|
||||
|
||||
inline FGILSList *get_ilslist() const { return ilslist; }
|
||||
inline void set_ilslist( FGILSList *i ) { ilslist = i; }
|
||||
|
||||
inline FGMarkerBeacons *get_beacons() const { return beacons; }
|
||||
inline void set_beacons( FGMarkerBeacons *b ) { beacons = b; }
|
||||
|
||||
|
||||
/**
|
||||
* Save the current state as the initial state.
|
||||
*/
|
||||
void saveInitialState ();
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
noinst_LIBRARIES = libNavaids.a
|
||||
|
||||
noinst_PROGRAMS = testnavs
|
||||
# noinst_PROGRAMS = testnavs
|
||||
|
||||
libNavaids_a_SOURCES = \
|
||||
fix.hxx fixlist.hxx fixlist.cxx \
|
||||
ils.hxx ilslist.hxx ilslist.cxx \
|
||||
mkrbeacons.hxx mkrbeacons.cxx \
|
||||
nav.hxx navlist.hxx navlist.cxx
|
||||
nav.hxx navlist.hxx navlist.cxx \
|
||||
navrecord.hxx
|
||||
|
||||
testnavs_SOURCES = testnavs.cxx
|
||||
testnavs_LDADD = \
|
||||
libNavaids.a \
|
||||
-lsgtiming -lsgmath -lsgmisc -lsgdebug -lsgmagvar -lsgxml \
|
||||
$(base_LIBS) -lz
|
||||
# testnavs_SOURCES = testnavs.cxx
|
||||
# testnavs_LDADD = \
|
||||
# libNavaids.a \
|
||||
# -lsgtiming -lsgmath -lsgmisc -lsgdebug -lsgmagvar -lsgxml \
|
||||
# $(base_LIBS) -lz
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
|
||||
|
|
|
@ -67,7 +67,4 @@ public:
|
|||
};
|
||||
|
||||
|
||||
extern FGFixList *current_fixlist;
|
||||
|
||||
|
||||
#endif // _FG_FIXLIST_HXX
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <simgear/misc/sgstream.hxx>
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
|
||||
#include "mkrbeacons.hxx"
|
||||
#include "ilslist.hxx"
|
||||
|
||||
|
@ -98,18 +100,21 @@ bool FGILSList::init( SGPath path ) {
|
|||
// update the marker beacon list
|
||||
if ( fabs(ils->get_omlon()) > SG_EPSILON ||
|
||||
fabs(ils->get_omlat()) > SG_EPSILON ) {
|
||||
current_beacons->add( ils->get_omlon(), ils->get_omlat(),
|
||||
ils->get_gselev(), FGMkrBeacon::OUTER );
|
||||
globals->get_beacons()->add( ils->get_omlon(), ils->get_omlat(),
|
||||
ils->get_gselev(),
|
||||
FGMkrBeacon::OUTER );
|
||||
}
|
||||
if ( fabs(ils->get_mmlon()) > SG_EPSILON ||
|
||||
fabs(ils->get_mmlat()) > SG_EPSILON ) {
|
||||
current_beacons->add( ils->get_mmlon(), ils->get_mmlat(),
|
||||
ils->get_gselev(), FGMkrBeacon::MIDDLE );
|
||||
globals->get_beacons()->add( ils->get_mmlon(), ils->get_mmlat(),
|
||||
ils->get_gselev(),
|
||||
FGMkrBeacon::MIDDLE );
|
||||
}
|
||||
if ( fabs(ils->get_imlon()) > SG_EPSILON ||
|
||||
fabs(ils->get_imlat()) > SG_EPSILON ) {
|
||||
current_beacons->add( ils->get_imlon(), ils->get_imlat(),
|
||||
ils->get_gselev(), FGMkrBeacon::INNER );
|
||||
globals->get_beacons()->add( ils->get_imlon(), ils->get_imlat(),
|
||||
ils->get_gselev(),
|
||||
FGMkrBeacon::INNER );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,4 @@ public:
|
|||
};
|
||||
|
||||
|
||||
extern FGILSList *current_ilslist;
|
||||
|
||||
|
||||
#endif // _FG_ILSLIST_HXX
|
||||
|
|
|
@ -134,7 +134,8 @@ bool FGMarkerBeacons::add( double lon, double lat, double elev,
|
|||
// returns marker beacon type if we are over a marker beacon, NOBEACON
|
||||
// otherwise
|
||||
FGMkrBeacon::fgMkrBeacType FGMarkerBeacons::query( double lon, double lat,
|
||||
double elev ) {
|
||||
double elev )
|
||||
{
|
||||
double diff;
|
||||
|
||||
int lonidx = (int)lon;
|
||||
|
@ -160,7 +161,8 @@ FGMkrBeacon::fgMkrBeacType FGMarkerBeacons::query( double lon, double lat,
|
|||
beacon_list_iterator current = beacons.begin();
|
||||
beacon_list_iterator last = beacons.end();
|
||||
|
||||
Point3D aircraft = sgGeodToCart(Point3D(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, 0));
|
||||
Point3D aircraft = sgGeodToCart( Point3D(lon*SGD_DEGREES_TO_RADIANS,
|
||||
lat*SGD_DEGREES_TO_RADIANS, 0) );
|
||||
|
||||
double min_dist = 999999999.0;
|
||||
|
||||
|
|
|
@ -110,7 +110,4 @@ public:
|
|||
};
|
||||
|
||||
|
||||
extern FGMarkerBeacons *current_beacons;
|
||||
|
||||
|
||||
#endif // _FG_MKRBEACON_HXX
|
||||
|
|
|
@ -82,7 +82,4 @@ public:
|
|||
};
|
||||
|
||||
|
||||
extern FGNavList *current_navlist;
|
||||
|
||||
|
||||
#endif // _FG_NAVLIST_HXX
|
||||
|
|
|
@ -11,7 +11,7 @@ const string FG_DATA_DIR("/usr/local/lib/FlightGear");
|
|||
int main() {
|
||||
double heading, dist;
|
||||
|
||||
current_navlist = new FGNavList;
|
||||
FGNavList *current_navlist = new FGNavList;
|
||||
SGPath p_nav( FG_DATA_DIR + "/Navaids/default.nav" );
|
||||
|
||||
current_navlist->init( p_nav );
|
||||
|
@ -42,10 +42,10 @@ int main() {
|
|||
}
|
||||
|
||||
// we have to init the marker beacon storage before we parse the ILS file
|
||||
current_beacons = new FGMarkerBeacons;
|
||||
FGMarkerBeacons *current_beacons = new FGMarkerBeacons;
|
||||
current_beacons->init();
|
||||
|
||||
current_ilslist = new FGILSList;
|
||||
FGILSList *current_ilslist = new FGILSList;
|
||||
SGPath p_ils( FG_DATA_DIR + "/Navaids/default.ils" );
|
||||
current_ilslist->init( p_ils );
|
||||
FGILS *i = current_ilslist->findByFreq( -93.1 * SG_DEGREES_TO_RADIANS,
|
||||
|
@ -59,7 +59,7 @@ int main() {
|
|||
cout << "not picking up ils. :-(" << endl;
|
||||
}
|
||||
|
||||
current_fixlist = new FGFixList;
|
||||
FGFixList *current_fixlist = new FGFixList;
|
||||
SGPath p_fix( FG_DATA_DIR + "/Navaids/default.fix" );
|
||||
current_fixlist->init( p_fix );
|
||||
FGFix fix;
|
||||
|
|
Loading…
Reference in a new issue