mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T273, high level functions to compare "equal" situations
Remark: "==" compares a lot of attributes, those will only compare values to determine equal PBH/vector ...
This commit is contained in:
@@ -68,6 +68,13 @@ namespace BlackMisc
|
||||
return this->getPartsDetails() == NotSet && m_flapsPercentage < 0;
|
||||
}
|
||||
|
||||
bool CAircraftParts::equalValues(const CAircraftParts &other) const
|
||||
{
|
||||
// currently same as some values are diabled for comparison
|
||||
// but that could change in future
|
||||
return other == *this;
|
||||
}
|
||||
|
||||
const CAircraftParts &CAircraftParts::null()
|
||||
{
|
||||
static const CAircraftParts null(-1);
|
||||
|
||||
@@ -169,6 +169,9 @@ namespace BlackMisc
|
||||
//! NULL parts object?
|
||||
bool isNull() const;
|
||||
|
||||
//! Equal values, but not comparing timestamp etc.
|
||||
bool equalValues(const CAircraftParts &other) const;
|
||||
|
||||
//! NULL parts object
|
||||
static const CAircraftParts &null();
|
||||
|
||||
|
||||
@@ -234,6 +234,16 @@ namespace BlackMisc
|
||||
return this->isPositionNull();
|
||||
}
|
||||
|
||||
bool CAircraftSituation::equalPbh(const CAircraftSituation &other) const
|
||||
{
|
||||
return this->getPitch() == other.getPitch() && this->getBank() == other.getBank() && this->getHeading() == other.getHeading();
|
||||
}
|
||||
|
||||
bool CAircraftSituation::equalPbhAndVector(const CAircraftSituation &other) const
|
||||
{
|
||||
return this->equalNormalVectorDouble(other.normalVectorDouble()) && this->equalPbh(other);
|
||||
}
|
||||
|
||||
void CAircraftSituation::setNull()
|
||||
{
|
||||
m_position.setNull();
|
||||
@@ -482,6 +492,21 @@ namespace BlackMisc
|
||||
return this->onGroundAsString() % QLatin1Char(' ') % this->getOnDetailsAsString();
|
||||
}
|
||||
|
||||
bool CAircraftSituation::canTransferGroundElevation(const CAircraftSituation &otherSituation, const CLength &radius) const
|
||||
{
|
||||
if (!this->hasGroundElevation()) { return false; }
|
||||
const CLength distance = this->getGroundElevationPlane().calculateGreatCircleDistance(otherSituation);
|
||||
const bool transferable = distance <= radius;
|
||||
return transferable;
|
||||
}
|
||||
|
||||
bool CAircraftSituation::transferGroundElevation(CAircraftSituation &otherSituation, const CLength &radius) const
|
||||
{
|
||||
if (!this->canTransferGroundElevation(otherSituation, radius)) { return false; }
|
||||
otherSituation.setGroundElevation(this->getGroundElevationPlane());
|
||||
return true;
|
||||
}
|
||||
|
||||
CAircraftSituation::IsOnGround CAircraftSituation::isOnGroundByElevation() const
|
||||
{
|
||||
return this->isOnGroundByElevation(m_cg);
|
||||
@@ -548,6 +573,11 @@ namespace BlackMisc
|
||||
return false;
|
||||
}
|
||||
|
||||
void CAircraftSituation::resetGroundElevation()
|
||||
{
|
||||
m_groundElevationPlane = CElevationPlane::null();
|
||||
}
|
||||
|
||||
const CLength &CAircraftSituation::getGroundElevationRadius() const
|
||||
{
|
||||
if (!this->hasGroundElevation()) { return CLength::null(); }
|
||||
|
||||
@@ -154,6 +154,14 @@ namespace BlackMisc
|
||||
//! Null situation
|
||||
virtual bool isNull() const override;
|
||||
|
||||
//! Equal pitch, bank heading
|
||||
//! \sa Geo::ICoordinateGeodetic::equalNormalVectorDouble
|
||||
bool equalPbh(const CAircraftSituation &other) const;
|
||||
|
||||
//! Equal PBH and vector
|
||||
//! \sa Geo::ICoordinateGeodetic::equalNormalVectorDouble
|
||||
bool equalPbhAndVector(const CAircraftSituation &other) const;
|
||||
|
||||
//! Set to null
|
||||
void setNull();
|
||||
|
||||
@@ -244,6 +252,12 @@ namespace BlackMisc
|
||||
//! Elevation of the ground directly beneath
|
||||
const Geo::CElevationPlane &getGroundElevationPlane() const { return m_groundElevationPlane; }
|
||||
|
||||
//! Can the elevation be transferred to another situation?
|
||||
bool canTransferGroundElevation(const CAircraftSituation &otherSituation, const PhysicalQuantities::CLength &radius = Geo::CElevationPlane::singlePointRadius()) const;
|
||||
|
||||
//! Transfer from "this" situation to \c otherSituation
|
||||
bool transferGroundElevation(CAircraftSituation &otherSituation, const PhysicalQuantities::CLength &radius = Geo::CElevationPlane::singlePointRadius()) const;
|
||||
|
||||
//! Is on ground by elevation data, requires elevation and CG
|
||||
//! @{
|
||||
IsOnGround isOnGroundByElevation() const;
|
||||
@@ -266,6 +280,9 @@ namespace BlackMisc
|
||||
//! \remark override if better
|
||||
bool setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane);
|
||||
|
||||
//! Reset ground elevation
|
||||
void resetGroundElevation();
|
||||
|
||||
//! Distance of ground elevation
|
||||
const PhysicalQuantities::CLength &getGroundElevationRadius() const;
|
||||
|
||||
@@ -345,6 +362,9 @@ namespace BlackMisc
|
||||
//! Corresponding callsign
|
||||
const CCallsign &getCallsign() const { return m_correspondingCallsign; }
|
||||
|
||||
//! Has corresponding callsign
|
||||
bool hasCallsign() const { return !this->getCallsign().isEmpty(); }
|
||||
|
||||
//! Corresponding callsign
|
||||
void setCallsign(const CCallsign &callsign);
|
||||
|
||||
@@ -408,13 +428,13 @@ namespace BlackMisc
|
||||
return isDoubleEpsilonEqual(0.0, oldGroundFactor) && isDoubleEpsilonEqual(0.0, newGroundFactor);
|
||||
}
|
||||
|
||||
//! Plane is starting
|
||||
//! Aircraft is starting
|
||||
static bool isGfStarting(double oldGroundFactor, double newGroundFactor)
|
||||
{
|
||||
return isDoubleEpsilonEqual(0.0, oldGroundFactor) && isDoubleEpsilonEqual(1.0, newGroundFactor);
|
||||
}
|
||||
|
||||
//! Plane is landing
|
||||
//! Aircraft is landing
|
||||
static bool isGfLanding(double oldGroundFactor, double newGroundFactor)
|
||||
{
|
||||
return isDoubleEpsilonEqual(1.0, oldGroundFactor) && isDoubleEpsilonEqual(0.0, newGroundFactor);
|
||||
|
||||
@@ -81,6 +81,11 @@ namespace BlackMisc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ICoordinateGeodetic::equalNormalVectorDouble(const ICoordinateGeodetic &otherCoordinate) const
|
||||
{
|
||||
return this->equalNormalVectorDouble(otherCoordinate.normalVectorDouble());
|
||||
}
|
||||
|
||||
CLength ICoordinateGeodetic::calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const
|
||||
{
|
||||
return Geo::calculateGreatCircleDistance((*this), otherCoordinate);
|
||||
|
||||
@@ -83,9 +83,12 @@ namespace BlackMisc
|
||||
//! Normal vector with double precision
|
||||
virtual std::array<double, 3> normalVectorDouble() const = 0;
|
||||
|
||||
//! Is equal, epsilon considered
|
||||
//! Is equal, epsilon considered?
|
||||
bool equalNormalVectorDouble(const std::array<double, 3> &otherVector) const;
|
||||
|
||||
//! Is equal, epsilon considered?
|
||||
bool equalNormalVectorDouble(const ICoordinateGeodetic &otherCoordinate) const;
|
||||
|
||||
//! Latitude as string
|
||||
QString latitudeAsString() const { return this->latitude().toQString(true); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user