swift
Loading...
Searching...
No Matches
aircraftsituationchange.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <QPair>
7#include <QtGlobal>
8
9#include "QStringBuilder"
10
11#include "config/buildconfig.h"
15#include "misc/math/mathutils.h"
16#include "misc/pq/angle.h"
17#include "misc/pq/length.h"
18#include "misc/pq/units.h"
21#include "misc/stringutils.h"
22#include "misc/verify.h"
23
24using namespace swift::misc::physical_quantities;
25using namespace swift::misc::math;
26using namespace swift::config;
27
28SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::aviation, CAircraftSituationChange)
29
30namespace swift::misc::aviation
31{
33 {
35 qRegisterMetaType<CAircraftSituationChange::GuessedSceneryDeviation>();
36 }
37
39 const physical_quantities::CLength &cg, bool isVtol,
40 bool alreadySortedLatestFirst, bool calcStdDeviations)
41 {
42 if (situations.size() < 2)
43 {
44 return;
45 }
46 const CAircraftSituationList sorted(alreadySortedLatestFirst ? situations :
47 situations.getSortedAdjustedLatestFirst());
48
50 {
51 Q_ASSERT_X(sorted.isSortedAdjustedLatestFirstWithoutNullPositions(), Q_FUNC_INFO,
52 "Wrong sort order or NULL position");
53 }
54
55 const CAircraftSituation latest(sorted.front());
56 const CAircraftSituation oldest(sorted.back());
57 const CCallsign cs(latest.getCallsign());
58
59 m_situationsCount = situations.size();
60 m_correspondingCallsign = cs;
63 m_oldestTimestampMSecsSinceEpoch = oldest.getMSecsSinceEpoch();
64 m_latestAdjustedTimestampMSecsSinceEpoch = latest.getAdjustedMSecsSinceEpoch();
65 m_oldestAdjustedTimestampMSecsSinceEpoch = oldest.getAdjustedMSecsSinceEpoch();
66 m_constAscending = sorted.isConstAscending(true);
67 m_constDescending = sorted.isConstDescending(true);
68 m_constOnGround = sorted.isConstOnGround();
69 m_constNotOnGround = sorted.isConstNotOnGround();
70 m_justTakeoff = sorted.isJustTakingOff(true);
71 m_justTouchdown = sorted.isJustTouchingDown(true);
72 m_constAccelerating = sorted.isConstAccelerating(true);
73 m_constDecelerating = sorted.isConstDecelarating(true);
74 m_containsPushBack = !isVtol && sorted.containsPushBack();
75
76 if (sorted.size() >= 3)
77 {
78 const CAircraftSituationList sortedWithout = sorted.withoutFrontSituation();
79 m_wasNotOnGround = sortedWithout.isConstNotOnGround();
80 m_wasOnGround = sortedWithout.isConstOnGround();
81 }
82
83 if (calcStdDeviations)
84 {
85 this->calculateStdDeviations(situations, cg);
86 m_rotateUp = sorted.front().getPitch() > (m_pitchMean + m_pitchStdDev);
87 }
88 else
89 {
90 m_rotateUp = sorted.isRotatingUp(true);
91 }
92 }
93
95 const simulation::CAircraftModel &model) const
96 {
97 if (!situation.shouldGuessOnGround())
98 {
99 return false;
100 }
101
102 // for debugging purposed
103 QString *details = /*CBuildConfig::isLocalDeveloperDebugBuild() ? &m_onGroundGuessingDetails :*/ nullptr;
104
105 // Non VTOL aircraft have to move to be not on ground
106 const bool vtol = model.isVtol();
107 if (!vtol)
108 {
110 {
111 situation.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::OnGroundByGuessing });
112 if (details)
113 {
114 *details = QStringLiteral("No VTOL, push back");
115 }
116 return true;
117 }
118
119 if (!situation.isMoving())
120 {
121 situation.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::OnGroundByGuessing });
122 if (details)
123 {
124 *details = QStringLiteral("No VTOL, not moving => on ground");
125 }
126 return true;
127 }
128 }
129
130 // not on ground is default
131 situation.setOnGroundInfo({ COnGroundInfo::NotOnGround, COnGroundInfo::OnGroundByGuessing });
132
133 CLength cg = situation.hasCG() ? situation.getCG() : model.getCG();
134 CSpeed guessedRotateSpeed = CSpeed::null();
135 CSpeed sureRotateSpeed = CSpeed(130, CSpeedUnit::kts());
136 model.getAircraftIcaoCode().guessModelParameters(cg, guessedRotateSpeed);
137 if (!guessedRotateSpeed.isNull())
138 {
139 // does the value make any sense?
140 const bool validGuessedSpeed = (guessedRotateSpeed.value(CSpeedUnit::km_h()) > 5.0);
141 SWIFT_VERIFY_X(validGuessedSpeed, Q_FUNC_INFO, "Wrong guessed value for lift off");
142 if (!validGuessedSpeed)
143 {
144 guessedRotateSpeed = CSpeed(80, CSpeedUnit::kts());
145 } // fix
146 sureRotateSpeed = guessedRotateSpeed * 1.25;
147 }
148
149 // "extreme" values for which we are surely not on ground
150 if (qAbs(situation.getPitch().value(CAngleUnit::deg())) > 20)
151 {
152 if (details)
153 {
154 *details = QStringLiteral("max.pitch");
155 }
156 return true;
157 } // some tail wheel aircraft already have 11° pitch on ground
158 if (qAbs(situation.getBank().value(CAngleUnit::deg())) > 10)
159 {
160 if (details)
161 {
162 *details = QStringLiteral("max.bank");
163 }
164 return true;
165 }
166 if (situation.getGroundSpeed() > sureRotateSpeed)
167 {
168 if (details)
169 {
170 *details = u"gs. > vr " % sureRotateSpeed.valueRoundedWithUnit(1);
171 }
172 return true;
173 }
174
175 // use the most accurate or reliable guesses here first
176 // ------------------------------------------------------
177 // by elevation
178 // we can detect "on ground" (underflow, near ground), but not "not on ground" because of overflow
179
180 // we can detect on ground for underflow, but not for overflow (so we can not rely on NotOnGround)
181 COnGroundInfo og(cg, situation.getGroundDistance(cg));
182 if (og.getOnGround() == COnGroundInfo::OnGround)
183 {
184 if (details)
185 {
186 *details = QStringLiteral("elevation on ground");
187 }
189 situation.setOnGroundInfo(og);
190 return true;
191 }
192
193 if (!isNull())
194 {
195 if (!vtol && wasConstOnGround())
196 {
197 if (isRotatingUp())
198 {
199 // not OG
200 if (details)
201 {
202 *details = QStringLiteral("rotating up detected");
203 }
204 return true;
205 }
206
207 // here we stick to ground until we detect rotate up
208 situation.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::OnGroundByGuessing });
209 if (details)
210 {
211 *details = QStringLiteral("waiting for rotating up");
212 }
213 return true;
214 }
215
216 if (isConstAscending())
217 {
218 // not OG
219 if (details)
220 {
221 *details = QStringLiteral("const ascending");
222 }
223 return true;
224 }
225 }
226
227 // on VTOL we stop here
228 if (vtol)
229 {
230 // no idea
231 situation.setOnGroundInfo({ COnGroundInfo::OnGroundSituationUnknown, COnGroundInfo::NotSetGroundDetails });
232 return false;
233 }
234
235 // guessed speed null -> vtol
236 if (!guessedRotateSpeed.isNull())
237 {
238 // does the value make any sense?
239 if (situation.getGroundSpeed() < guessedRotateSpeed)
240 {
241 situation.setOnGroundInfo({ COnGroundInfo::OnGround, COnGroundInfo::OnGroundByGuessing });
242 if (details)
243 {
244 *details = QStringLiteral("Guessing, max.guessed gs.") +
245 guessedRotateSpeed.valueRoundedWithUnit(CSpeedUnit::kts(), 1);
246 }
247 return true;
248 }
249 }
250
251 // not sure, but this is a guess
252 if (details)
253 {
254 *details = QStringLiteral("Fall through");
255 }
256 return true;
257 }
258
259 bool CAircraftSituationChange::hasSceneryDeviation() const { return !m_guessedSceneryDeviation.isNull(); }
260
262 {
263 if (m_elvStdDev.isNull())
264 {
265 return false;
266 }
268 }
269
271 {
272 if (m_altStdDev.isNull())
273 {
274 return false;
275 }
277 }
278
280 {
281 Q_UNUSED(i18n)
282 static const QString null("null");
283 if (this->isNull())
284 {
285 return null;
286 }
287 return u"CS: '" % this->getCallsign().asString() % u" ' ts: " % this->getTimestampAndOffset(true) %
288 u" | situations:" % QString::number(m_situationsCount) % u" | ts adj.: " %
289 QString::number(m_oldestAdjustedTimestampMSecsSinceEpoch) % u'-' %
290 QString::number(m_latestAdjustedTimestampMSecsSinceEpoch) % u" | just takeoff: " %
291 boolToYesNo(this->isJustTakingOff()) % u" just touchdown: " % boolToYesNo(this->isJustTouchingDown()) %
292 u" | all gnd: " % boolToYesNo(this->isConstOnGround()) % u'/' % boolToYesNo(this->wasConstOnGround()) %
293 u" | all not gnd: " % boolToYesNo(this->isConstNotOnGround()) % u'/' %
294 boolToYesNo(this->wasConstNotOnGround()) % u" | ascending: " % boolToYesNo(this->isConstAscending()) %
295 u" descending: " % boolToYesNo(this->isConstDescending()) % u" | accelerating.: " %
296 boolToYesNo(this->isConstAccelerating()) % u" decelarating: " %
297 boolToYesNo(this->isConstDecelarating()) % u" | rotate up: " % boolToYesNo(this->isRotatingUp()) %
298 u" | push back: " % boolToYesNo(this->containsPushBack()) % u" | scenery delta: " %
299 m_guessedSceneryDeviation.valueRoundedWithUnit(1) % u" [" % this->getSceneryDeviationHintAsString() %
300 u"] | AGL delta: " % m_gndDistMean.valueRoundedWithUnit(1) % u'/' %
301 m_gndDistStdDev.valueRoundedWithUnit(1) % u" | std.dev/mean: pitch " %
302 m_pitchMean.valueRoundedWithUnit(1) % u'/' % m_pitchStdDev.valueRoundedWithUnit(1) % u" gs " %
303 m_gsMean.valueRoundedWithUnit(1) % u'/' % m_gsStdDev.valueRoundedWithUnit(1) % u" alt. " %
304 m_altMean.valueRoundedWithUnit(1) % u'/' % m_altStdDev.valueRoundedWithUnit(1) % u" elv. " %
305 m_elvMean.valueRoundedWithUnit(1) % u'/' % m_elvStdDev.valueRoundedWithUnit(1);
306 }
307
309 {
310 if (index.isMyself())
311 {
312 return QVariant::fromValue(*this);
313 }
315 {
317 }
318
319 const auto i = index.frontCasted<ColumnIndex>();
320 switch (i)
321 {
322 case IndexCallsign: return m_correspondingCallsign.propertyByIndex(index.copyFrontRemoved());
323 case IndexSituationsCount: return QVariant::fromValue(m_situationsCount);
324 case IndexConstAscending: return QVariant::fromValue(m_constAscending);
325 case IndexConstDescending: return QVariant::fromValue(m_constDescending);
326 case IndexConstNotOnGround: return QVariant::fromValue(m_constNotOnGround);
327 case IndexConstOnGround: return QVariant::fromValue(m_constOnGround);
328 case IndexIsNull: return QVariant::fromValue(this->isNull());
329 case IndexJustTakingOff: return QVariant::fromValue(m_justTakeoff);
330 case IndexJustTouchingDown: return QVariant::fromValue(m_justTouchdown);
331 case IndexRotatingUp: return QVariant::fromValue(m_rotateUp);
332 case IndexContainsPushBack: return QVariant::fromValue(m_containsPushBack);
333 case IndexAltitudeMean: return QVariant::fromValue(m_altMean);
334 case IndexAltitudeStdDev: return QVariant::fromValue(m_altStdDev);
335 case IndexElevationMean: return QVariant::fromValue(m_elvMean);
336 case IndexElevationStdDev: return QVariant::fromValue(m_elvStdDev);
337 default: return CValueObject::propertyByIndex(index);
338 }
339 }
340
342 {
343 if (index.isMyself())
344 {
345 (*this) = variant.value<CAircraftSituationChange>();
346 return;
347 }
349 {
351 return;
352 }
353
354 const auto i = index.frontCasted<ColumnIndex>();
355 switch (i)
356 {
357 case IndexCallsign: m_correspondingCallsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
358 case IndexSituationsCount: m_situationsCount = variant.toInt(); break;
359 case IndexConstAscending: m_constAscending = variant.toBool(); break;
360 case IndexConstDescending: m_constDescending = variant.toBool(); break;
361 case IndexConstNotOnGround: m_constNotOnGround = variant.toBool(); break;
362 case IndexConstOnGround: m_constOnGround = variant.toBool(); break;
363 case IndexJustTakingOff: m_justTakeoff = variant.toBool(); break;
364 case IndexJustTouchingDown: m_justTouchdown = variant.toBool(); break;
365 case IndexRotatingUp: m_rotateUp = variant.toBool(); break;
366 case IndexContainsPushBack: m_containsPushBack = variant.toBool(); break;
367 case IndexIsNull:
368 case IndexAltitudeMean:
369 case IndexAltitudeStdDev:
370 case IndexElevationMean:
371 case IndexElevationStdDev: break; // read only
372 default: CValueObject::setPropertyByIndex(index, variant); break;
373 }
374 }
375
377 const CAircraftSituationChange &compareValue) const
378 {
379 if (index.isMyself())
380 {
382 }
384 {
385 return ITimestampWithOffsetBased::comparePropertyByIndex(index, compareValue);
386 }
387
388 const auto i = index.frontCasted<ColumnIndex>();
389 switch (i)
390 {
391 case IndexCallsign:
392 return m_correspondingCallsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
393 case IndexSituationsCount:
394 return Compare::compare(this->getSituationsCount(), compareValue.getSituationsCount());
395 case IndexConstAscending: return Compare::compare(this->isConstAscending(), compareValue.isConstAscending());
396 case IndexConstDescending: return Compare::compare(this->isConstDescending(), compareValue.isConstDescending());
397 case IndexConstNotOnGround:
398 return Compare::compare(this->isConstNotOnGround(), compareValue.isConstNotOnGround());
399 case IndexConstOnGround: return Compare::compare(this->isConstOnGround(), compareValue.isConstOnGround());
400 case IndexJustTakingOff: return Compare::compare(this->isJustTakingOff(), compareValue.isJustTakingOff());
401 case IndexJustTouchingDown:
402 return Compare::compare(this->isJustTouchingDown(), compareValue.isJustTouchingDown());
403 case IndexRotatingUp: return Compare::compare(this->isRotatingUp(), compareValue.isRotatingUp());
404 case IndexContainsPushBack: return Compare::compare(this->containsPushBack(), compareValue.containsPushBack());
405 case IndexIsNull: return Compare::compare(this->isNull(), compareValue.isNull());
406 case IndexAltitudeMean:
407 return m_altMean.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_altMean);
408 case IndexAltitudeStdDev:
409 return m_altStdDev.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_altStdDev);
410 case IndexElevationMean:
411 return m_elvMean.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_elvMean);
412 case IndexElevationStdDev:
413 return m_elvStdDev.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_elvStdDev);
414 default: return CValueObject::comparePropertyByIndex(index, *this);
415 }
416 Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
417 return 0;
418 }
419
421 {
422 if (situations.isEmpty())
423 {
424 return false;
425 }
426
427 const QPair<CSpeed, CSpeed> gsStdDevMean = situations.groundSpeedStandardDeviationAndMean();
428 m_gsStdDev = gsStdDevMean.first;
429 m_gsMean = gsStdDevMean.second;
430
431 const QPair<CAngle, CAngle> pitchStdDevMean = situations.pitchStandardDeviationAndMean();
432 m_pitchStdDev = pitchStdDevMean.first;
433 m_pitchMean = pitchStdDevMean.second;
434
435 const QList<double> altValues = situations.altitudeValues(CAltitude::defaultUnit());
436 if (altValues.size() == situations.size())
437 {
438 const QPair<double, double> altDevMean = CMathUtils::standardDeviationAndMean(altValues);
439 m_altStdDev = CAltitude(altDevMean.first, CAltitude::MeanSeaLevel, CAltitude::defaultUnit());
440 m_altMean = CAltitude(altDevMean.second, CAltitude::MeanSeaLevel, CAltitude::defaultUnit());
441 }
442
443 const QList<double> elvValues = situations.elevationValues(CAltitude::defaultUnit());
444 if (elvValues.size() == situations.size())
445 {
446 const QPair<double, double> elvDevMean = CMathUtils::standardDeviationAndMean(elvValues);
447 m_elvStdDev = CAltitude(elvDevMean.first, CAltitude::MeanSeaLevel, CAltitude::defaultUnit());
448 m_elvMean = CAltitude(elvDevMean.second, CAltitude::MeanSeaLevel, CAltitude::defaultUnit());
449
450 if (altValues.size() == situations.size())
451 {
452 QList<double> gndDistance;
453 for (int i = 0; i < altValues.size(); i++)
454 {
455 const double delta = altValues[i] - elvValues[i];
456 gndDistance.push_back(delta);
457 }
458 const QPair<double, double> gndDistanceDevMean = CMathUtils::standardDeviationAndMean(gndDistance);
459 m_gndDistStdDev = CLength(gndDistanceDevMean.first, CAltitude::defaultUnit());
460 m_gndDistMean = CLength(gndDistanceDevMean.second, CAltitude::defaultUnit());
461
462 const auto gndDistMinMax = std::minmax_element(gndDistance.constBegin(), gndDistance.constEnd());
463 const double gndDistMin = *gndDistMinMax.first;
464 const double gndDistMax = *gndDistMinMax.second;
465 m_minGroundDistance = CLength(gndDistMin, CAltitude::defaultUnit());
466 m_maxGroundDistance = CLength(gndDistMax, CAltitude::defaultUnit());
467 this->guessSceneryDeviation(cg);
468 }
469 }
470 return true;
471 }
472
478
480 {
481 static const QString noInfo("no info");
482 static const QString completeOg("complete og");
483 static const QString wasOg("was og");
484 static const QString smallAGLDev("small AGL dev. near gnd.");
485
486 switch (hint)
487 {
488 case AllOnGround: return completeOg;
489 case WasOnGround: return wasOg;
490 case SmallAGLDeviationNearGround: return smallAGLDev;
491 case NoDeviationInfo:
492 default: break;
493 }
494 return noInfo;
495 }
496
497 void CAircraftSituationChange::setSceneryDeviation(const CLength &deviation, const CLength &cg,
499 {
500 m_guessedSceneryDeviation = deviation;
501 m_guessedSceneryDeviationCG = cg.isNull() ? CLength::null() : deviation - cg;
502 this->setSceneryDeviationHint(hint);
503 }
504
505 void CAircraftSituationChange::guessSceneryDeviation(const CLength &cg)
506 {
507 m_guessedSceneryDeviation = CLength::null();
508 this->setSceneryDeviationHint(NoDeviationInfo);
509 if (m_gndDistStdDev.isNull())
510 {
511 return;
512 }
513 if (m_gndDistMean.isNull())
514 {
515 return;
516 }
517
518 // only for a small deviation we can calculate scenery differemce
519 static const CLength maxDeviation(2, CLengthUnit::ft());
520
521 // Small deviation means "const" AGL
522 if (m_gndDistStdDev <= maxDeviation)
523 {
524 do
525 {
526 if (this->isConstOnGround())
527 {
528 this->setSceneryDeviation(m_gndDistMean, cg, AllOnGround);
529 break;
530 }
531 if (this->wasConstNotOnGround())
532 {
533 this->setSceneryDeviation(m_gndDistMean, cg, WasOnGround);
534 break;
535 }
536 if (!m_altStdDev.isNull() && m_altStdDev <= maxDeviation)
537 {
538 // small alt.deviation too!
539 if (!m_maxGroundDistance.isNull() && m_maxGroundDistance < cg)
540 {
541 if (this->isConstOnGround())
542 {
543 this->setSceneryDeviation(m_gndDistMean, cg, SmallAGLDeviationNearGround);
544 break;
545 }
546 }
547 }
548 }
549 while (false);
550 }
551 }
552} // namespace swift::misc::aviation
static CAngleUnit deg()
Degrees.
Definition units.h:276
static bool isLocalDeveloperDebugBuild()
Local build for developers.
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
size_type size() const
Returns number of elements in the sequence.
Definition sequence.h:273
reference front()
Access the first element.
Definition sequence.h:225
reference back()
Access the last element.
Definition sequence.h:249
bool isEmpty() const
Synonym for empty.
Definition sequence.h:285
qint64 getMSecsSinceEpoch() const
Timestamp as ms value.
qint64 m_timestampMSecsSinceEpoch
timestamp value
qint64 getAdjustedMSecsSinceEpoch() const
Timestamp with offset added for interpolation.
static bool canHandleIndex(CPropertyIndexRef index)
Can given index be handled.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
qint64 getTimeOffsetMs() const
Milliseconds to add to timestamp for interpolation.
int comparePropertyByIndex(CPropertyIndexRef index, const ITimestampWithOffsetBased &compareValue) const
Compare for index.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QString getTimestampAndOffset(bool formatted) const
Timestamp and offset.
CONTAINER getSortedAdjustedLatestFirst() const
As sorted copy.
void guessModelParameters(physical_quantities::CLength &guessedCGOut, physical_quantities::CSpeed &guessedVRotateOut) const
Guess aircraft model parameters.
QString convertToQString(bool i18n=false) const
Cast as QString.
bool hasSceneryDeviation() const
Scenery deviation available?
int getSituationsCount() const
Basend on n situations.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool containsPushBack() const
Contains any push back?
static const QString & guessedSceneryDeviationToString(GuessedSceneryDeviation hint)
The enum as string.
bool isConstDescending() const
Constantly descending?
bool hasAltitudeDevWithinAllowedRange() const
Altitude within CAircraftSituation::allowedAltitudeDeviation range.
bool wasConstNotOnGround() const
Was not on ground (without latest situation)?
bool hasElevationDevWithinAllowedRange() const
Elevation within CAircraftSituation::allowedAltitudeDeviation range.
bool isConstAccelerating() const
Constantly accelerating?
const CCallsign & getCallsign() const
Get callsign.
CAircraftSituationChange()=default
Default constructor.
GuessedSceneryDeviation
Hint about the guessed scenery deviation.
@ WasOnGround
was on ground except last situation
@ SmallAGLDeviationNearGround
"Almost const AGL" near Ground
bool isConstDecelarating() const
Constantly decelarating?
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
bool isJustTouchingDown() const
Is just touching down?
int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftSituationChange &compareValue) const
Compare for index.
const QString & getSceneryDeviationHintAsString() const
Scenery deviation hint hint as string.
bool isConstOnGround() const
Are all situations on ground?
bool isConstNotOnGround() const
Are all situations not on ground?
static const CAircraftSituationChange & null()
NULL object.
bool guessOnGround(CAircraftSituation &situation, const simulation::CAircraftModel &model) const
Guess on ground flag.
bool wasConstOnGround() const
Was on ground (without latest situation)?
bool calculateStdDeviations(const CAircraftSituationList &situations, const physical_quantities::CLength &cg)
Calculate the standard deviiations.
Value object encapsulating information of an aircraft's situation.
const physical_quantities::CLength & getCG() const
Get CG if any.
bool shouldGuessOnGround() const
Should we guess on ground?
const physical_quantities::CAngle & getBank() const
Get bank (angle).
physical_quantities::CLength getGroundDistance(const physical_quantities::CLength &centerOfGravity) const
Distance to ground, null if impossible to calculate.
void setOnGroundInfo(const aviation::COnGroundInfo &info)
Set the on ground info.
const physical_quantities::CAngle & getPitch() const
Get pitch.
const physical_quantities::CSpeed & getGroundSpeed() const
Get ground speed.
bool isMoving() const
Is moving? Means ground speed > epsilon.
const CCallsign & getCallsign() const
Corresponding callsign.
static const physical_quantities::CLength & allowedAltitudeDeviation()
Within this range deviation is so small we consider values "almost constant".
bool isJustTouchingDown(bool alreadySortedLatestFirst=false) const
Is just touching down?
CAircraftSituationList withoutFrontSituation() const
Remove the first situation.
bool isConstAccelerating(bool alreadySortedLatestFirst=false) const
Constantly accelerating?
bool isConstNotOnGround() const
Are all situations not on ground?
physical_quantities::CAnglePair pitchStandardDeviationAndMean() const
Pitch angles standard deviation and mean.
QList< double > elevationValues(const physical_quantities::CLengthUnit &unit) const
All elevation values.
bool isConstDecelarating(bool alreadySortedLatestFirst=false) const
Constantly decelarating?
bool isConstDescending(bool alreadySortedLatestFirst=false) const
Constantly descending?
bool isConstOnGround() const
Are all situations on ground?
bool isRotatingUp(bool alreadySortedLatestFirst=false) const
Is rotating up?
bool isJustTakingOff(bool alreadySortedLatestFirst=false) const
Is just taking off?
QList< double > altitudeValues(const physical_quantities::CLengthUnit &unit) const
All altitude values.
bool isSortedAdjustedLatestFirstWithoutNullPositions() const
Latest first and no null positions?
bool isConstAscending(bool alreadySortedLatestFirst=false) const
Constantly ascending?
bool containsPushBack() const
Contains any push back?
physical_quantities::CSpeedPair groundSpeedStandardDeviationAndMean() const
Ground speed standard deviation and mean.
Altitude as used in aviation, can be AGL or MSL altitude.
Definition altitude.h:52
static physical_quantities::CLengthUnit defaultUnit()
Default unit for calculations.
Definition altitude.cpp:517
Value object encapsulating information of a callsign.
Definition callsign.h:30
const QString & asString() const
Get callsign (normalized).
Definition callsign.h:96
Information about the ground status.
@ NotSetGroundDetails
not set or unknown if correct (e.g.
void setOnGroundDetails(OnGroundDetails details)
When source of knowledge changes.
IsOnGround getOnGround() const
Is on ground?
static QPair< double, double > standardDeviationAndMean(const QList< double > &values)
Standard deviation (first) and mean (second).
int comparePropertyByIndex(CPropertyIndexRef index, const Derived &compareValue) const
Compare for index.
Definition mixinindex.h:203
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Definition mixinindex.h:167
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition mixinindex.h:180
static void registerMetadata()
Register metadata.
Physical unit length (length).
Definition length.h:18
static CLengthUnit ft()
Foot ft.
Definition units.h:157
bool isNegativeWithEpsilonConsidered() const
Value <= 0 epsilon considered.
double value(MU unit) const
Value in given unit.
QString valueRoundedWithUnit(const MU &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value to QString with the given unit, e.g. "5.00m".
static CSpeedUnit km_h()
Kilometer/hour km/h.
Definition units.h:852
static CSpeedUnit kts()
Knots.
Definition units.h:817
Aircraft model (used by another pilot, my models on disk).
const physical_quantities::CLength & getCG() const
Get center of gravity.
const aviation::CAircraftIcaoCode & getAircraftIcaoCode() const
Aircraft ICAO code.
int compare(T a, T b)
Compare arithmetic values.
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
QList< T >::const_iterator constBegin() const const
QList< T >::const_iterator constEnd() const const
void push_back(QList< T >::parameter_type value)
qsizetype size() const const
QString number(double n, char format, int precision)
QVariant fromValue(T &&value)
bool toBool() const const
int toInt(bool *ok) const const
T value() const &const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
Definition valueobject.h:67
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.
Definition verify.h:26