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
115 const physical_quantities::CAngle &bank = {},
const physical_quantities::CSpeed &gs = {},
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 virtual 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;
213 virtual QVector3D
normalVector()
const override {
return m_position.normalVector(); }
218 return m_position.normalVectorDouble();
228 GndElevationInfo getGroundElevationInfo()
const;
231 QString getGroundElevationInfoAsString()
const;
234 QString getGroundElevationAndInfo()
const;
243 bool canTransferGroundElevation(
251 bool transferGroundElevationFromMe(
260 bool transferGroundElevationToMe(
const CAircraftSituation &fromSituation,
bool transferred);
270 bool hasGroundElevation()
const;
273 bool hasInboundGroundDetails()
const;
277 bool transferred =
false);
281 bool transferred =
false);
285 bool setGroundElevationChecked(
const geo::CElevationPlane &elevationPlane, GndElevationInfo info,
286 bool transferred =
false);
289 void resetGroundElevation();
298 void setHeading(
const CHeading &heading);
312 CAltitude getCorrectedAltitude(
bool enableDragToGround =
true,
313 AltitudeCorrection *correction =
nullptr)
const;
315 bool enableDragToGround =
true,
316 AltitudeCorrection *correction =
nullptr)
const;
321 AltitudeCorrection correctAltitude(
bool enableDragToGround =
true);
324 bool enableDragToGround =
true);
328 void setAltitude(
const CAltitude &altitude);
340 void setPressureAltitude(
const CAltitude &altitude);
358 void setZeroPBHandGs();
361 QString getPBHInfo()
const;
366 m_velocity = velocity;
367 m_hasVelocity =
true;
383 bool isMoving()
const;
386 bool canLikelySkipNearGroundInterpolation()
const;
390 getDistancePerTime(std::chrono::milliseconds,
401 bool hasCallsign()
const {
return !this->getCallsign().isEmpty(); }
404 void setCallsign(
const CCallsign &callsign);
413 bool hasCG()
const {
return !m_cg.isNull(); }
423 bool adjustGroundFlag(
const CAircraftParts &parts,
bool alwaysSetDetails,
double timeDeviationFactor = 0.1,
424 qint64 *differenceMs =
nullptr);
432 double timeDeviationFactor = 0.1, qint64 *differenceMs =
nullptr);
438 static const QString &altitudeCorrectionToString(AltitudeCorrection correction);
441 static bool isCorrectedAltitude(AltitudeCorrection correction);
444 static const QString &gndElevationInfoToString(GndElevationInfo details);
461 using namespace swift::misc::math;
462 return CMathUtils::epsilonEqualLimits(1.0, oldGroundFactor) &&
463 CMathUtils::epsilonEqualLimits(1.0, newGroundFactor);
469 using namespace swift::misc::math;
470 return CMathUtils::epsilonEqualLimits(0.0, oldGroundFactor) &&
471 CMathUtils::epsilonEqualLimits(0.0, newGroundFactor);
475 static bool isGfStarting(
double oldGroundFactor,
double newGroundFactor)
477 using namespace swift::misc::math;
478 return CMathUtils::epsilonEqualLimits(0.0, oldGroundFactor) &&
479 CMathUtils::epsilonEqualLimits(1.0, newGroundFactor);
483 static bool isGfLanding(
double oldGroundFactor,
double newGroundFactor)
485 using namespace swift::misc::math;
486 return CMathUtils::epsilonEqualLimits(1.0, oldGroundFactor) &&
487 CMathUtils::epsilonEqualLimits(0.0, newGroundFactor);
499 static constexpr
double MaxDeltaElevationFt = 25.0;
517 physical_quantities::CAngle m_bank { 0,
nullptr };
518 physical_quantities::CSpeed m_groundSpeed { 0,
nullptr };
519 physical_quantities::CLength m_cg { 0,
nullptr };
520 bool m_hasVelocity =
false;
521 CAircraftVelocity m_velocity;
522 bool m_isInterim =
false;
523 bool m_isElvInfoTransferred =
false;
524 int m_elvInfo =
static_cast<int>(CAircraftSituation::NoElevationInfo);
525 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.
static bool isGfStarting(double oldGroundFactor, double newGroundFactor)
Aircraft is starting.
bool isPositionOrAltitudeNull() const
Position or altitude null?
virtual QVector3D normalVector() const
Normal vector.
const CAltitude & geodeticHeight() const
Height, ellipsoidal or geodetic height (used in GPS)
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
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.
virtual geo::CLatitude latitude() const
Latitude.
const physical_quantities::CSpeed & getGroundSpeed() const
Get ground speed.
virtual std::array< double, 3 > normalVectorDouble() const
Normal vector with double precision.
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?
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.
virtual geo::CLongitude longitude() const
Longitude.
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 ...