From 459242b9db0a793d9853440991bb0d29f3f3771c Mon Sep 17 00:00:00 2001 From: Roman Ludwicki Date: Sat, 16 Sep 2023 15:37:00 +0200 Subject: [PATCH] Fix calculate temerature for ISA METAR scenario --- src/Environment/climate.cxx | 5 ++--- src/Environment/climate.hxx | 2 -- src/Environment/environment.cxx | 4 ++++ src/Environment/metarproperties.cxx | 2 ++ src/GUI/qml/Environment.qml | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Environment/climate.cxx b/src/Environment/climate.cxx index 57c329b14..14ef2d2df 100644 --- a/src/Environment/climate.cxx +++ b/src/Environment/climate.cxx @@ -20,6 +20,7 @@ #include "environment.hxx" #include "atmosphere.hxx" +#include "environment_mgr.hxx" #include "climate.hxx" // Based on "World Map of the Köppen-Geiger climate classification" @@ -99,8 +100,6 @@ void FGClimate::bind() _tiedProperties.Tie( "snow-level-m", &_snow_level); _tiedProperties.Tie( "wind-speed-mps", &_wind_speed); _tiedProperties.Tie( "wind-direction-deg", &_wind_direction); - - _tiedProperties.Tie("is-isa", &_is_isa); } void FGClimate::unbind () @@ -216,7 +215,7 @@ void FGClimate::update(double dt) // calculate sea level parameters from ground level parameters // adapted from metarproperties.cxx FGEnvironment dummy; - dummy.set_is_isa(_is_isa); + dummy.set_is_isa(globals->get_subsystem()->getEnvironment().get_is_isa()); dummy.set_live_update(false); dummy.set_elevation_ft(_gl.elevation_m*SG_METER_TO_FEET); dummy.set_dewpoint_degc(_gl.dewpoint); diff --git a/src/Environment/climate.hxx b/src/Environment/climate.hxx index bbb9b5afc..7f5a4a49d 100644 --- a/src/Environment/climate.hxx +++ b/src/Environment/climate.hxx @@ -192,8 +192,6 @@ private: double _wind_direction = -99999.0; // wind direction in degrees char _metar[256] = ""; - - bool _is_isa = false; }; #endif // _FGCLIMATE_HXX diff --git a/src/Environment/environment.cxx b/src/Environment/environment.cxx index 250f5837b..073edc53e 100644 --- a/src/Environment/environment.cxx +++ b/src/Environment/environment.cxx @@ -354,6 +354,10 @@ void FGEnvironment::Tie( SGPropertyNode_ptr base, bool archivable ) _tiedProperties.Tie("atmosphere/density-tropo-avg", this, &FGEnvironment::get_density_tropo_avg_kgm3); //ro + + _tiedProperties.Tie("atmosphere/is-isa", this, + &FGEnvironment::get_is_isa, + &FGEnvironment::set_is_isa); } void FGEnvironment::Untie() diff --git a/src/Environment/metarproperties.cxx b/src/Environment/metarproperties.cxx index e54d7b46e..e1ce9e7e7 100644 --- a/src/Environment/metarproperties.cxx +++ b/src/Environment/metarproperties.cxx @@ -13,6 +13,7 @@ #include // for strlen #include "metarproperties.hxx" +#include "environment_mgr.hxx" #include "fgmetar.hxx" #include "environment.hxx" #include "atmosphere.hxx" @@ -291,6 +292,7 @@ void MetarProperties::setMetar( SGSharedPtr m ) { // calculate sea level temperature, dewpoint and pressure FGEnvironment dummy; // instantiate a dummy so we can leech a method + dummy.set_is_isa( globals->get_subsystem()->getEnvironment().get_is_isa() ); dummy.set_elevation_ft( _station_elevation ); dummy.set_temperature_degc( _temperature ); dummy.set_dewpoint_degc( _dewpoint ); diff --git a/src/GUI/qml/Environment.qml b/src/GUI/qml/Environment.qml index 2d76bfdba..94e3d4486 100644 --- a/src/GUI/qml/Environment.qml +++ b/src/GUI/qml/Environment.qml @@ -194,7 +194,7 @@ Item { _config.setArg("metar", _weatherScenarios.metarForItem(index)) var isISA = _weatherScenarios.nameForItem(index) == "International Standard Atmosphere"; - _config.setProperty("/environment/climate/is-isa", isISA); + _config.setProperty("/environment/atmosphere/is-isa", isISA); } // either way, set the scenario name since Local-Weather keys off