]> git.mxchange.org Git - flightgear.git/commitdiff
Often, the elevation of an ILS component is not listed in our nav database.
authorcurt <curt>
Wed, 9 Jun 2004 03:13:13 +0000 (03:13 +0000)
committercurt <curt>
Wed, 9 Jun 2004 03:13:13 +0000 (03:13 +0000)
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
src/Airports/simple.hxx
src/Cockpit/navcom.cxx
src/Cockpit/navcom.hxx
src/Main/fg_init.cxx
src/Navaids/navdb.cxx
src/Navaids/navdb.hxx
src/Navaids/navrecord.hxx

index ca3fd39959f529e7f165d11f0f87b1709171d7e7..cfbb61ac24092b841883d75331581a575aa9d343 100644 (file)
@@ -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];
 }
 
index 9b98f97a49fbd035294ea73ee8ae27946bbae5af..be0b8ed6899451ec22da563686db1084b265ffe8 100644 (file)
@@ -48,7 +48,6 @@ SG_USING_STD(vector);
 
 
 struct FGAirport {
-
     string id;
     double longitude;
     double latitude;
index 5081c7fb0f6a526cdba6946d85ade5e2301c0261..6dab45329f3079333af301adf2dfaaab2e90e644 100644 (file)
@@ -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;
index 33135728f34609929034a39e6edf810d7573c4c4..6f7d61bf505efeaea18d435266fb14535088d18c 100644 (file)
@@ -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;
index 15681791f561346fbe550acaaf0724a00d56f076..a24b725c89725e5cfff11b8a574f5fba9092cce5 100644 (file)
@@ -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" );
     }
index 92253f357eb7f63381f91430d3a1049581f915da..09eaa8fd8224e2d511775dcf87cf52845595ae01 100644 (file)
@@ -28,6 +28,7 @@
 #include <simgear/debug/logstream.hxx>
 
 #include <Airports/runways.hxx>
+#include <Airports/simple.hxx>
 #include <Main/globals.hxx>
 
 #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 );
index 5f0c39ff9496a5d4c70f773a75d0fc45912d0759..355ff55079aaea435753fe0f875e97562fbbfa3b 100644 (file)
@@ -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 );
 
 
index ce8fde82da75e0afb5c332f960461feabc73a435..ab1ca85c0281d632e7bf4f87f88732363baf057d 100644 (file)
@@ -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;