swift
Public Types | Public Member Functions | Static Public Member Functions | List of all members
swift::misc::aviation::CAltitude Class Reference

Altitude as used in aviation, can be AGL or MSL altitude. More...

Inheritance diagram for swift::misc::aviation::CAltitude:
[legend]

Public Types

enum  ReferenceDatum { MeanSeaLevel = 0 , AboveGround , FlightLevel }
 Enum type to distinguish between MSL and AGL. More...
 
enum  AltitudeType { PressureAltitude , TrueAltitude }
 Altitude type. More...
 
using base_type = physical_quantities::CLength
 Base type.
 
using MetricTuple = std::tuple< int, int >
 Metric tuple.
 
- Public Types inherited from swift::misc::physical_quantities::CPhysicalQuantity< CLengthUnit, CLength >
enum  ColumnIndex
 Index.
 
- Public Types inherited from swift::misc::mixin::Index< Derived >
enum  ColumnIndex { IndexPixmap = 10 , IndexIcon , IndexString }
 Base class enums.
 
- Public Types inherited from swift::misc::mixin::Index< CAltitude >
enum  ColumnIndex
 Base class enums.
 

Public Member Functions

 CAltitude ()
 Default constructor: 0m Altitude MSL.
 
 CAltitude (double value, ReferenceDatum datum, const physical_quantities::CLengthUnit &unit)
 Constructor.
 
 CAltitude (double value, ReferenceDatum datum, AltitudeType type, const physical_quantities::CLengthUnit &unit)
 Constructor.
 
 CAltitude (double value, const physical_quantities::CLengthUnit &unit)
 Constructor, value as CAltitude::MeanSeaLevel.
 
 CAltitude (double value, const physical_quantities::CLengthUnit &unit, const physical_quantities::CLengthUnit &switchUnit)
 Constructor, value as CAltitude::MeanSeaLevel.
 
 CAltitude (const QString &altitudeAsString, physical_quantities::CPqString::SeparatorMode mode=physical_quantities::CPqString::SeparatorBestGuess)
 Altitude as string.
 
 CAltitude (const physical_quantities::CLength &altitude, ReferenceDatum datum)
 Constructor by CLength.
 
CAltitude withOffset (const CLength &offset) const
 Altitude with offset. More...
 
void addOffset (const CLength &offset)
 Add offset value.
 
CAltitudeswitchUnit (const physical_quantities::CLengthUnit &newUnit)
 Value in switched unit.
 
CAltitude switchedUnit (const physical_quantities::CLengthUnit &newUnit) const
 Value in switched unit.
 
bool isAboveGroundLevel () const
 AGL Above ground level?
 
bool isMeanSeaLevel () const
 MSL Mean sea level?
 
bool isFlightLevel () const
 Flight level?
 
ReferenceDatum getReferenceDatum () const
 Get reference datum (MSL or AGL)
 
bool toFlightLevel ()
 MSL to flightlevel.
 
bool toMeanSeaLevel ()
 Flightlevel to MSL.
 
bool hasMeanSeaLevelValue () const
 Non-NULL MSL value?
 
AltitudeType getAltitudeType () const
 Current altitude type.
 
void convertToPressureAltitude (const physical_quantities::CPressure &seaLevelPressure)
 Converts this to pressure altitude. Requires the current barometric pressure at MSL.
 
CAltitude toPressureAltitude (const physical_quantities::CPressure &seaLevelPressure) const
 Returns the altitude converted to pressure altitude. Requires the current barometric pressure at MSL.
 
void parseFromString (const QString &value)
 Parse value from string.
 
void parseFromString (const QString &value, physical_quantities::CPqString::SeparatorMode mode)
 Parse value from string, with specified separator.
 
bool parseFromFpAltitudeString (const QString &value, CStatusMessageList *msgs=nullptr)
 Parse from FP altitude string. More...
 
bool isValidFpAltitude (CStatusMessageList *msgs=nullptr) const
 Is this a valid FP altitude. More...
 
QString asFpICAOAltitudeString () const
 Altitude string (official version) More...
 
QString asFpVatsimAltitudeString () const
 As simple VATSIM string, only FLxxx or altitude as ft.
 
swift::misc::CIcons::IconIndex toIcon () const
 As icon, not implemented by all classes. More...
 
