10 using namespace swift::misc::physical_quantities;
12 namespace swift::misc::aviation
16 : m_onGroundDetails(static_cast<int>(details))
20 case IsOnGround::OnGroundSituationUnknown: m_onGroundFactor = -1.0;
break;
21 case IsOnGround::OnGround: m_onGroundFactor = 1.0;
break;
22 case IsOnGround::NotOnGround: m_onGroundFactor = 0.0;
break;
28 static const QString notog(
"not on ground");
29 static const QString og(
"on ground");
30 static const QString unknown(
"unknown");
34 case IsOnGround::NotOnGround:
return notog;
35 case IsOnGround::OnGround:
return og;
36 case IsOnGround::OnGroundSituationUnknown:
37 default:
return unknown;
43 static const QString elvCg(
"elevation/CG");
44 static const QString interpolation(
"interpolation");
45 static const QString guess(
"guessing");
46 static const QString unknown(
"unknown");
47 static const QString outOwnAircraft(
"own aircraft");
48 static const QString inNetwork(
"from network");
49 static const QString inFromParts(
"from parts");
53 case OnGroundDetails::OnGroundByElevationAndCG:
return elvCg;
54 case OnGroundDetails::OnGroundByGuessing:
return guess;
55 case OnGroundDetails::OnGroundByInterpolation:
return interpolation;
56 case OnGroundDetails::OutOnGroundOwnAircraft:
return outOwnAircraft;
57 case OnGroundDetails::InFromNetwork:
return inNetwork;
58 case OnGroundDetails::InFromParts:
return inFromParts;
59 case OnGroundDetails::NotSetGroundDetails:
60 default:
return unknown;
67 qRegisterMetaType<IsOnGround>();
68 qRegisterMetaType<OnGroundDetails>();
71 COnGroundInfo::COnGroundInfo(
double interpolatedGndFactor)
72 : m_onGroundDetails(static_cast<int>(
OnGroundDetails::OnGroundByInterpolation)),
73 m_onGroundFactor(interpolatedGndFactor)
76 if (m_onGroundFactor < -0.1) { m_onGroundFactor = -1.0; }
77 else if (m_onGroundFactor < 0.001) { m_onGroundFactor = 0.0; }
78 else if (m_onGroundFactor > 0.999) { m_onGroundFactor = 1.0; }
81 COnGroundInfo::COnGroundInfo(
const CLength &cg,
const CLength &groundDistance)
83 m_onGroundDetails =
static_cast<int>(OnGroundDetails::OnGroundByElevationAndCG);
84 if (groundDistance.
isNull()) { m_onGroundFactor = -1.0; }
90 const CLength cgFactor(cg * 0.1);
91 if (groundDistance.
abs() < cgFactor.
abs()) { m_onGroundFactor = 1.0; }
93 m_onGroundFactor = 0.0;
96 bool COnGroundInfo::isOnGround()
const
98 SWIFT_VERIFY_X(m_onGroundFactor >= 0.0, Q_FUNC_INFO,
"Should only be called with positive groundfactors");
99 if (m_onGroundDetails == OnGroundDetails::OnGroundByInterpolation)
101 return m_onGroundFactor > m_groundFactorThreshold;
108 if (this->m_onGroundFactor < 0.0) {
return OnGroundSituationUnknown; }
110 const bool onGround = isOnGround();
111 return onGround ? OnGround : NotOnGround;
121 static const CLength small(0.5, CLengthUnit::m());
127 return u
" | factor: " % QString::number(m_onGroundFactor,
'f', 2) % u
" | source: " %
133 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
138 case IndexOnGroundFactor:
return QVariant::fromValue(m_onGroundFactor);
139 case IndexOnGroundDetails:
return QVariant::fromValue(m_onGroundDetails);
155 case IndexOnGroundFactor: m_onGroundFactor = variant.toDouble();
break;
156 case IndexOnGroundDetails: m_onGroundDetails = variant.toInt();
break;
Non-owning reference to a CPropertyIndex with a subset of its features.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
Information about the ground status.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
static void registerMetadata()
Register metadata.
static const QString & isOnGroundToString(IsOnGround onGround)
Enum to string.
OnGroundDetails
Reliability of on ground information.
QString convertToQString(bool i18n=false) const
Cast as QString.
IsOnGround getOnGround() const
Is on ground?
OnGroundDetails getGroundDetails() const
Get ground details.
static const physical_quantities::CLength & deltaNearGround()
Delta distance, near to ground.
ColumnIndex
Properties by index.
static const QString & onGroundDetailsToString(OnGroundDetails reliability)
Enum to string.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
static bool epsilonEqual(float v1, float v2, float epsilon=1E-06f)
Epsilon safe equal.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Physical unit length (length)
bool isNegativeWithEpsilonConsidered() const
Value <= 0 epsilon considered.
bool isNull() const
Is quantity null?
PQ abs() const
Absolute value (always >=0)
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.