AnMaster wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

I was working on trying to find the cause why tower altitude set to 70 in 
apt.dat wasn't correct and
caused ATC aircraft to end up under ground.

As far as I understood we use same format as x-plane for apt.dat? Then the 
tower elevation in
apt.dat should be ft above ground.

FlightGear stores the tower altitude under /sim/tower/altitude-ft. ATC use this 
as absolute altitude.
Shouldn't that property be renamed to "altitude-agl-ft" in order to indicate 
that it is relative to
ground? That naming scheme is used under /position.
Or the property could be changed to give the altitude above sea level maybe?

Regards,

Arvid Norlander


This patch solves it but should be tested

-> it introduces /sim/tower/height-ft (which is /sim/tower/altitude-ft under a new name) - this is the *height* of the tower, not the altitude

-> /sim/tower/altitude-ft now contains the "proper" altitude of the top of tower ASL. This altitude is the height plus the ground elevation ASL( so it's top of the tower ASL). All things i could find referencing this property (tower view and atc control aircraft) should be improved by the change

How it works:

when fg loads, the old code executes (before the scenery is loaded) and uses the airport elevation as ground elevation

the new function is called after scenery loading, and will attempt to obtain the scenery's ground elevation at the tower position. If it fails , the airport elevation prevails.

Potential problems:

->the intended scenery tile may for some reason not be loaded and get_elevation_m fails (there's an alert level warning for this)

-> given that the towers are an obstruction, i'm not sure if globals->get_scenery()->get_elevation_m will return ground level or the top of the tower. Can someone shed some light here?

Cheers,
Tiago
Index: fg_init.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/fg_init.cxx,v
retrieving revision 1.192
diff -u -p -u -r1.192 fg_init.cxx
--- fg_init.cxx 14 Dec 2007 22:51:57 -0000      1.192
+++ fg_init.cxx 5 Jan 2008 23:25:52 -0000
@@ -729,19 +729,34 @@ static bool fgSetPosFromAirportID( const
 #endif
 
 
-// Set current tower position lon/lat given an airport id
+// Set current tower position lon/lat and altitude given an airport id
 static bool fgSetTowerPosFromAirportID( const string& id) {
     const FGAirport *a = fgFindAirportID( id);
     if (a) {
         SGGeod tower = a->getTowerLocation();
         fgSetDouble("/sim/tower/longitude-deg",  tower.getLongitudeDeg());
         fgSetDouble("/sim/tower/latitude-deg",  tower.getLatitudeDeg());
-        fgSetDouble("/sim/tower/altitude-ft", tower.getElevationFt());
-        return true;
-    } else {
-        return false;
-    }
+        fgSetDouble("/sim/tower/height-ft", tower.getElevationFt());
+        fgSetDouble("/sim/tower/altitude-ft", tower.getElevationFt() + 
a->getElevation());
+    return true;
+    } 
+    return false;
+}
 
+// calculates a more precise tower altitude (separated because it needs the 
scenery loaded)
+static void fgSetTowerAltitudeAirportID( )
+{
+    double ground;
+    
if(globals->get_scenery()->get_elevation_m(fgGetDouble("/sim/tower/latitude-deg"),
 fgGetDouble("/sim/tower/longitude-deg"), 999999, ground, NULL))
+    {
+        ground+=fgGetDouble("/sim/tower/height-ft");
+        fgSetDouble("/sim/tower/altitude-ft", 
fgGetDouble("/sim/tower/height-ft") + ground);
+    }
+    else 
+    {
+        SG_LOG( SG_GENERAL, SG_ALERT,
+        "Unable to obtain exact elevation for tower, Using airport elevation" 
<< '\n' );
+    }
 }
 
 struct FGTowerLocationListener : SGPropertyChangeListener {
@@ -751,9 +766,19 @@ struct FGTowerLocationListener : SGPrope
     }
 };
 
+struct FGTowerElevationListener : SGPropertyChangeListener {
+    void valueChanged(SGPropertyNode* node) {
+        if(node->getBoolValue()==true) fgSetTowerAltitudeAirportID();
+    }
+};
+
+
 void fgInitTowerLocationListener() {
     fgGetNode("/sim/tower/airport-id",  true)
         ->addChangeListener( new FGTowerLocationListener(), true );
+    fgGetNode("/sim/sceneryloaded",  true)
+        ->addChangeListener( new FGTowerElevationListener(), true );
+
 }
 
 // Set current_options lon/lat given an airport id and heading (degrees)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to