int compare (const CAltitude &otherAltitude) const
 Return negative, zero, or positive if a is less than, equal to, or greater than b. More...
 
QString convertToQString (bool i18n=false) const
 Cast as QString. More...
 
int comparePropertyByIndex (CPropertyIndexRef index, const CAltitude &compareValue) const
 Set property by index. More...
 
CAltitude roundedToNearest100ft (bool roundDown) const
 Round to the nearest 100ft, like needed for China and Russia. More...
 
- Public Member Functions inherited from swift::misc::physical_quantities::CLength
 CLength ()
 Default constructor.
 
 CLength (double value, const CLengthUnit &unit)
 Init by double value.
 
 CLength (double value, const CLengthUnit &unit, const CLengthUnit &switchUnit)
 Init by double value and switch unit.
 
 CLength (const QString &unitString)
 Constructor by parsed string, e.g. 10m. More...
 
- Public Member Functions inherited from swift::misc::physical_quantities::CPhysicalQuantity< CLengthUnit, CLength >
int compare (const CLength &other) const
 Compare with other PQ.
 
const CLengthUnitgetUnit () const
 Unit.
 
void setUnit (const CLengthUnit &unit)
 Simply set unit, do no calclulate conversion. More...
 
void setUnitBySymbol (const QString &unitName)
 Set unit by string.
 
QString getUnitSymbol () const
 Unit.
 
CLengthswitchUnit (const CLengthUnit &newUnit)
 Change unit, and convert value to maintain the same quantity.
 
CLength switchedUnit (const CLengthUnit &newUnit) const
 Return copy with switched unit.
 
bool isNull () const
 Is quantity null?
 
void setNull ()
 Set null.
 
double value (CLengthUnit unit) const
 Value in given unit.
 
double value () const
 Value in current unit.
 
void setCurrentUnitValue (double value)
 Set value in current unit.
 
int valueInteger (CLengthUnit unit) const
 As integer value.
 
int valueInteger () const
 As integer value in current unit.
 
QString valueIntegerAsString (CLengthUnit unit) const
 As integer value.
 
QString valueIntegerAsString () const
 As integer value in current unit.
 
bool isInteger () const
 Is value an integer.
 
double valueRounded (CLengthUnit unit, int digits=-1) const
 Rounded value in given unit. More...
 
double valueRounded (int digits=-1) const
 Rounded value in current unit. More...
 
QString valueRoundedAsString (CLengthUnit unit, int digits=-1) const
 Rounded value in given unit. More...
 
