Fix sending the correct pressure altitude for a pilot position

* Before this commit, only the true altitude was known for an aircraft situation. The pressure altitude was not available anywhere yet.
* This caused a wrong altitude in radar clients.
* We fix this reading the pressure altitude from the simulators and set it in the own aircraft situation.
* MS Flight Simulators have the pressure altitude in the APIs available.
* For X-Plane and emulated simulator, we need to calculate it from the pressure at sea level.
* Finally, we use the new available pressure altitude to send it to the FSD server.

Maniphest Tasks: Ref T223
This commit is contained in:
Roland Winklmeier
2018-01-12 13:30:30 +01:00
committed by Klaus Basan
parent 51a90a9a71
commit de4fe44156
30 changed files with 298 additions and 43 deletions

View File

@@ -64,11 +64,11 @@ namespace BlackMisc
void CAltitude::convertToPressureAltitude(const CPressure &seaLevelPressure)
{
if (m_altitudeType == PressureAltitude) { return; }
static const CPressure standardPressure(1013.25, CPressureUnit::mbar());
const CPressure delta = (standardPressure - seaLevelPressure);
double deltaV = delta.value(CPressureUnit::mbar());
deltaV *= 30.0;
addValueSameUnit(deltaV);
const CPressure deltaPressure = standardISASeaLevelPressure() - seaLevelPressure;
const double deltaPressureV = deltaPressure.value(CPressureUnit::mbar());
const double deltaAltitudeV = deltaPressureV * 30.0; // 30.0 ft per mbar
CLength deltaAltitude(deltaAltitudeV, CLengthUnit::ft());
*this += deltaAltitude;
m_altitudeType = PressureAltitude;
}