6 #ifndef SWIFT_MISC_AVIATION_AIRCRAFTSITUATION_H
7 #define SWIFT_MISC_AVIATION_AIRCRAFTSITUATION_H
41 class CElevationPlane;
46 class CAircraftPartsList;
47 class CAircraftLights;
59 IndexPosition = CPropertyIndexRef::GlobalIndexCAircraftSituation,
70 IndexGroundElevationPlane,
71 IndexGroundElevationInfo,
72 IndexGroundElevationInfoTransferred,
73 IndexGroundElevationInfoString,
74 IndexGroundElevationPlusInfo,
77 IndexCanLikelySkipNearGroundInterpolation
116 const geo::CElevationPlane &groundElevation = {});
119 CAircraftSituation(
const CCallsign &correspondingCallsign,
const geo::CCoordinateGeodetic &position,
120 const CHeading &heading = {},
const physical_quantities::CAngle &pitch = {},
121 const physical_quantities::CAngle &bank = {},
const physical_quantities::CSpeed &gs = {},
122 const geo::CElevationPlane &groundElevation = {});
125 QString convertToQString(
bool i18n =
false)
const;
128 QVariant propertyByIndex(CPropertyIndexRef index)
const;
131 void setPropertyByIndex(CPropertyIndexRef index,
const QVariant &variant);
134 int comparePropertyByIndex(CPropertyIndexRef index,
const CAircraftSituation &compareValue)
const;
146 bool isNull()
const override;
149 bool isOtherElevationInfoBetter(GndElevationInfo otherInfo,
bool transferred)
const;
180 bool isOnGround()
const {
return m_onGroundInfo.getOnGround() == COnGroundInfo::OnGround; }
183 bool isOnGroundFromParts()
const;
186 bool isOnGroundFromNetwork()
const;
189 bool isOnGroundInfoAvailable()
const;
192 bool shouldGuessOnGround()
const;
198 bool hasGroundDetailsForGndInterpolation()
const;
216 std::array<double, 3>
normalVectorDouble()
const override {
return m_position.normalVectorDouble(); }
225 GndElevationInfo getGroundElevationInfo()
const;
228 QString getGroundElevationInfoAsString()
const;
231 QString getGroundElevationAndInfo()
const;
240 bool canTransferGroundElevation(
248 bool transferGroundElevationFromMe(
257 bool transferGroundElevationToMe(
const CAircraftSituation &fromSituation,
bool transferred);
267 bool hasGroundElevation()
const;
270 bool hasInboundGroundDetails()
const;
274 bool transferred =
false);
278 bool transferred =
false);
282 bool setGroundElevationChecked(
const geo::CElevationPlane &elevationPlane, GndElevationInfo info,
283 bool transferred =
false);
286 void resetGroundElevation();
295 void setHeading(
const CHeading &heading);
309 CAltitude getCorrectedAltitude(
bool enableDragToGround =
true,
310 AltitudeCorrection *correction =
nullptr)
const;
312 bool enableDragToGround =
true,
313 AltitudeCorrection *correction =
nullptr)
const;
318 AltitudeCorrection correctAltitude(
bool enableDragToGround =
true);
321 bool enableDragToGround =
true);
325 void setAltitude(
const CAltitude &altitude);
337 void setPressureAltitude(
const CAltitude &altitude);
355 void setZeroPBHandGs();
363 m_velocity = velocity;
364 m_hasVelocity =
true;
380 bool isMoving()
const;
383 bool canLikelySkipNearGroundInterpolation()
const;
387 getDistancePerTime(std::chrono::milliseconds,
398 bool hasCallsign()
const {
return !this->getCallsign().isEmpty(); }
401 void setCallsign(
const CCallsign &callsign);
410 bool hasCG()
const {
return !m_cg.isNull(); }
420 bool adjustGroundFlag(
const CAircraftParts &parts,
bool alwaysSetDetails,
double timeDeviationFactor = 0.1,
421 qint64 *differenceMs =
nullptr);
429 double timeDeviationFactor = 0.1, qint64 *differenceMs =
nullptr);
435 static const QString &altitudeCorrectionToString(AltitudeCorrection correction);
438 static bool isCorrectedAltitude(AltitudeCorrection correction);
441 static const QString &gndElevationInfoToString(GndElevationInfo details);
458 using namespace swift::misc::math;
459 return CMathUtils::epsilonEqualLimits(1.0, oldGroundFactor) &&
460 CMathUtils::epsilonEqualLimits(1.0, newGroundFactor);
466 using namespace swift::misc::math;
467 return CMathUtils::epsilonEqualLimits(0.0, oldGroundFactor) &&
468 CMathUtils::epsilonEqualLimits(0.0, newGroundFactor);
472 static bool isGfStarting(
double oldGroundFactor,
double newGroundFactor)
474 using namespace swift::misc::math;
475 return CMathUtils::epsilonEqualLimits(0.0, oldGroundFactor) &&
476 CMathUtils::epsilonEqualLimits(1.0, newGroundFactor);
480 static bool isGfLanding(
double oldGroundFactor,
double newGroundFactor)
482 using namespace swift::misc::math;
483 return CMathUtils::epsilonEqualLimits(1.0, oldGroundFactor) &&
484 CMathUtils::epsilonEqualLimits(0.0, newGroundFactor);
496 static constexpr
double MaxDeltaElevationFt = 25.0;
514 physical_quantities::CAngle m_bank { 0,
nullptr };
515 physical_quantities::CSpeed m_groundSpeed { 0,
nullptr };
516 physical_quantities::CLength m_cg { 0,
nullptr };
517 bool m_hasVelocity =
false;
518 CAircraftVelocity m_velocity;
519 bool m_isInterim =
false;
520 bool m_isElvInfoTransferred =
false;
521 int m_elvInfo =
static_cast<int>(CAircraftSituation::NoElevationInfo);
522 aviation::COnGroundInfo m_onGroundInfo;
Mix of the most commonly used mixin classes.
Value object encapsulating information about aircraft's lights.
Value object encapsulating information of aircraft's parts.
Value object encapsulating a list of aircraft parts.
Value object encapsulating information of an aircraft's situation.
const CAltitude & getGroundElevation() const
Elevation of the ground directly beneath.
static bool isGfLanding(double oldGroundFactor, double newGroundFactor)
Aircraft is landing.
void setGroundSpeed(const physical_quantities::CSpeed &groundspeed)
Set ground speed.
bool hasCallsign() const
Has corresponding callsign.
const CHeading & getHeading() const
Get heading.
std::array< double, 3 > normalVectorDouble() const
Normal vector with double precision.
CAircraftSituation()=default
Default constructor.
static bool isGfStarting(double oldGroundFactor, double newGroundFactor)
Aircraft is starting.
bool isPositionOrAltitudeNull() const
Position or altitude null?
const CAltitude & geodeticHeight() const
Height, ellipsoidal or geodetic height (used in GPS)
geo::CLongitude longitude() const
Longitude.
static bool isGfEqualAirborne(double oldGroundFactor, double newGroundFactor)
Both not on ground.
AltitudeCorrection
How was altitude corrected?
@ NoElevation
no correction as there is no elevation
@ Underflow
aircraft too low
@ DraggedToGround
other scenery too high, but on ground
physical_quantities::CLengthUnit getAltitudeUnit() const
Get altitude unit.
GndElevationInfo
Where did we get elevation from?
@ Extrapolated
extrapolated ("guessing")
@ SituationChange
from swift::misc::aviation::CAircraftSituationChange
@ Interpolated
interpolated between 2 elevations
geo::CLatitude latitude() const
Latitude.
void setInterimFlag(bool flag)
Set flag indicating this is an interim position update.
bool hasCG() const
Has CG set?
bool hasVelocity() const
Is velocity non-zero?
bool isPositionNull() const
Position null?
void setGroundElevationInfo(GndElevationInfo details)
How we did get gnd.elevation.
bool isOnGround() const
Is on ground?
const CCallsign & getCallsign() const
Corresponding callsign.
const physical_quantities::CSpeed & getGroundSpeed() const
Get ground speed.
const CAltitude & getAltitude() const
Get altitude.
const CAircraftVelocity & getVelocity() const
Get 6DOF velocity.
const CAltitude & getPressureAltitude() const
Get pressure altitude.
const physical_quantities::CAngle & getBank() const
Get bank (angle)
bool isGroundElevationInfoTransferred() const
Is the elv.info transferred?
QVector3D normalVector() const
Normal vector.
const physical_quantities::CAngle & getPitch() const
Get pitch.
void setVelocity(const CAircraftVelocity &velocity)
Set 6DOF velocity.
const physical_quantities::CLength & getCG() const
Get CG if any.
const geo::CCoordinateGeodetic & getPosition() const
Get position.
const geo::CElevationPlane & getGroundElevationPlane() const
Elevation of the ground directly beneath.
bool isInterim() const
Get flag indicating this is an interim position update.
ColumnIndex
Properties by index.
static bool isGfEqualOnGround(double oldGroundFactor, double newGroundFactor)
Both on ground.
void setPosition(const geo::CCoordinateGeodetic &position)
Set position.
Velocity and angular velocity for 6DOF bodies.
Altitude as used in aviation, can be AGL or MSL altitude.
Value object encapsulating information of a callsign.
Heading as used in aviation, can be true or magnetic heading.
Information about the ground status.
OnGroundDetails
Reliability of on ground information.
Plane of same elevation, can be a single point or larger area (e.g. airport)
static const physical_quantities::CLength & singlePointRadius()
Radius for single point.
Geodetic coordinate, a position in 3D space relative to the reference geoid.
Physical unit angle (radians, degrees)
Physical unit length (length)
Specialized class for distance units (meter, foot, nautical miles).
static const CLength & null()
NULL PQ.
Free functions in swift::misc.
void registerMetadata()
Register all relevant metadata in Misc.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...