From 108f2d43286acf74c00ea0698e346d13b8715073 Mon Sep 17 00:00:00 2001 From: Erik Hofman <erik@ehofman.com> Date: Wed, 18 Nov 2020 12:33:43 +0100 Subject: [PATCH] Swith to the terrain presampling code for a more stable ground elevation if it is enabled. --- src/Environment/climate.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Environment/climate.cxx b/src/Environment/climate.cxx index c433103a2..a7802cc79 100644 --- a/src/Environment/climate.cxx +++ b/src/Environment/climate.cxx @@ -70,7 +70,8 @@ void FGClimate::init() _positionLatitudeNode = fgGetNode("/position/latitude-deg", true); _positionLongitudeNode= fgGetNode("/position/longitude-deg", true); - _ground_elev_node = fgGetNode("/position/ground-elev-ft", true ); + + _ground_elev_node = fgGetNode("/environment/terrain/area[0]/enabled", true); } void FGClimate::bind() @@ -206,8 +207,15 @@ void FGClimate::update(double dt) _rootNode->getNode("description")->setStringValue(_description[_code]); _rootNode->getNode("classification")->setStringValue(_classification[_code]); - double alt_km; - alt_km = _ground_elev_node->getDoubleValue()*SG_FEET_TO_METER/1000.0; + double alt_ft; + if (_ground_elev_node->getBoolValue() && + fgGetBool("/environment/terrain/area[0]/output/valid")) + { + alt_ft = fgGetDouble("/environment/terrain/area[0]/output/alt-median-ft"); + } else { + alt_ft = fgGetDouble("/position/ground-elev-ft"); + } + double alt_km = alt_ft*SG_FEET_TO_METER/1000.0; // Relative humidity decreases with an average of 4% per kilometer _relative_humidity_sl = std::min(_relative_humidity_gl + 4.0*alt_km, 100.0);