mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Differentiate between true and pressure altitude
Altitude can have different meanings in aviation. So far all our altitudes were true altitudes. But now we also require pressure altitude including a conversion method between the two. Maniphest Tasks: T223
This commit is contained in:
committed by
Klaus Basan
parent
718d5abf90
commit
51a90a9a71
@@ -16,8 +16,7 @@
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
|
||||
using BlackMisc::PhysicalQuantities::CLength;
|
||||
using BlackMisc::PhysicalQuantities::CLengthUnit;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -62,6 +61,24 @@ namespace BlackMisc
|
||||
this->m_datum = MeanSeaLevel;
|
||||
}
|
||||
|
||||
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);
|
||||
m_altitudeType = PressureAltitude;
|
||||
}
|
||||
|
||||
CAltitude CAltitude::toPressureAltitude(const CPressure &seaLevelPressure) const
|
||||
{
|
||||
CAltitude other(*this);
|
||||
other.convertToPressureAltitude(seaLevelPressure);
|
||||
return other;
|
||||
}
|
||||
|
||||
void CAltitude::parseFromString(const QString &value)
|
||||
{
|
||||
this->parseFromString(value, PhysicalQuantities::CPqString::SeparatorsCLocale);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "blackmisc/dictionary.h"
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/pq/pressure.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include "blackmisc/variant.h"
|
||||
@@ -71,6 +72,13 @@ namespace BlackMisc
|
||||
FlightLevel //!< Flight level
|
||||
};
|
||||
|
||||
//! Altitude type
|
||||
enum AltitudeType
|
||||
{
|
||||
PressureAltitude, //!< Altitude above the standard datum plane
|
||||
TrueAltitude //!< Height of the airplane above Mean Sea Level (MSL)
|
||||
};
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
@@ -80,6 +88,9 @@ namespace BlackMisc
|
||||
//! Constructor
|
||||
CAltitude(double value, ReferenceDatum datum, const PhysicalQuantities::CLengthUnit &unit) : CLength(value, unit), m_datum(datum) {}
|
||||
|
||||
//! Constructor
|
||||
CAltitude(double value, ReferenceDatum datum, AltitudeType type, const PhysicalQuantities::CLengthUnit &unit) : CLength(value, unit), m_datum(datum), m_altitudeType(type) {}
|
||||
|
||||
//! Constructor, value as CAltitude::MeanSeaLevel
|
||||
CAltitude(double value, const PhysicalQuantities::CLengthUnit &unit) : CLength(value, unit), m_datum(MeanSeaLevel) {}
|
||||
|
||||
@@ -107,6 +118,15 @@ namespace BlackMisc
|
||||
//! Flightlevel to MSL
|
||||
void toMeanSeaLevel();
|
||||
|
||||
//! Current altitude type
|
||||
AltitudeType getAltitudeType() const { return m_altitudeType; }
|
||||
|
||||
//! Converts this to pressure altitude. Requires the current barometric pressure at MSL
|
||||
void convertToPressureAltitude(const PhysicalQuantities::CPressure &seaLevelPressure);
|
||||
|
||||
//! Returns the altitude converted to pressure altitude. Requires the current barometric pressure at MSL
|
||||
CAltitude toPressureAltitude(const PhysicalQuantities::CPressure &seaLevelPressure) const;
|
||||
|
||||
//! Parse value from string
|
||||
void parseFromString(const QString &value);
|
||||
|
||||
@@ -150,10 +170,12 @@ namespace BlackMisc
|
||||
|
||||
private:
|
||||
ReferenceDatum m_datum; //!< MSL or AGL?
|
||||
AltitudeType m_altitudeType = TrueAltitude;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CAltitude,
|
||||
BLACK_METAMEMBER(datum)
|
||||
BLACK_METAMEMBER(datum),
|
||||
BLACK_METAMEMBER(altitudeType)
|
||||
);
|
||||
};
|
||||
} // ns
|
||||
@@ -161,5 +183,6 @@ namespace BlackMisc
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAltitude)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAltitude::ReferenceDatum)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAltitude::AltitudeType)
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user