10using namespace swift::misc::physical_quantities;
12namespace 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;
60 default:
return unknown;
67 qRegisterMetaType<IsOnGround>();
68 qRegisterMetaType<OnGroundDetails>();
71 COnGroundInfo::COnGroundInfo(
double interpolatedGndFactor)
73 m_onGroundFactor(interpolatedGndFactor)
76 if (m_onGroundFactor < -0.1)
78 m_onGroundFactor = -1.0;
80 else if (m_onGroundFactor < 0.001)
82 m_onGroundFactor = 0.0;
84 else if (m_onGroundFactor > 0.999)
86 m_onGroundFactor = 1.0;
90 COnGroundInfo::COnGroundInfo(
const CLength &cg,
const CLength &groundDistance)
92 m_onGroundDetails =
static_cast<int>(OnGroundDetails::OnGroundByElevationAndCG);
93 if (groundDistance.
isNull())
95 m_onGroundFactor = -1.0;
99 m_onGroundFactor = 1.0;
103 m_onGroundFactor = 1.0;
108 const CLength cgFactor(cg * 0.1);
109 if (groundDistance.
abs() < cgFactor.
abs())
111 m_onGroundFactor = 1.0;
114 m_onGroundFactor = 0.0;
117 bool COnGroundInfo::isOnGround()
const
119 SWIFT_VERIFY_X(m_onGroundFactor >= 0.0, Q_FUNC_INFO,
"Should only be called with positive groundfactors");
122 return m_onGroundFactor > m_groundFactorThreshold;
132 if (this->m_onGroundFactor < 0.0)
134 return OnGroundSituationUnknown;
137 const bool onGround = isOnGround();
138 return onGround ? OnGround : NotOnGround;
154 return u
" | factor: " %
QString::number(m_onGroundFactor,
'f', 2) % u
" | source: " %
178 (*this) = variant.
value<COnGroundInfo>();
185 case IndexOnGroundFactor: m_onGroundFactor = variant.
toDouble();
break;
186 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.
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.
@ InFromParts
set from aircraft parts
@ InFromNetwork
received from network
@ OutOnGroundOwnAircraft
sending on ground
@ OnGroundByInterpolation
strongest for remote aircraft
@ OnGroundByGuessing
weakest
@ NotSetGroundDetails
not set or unknown if correct (e.g.
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).
static CLengthUnit m()
Meter m.
bool isNegativeWithEpsilonConsidered() const
Value <= 0 epsilon considered.
bool isNull() const
Is quantity null?
PQ abs() const
Absolute value (always >=0).
QString number(double n, char format, int precision)
QVariant fromValue(T &&value)
double toDouble(bool *ok) const const
int toInt(bool *ok) const const
#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.