Synchronize elevation-ft property in environment
This fixes some issues with Basic Weather producing invalid pressure altitudes under some circumstances.
This commit is contained in:
parent
b6e4cbbf14
commit
c8a3f60245
2 changed files with 27 additions and 4 deletions
|
@ -270,6 +270,10 @@ void FGEnvironment::Tie( SGPropertyNode_ptr base, bool archivable )
|
|||
&FGEnvironment::get_visibility_m,
|
||||
&FGEnvironment::set_visibility_m);
|
||||
|
||||
_tiedProperties.Tie("elevation-ft", this,
|
||||
&FGEnvironment::get_elevation_ft,
|
||||
&FGEnvironment::set_elevation_ft);
|
||||
|
||||
_tiedProperties.Tie("temperature-sea-level-degc", this,
|
||||
&FGEnvironment::get_temperature_sea_level_degc,
|
||||
&FGEnvironment::set_temperature_sea_level_degc);
|
||||
|
|
|
@ -197,10 +197,12 @@ void LayerTable::Bind()
|
|||
{
|
||||
// tie all environments to ~/entry[n]/xxx
|
||||
// register this as a changelistener of ~/entry[n]/pressure-sea-level-inhg
|
||||
// and ~/entry[n]/elevation-ft
|
||||
for( unsigned i = 0; i < size(); i++ ) {
|
||||
SGPropertyNode_ptr baseNode = _rootNode->getChild("entry", i, true );
|
||||
at(i)->environment.Tie( baseNode );
|
||||
baseNode->getNode( "pressure-sea-level-inhg", true )->addChangeListener( this );
|
||||
baseNode->getNode("elevation-ft", true)->addChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,19 +210,36 @@ void LayerTable::Unbind()
|
|||
{
|
||||
// untie all environments to ~/entry[n]/xxx
|
||||
// deregister this as a changelistener of ~/entry[n]/pressure-sea-level-inhg
|
||||
// and ~/entry[n]/elevation-ft
|
||||
for( unsigned i = 0; i < size(); i++ ) {
|
||||
SGPropertyNode_ptr baseNode = _rootNode->getChild("entry", i, true );
|
||||
at(i)->environment.Untie();
|
||||
baseNode->getNode( "pressure-sea-level-inhg", true )->removeChangeListener( this );
|
||||
baseNode->getNode("elevation-ft", true)->removeChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
void LayerTable::valueChanged( SGPropertyNode * node )
|
||||
{
|
||||
// Make sure all environments in our column use the same sea level pressure
|
||||
double value = node->getDoubleValue();
|
||||
for( iterator it = begin(); it != end(); it++ )
|
||||
(*it)->environment.set_pressure_sea_level_inhg( value );
|
||||
// - Make sure all environments in our column use the same sea level pressure
|
||||
// - Synchronize layer elevations
|
||||
if (node->getNameString() == "pressure-sea-level-inhg") {
|
||||
double value = node->getDoubleValue();
|
||||
for (iterator it = begin(); it != end(); it++) {
|
||||
(*it)->environment.set_pressure_sea_level_inhg(value);
|
||||
}
|
||||
} else {
|
||||
bool sort_required = false;
|
||||
double last_altitude_ft = 0.0;
|
||||
for (iterator it = begin(); it != end(); it++) {
|
||||
(*it)->altitude_ft = (*it)->environment.get_elevation_ft();
|
||||
if ((*it)->altitude_ft < last_altitude_ft)
|
||||
sort_required = true;
|
||||
last_altitude_ft = (*it)->altitude_ft;
|
||||
}
|
||||
if (sort_required)
|
||||
sort(begin(), end(), LayerTableBucket::lessThan);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue