Fix incorrect QNH in spoken ATIS when using live weather fetch
When using live weather fetch, the QNH should be obtained from environment/metar/pressure-inhg. See: http://sourceforge.net/p/flightgear/mailman/message/35037125 Add new method getQnhInHg to ATISInformationProvider and its implementations to avoid rounding errors converting from hPa back to inches in ATIS reports. The CurrentWeatherATISInformationProvider (used when live weather fetch is not in use) continues to use the property environment/pressure-sea-level-inhg. This produces the incorrect QNH at airports significantly above sea level but this needs fixing elsewhere to calculate the correct QNH.
This commit is contained in:
parent
f825bb4f3c
commit
29fe6569c4
6 changed files with 18 additions and 4 deletions
|
@ -565,13 +565,13 @@ string ATISEncoder::getQnh( SGPropertyNode_ptr )
|
|||
|
||||
string ATISEncoder::getInhgInteger( SGPropertyNode_ptr )
|
||||
{
|
||||
double qnh = _atis->getQnh() * 100 / SG_INHG_TO_PA;
|
||||
double qnh = _atis->getQnhInHg();
|
||||
return getSpokenNumber( (int)qnh, true, 2 );
|
||||
}
|
||||
|
||||
string ATISEncoder::getInhgFraction( SGPropertyNode_ptr )
|
||||
{
|
||||
double qnh = _atis->getQnh() * 100 / SG_INHG_TO_PA;
|
||||
double qnh = _atis->getQnhInHg();
|
||||
int f = int(100 * (qnh - int(qnh)) + 0.5);
|
||||
return getSpokenNumber( f, true, 2 );
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
virtual int getWindSpeedKt() = 0;
|
||||
virtual int getGustsKt() = 0;
|
||||
virtual int getQnh() = 0;
|
||||
virtual double getQnhInHg() = 0;
|
||||
virtual bool isCavok() = 0;
|
||||
virtual int getVisibilityMeters() = 0;
|
||||
virtual std::string getPhenomena() = 0;
|
||||
|
|
|
@ -85,9 +85,16 @@ int CurrentWeatherATISInformationProvider::getGustsKt()
|
|||
|
||||
int CurrentWeatherATISInformationProvider::getQnh()
|
||||
{
|
||||
// TODO: Calculate QNH correctly from environment
|
||||
return roundToInt( _environment->getNode("pressure-sea-level-inhg",true)->getDoubleValue() * SG_INHG_TO_PA / 100 );
|
||||
}
|
||||
|
||||
double CurrentWeatherATISInformationProvider::getQnhInHg()
|
||||
{
|
||||
// TODO: Calculate QNH correctly from environment
|
||||
return _environment->getNode("pressure-sea-level-inhg",true)->getDoubleValue();
|
||||
}
|
||||
|
||||
bool CurrentWeatherATISInformationProvider::isCavok()
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -41,6 +41,7 @@ protected:
|
|||
virtual int getWindSpeedKt();
|
||||
virtual int getGustsKt();
|
||||
virtual int getQnh();
|
||||
virtual double getQnhInHg();
|
||||
virtual bool isCavok();
|
||||
virtual int getVisibilityMeters();
|
||||
virtual std::string getPhenomena();
|
||||
|
|
|
@ -72,10 +72,14 @@ int MetarPropertiesATISInformationProvider::getGustsKt()
|
|||
return _metar->getIntValue( "gust-wind-speed-kt" );
|
||||
}
|
||||
|
||||
|
||||
int MetarPropertiesATISInformationProvider::getQnh()
|
||||
{
|
||||
return _metar->getDoubleValue("pressure-sea-level-inhg") * SG_INHG_TO_PA / 100.0;
|
||||
return _metar->getDoubleValue("pressure-inhg") * SG_INHG_TO_PA / 100.0;
|
||||
}
|
||||
|
||||
double MetarPropertiesATISInformationProvider::getQnhInHg()
|
||||
{
|
||||
return _metar->getDoubleValue("pressure-inhg");
|
||||
}
|
||||
|
||||
bool MetarPropertiesATISInformationProvider::isCavok()
|
||||
|
|
|
@ -43,6 +43,7 @@ protected:
|
|||
virtual int getWindSpeedKt();
|
||||
virtual int getGustsKt();
|
||||
virtual int getQnh();
|
||||
virtual double getQnhInHg();
|
||||
virtual bool isCavok();
|
||||
virtual int getVisibilityMeters();
|
||||
virtual std::string getPhenomena();
|
||||
|
|
Loading…
Add table
Reference in a new issue