From: Torsten Dreyer Date: Tue, 20 Jul 2010 20:56:15 +0000 (+0200) Subject: Bugfix: set temp and dewpoint from the gui X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=da02c09ec08cc357926ce6f06b3c6fc5925986d8;p=flightgear.git Bugfix: set temp and dewpoint from the gui 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. --- diff --git a/src/Environment/environment.cxx b/src/Environment/environment.cxx index 9a5755e3d..30354ffd9 100644 --- a/src/Environment/environment.cxx +++ b/src/Environment/environment.cxx @@ -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; diff --git a/src/Environment/environment_ctrl.cxx b/src/Environment/environment_ctrl.cxx index ea9c9b628..ac870e5e2 100644 --- a/src/Environment/environment_ctrl.cxx +++ b/src/Environment/environment_ctrl.cxx @@ -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 &table) +FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector &table, FGEnvironment * parent ) { double last_altitude_ft = 0.0; double sort_required = false; @@ -163,8 +165,11 @@ FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vectorenvironment.copy( *parent ); if (i > 0) b->environment.copy(table[i-1]->environment); + b->environment.read(child); b->altitude_ft = b->environment.get_elevation_ft(); diff --git a/src/Environment/environment_ctrl.hxx b/src/Environment/environment_ctrl.hxx index aec1442cb..1f81c0259 100644 --- a/src/Environment/environment_ctrl.hxx +++ b/src/Environment/environment_ctrl.hxx @@ -101,7 +101,7 @@ private: static bool lessThan(bucket *a, bucket *b); }; - void read_table (const SGPropertyNode * node, std::vector &table); + void read_table (const SGPropertyNode * node, std::vector &table, FGEnvironment * parent = NULL ); void do_interpolate (std::vector &table, double altitude_ft, FGEnvironment * environment);