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; }
86 if (this->
isEmpty()) {
return false; }
93 if (this->
isEmpty()) {
return false; }
96 return situation.
getOnGroundInfo().getOnGround() == COnGroundInfo::NotOnGround;
102 if (this->
size() < 2) {
return false; }
109 if (!newerSituation.
isNull())
111 Q_ASSERT_X(situation.getAltitude().getReferenceDatum() ==
113 Q_FUNC_INFO,
"Wrong reference");
117 newerSituation = situation;
124 if (this->
size() < 2) {
return false; }
132 if (!newerSituation.
isNull())
134 Q_ASSERT_X(situation.getAltitude().getReferenceDatum() ==
136 Q_FUNC_INFO,
"Wrong reference");
140 newerSituation = situation;
147 if (this->
size() < 2) {
return false; }
151 CSpeed newerGs = CSpeed::null();
156 const CSpeed deltaSpeed = newerGs - situation.getGroundSpeed();
159 newerGs = situation.getGroundSpeed();
166 if (this->
size() < 2) {
return false; }
170 CSpeed newerGs = CSpeed::null();
175 const CSpeed deltaSpeed = newerGs - situation.getGroundSpeed();
178 newerGs = situation.getGroundSpeed();
183 QPair<bool, COnGroundInfo::IsOnGround>
186 if (this->
size() < 2)
188 return QPair<bool, COnGroundInfo::IsOnGround>(
false, COnGroundInfo::OnGroundSituationUnknown);
194 QPair<bool, COnGroundInfo::IsOnGround> ret(
false, f);
195 if (f == t) {
return ret; }
197 bool changed =
false;
201 if (!changed && s.getOnGroundInfo().getOnGround() == f) {
continue; }
207 if (s.getOnGroundInfo().getOnGround() != t) {
return ret; }
215 if (this->
size() < 2) {
return false; }
221 return this->
size() - 1 == c;
226 if (this->
size() < 2) {
return false; }
231 const int c = this->
countOnGround(COnGroundInfo::NotOnGround);
232 return this->
size() - 1 == c;
237 if (this->
size() < 2) {
return false; }
239 const QList<double> pitches =
sorted.pitchValues(CAngleUnit::deg());
240 const QPair<double, double> stdDevAndMean = CMathUtils::standardDeviationAndMean(pitches);
241 const double minRotate = stdDevAndMean.first + stdDevAndMean.second;
242 const bool rotate = pitches.front() > minRotate;
265 const CLength r = range.
isNull() || range < CElevationPlane::singlePointRadius() ?
266 CElevationPlane::singlePointRadius() :
270 CLength bestDistance = CLength::null();
280 if (distance > r) {
continue; }
281 if (bestDistance.
isNull() || bestDistance > distance)
283 situationWithElevation = s;
284 bestDistance = distance;
287 return situationWithElevation;
302 if (offset.
isNull() || this->isEmpty()) {
return 0; }
327 QList<double> values;
334 QList<double> values;
345 QList<double> values;
356 QList<double> values;
360 if (alt.
isNull()) {
continue; }
361 values.push_back(alt.
value(unit));
369 if (gsValues.size() != this->size()) {
return QPair<CSpeed, CSpeed>(CSpeed::null(), CSpeed::null()); }
370 const QPair<double, double> gsKts = CMathUtils::standardDeviationAndMean(gsValues);
377 if (
pitchValues.size() != this->size()) {
return QPair<CAngle, CAngle>(CAngle::null(), CAngle::null()); }
378 const QPair<double, double> pitchDeg = CMathUtils::standardDeviationAndMean(
pitchValues);
384 if (this->
size() < 2) {
return 0; }
385 Q_ASSERT_X(
m_tsAdjustedSortHint == CAircraftSituationList::AdjustedTimestampLatestFirst, Q_FUNC_INFO,
386 "need latest first");
388 for (
int i = 1; i < this->
size(); ++i)
400 if (this->
size() < minValues) {
return CElevationPlane::null(); }
403 .findWithinRange(reference, range)
404 .sortedByEuclideanDistanceSquared(
reference);
405 if (
sorted.
size() < minValues) {
return CElevationPlane::null(); }
406 QList<double> valuesInFt;
412 if (!canUse) {
continue; }
415 valuesInFt.push_back(elvFt);
416 if (valuesInFt.size() >= sufficientValues) {
break; }
419 if (valuesInFt.size() < minValues) {
return CElevationPlane::null(); }
422 const QPair<double, double> elvStdDevMean = CMathUtils::standardDeviationAndMean(valuesInFt);
423 if (elvStdDevMean.first > MaxDevFt) {
return CElevationPlane::null(); }
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.
bool empty() const
Returns true if the sequence is empty.
reference front()
Access the first element.
reference back()
Access the last element.
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.
virtual 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?
CAircraftSituationList()=default
Default constructor.
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?
OnGroundDetails getGroundDetails() const
Get ground details.
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)
virtual 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).
#define SWIFT_DEFINE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template definition of mixins for a CSequence subclass.
QPair< CSpeed, CSpeed > CSpeedPair
Pair of speeds.