6#ifndef SWIFT_MISC_AVIATION_AIRCRAFTSITUATION_H
7#define SWIFT_MISC_AVIATION_AIRCRAFTSITUATION_H
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,
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;
466 using namespace swift::misc::math;
472 static bool isGfStarting(
double oldGroundFactor,
double newGroundFactor)
474 using namespace swift::misc::math;
480 static bool isGfLanding(
double oldGroundFactor,
double newGroundFactor)
482 using namespace swift::misc::math;
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;
static bool epsilonEqualLimits(double v1, double v2)
Epsilon safe equal.
ITimestampWithOffsetBased()=default
Constructor.
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.
static bool isGfLanding(double oldGroundFactor, double newGroundFactor)
Aircraft is landing.
void setGroundSpeed(const physical_quantities::CSpeed &groundspeed)
Set ground speed.
const physical_quantities::CLength & getCG() const
Get CG if any.
bool hasCallsign() const
Has corresponding callsign.
std::array< double, 3 > normalVectorDouble() const
Normal vector with double precision.
static constexpr double MaxDeltaElevationFt
Threshold until we interpolate elevations.
CAircraftSituation()=default
Default constructor.
static bool isGfStarting(double oldGroundFactor, double newGroundFactor)
Aircraft is starting.
static void registerMetadata()
Register metadata.
bool isPositionOrAltitudeNull() const
Position or altitude null?
const CHeading & getHeading() const
Get heading.
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
const physical_quantities::CAngle & getBank() const
Get bank (angle).
physical_quantities::CLengthUnit getAltitudeUnit() const
Get altitude unit.
GndElevationInfo
Where did we get elevation from?
@ Extrapolated
extrapolated ("guessing")
@ SituationChange
from swift::misc::aviation::CAircraftSituationChange
@ FromProvider
from swift::misc::simulation::ISimulationEnvironmentProvider
@ Average
average value of "nearby" situation CAircraftSituationList::averageElevationOfNonMovingAircraft
@ 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?
const CAltitude & geodeticHeight() const
Height, ellipsoidal or geodetic height (used in GPS).
void setGroundElevationInfo(GndElevationInfo details)
How we did get gnd.elevation.
bool isOnGround() const
Is on ground?
const CAltitude & getGroundElevation() const
Elevation of the ground directly beneath.
const CAircraftVelocity & getVelocity() const
Get 6DOF velocity.
CAircraftLights guessLights() const
Guessed lights.
const physical_quantities::CAngle & getPitch() const
Get pitch.
const CAltitude & getAltitude() const
Get altitude.
const physical_quantities::CSpeed & getGroundSpeed() const
Get ground speed.
bool isGroundElevationInfoTransferred() const
Is the elv.info transferred?
const geo::CElevationPlane & getGroundElevationPlane() const
Elevation of the ground directly beneath.
QVector3D normalVector() const
Normal vector.
void setVelocity(const CAircraftVelocity &velocity)
Set 6DOF velocity.
const CAltitude & getPressureAltitude() const
Get pressure altitude.
const CCallsign & getCallsign() const
Corresponding callsign.
const geo::CCoordinateGeodetic & getPosition() const
Get position.
bool isInterim() const
Get flag indicating this is an interim position update.
ColumnIndex
Properties by index.
static const physical_quantities::CLength & allowedAltitudeDeviation()
Within this range deviation is so small we consider values "almost constant".
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()
Free functions in swift::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 ...