]> git.mxchange.org Git - flightgear.git/commitdiff
Bugfix: set temp and dewpoint from the gui
authorTorsten Dreyer <Torsten@t3r.de>
Tue, 20 Jul 2010 20:56:15 +0000 (22:56 +0200)
committerTorsten Dreyer <Torsten@t3r.de>
Tue, 20 Jul 2010 20:56:15 +0000 (22:56 +0200)
This fix (re)enables the setting of temperature and
dewpoint from the weather-conditions dialog and other
sources for various altitude layers. These temperatures
are reduced to the corresponding sea level temperatures
according to ICAO standard atmosphere which is the inverse
function of the calculation of temperature at altitude based
on sea-level-temperature.
Note: this only works for the troposphere.

src/Environment/environment.cxx
src/Environment/environment_ctrl.cxx
src/Environment/environment_ctrl.hxx

index 9a5755e3db3d7f8cabeaa89a739547c8b28fb71f..30354ffd9255c54d1f98b9a2207e033e2e2e2932 100644 (file)
@@ -211,20 +211,32 @@ FGEnvironment::read (const SGPropertyNode * node)
     maybe_copy_value(this, node, "visibility-m",
                      &FGEnvironment::set_visibility_m);
 
+    maybe_copy_value(this, node, "elevation-ft",
+                     &FGEnvironment::set_elevation_ft);
+
     if (!maybe_copy_value(this, node, "temperature-sea-level-degc",
-                          &FGEnvironment::set_temperature_sea_level_degc))
-        maybe_copy_value(this, node, "temperature-degc",
-                         &FGEnvironment::set_temperature_degc);
+                          &FGEnvironment::set_temperature_sea_level_degc)) {
+        if( maybe_copy_value(this, node, "temperature-degc",
+                         &FGEnvironment::set_temperature_degc)) {
+            _recalc_sl_temperature();
+        }
+    }
 
     if (!maybe_copy_value(this, node, "dewpoint-sea-level-degc",
-                          &FGEnvironment::set_dewpoint_sea_level_degc))
-        maybe_copy_value(this, node, "dewpoint-degc",
-                         &FGEnvironment::set_dewpoint_degc);
+                          &FGEnvironment::set_dewpoint_sea_level_degc)) {
+        if( maybe_copy_value(this, node, "dewpoint-degc",
+                         &FGEnvironment::set_dewpoint_degc)) {
+            _recalc_sl_dewpoint();
+        }
+    }
 
     if (!maybe_copy_value(this, node, "pressure-sea-level-inhg",
-                          &FGEnvironment::set_pressure_sea_level_inhg))
-        maybe_copy_value(this, node, "pressure-inhg",
-                         &FGEnvironment::set_pressure_inhg);
+                          &FGEnvironment::set_pressure_sea_level_inhg)) {
+        if( maybe_copy_value(this, node, "pressure-inhg",
+                         &FGEnvironment::set_pressure_inhg)) {
+            _recalc_sl_pressure();
+        }
+   }
 
     maybe_copy_value(this, node, "wind-from-heading-deg",
                      &FGEnvironment::set_wind_from_heading_deg);
@@ -232,9 +244,6 @@ FGEnvironment::read (const SGPropertyNode * node)
     maybe_copy_value(this, node, "wind-speed-kt",
                      &FGEnvironment::set_wind_speed_kt);
 
-    maybe_copy_value(this, node, "elevation-ft",
-                     &FGEnvironment::set_elevation_ft);
-
     maybe_copy_value(this, node, "turbulence/magnitude-norm",
                      &FGEnvironment::set_turbulence_magnitude_norm);
 
@@ -652,7 +661,7 @@ FGEnvironment::_recalc_sl_temperature ()
   }
 #endif
 
-  if (elevation_ft >= ISA_def[1].height) {
+  if (elevation_ft * atmodel::foot >= ISA_def[1].height) {
     SG_LOG(SG_GENERAL, SG_ALERT, "recalc_sl_temperature: "
         << "valid only in troposphere, not " << elevation_ft);
     return;
index ea9c9b628d9bb490985b0955d480ea0abf5c7bbc..ac870e5e2a377c17d119fe968c7327260ef39f14 100644 (file)
@@ -132,7 +132,9 @@ void
 FGInterpolateEnvironmentCtrl::init ()
 {
        read_table( boundary_n, _boundary_table);
-       read_table( aloft_n, _aloft_table);
+       // pass in a pointer to the environment of the last bondary layer as
+       // a starting point
+       read_table( aloft_n, _aloft_table, &(*(_boundary_table.end()-1))->environment);
 }
 
 void
@@ -142,7 +144,7 @@ FGInterpolateEnvironmentCtrl::reinit ()
 }
 
 void
-FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bucket *> &table)
+FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bucket *> &table, FGEnvironment * parent )
 {
        double last_altitude_ft = 0.0;
        double sort_required = false;
@@ -163,8 +165,11 @@ FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bu
                                b = new bucket;
                                table.push_back(b);
                        }
+                       if (i == 0 && parent != NULL )
+                               b->environment.copy( *parent );
                        if (i > 0)
                                b->environment.copy(table[i-1]->environment);
+                       
                        b->environment.read(child);
                        b->altitude_ft = b->environment.get_elevation_ft();
 
index aec1442cb375f56f142facb786ac5d46865d60c9..1f81c025901d6305ee175c1e870e04bd42d56272 100644 (file)
@@ -101,7 +101,7 @@ private:
                static bool lessThan(bucket *a, bucket *b);
        };
 
-       void read_table (const SGPropertyNode * node, std::vector<bucket *> &table);
+       void read_table (const SGPropertyNode * node, std::vector<bucket *> &table, FGEnvironment * parent = NULL );
        void do_interpolate (std::vector<bucket *> &table, double altitude_ft,
                                                 FGEnvironment * environment);