From 225298a09e450821f1b620f7097cc282d56f005f Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 9 Jun 2004 03:13:13 +0000 Subject: [PATCH] Often, the elevation of an ILS component is not listed in our nav database. A good elevation is critical for proper glide slope modeling. This patch assigns the average field elevation to any ILS component that doesn't have a valid elevation. Also, for an ILS approach, use the GS transmitter elevation for glide slope calculations rather than the localizer elevation, in some cases this can make a big difference. --- src/Airports/simple.cxx | 1 - src/Airports/simple.hxx | 1 - src/Cockpit/navcom.cxx | 7 +++++-- src/Cockpit/navcom.hxx | 2 +- src/Main/fg_init.cxx | 2 +- src/Navaids/navdb.cxx | 15 ++++++++++++++- src/Navaids/navdb.hxx | 3 ++- src/Navaids/navrecord.hxx | 12 +++++++++++- 8 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index ca3fd3995..cfbb61ac2 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -122,7 +122,6 @@ FGAirportList::FGAirportList( const string &airport_file, // search for the specified id FGAirport FGAirportList::search( const string& id) { - return airports_by_id[id]; } diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx index 9b98f97a4..be0b8ed68 100644 --- a/src/Airports/simple.hxx +++ b/src/Airports/simple.hxx @@ -48,7 +48,6 @@ SG_USING_STD(vector); struct FGAirport { - string id; double longitude; double latitude; diff --git a/src/Cockpit/navcom.cxx b/src/Cockpit/navcom.cxx index 5081c7fb0..6dab45329 100644 --- a/src/Cockpit/navcom.cxx +++ b/src/Cockpit/navcom.cxx @@ -627,6 +627,7 @@ void FGNavCom::search() if ( nav_has_gs ) { nav_gslon = gs->get_lon(); nav_gslat = gs->get_lat(); + nav_elev = gs->get_elev_ft(); int tmp = (int)(gs->get_multiuse() / 1000.0); nav_target_gs = (double)tmp / 100.0; nav_gs_x = gs->get_x(); @@ -643,7 +644,8 @@ void FGNavCom::search() // << endl; Point3D p1 = sgGeodToCart( Point3D(tlon*SGD_DEGREES_TO_RADIANS, tlat*SGD_DEGREES_TO_RADIANS, - nav_elev*SG_FEET_TO_METER) ); + nav_elev*SG_FEET_TO_METER) + ); // cout << nav_gs_x << "," << nav_gs_y << "," << nav_gs_z // << endl; // cout << p1 << endl; @@ -651,10 +653,11 @@ void FGNavCom::search() p1.x()-nav_gs_x, p1.y()-nav_gs_y, p1.z()-nav_gs_z ); // cout << gs_base_vec[0] << "," << gs_base_vec[1] << "," // << gs_base_vec[2] << endl; + } else { + nav_elev = loc->get_elev_ft(); } nav_loclon = loc->get_lon(); nav_loclat = loc->get_lat(); - nav_elev = loc->get_elev_ft(); nav_twist = 0; nav_range = FG_LOC_DEFAULT_RANGE; nav_effective_range = nav_range; diff --git a/src/Cockpit/navcom.hxx b/src/Cockpit/navcom.hxx index 33135728f..6f7d61bf5 100644 --- a/src/Cockpit/navcom.hxx +++ b/src/Cockpit/navcom.hxx @@ -105,6 +105,7 @@ class FGNavCom : public SGSubsystem double nav_loc_dist; double nav_gslon; double nav_gslat; + double nav_elev; // use gs elev if available double nav_gs_x; double nav_gs_y; double nav_gs_z; @@ -114,7 +115,6 @@ class FGNavCom : public SGSubsystem double nav_gs_rate_of_climb; SGTimeStamp prev_time; SGTimeStamp curr_time; - double nav_elev; double nav_range; double nav_effective_range; double nav_target_gs; diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 15681791f..a24b725c8 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1058,7 +1058,7 @@ fgInitNav () globals->set_dmelist( dmelist ); globals->set_mkrlist( mkrlist ); - if ( !fgNavDBInit( navlist, loclist, gslist, dmelist, mkrlist ) ) { + if ( !fgNavDBInit(airports, navlist, loclist, gslist, dmelist, mkrlist) ) { SG_LOG( SG_GENERAL, SG_ALERT, "Problems loading one or more navigational database" ); } diff --git a/src/Navaids/navdb.cxx b/src/Navaids/navdb.cxx index 92253f357..09eaa8fd8 100644 --- a/src/Navaids/navdb.cxx +++ b/src/Navaids/navdb.cxx @@ -28,6 +28,7 @@ #include #include +#include #include
#include "navrecord.hxx" @@ -37,7 +38,8 @@ SG_USING_STD( string ); // load and initialize the navigational databases -bool fgNavDBInit( FGNavList *navlist, FGNavList *loclist, FGNavList *gslist, +bool fgNavDBInit( FGAirportList *airports, + FGNavList *navlist, FGNavList *loclist, FGNavList *gslist, FGNavList *dmelist, FGNavList *mkrlist ) { SG_LOG(SG_GENERAL, SG_INFO, "Loading Navaid Databases"); @@ -89,6 +91,17 @@ bool fgNavDBInit( FGNavList *navlist, FGNavList *loclist, FGNavList *gslist, cout << " freq = " << n.get_freq() << endl; cout << " range = " << n.get_range() << endl << endl; */ + // fudge elevation to the field elevation if it's not specified + if ( fabs(r->get_elev_ft()) < 0.01 && r->get_apt_id().length() ) { + // cout << r->get_type() << " " << r->get_apt_id() << " zero elev" + // << endl; + FGAirport a = airports->search( r->get_apt_id() ); + if ( a.id == r->get_apt_id() ) { + r->set_elev_ft( a.elevation ); + // cout << " setting to " << a.elevation << endl; + } + } + if ( r->get_type() == 2 || r->get_type() == 3 ) { // NDB=2, VOR=3 navlist->add( r ); diff --git a/src/Navaids/navdb.hxx b/src/Navaids/navdb.hxx index 5f0c39ff9..355ff5507 100644 --- a/src/Navaids/navdb.hxx +++ b/src/Navaids/navdb.hxx @@ -41,7 +41,8 @@ // load and initialize the navigational databases -bool fgNavDBInit( FGNavList *navlist, FGNavList *loclist, FGNavList *gslist, +bool fgNavDBInit( FGAirportList *airports, + FGNavList *navlist, FGNavList *loclist, FGNavList *gslist, FGNavList *dmelist, FGNavList *mkrbeacons ); diff --git a/src/Navaids/navrecord.hxx b/src/Navaids/navrecord.hxx index ce8fde82d..ab1ca85c0 100644 --- a/src/Navaids/navrecord.hxx +++ b/src/Navaids/navrecord.hxx @@ -61,7 +61,8 @@ class FGNavRecord { // (degrees) or dme bias (nm) string ident; // navaid ident - string name; // "given" name + string name; // verbose name in nav database + string apt_id; // corresponding airport id bool serviceable; // for failure modeling @@ -78,6 +79,7 @@ public: inline double get_lat() const { return lat; } inline void set_lat( double l ) { lat = l; } inline double get_elev_ft() const { return elev_ft; } + inline void set_elev_ft( double e ) { elev_ft = e; } inline double get_x() const { return x; } inline double get_y() const { return y; } inline double get_z() const { return z; } @@ -87,6 +89,7 @@ public: inline void set_multiuse( double m ) { multiuse = m; } inline const char *get_ident() { return ident.c_str(); } inline string get_name() { return name; } + inline string get_apt_id() { return apt_id; } inline bool get_serviceable() { return serviceable; } inline const char *get_trans_ident() { return trans_ident.c_str(); } @@ -105,6 +108,7 @@ FGNavRecord::FGNavRecord(void) : multiuse(0.0), ident(""), name(""), + apt_id(""), serviceable(true), trans_ident("") { @@ -135,6 +139,12 @@ operator >> ( istream& in, FGNavRecord& n ) n.name = n.name.erase(0,1); } + if ( n.type >= 4 && n.type <= 9 ) { + // these types are always associated with an airport id + string::size_type pos = n.name.find(" "); + n.apt_id = n.name.substr(0, pos); + } + // assign default ranges if ( n.type == 2 || n.type == 3 ) { n.range = FG_NAV_DEFAULT_RANGE; -- 2.39.5