mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
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:
committed by
Klaus Basan
parent
51a90a9a71
commit
de4fe44156
@@ -30,7 +30,10 @@ namespace BlackMisc
|
||||
|
||||
CAircraftSituation::CAircraftSituation(const CCoordinateGeodetic &position, const CHeading &heading, const CAngle &pitch, const CAngle &bank, const CSpeed &gs, const CAltitude &groundElevation)
|
||||
: m_position(position), m_heading(heading), m_pitch(pitch),
|
||||
m_bank(bank), m_groundSpeed(gs), m_groundElevation(groundElevation) {}
|
||||
m_bank(bank), m_groundSpeed(gs), m_groundElevation(groundElevation)
|
||||
{
|
||||
m_pressureAltitude = position.geodeticHeight().toPressureAltitude(CPressure(1013.25, CPressureUnit::mbar()));
|
||||
}
|
||||
|
||||
CAircraftSituation::CAircraftSituation(const CCallsign &correspondingCallsign, const CCoordinateGeodetic &position, const CHeading &heading, const CAngle &pitch, const CAngle &bank, const CSpeed &gs, const CAltitude &groundElevation)
|
||||
: m_correspondingCallsign(correspondingCallsign),
|
||||
@@ -38,6 +41,7 @@ namespace BlackMisc
|
||||
m_bank(bank), m_groundSpeed(gs), m_groundElevation(groundElevation)
|
||||
{
|
||||
m_correspondingCallsign.setTypeHint(CCallsign::Aircraft);
|
||||
m_pressureAltitude = position.geodeticHeight().toPressureAltitude(CPressure(1013.25, CPressureUnit::mbar()));
|
||||
}
|
||||
|
||||
QString CAircraftSituation::convertToQString(bool i18n) const
|
||||
@@ -219,6 +223,12 @@ namespace BlackMisc
|
||||
return this->getGroundElevation();
|
||||
}
|
||||
|
||||
void CAircraftSituation::setPressureAltitude(const CAltitude &altitude)
|
||||
{
|
||||
Q_ASSERT(altitude.getAltitudeType() == CAltitude::PressureAltitude);
|
||||
m_pressureAltitude = altitude;
|
||||
}
|
||||
|
||||
void CAircraftSituation::setCallsign(const CCallsign &callsign)
|
||||
{
|
||||
m_correspondingCallsign = callsign;
|
||||
|
||||
@@ -187,6 +187,12 @@ namespace BlackMisc
|
||||
//! Set altitude
|
||||
void setAltitude(const CAltitude &altitude) { m_position.setGeodeticHeight(altitude); }
|
||||
|
||||
//! Get pressure altitude
|
||||
const CAltitude &getPressureAltitude() const { return m_pressureAltitude; }
|
||||
|
||||
//! Set pressure altitude
|
||||
void setPressureAltitude(const CAltitude &altitude);
|
||||
|
||||
//! Get pitch
|
||||
const PhysicalQuantities::CAngle &getPitch() const { return m_pitch; }
|
||||
|
||||
@@ -238,6 +244,7 @@ namespace BlackMisc
|
||||
private:
|
||||
CCallsign m_correspondingCallsign;
|
||||
Geo::CCoordinateGeodetic m_position;
|
||||
Aviation::CAltitude m_pressureAltitude { 0, nullptr };
|
||||
CHeading m_heading;
|
||||
PhysicalQuantities::CAngle m_pitch;
|
||||
PhysicalQuantities::CAngle m_bank;
|
||||
@@ -252,6 +259,7 @@ namespace BlackMisc
|
||||
CAircraftSituation,
|
||||
BLACK_METAMEMBER(correspondingCallsign),
|
||||
BLACK_METAMEMBER(position),
|
||||
BLACK_METAMEMBER(pressureAltitude),
|
||||
BLACK_METAMEMBER(heading),
|
||||
BLACK_METAMEMBER(pitch),
|
||||
BLACK_METAMEMBER(bank),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user