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.
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 );
}
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;
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;
virtual int getWindSpeedKt();
virtual int getGustsKt();
virtual int getQnh();
+ virtual double getQnhInHg();
virtual bool isCavok();
virtual int getVisibilityMeters();
virtual std::string getPhenomena();
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()
virtual int getWindSpeedKt();
virtual int getGustsKt();
virtual int getQnh();
+ virtual double getQnhInHg();
virtual bool isCavok();
virtual int getVisibilityMeters();
virtual std::string getPhenomena();