QString valueRoundedWithUnit (const CLengthUnit &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
 Value to QString with the given unit, e.g. "5.00m". More...
 
QString valueRoundedWithUnit (int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
 Value to QString with the current unit, e.g. "5.00m". More...
 
void roundToEpsilon ()
 Round current value in current unit to epsilon. More...
 
void setValueSameUnit (double value)
 Change value without changing unit.
 
void addValueSameUnit (double value)
 Add to the value in the current unit.
 
void substractValueSameUnit (double value)
 Substract from the value in the current unit.
 
CPhysicalQuantityoperator*= (double multiply)
 Multiply operator *=.
 
CPhysicalQuantityoperator/= (double divide)
 Divide operator /=.
 
CLength operator* (double multiply) const
 Operator *.
 
CLength operator/ (double divide) const
 Operator /.
 
CLength operator- () const
 Unary operator -.
 
CPhysicalQuantityoperator+= (const CPhysicalQuantity &other)
 Plus operator +=.
 
CPhysicalQuantityoperator-= (const CPhysicalQuantity &other)
 Minus operator-=.
 
bool isZeroEpsilonConsidered () const
 Quantity value <= epsilon.
 
bool isPositiveWithEpsilonConsidered () const
 Value >= 0 epsilon considered.
 
bool isNegativeWithEpsilonConsidered () const
 Value <= 0 epsilon considered.
 
const CLengthmakePositive ()
 Make value always positive.
 
const CLengthmakeNegative ()
 Make value always negative.
 
CLength abs () const
 Absolute value (always >=0)
 
void marshallToDbus (QDBusArgument &argument) const
 Marshall without begin/endStructure, for when composed within another object. More...
 
void marshallToDbus (QDBusArgument &argument, LosslessTag) const
 Marshal to DBus, preserving the measurement unit.
 
void unmarshallFromDbus (const QDBusArgument &argument)
 Unmarshall without begin/endStructure, for when composed within another object. More...
 
void unmarshallFromDbus (const QDBusArgument &argument, LosslessTag)
 Unmarshal from DBus, with preserved measurement unit.
 
void marshalToDataStream (QDataStream &stream) const
 Marshal a value to a QDataStream. More...
 
void unmarshalFromDataStream (QDataStream &stream)
 Unmarshal a value from a QDataStream. More...
 
size_t getValueHash () const
 qHash overload, needed for storing value in a QSet. More...
 
QJsonObject toJson () const
 Cast to JSON object. More...
 
void convertFromJson (const QJsonObject &json)
 Assign from JSON object. More...
 
QVariant propertyByIndex (CPropertyIndexRef index) const
 Property by index. More...
 
void setPropertyByIndex (CPropertyIndexRef index, const QVariant &variant)
 Set property by index. More...
 
int comparePropertyByIndex (CPropertyIndexRef index, const CLength &pq) const
 Compare for index. More...
 
QString convertToQString (bool i18n=false) const
 Cast as QString. More...
 
void parseFromString (const QString &value)
 Parse value from string.
 
void parseFromString (const QString &value, CPqString::SeparatorMode mode)
 Parse to string, with specified separator.
 
void parseFromString (const QString &value, CPqString::SeparatorMode mode, const CLengthUnit &defaultUnitIfMissing)
 Parse to string, with specified separator.
 
- Public Member Functions inherited from swift::misc::mixin::Index< Derived >
CPropertyIndexList apply (const CPropertyIndexVariantMap &indexMap, bool skipEqualValues=false)
 Update by variant map. More...
 
void setPropertyByIndex (CPropertyIndexRef index, const QVariant &variant)
 Set property by index.
 
QVariant propertyByIndex (CPropertyIndexRef index) const
 Property by index.
 
int comparePropertyByIndex (CPropertyIndexRef index, const Derived &compareValue) const
 Compare for index.
 
bool equalsPropertyByIndex (const QVariant &compareValue, CPropertyIndexRef index) const
 Is given variant equal to value of property index?
 
- Public Member Functions inherited from swift::misc::mixin::MetaType< Derived >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object. More...
 
QString getClassName () const
 Class name.
 
bool isA (int metaTypeId) const
 Returns true if this object is an instance of the class with the given meta type ID, or one of its subclasses.
 
- Public Member Functions inherited from swift::misc::mixin::String< Derived >
QString toQString (bool i18n=false) const
 Cast as QString.
 
std::string toStdString (bool i18n=false) const
 To std string.
 
QString stringForStreaming () const
 String for streaming operators.
 
- Public Member Functions inherited from swift::misc::mixin::Icon< Derived, IconIndex >
CIcons::IconIndex toIcon () const
 As icon, not implemented by all classes.
 
- Public Member Functions inherited from swift::misc::mixin::MetaType< CAltitude >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object. More...
 
QString getClassName () const
 Class name.
 
bool isA (int metaTypeId) const
 Returns true if this object is an instance of the class with the given meta type ID, or one of its subclasses.
 
- Public Member Functions inherited from swift::misc::mixin::DBusByMetaClass< CAltitude >
void marshallToDbus (QDBusArgument &arg, Tags...) const
 Marshall without begin/endStructure, for when composed within another object.
 
void unmarshallFromDbus (const QDBusArgument &arg, Tags...)
 Unmarshall without begin/endStructure, for when composed within another object.
 
- Public Member Functions inherited from swift::misc::mixin::DBusByMetaClass< CAltitude, LosslessTag >
void marshallToDbus (QDBusArgument &arg, Tags...) const
 Marshall without begin/endStructure, for when composed within another object.
 
void unmarshallFromDbus (const QDBusArgument &arg, Tags...)
 Unmarshall without begin/endStructure, for when composed within another object.
 
- Public Member Functions inherited from swift::misc::mixin::DataStreamByMetaClass< CAltitude >
void marshalToDataStream (QDataStream &stream) const
 Marshal a value to a QDataStream.
 
void unmarshalFromDataStream (QDataStream &stream)
 Unmarshal a value from a QDataStream.
 
- Public Member Functions inherited from swift::misc::mixin::JsonByMetaClass< CAltitude >
QJsonObject toJson () const
 Cast to JSON object.
 
QString toJsonString (QJsonDocument::JsonFormat format=QJsonDocument::Indented) const
 Convenience function JSON as string.
 
void convertFromJson (const QJsonObject &json)
 Assign from JSON object.
 
void convertFromJson (const QString &jsonString, bool acceptCacheFormat=false)
 Assign from JSON object string.
 
- Public Member Functions inherited from swift::misc::mixin::String< CAltitude >
QString toQString (bool i18n=false) const
 Cast as QString.
 
std::string toStdString (bool i18n=false) const
 To std string.
 
QString stringForStreaming () const
 String for streaming operators.
 
- Public Member Functions inherited from swift::misc::mixin::Icon< CAltitude >
CIcons::IconIndex toIcon () const
 As icon, not implemented by all classes.
 
- Public Member Functions inherited from swift::misc::mixin::Index< CAltitude >
CPropertyIndexList apply (const CPropertyIndexVariantMap &indexMap, bool skipEqualValues=false)
 Update by variant map. More...
 
void setPropertyByIndex (CPropertyIndexRef index, const QVariant &variant)
 Set property by index.
 
QVariant propertyByIndex (CPropertyIndexRef index) const
 Property by index.
 
int comparePropertyByIndex (CPropertyIndexRef index, const CAltitude &compareValue) const
 Compare for index.
 
bool equalsPropertyByIndex (const QVariant &compareValue, CPropertyIndexRef index) const
 Is given variant equal to value of property index?
 

Static Public Member Functions

static const QRegularExpression & fpAltitudeRegExp ()
 Checking FP altitude strings like "A20", "FL100". More...
 
static QString fpAltitudeInfo (const QString &separator=", ")
 Info for FP altitude strings. More...
 
static QString fpAltitudeExamples ()
 Examples of FP altitude strings.
 
static const CAltitudenull ()
 Null altitude (MSL)
 
static physical_quantities::CLengthUnit defaultUnit ()
 Default unit for calculations. More...
 
static const physical_quantities::CPressurestandardISASeaLevelPressure ()
 Standard pressure 1013.25mbar/hPa.
 
static void registerMetadata ()
 Register metadata.
 
static int findMetricAltitude (int feet)
 Search the corresponding feet <-> metric / metric <-> feet.
 
static int findAltitudeForMetricAltitude (int metric)
 Search the corresponding feet <-> metric / metric <-> feet.
 
- Static Public Member Functions inherited from swift::misc::physical_quantities::CPhysicalQuantity< CLengthUnit, CLength >
static int compare (const CLength &a, const CLength &b)
 Implementation of compare.
 
static const CLengthmaxValue (const CLength &pq1, const CLength &pq2)
 Maximum of 2 quantities.
 
static const CLengthminValue (const CLength &pq1, const CLength &pq2)
 Minimum of 2 quantities.
 
static const CLengthnull ()
 NULL PQ.
 
static CLength parsedFromString (const QString &value, CPqString::SeparatorMode mode=CPqString::SeparatorBestGuess)
 Parsed from given string.
 
static CLength parsedFromString (const QString &value, CPqString::SeparatorMode mode, const CLengthUnit &defaultUnitIfMissing)
 Parsed from given string.
 
- Static Public Member Functions inherited from swift::misc::mixin::MetaType< Derived >
static void registerMetadata ()
 Register metadata.
 
- Static Public Member Functions inherited from swift::misc::mixin::MetaType< CAltitude >
static void registerMetadata ()
 Register metadata.
 
- Static Public Member Functions inherited from swift::misc::mixin::JsonByMetaClass< CAltitude >
static DerivedObj fromJson (const QJsonObject &json)
 Get object from QJsonObject.
 
static DerivedObj fromJson (const QString &jsonString, bool acceptCacheJson=false)
 Get object from JSON string.
 
static DerivedObj fromJsonNoThrow (const QString &jsonString, bool acceptCacheJson, bool &success, QString &errMsg)
 Get object from JSON string.
 

Additional Inherited Members

- Protected Member Functions inherited from swift::misc::physical_quantities::CPhysicalQuantity< CLengthUnit, CLength >
 CPhysicalQuantity (double value, CLengthUnit unit)
 Constructor with double.
 
 CPhysicalQuantity (const QString &unitString)
 Constructor by parsed string, e.g. 10m.
 

Detailed Description

Altitude as used in aviation, can be AGL or MSL altitude.

Remarks
Intentionally allowing +/- CLength , and >= / <= CLength.

Definition at line 39 of file altitude.h.

Member Enumeration Documentation

◆ AltitudeType

Altitude type.

Enumerator
PressureAltitude 

Altitude above the standard datum plane.

TrueAltitude 

Height of the airplane above Mean Sea Level (MSL)

Definition at line 80 of file altitude.h.

◆ ReferenceDatum

Enum type to distinguish between MSL and AGL.

Enumerator
MeanSeaLevel 

MSL.

AboveGround 

AGL.

FlightLevel 

Flight level.

Definition at line 72 of file altitude.h.

Member Function Documentation

◆ asFpICAOAltitudeString()

QString swift::misc::aviation::CAltitude::asFpICAOAltitudeString ( ) const

Altitude string (official version)

  • flight level, expressed as "F" followed by 3 figures, example: F085 (which means flight level 085),
  • standard metric level in tens of meters, expressed as "S" followed by 4 figures, example: S0150 (which means 1500 metres)
  • altitude in hundreds of feet, expressed as "A" followed by 3 figures, example: A055 (which means 5500 feet altitude)
  • altitude in tens of meters expressed as "M" followed by 4 figures, example: M0610 (which means 6100 metres altitude)

Definition at line 340 of file altitude.cpp.

◆ compare()

int swift::misc::aviation::CAltitude::compare ( const CAltitude otherAltitude) const

Return negative, zero, or positive if a is less than, equal to, or greater than b.

Definition at line 399 of file altitude.cpp.

◆ comparePropertyByIndex()

int swift::misc::aviation::CAltitude::comparePropertyByIndex ( CPropertyIndexRef  index,
const CAltitude compareValue 
) const

Set property by index.

Definition at line 99 of file altitude.cpp.

◆ convertToQString()

QString swift::misc::aviation::CAltitude::convertToQString ( bool  i18n = false) const

Cast as QString.

Definition at line 86 of file altitude.cpp.

◆ defaultUnit()

CLengthUnit swift::misc::aviation::CAltitude::defaultUnit ( )
static

Default unit for calculations.

Remarks
using this is optional and will simplify debugging and calculations

Definition at line 445 of file altitude.cpp.

◆ fpAltitudeInfo()

QString swift::misc::aviation::CAltitude::fpAltitudeInfo ( const QString &  separator = ", ")
static

Info for FP altitude strings.

See also
CFlightPlan::asFpAltitudeString

Definition at line 381 of file altitude.cpp.

◆ fpAltitudeRegExp()

const QRegularExpression & swift::misc::aviation::CAltitude::fpAltitudeRegExp ( )
static

Checking FP altitude strings like "A20", "FL100".

See also
CFlightPlan::asFpAltitudeString

Definition at line 374 of file altitude.cpp.

◆ isValidFpAltitude()

bool swift::misc::aviation::CAltitude::isValidFpAltitude ( CStatusMessageList msgs = nullptr) const

Is this a valid FP altitude.

See also
CFlightPlan::asFpAltitudeString

Definition at line 290 of file altitude.cpp.

◆ parseFromFpAltitudeString()

bool swift::misc::aviation::CAltitude::parseFromFpAltitudeString ( const QString &  value,
CStatusMessageList msgs = nullptr 
)

Parse from FP altitude string.

See also
CFlightPlan::asFpAltitudeString

Definition at line 188 of file altitude.cpp.

◆ roundedToNearest100ft()

CAltitude swift::misc::aviation::CAltitude::roundedToNearest100ft ( bool  roundDown) const

Round to the nearest 100ft, like needed for China and Russia.

Remarks
https://en.wikipedia.org/wiki/Flight_level

Definition at line 409 of file altitude.cpp.

◆ toIcon()

CIcons::IconIndex swift::misc::aviation::CAltitude::toIcon ( ) const

As icon, not implemented by all classes.

Definition at line 397 of file altitude.cpp.

◆ withOffset()

CAltitude swift::misc::aviation::CAltitude::withOffset ( const CLength offset) const

Altitude with offset.

Remarks
null offset adds nothing
epsilon 0 (zero) values ignored

Definition at line 61 of file altitude.cpp.


The documentation for this class was generated from the following files: