12 using namespace swift::misc::geo;
13 using namespace swift::misc::physical_quantities;
14 using namespace swift::misc::math;
18 namespace swift::misc::aviation
38 if (this->
size() > index) {
return (*
this)[index]; }
44 qint64 newerThanAdjustedMs)
46 if (elevationPlane.
isNull()) {
return 0; }
84 if (this->
isEmpty()) {
return false; }
91 if (this->
isEmpty()) {
return false; }
94 return situation.
getOnGroundInfo().getOnGround() == COnGroundInfo::NotOnGround;
100 if (this->
size() < 2) {
return false; }
107 if (!newerSituation.
isNull())
109 Q_ASSERT_X(situation.getAltitude().getReferenceDatum() ==
111 Q_FUNC_INFO,
"Wrong reference");
115 newerSituation = situation;
122 if (this->
size() < 2) {
return false; }
130 if (!newerSituation.
isNull())
132 Q_ASSERT_X(situation.getAltitude().getReferenceDatum() ==
134 Q_FUNC_INFO,
"Wrong reference");
138 newerSituation = situation;
145 if (this->
size() < 2) {
return false; }
149 CSpeed newerGs = CSpeed::null();
154 const CSpeed deltaSpeed = newerGs - situation.getGroundSpeed();
157 newerGs = situation.getGroundSpeed();
164 if (this->
size() < 2) {
return false; }
168 CSpeed newerGs = CSpeed::null();
173 const CSpeed deltaSpeed = newerGs - situation.getGroundSpeed();
176 newerGs = situation.getGroundSpeed();
181 QPair<bool, COnGroundInfo::IsOnGround>
184 if (this->
size() < 2) {
return {
false, COnGroundInfo::OnGroundSituationUnknown }; }
189 QPair<bool, COnGroundInfo::IsOnGround> ret(
false, f);
190 if (f == t) {
return ret; }
192 bool changed =
false;
196 if (!changed && s.getOnGroundInfo().getOnGround() == f) {
continue; }
202 if (s.getOnGroundInfo().getOnGround() != t) {
return ret; }
210 if (this->
size() < 2) {
return false; }
216 return this->
size() - 1 == c;
221 if (this->
size() < 2) {
return false; }
226 const int c = this->
countOnGround(COnGroundInfo::NotOnGround);
227 return this->
size() - 1 == c;
232 if (this->
size() < 2) {
return false; }
235 const QPair<double, double> stdDevAndMean = CMathUtils::standardDeviationAndMean(pitches);
236 const double minRotate = stdDevAndMean.first + stdDevAndMean.second;
237 const bool rotate = pitches.
front() > minRotate;
244 return situation.
getGroundSpeed().isNegativeWithEpsilonConsidered();
258 const CLength r = range.
isNull() || range < CElevationPlane::singlePointRadius() ?
259 CElevationPlane::singlePointRadius() :
263 CLength bestDistance = CLength::null();
273 if (distance > r) {
continue; }
274 if (bestDistance.
isNull() || bestDistance > distance)
276 situationWithElevation = s;
277 bestDistance = distance;
280 return situationWithElevation;
295 if (offset.
isNull() || this->isEmpty()) {
return 0; }
312 if (this->
empty()) {
return {}; }
353 if (alt.
isNull()) {
continue; }
362 if (gsValues.
size() != this->size()) {
return { CSpeed::null(), CSpeed::null() }; }
363 const QPair<double, double> gsKts = CMathUtils::standardDeviationAndMean(gsValues);
364 return {
CSpeed(gsKts.first, CSpeedUnit::kts()),
CSpeed(gsKts.second, CSpeedUnit::kts()) };
370 if (
pitchValues.
size() != this->size()) {
return { CAngle::null(), CAngle::null() }; }
371 const QPair<double, double> pitchDeg = CMathUtils::standardDeviationAndMean(
pitchValues);
372 return {
CAngle(pitchDeg.first, CAngleUnit::deg()),
CAngle(pitchDeg.second, CAngleUnit::deg()) };
377 if (this->
size() < 2) {
return 0; }
378 Q_ASSERT_X(
m_tsAdjustedSortHint == CAircraftSituationList::AdjustedTimestampLatestFirst, Q_FUNC_INFO,
379 "need latest first");
381 for (
int i = 1; i < this->
size(); ++i)
393 if (this->
size() < minValues) {
return CElevationPlane::null(); }
396 .findWithinRange(reference, range)
397 .sortedByEuclideanDistanceSquared(
reference);
398 if (
sorted.
size() < minValues) {
return CElevationPlane::null(); }
405 if (!canUse) {
continue; }
409 if (valuesInFt.
size() >= sufficientValues) {
break; }
412 if (valuesInFt.
size() < minValues) {
return CElevationPlane::null(); }
415 const QPair<double, double> elvStdDevMean = CMathUtils::standardDeviationAndMean(valuesInFt);
416 if (elvStdDevMean.first > MaxDevFt) {
return CElevationPlane::null(); }
417 return {
reference, elvStdDevMean.second, CElevationPlane::singlePointRadius() };
QPair< CAngle, CAngle > CAnglePair
Pair of angle.
size_type size() const
Returns number of elements in the sequence.
iterator begin()
Returns iterator at the beginning of the sequence.
Q_REQUIRED_RESULT CSequence sorted(Predicate p) const
Return a copy sorted by a given comparator predicate.
CAircraftSituation & reference
STL compatibility.
bool empty() const
Returns true if the sequence is empty.
const_iterator cbegin() const
Returns const iterator at the beginning of the sequence.
reference front()
Access the first element.
reference back()
Access the last element.
const_iterator cend() const
Returns const iterator one past the end of the sequence.
bool isEmpty() const
Synonym for empty.
iterator end()
Returns iterator one past the end of the sequence.
void pop_front()
Removes an element at the front of the sequence.
qint64 getAdjustedMSecsSinceEpoch() const
Timestamp with offset added for interpolation.
bool isSortedAdjustedLatestFirst() const
Is completely sorted: latest last.
CAircraftSituationList getSortedAdjustedLatestFirst() const
As sorted copy.
HintAdjustedTimestampSort m_tsAdjustedSortHint
sort hint
Value object encapsulating information of aircraft's parts.
Value object encapsulating information of an aircraft's situation.
const CAltitude & getGroundElevation() const
Elevation of the ground directly beneath.
bool hasGroundElevation() const
Is ground elevation value available.
CAltitude addAltitudeOffset(const physical_quantities::CLength &offset)
Add offset to altitude.
bool transferGroundElevationFromMe(CAircraftSituation &transferToSituation, const physical_quantities::CLength &radius=geo::CElevationPlane::singlePointRadius()) const
Transfer from "this" situation to otherSituation.
aviation::COnGroundInfo getOnGroundInfo() const
On ground info.
GndElevationInfo getGroundElevationInfo() const
How did we get gnd.elevation?
GndElevationInfo
Where did we get elevation from?
@ FromProvider
from swift::misc::simulation::ISimulationEnvironmentProvider
bool setGroundElevationChecked(const geo::CElevationPlane &elevationPlane, GndElevationInfo info, bool transferred=false)
Set elevation of the ground directly beneath, but checked.
static const CAircraftSituation & null()
Null situation.
bool isOnGround() const
Is on ground?
const physical_quantities::CSpeed & getGroundSpeed() const
Get ground speed.
void setOnGroundInfo(const aviation::COnGroundInfo &info)
Set the on ground info.
const CAltitude & getAltitude() const
Get altitude.
bool isNull() const
Null situation.
const physical_quantities::CAngle & getPitch() const
Get pitch.
bool isMoving() const
Is moving? Means ground speed > epsilon.
bool isOnGroundFromNetwork() const
On ground by network flag?
const geo::CElevationPlane & getGroundElevationPlane() const
Elevation of the ground directly beneath.
void setOnGroundDetails(COnGroundInfo::OnGroundDetails details)
On ground details.
bool isOnGroundFromParts() const
On ground by parts?
static const physical_quantities::CLength & allowedAltitudeDeviation()
Within this range deviation is so small we consider values "almost constant".
bool adjustGroundFlag(const CAircraftParts &parts, bool alwaysSetDetails, double timeDeviationFactor=0.1, qint64 *differenceMs=nullptr)
Transfer ground flag from parts.
List of aircraft situations.
bool isJustTouchingDown(bool alreadySortedLatestFirst=false) const
Is just touching down?
CAircraftSituation findClosestElevationWithinRange(const geo::ICoordinateGeodetic &coordinate, const physical_quantities::CLength &range=geo::CElevationPlane::singlePointRadius()) const
CLosest elevation within given range.
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.
QPair< bool, COnGroundInfo::IsOnGround > isGndFlagStableChanging(bool alreadySortedLatestFirst=false) const
Is the ground flag changing for the situations.
int countOnGround(COnGroundInfo::IsOnGround og) const
Count the number of situations with COnGroundInfo::IsOnGround.
QList< double > elevationValues(const physical_quantities::CLengthUnit &unit) const
All elevation values.
QList< double > groundSpeedValues(const physical_quantities::CSpeedUnit &unit) const
All ground speed values.
QList< double > pitchValues(const physical_quantities::CAngleUnit &unit) const
All pitch values.
int setGroundElevationChecked(const geo::CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, qint64 newerThanAdjustedMs=-1)
Set ground elevation from elevation plane.
geo::CElevationPlane averageElevationOfTaxiingOnGroundAircraft(const CAircraftSituation &reference, const physical_quantities::CLength &range, int minValues=1, int sufficientValues=2) const
Average elevation for "nearby" aircraft "not/slowly moving" and having an elevation.
bool isConstDecelarating(bool alreadySortedLatestFirst=false) const
Constantly decelarating?
CAircraftSituation indexOrNull(int index) const
Index or NULL.
bool isConstDescending(bool alreadySortedLatestFirst=false) const
Constantly descending?
int adjustGroundFlag(const CAircraftParts &parts, double timeDeviationFactor=0.1)
Adjust flag from parts by using CAircraftSituation::adjustGroundFlag.
bool isConstOnGround() const
Are all situations on ground?
int addAltitudeOffset(const physical_quantities::CLength &offset)
Add an offset to each altitude.
bool isRotatingUp(bool alreadySortedLatestFirst=false) const
Is rotating up?
bool isJustTakingOff(bool alreadySortedLatestFirst=false) const
Is just taking off?
int transferElevationForward(const physical_quantities::CLength &radius=geo::CElevationPlane::singlePointRadius())
Transfer elevations forward from older to newer.
void setOnGroundInfo(const COnGroundInfo &info)
Set on ground.
void setOnGroundDetails(COnGroundInfo::OnGroundDetails details)
Set on ground details for all situations.
bool areAllOnGroundDetailsSame(COnGroundInfo::OnGroundDetails details) const
Are all on ground details the same?
bool containsOnGroundDetails(COnGroundInfo::OnGroundDetails details) const
Contains on ground details?
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?
CAircraftSituation backOrNull() const
Back or NULL.
CAircraftSituation frontOrNull() const
Front or NULL.
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.
ReferenceDatum getReferenceDatum() const
Get reference datum (MSL or AGL)
Information about the ground status.
OnGroundDetails
Reliability of on ground information.
@ InFromParts
set from aircraft parts
IsOnGround getOnGround() const
Is on ground?
Plane of same elevation, can be a single point or larger area (e.g. airport)
const aviation::CAltitude & getAltitude() const
Altitude (synonym for geodetic height)
bool isNull() const
Existing value?
Geodetic coordinate, a position in 3D space relative to the reference geoid.
physical_quantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const
Great circle distance.
bool containsNullPosition() const
Any NULL position?
bool containsNullPositionOrHeight() const
Any NULL position or NULL height.
CAircraftSituationList findWithGeodeticMSLHeight() const
Elements with geodetic height (only MSL)
Physical unit angle (radians, degrees)
Specialized class for angles (degrees, radian).
Physical unit length (length)
Specialized class for distance units (meter, foot, nautical miles).
bool isNegativeWithEpsilonConsidered() const
Value <= 0 epsilon considered.
bool isNull() const
Is quantity null?
double value(MU unit) const
Value in given unit.
bool isPositiveWithEpsilonConsidered() const
Value >= 0 epsilon considered.
Specialized class for speed units (m/s, ft/s, NM/h).
QList< T >::reference front()
void push_back(QList< T >::parameter_type value)
qsizetype size() const const
#define SWIFT_DEFINE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template definition of mixins for a CSequence subclass.
QPair< CSpeed, CSpeed > CSpeedPair
Pair of speeds.