Ref T243, Ref T273, added info about elevation (where did we obtain it?)

This commit is contained in:
Klaus Basan
2018-06-03 23:40:03 +02:00
parent f3a7eef458
commit 6ed541b6ab
22 changed files with 165 additions and 63 deletions

View File

@@ -932,12 +932,12 @@ namespace BlackCore
BLACK_VERIFY_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign"); BLACK_VERIFY_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign");
if (callsign.isEmpty()) { return; } if (callsign.isEmpty()) { return; }
CAircraftSituation correctedSituation(situation); CAircraftSituation correctedSituation(this->testAddAltitudeOffsetToSituation(situation));
if (!correctedSituation.hasGroundElevation() && !correctedSituation.canLikelySkipNearGroundInterpolation()) if (!correctedSituation.hasGroundElevation() && !correctedSituation.canLikelySkipNearGroundInterpolation())
{ {
const CLength distance(correctedSituation.getDistancePerTime(1000)); const CLength distance(correctedSituation.getDistancePerTime(250));
const CElevationPlane ep = this->findClosestElevationWithinRangeOrRequest(correctedSituation, distance, callsign); const CElevationPlane ep = this->findClosestElevationWithinRangeOrRequest(correctedSituation, distance, callsign);
correctedSituation.setGroundElevation(ep); correctedSituation.setGroundElevation(ep, CAircraftSituation::FromCache);
} }
// do we already have ground details? // do we already have ground details?
@@ -957,7 +957,7 @@ namespace BlackCore
} }
this->guessOnGroundAndUpdateModelCG(correctedSituation); // does nothing if situation is not appropriate for guessing this->guessOnGroundAndUpdateModelCG(correctedSituation); // does nothing if situation is not appropriate for guessing
CRemoteAircraftProvider::storeAircraftSituation(correctedSituation); CRemoteAircraftProvider::storeAircraftSituation(correctedSituation, false); // we already added offset if any
} }
bool CAirspaceMonitor::guessOnGroundAndUpdateModelCG(CAircraftSituation &situation) bool CAirspaceMonitor::guessOnGroundAndUpdateModelCG(CAircraftSituation &situation)

View File

@@ -384,8 +384,8 @@ namespace BlackCore
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CCallsignSet callsigns; CCallsignSet callsigns;
callsigns.push_back(callsign); callsigns.push_back(callsign);
CUserList users = this->getUsersForCallsigns(callsigns); const CUserList users = this->getUsersForCallsigns(callsigns);
if (users.size() < 1) return CUser(); if (users.size() < 1) { return CUser(); }
return users[0]; return users[0];
} }
@@ -786,9 +786,9 @@ namespace BlackCore
return c; return c;
} }
int CContextNetwork::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation) int CContextNetwork::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation, CAircraftSituation::GndElevationInfo info)
{ {
return m_airspace->updateAircraftGroundElevation(callsign, elevation); return m_airspace->updateAircraftGroundElevation(callsign, elevation, info);
} }
void CContextNetwork::updateMarkAllAsNotRendered() void CContextNetwork::updateMarkAllAsNotRendered()

View File

@@ -105,7 +105,7 @@ namespace BlackCore
std::function<void(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &)> aircraftSnapshotSlot std::function<void(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &)> aircraftSnapshotSlot
) override; ) override;
virtual bool updateAircraftRendered(const BlackMisc::Aviation::CCallsign &callsign, bool rendered) override; virtual bool updateAircraftRendered(const BlackMisc::Aviation::CCallsign &callsign, bool rendered) override;
virtual int updateAircraftGroundElevation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Geo::CElevationPlane &elevation) override; virtual int updateAircraftGroundElevation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Geo::CElevationPlane &elevation, BlackMisc::Aviation::CAircraftSituation::GndElevationInfo info) override;
virtual void updateMarkAllAsNotRendered() override; virtual void updateMarkAllAsNotRendered() override;
virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const override; virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const override;
//! @} //! @}

View File

@@ -56,7 +56,7 @@ namespace BlackCore
// CLogMessage(this).info("'%1' Received req. elevation") << callsign.asString(); // CLogMessage(this).info("'%1' Received req. elevation") << callsign.asString();
this->rememberGroundElevation(plane); this->rememberGroundElevation(plane);
const int updated = this->updateAircraftGroundElevation(callsign, plane); const int updated = this->updateAircraftGroundElevation(callsign, plane, CAircraftSituation::FromProvider);
if (updated < 1) { return; } if (updated < 1) { return; }
emit this->receivedRequestedElevation(plane, callsign); emit this->receivedRequestedElevation(plane, callsign);
} }

View File

@@ -37,7 +37,8 @@ namespace BlackGui
m_columns.addColumn(CColumn("gs.", CAircraftSituation::IndexGroundSpeed, new CSpeedKtsFormatter())); m_columns.addColumn(CColumn("gs.", CAircraftSituation::IndexGroundSpeed, new CSpeedKtsFormatter()));
m_columns.addColumn(CColumn("on gnd.", "is on gnd.", CAircraftSituation::IndexIsOnGround, new CBoolIconFormatter("yes", "no"), true)); m_columns.addColumn(CColumn("on gnd.", "is on gnd.", CAircraftSituation::IndexIsOnGround, new CBoolIconFormatter("yes", "no"), true));
m_columns.addColumn(CColumn::standardString("reliability", CAircraftSituation::IndexOnGroundReliabilityString)); m_columns.addColumn(CColumn::standardString("reliability", CAircraftSituation::IndexOnGroundReliabilityString));
m_columns.addColumn(CColumn::standardString("gnd.elv.", { CAircraftSituation::IndexGroundElevationPlane, CElevationPlane::IndexGeodeticHeightAsString })); m_columns.addColumn(CColumn::standardString("gnd.elv.", CAircraftSituation::IndexGroundElevationPlusInfo));
m_columns.addColumn(CColumn::standardString("gnd.elv.alt.", { CAircraftSituation::IndexGroundElevationPlane, CElevationPlane::IndexGeodeticHeightAsString }));
m_columns.addColumn(CColumn("elv.radius", { CAircraftSituation::IndexGroundElevationPlane, CElevationPlane::IndexRadius }, new CPhysiqalQuantiyFormatter<CLengthUnit, CLength>(CLengthUnit::m(), 1))); m_columns.addColumn(CColumn("elv.radius", { CAircraftSituation::IndexGroundElevationPlane, CElevationPlane::IndexRadius }, new CPhysiqalQuantiyFormatter<CLengthUnit, CLength>(CLengthUnit::m(), 1)));
// default sort order // default sort order

View File

@@ -64,12 +64,13 @@ namespace BlackMisc
QStringLiteral(" | cg: ") % QStringLiteral(" | cg: ") %
(m_cg.isNull() ? QStringLiteral("null") : m_cg.valueRoundedWithUnit(CLengthUnit::m(), 1) % QStringLiteral(" ") % m_cg.valueRoundedWithUnit(CLengthUnit::ft(), 1)) % (m_cg.isNull() ? QStringLiteral("null") : m_cg.valueRoundedWithUnit(CLengthUnit::m(), 1) % QStringLiteral(" ") % m_cg.valueRoundedWithUnit(CLengthUnit::ft(), 1)) %
QStringLiteral(" | factor [0..1]: ") % QString::number(m_onGroundFactor, 'f', 2) % QStringLiteral(" | factor [0..1]: ") % QString::number(m_onGroundFactor, 'f', 2) %
QStringLiteral(" | skip ng: ") % boolToYesNo(this->canLikelySkipNearGroundInterpolation()) %
QStringLiteral(" | bank: ") % m_bank.toQString(i18n) % QStringLiteral(" | bank: ") % m_bank.toQString(i18n) %
QStringLiteral(" | pitch: ") % m_pitch.toQString(i18n) % QStringLiteral(" | pitch: ") % m_pitch.toQString(i18n) %
QStringLiteral(" | heading: ") % m_heading.toQString(i18n) % QStringLiteral(" | heading: ") % m_heading.toQString(i18n) %
QStringLiteral(" | gs: ") % m_groundSpeed.valueRoundedWithUnit(CSpeedUnit::kts(), 1, true) % QStringLiteral(" | gs: ") % m_groundSpeed.valueRoundedWithUnit(CSpeedUnit::kts(), 1, true) %
QStringLiteral(" ") % m_groundSpeed.valueRoundedWithUnit(CSpeedUnit::m_s(), 1, true) % QStringLiteral(" ") % m_groundSpeed.valueRoundedWithUnit(CSpeedUnit::m_s(), 1, true) %
QStringLiteral(" | elevation: ") % (m_groundElevationPlane.toQString(i18n)); QStringLiteral(" | elevation [") % this->getGroundElevationInfoAsString() % QStringLiteral("]: ") % (m_groundElevationPlane.toQString(i18n));
} }
const QString &CAircraftSituation::isOnGroundToString(CAircraftSituation::IsOnGround onGround) const QString &CAircraftSituation::isOnGroundToString(CAircraftSituation::IsOnGround onGround)
@@ -134,6 +135,29 @@ namespace BlackMisc
return unknown; return unknown;
} }
const QString &CAircraftSituation::gndElevationInfoToString(GndElevationInfo details)
{
static const QString no("no details");
static const QString unknown("unknown");
static const QString transferred("transferred");
static const QString provider("provider");
static const QString change("situation change");
static const QString cache("cached");
static const QString test("test");
switch (details)
{
case NoElevationInfo: return no;
case TransferredElevation: return transferred;
case FromProvider: return provider;
case SituationChange: return change;
case FromCache: return cache;
case Test: return test;
default: break;
}
return unknown;
}
const CLength &CAircraftSituation::deltaNearGround() const CLength &CAircraftSituation::deltaNearGround()
{ {
static const CLength small(0.5, CLengthUnit::m()); static const CLength small(0.5, CLengthUnit::m());
@@ -176,6 +200,10 @@ namespace BlackMisc
case IndexIsOnGroundString: return CVariant::fromValue(this->onGroundAsString()); case IndexIsOnGroundString: return CVariant::fromValue(this->onGroundAsString());
case IndexOnGroundReliability: return CVariant::fromValue(m_onGroundDetails); case IndexOnGroundReliability: return CVariant::fromValue(m_onGroundDetails);
case IndexOnGroundReliabilityString: return CVariant::fromValue(this->getOnDetailsAsString()); case IndexOnGroundReliabilityString: return CVariant::fromValue(this->getOnDetailsAsString());
case IndexGroundElevationInfo: return CVariant::fromValue(this->getGroundElevationInfo());
case IndexGroundElevationInfoString: return CVariant::fromValue(this->getGroundElevationInfoAsString());
case IndexGroundElevationPlusInfo: return CVariant::fromValue(this->getGroundElevationAndInfo());
case IndexCanLikelySkipNearGroundInterpolation: return CVariant::fromValue(this->canLikelySkipNearGroundInterpolation());
default: return CValueObject::propertyByIndex(index); default: return CValueObject::propertyByIndex(index);
} }
} }
@@ -197,6 +225,9 @@ namespace BlackMisc
case IndexCallsign: m_correspondingCallsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break; case IndexCallsign: m_correspondingCallsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexIsOnGround: m_onGround = variant.toInt(); break; case IndexIsOnGround: m_onGround = variant.toInt(); break;
case IndexOnGroundReliability: m_onGroundDetails = variant.toInt(); break; case IndexOnGroundReliability: m_onGroundDetails = variant.toInt(); break;
case IndexGroundElevationInfo: m_elvInfo = variant.toInt(); break;
case IndexGroundElevationPlusInfo: break;
case IndexCanLikelySkipNearGroundInterpolation: break;
default: CValueObject::setPropertyByIndex(index, variant); break; default: CValueObject::setPropertyByIndex(index, variant); break;
} }
} }
@@ -214,7 +245,13 @@ namespace BlackMisc
case IndexBank: return m_bank.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getBank()); case IndexBank: return m_bank.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getBank());
case IndexCG: return m_cg.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCG()); case IndexCG: return m_cg.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCG());
case IndexGroundSpeed: return m_groundSpeed.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundSpeed()); case IndexGroundSpeed: return m_groundSpeed.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundSpeed());
case IndexGroundElevationPlane: return m_groundElevationPlane.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundElevationPlane()); case IndexGroundElevationPlane:
case IndexGroundElevationPlusInfo:
{
const int c = m_groundElevationPlane.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundElevationPlane());
if (c != 0 || i == IndexGroundElevationPlane) { return c; }
return Compare::compare(this->getGroundElevationInfo(), compareValue.getGroundElevationInfo());
}
case IndexCallsign: return m_correspondingCallsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); case IndexCallsign: return m_correspondingCallsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
case IndexIsOnGround: case IndexIsOnGround:
case IndexIsOnGroundString: case IndexIsOnGroundString:
@@ -222,6 +259,10 @@ namespace BlackMisc
case IndexOnGroundReliability: case IndexOnGroundReliability:
case IndexOnGroundReliabilityString: case IndexOnGroundReliabilityString:
return Compare::compare(m_onGroundDetails, compareValue.m_onGroundDetails); return Compare::compare(m_onGroundDetails, compareValue.m_onGroundDetails);
case IndexGroundElevationInfo:
case IndexGroundElevationInfoString:
return Compare::compare(this->getGroundElevationInfo(), compareValue.getGroundElevationInfo());
case IndexCanLikelySkipNearGroundInterpolation: return Compare::compare(this->canLikelySkipNearGroundInterpolation(), compareValue.canLikelySkipNearGroundInterpolation());
default: break; default: break;
} }
const QString assertMsg("No comparison for index " + index.toQString()); const QString assertMsg("No comparison for index " + index.toQString());
@@ -254,6 +295,7 @@ namespace BlackMisc
m_groundElevationPlane.setNull(); m_groundElevationPlane.setNull();
m_groundSpeed.setNull(); m_groundSpeed.setNull();
m_onGroundDetails = CAircraftSituation::NotSetGroundDetails; m_onGroundDetails = CAircraftSituation::NotSetGroundDetails;
m_elvInfo = NoElevationInfo;
} }
bool CAircraftSituation::isOnGroundFromParts() const bool CAircraftSituation::isOnGroundFromParts() const
@@ -322,7 +364,6 @@ namespace BlackMisc
return !this->hasInboundGroundDetails(); return !this->hasInboundGroundDetails();
} }
bool CAircraftSituation::guessOnGround(const CAircraftSituationChange &change, const CAircraftModel &model) bool CAircraftSituation::guessOnGround(const CAircraftSituationChange &change, const CAircraftModel &model)
{ {
Q_UNUSED(change); Q_UNUSED(change);
@@ -492,18 +533,33 @@ namespace BlackMisc
return this->onGroundAsString() % QLatin1Char(' ') % this->getOnDetailsAsString(); return this->onGroundAsString() % QLatin1Char(' ') % this->getOnDetailsAsString();
} }
CAircraftSituation::GndElevationInfo CAircraftSituation::getGroundElevationInfo() const
{
if (!this->hasGroundElevation()) { return NoElevationInfo; }
return static_cast<GndElevationInfo>(m_elvInfo);
}
QString CAircraftSituation::getGroundElevationAndInfo() const
{
static const QString n("null");
if (m_groundElevationPlane.isNull()) { return n; };
return m_groundElevationPlane.getAltitude().toQString(true) %
QStringLiteral(" [") % this->getGroundElevationInfoAsString() % QStringLiteral("]");
}
bool CAircraftSituation::canTransferGroundElevation(const CAircraftSituation &otherSituation, const CLength &radius) const bool CAircraftSituation::canTransferGroundElevation(const CAircraftSituation &otherSituation, const CLength &radius) const
{ {
if (!this->hasGroundElevation()) { return false; } if (!this->hasGroundElevation()) { return false; }
const CLength distance = this->getGroundElevationPlane().calculateGreatCircleDistance(otherSituation); const CLength distance = this->getGroundElevationPlane().calculateGreatCircleDistance(otherSituation);
const bool transferable = distance <= radius; const bool transferable = (distance <= radius);
return transferable; return transferable;
} }
bool CAircraftSituation::transferGroundElevation(CAircraftSituation &otherSituation, const CLength &radius) const bool CAircraftSituation::transferGroundElevation(CAircraftSituation &otherSituation, const CLength &radius) const
{ {
if (!this->canTransferGroundElevation(otherSituation, radius)) { return false; } if (!this->canTransferGroundElevation(otherSituation, radius)) { return false; }
otherSituation.setGroundElevation(this->getGroundElevationPlane()); otherSituation.setGroundElevation(this->getGroundElevationPlane(), TransferredElevation);
return true; return true;
} }
@@ -538,27 +594,37 @@ namespace BlackMisc
return this->getOnGroundDetails() == CAircraftSituation::InFromParts || this->getOnGroundDetails() == CAircraftSituation::InFromNetwork; return this->getOnGroundDetails() == CAircraftSituation::InFromParts || this->getOnGroundDetails() == CAircraftSituation::InFromNetwork;
} }
void CAircraftSituation::setGroundElevation(const CAltitude &altitude) void CAircraftSituation::setGroundElevation(const CAltitude &altitude, GndElevationInfo info)
{ {
if (altitude.isNull()) if (altitude.isNull())
{ {
m_groundElevationPlane = CElevationPlane::null(); m_groundElevationPlane = CElevationPlane::null();
this->setGroundElevationInfo(NoElevationInfo);
} }
else else
{ {
m_groundElevationPlane = CElevationPlane(*this); m_groundElevationPlane = CElevationPlane(*this);
m_groundElevationPlane.setSinglePointRadius(); m_groundElevationPlane.setSinglePointRadius();
m_groundElevationPlane.setGeodeticHeight(altitude.switchedUnit(this->getAltitudeUnit())); m_groundElevationPlane.setGeodeticHeight(altitude.switchedUnit(this->getAltitudeUnit()));
this->setGroundElevationInfo(info);
} }
} }
void CAircraftSituation::setGroundElevation(const CElevationPlane &elevationPlane) void CAircraftSituation::setGroundElevation(const CElevationPlane &elevationPlane, GndElevationInfo info)
{ {
m_groundElevationPlane = elevationPlane; m_groundElevationPlane = elevationPlane;
if (elevationPlane.isNull())
{
this->setGroundElevationInfo(NoElevationInfo);
}
else
{
this->setGroundElevationInfo(info);
m_groundElevationPlane.switchUnit(this->getAltitudeOrDefaultUnit()); // we use ft as internal unit, no "must" but simplification m_groundElevationPlane.switchUnit(this->getAltitudeOrDefaultUnit()); // we use ft as internal unit, no "must" but simplification
} }
}
bool CAircraftSituation::setGroundElevationChecked(const CElevationPlane &elevationPlane) bool CAircraftSituation::setGroundElevationChecked(const CElevationPlane &elevationPlane, GndElevationInfo info)
{ {
if (elevationPlane.isNull()) { return false; } if (elevationPlane.isNull()) { return false; }
const CLength distance = this->calculateGreatCircleDistance(elevationPlane); const CLength distance = this->calculateGreatCircleDistance(elevationPlane);
@@ -566,7 +632,7 @@ namespace BlackMisc
if (m_groundElevationPlane.isNull() || distance < m_groundElevationPlane.getRadius()) if (m_groundElevationPlane.isNull() || distance < m_groundElevationPlane.getRadius())
{ {
// better values // better values
this->setGroundElevation(elevationPlane); this->setGroundElevation(elevationPlane, info);
m_groundElevationPlane.setRadius(distance); m_groundElevationPlane.setRadius(distance);
return true; return true;
} }
@@ -576,6 +642,7 @@ namespace BlackMisc
void CAircraftSituation::resetGroundElevation() void CAircraftSituation::resetGroundElevation()
{ {
m_groundElevationPlane = CElevationPlane::null(); m_groundElevationPlane = CElevationPlane::null();
this->setGroundElevationInfo(NoElevationInfo);
} }
const CLength &CAircraftSituation::getGroundElevationRadius() const const CLength &CAircraftSituation::getGroundElevationRadius() const

View File

@@ -67,8 +67,12 @@ namespace BlackMisc
IndexPitch, IndexPitch,
IndexGroundSpeed, IndexGroundSpeed,
IndexGroundElevationPlane, IndexGroundElevationPlane,
IndexGroundElevationInfo,
IndexGroundElevationInfoString,
IndexGroundElevationPlusInfo,
IndexCallsign, IndexCallsign,
IndexCG IndexCG,
IndexCanLikelySkipNearGroundInterpolation
}; };
//! Is on ground? //! Is on ground?
@@ -96,17 +100,28 @@ namespace BlackMisc
OutOnGroundOwnAircraft //!< sending on ground OutOnGroundOwnAircraft //!< sending on ground
}; };
//! How was altitude corrected //! How was altitude corrected?
enum AltitudeCorrection enum AltitudeCorrection
{ {
NoCorrection, NoCorrection,
Underflow, Underflow, //!< aircraft too low
DraggedToGround, DraggedToGround, //!< other scenery too high, but on ground
AGL, AGL,
NoElevation, NoElevation, //!< no correction as there is no elevation
UnknownCorrection UnknownCorrection
}; };
//! Where did we get elevation from?
enum GndElevationInfo
{
NoElevationInfo,
TransferredElevation, //!< transferred from nearby situation
FromProvider, //!< from BlackMisc::Simulation::ISimulationEnvironmentProvider
FromCache, //!< from cache
SituationChange, //!< from BlackMisc::Aviation::CAircraftSituationChange
Test //!< unit test
};
//! Default constructor. //! Default constructor.
CAircraftSituation(); CAircraftSituation();
@@ -252,6 +267,18 @@ namespace BlackMisc
//! Elevation of the ground directly beneath //! Elevation of the ground directly beneath
const Geo::CElevationPlane &getGroundElevationPlane() const { return m_groundElevationPlane; } const Geo::CElevationPlane &getGroundElevationPlane() const { return m_groundElevationPlane; }
//! How did we get gnd.elevation?
GndElevationInfo getGroundElevationInfo() const;
//! How did we get gnd.elevation?
const QString &getGroundElevationInfoAsString() const { return gndElevationInfoToString(this->getGroundElevationInfo()); }
//! Ground elevation plus info
QString getGroundElevationAndInfo() const;
//! How we did get gnd.elevation
void setGroundElevationInfo(GndElevationInfo details) { m_elvInfo = static_cast<int>(details); }
//! Can the elevation be transferred to another situation? //! Can the elevation be transferred to another situation?
bool canTransferGroundElevation(const CAircraftSituation &otherSituation, const PhysicalQuantities::CLength &radius = Geo::CElevationPlane::singlePointRadius()) const; bool canTransferGroundElevation(const CAircraftSituation &otherSituation, const PhysicalQuantities::CLength &radius = Geo::CElevationPlane::singlePointRadius()) const;
@@ -271,14 +298,14 @@ namespace BlackMisc
bool hasInboundGroundDetails() const; bool hasInboundGroundDetails() const;
//! Elevation of the ground directly beneath at the given situation //! Elevation of the ground directly beneath at the given situation
void setGroundElevation(const Aviation::CAltitude &altitude); void setGroundElevation(const Aviation::CAltitude &altitude, GndElevationInfo info);
//! Elevation of the ground directly beneath //! Elevation of the ground directly beneath
void setGroundElevation(const Geo::CElevationPlane &elevationPlane); void setGroundElevation(const Geo::CElevationPlane &elevationPlane, GndElevationInfo info);
//! Set elevation of the ground directly beneath, but checked //! Set elevation of the ground directly beneath, but checked
//! \remark override if better //! \remark override if better
bool setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane); bool setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane, GndElevationInfo info);
//! Reset ground elevation //! Reset ground elevation
void resetGroundElevation(); void resetGroundElevation();
@@ -406,6 +433,9 @@ namespace BlackMisc
//! Enum to string //! Enum to string
static const QString &altitudeCorrectionToString(AltitudeCorrection correction); static const QString &altitudeCorrectionToString(AltitudeCorrection correction);
//! Enum to string
static const QString &gndElevationInfoToString(GndElevationInfo details);
//! Delta distance, near to ground //! Delta distance, near to ground
static const PhysicalQuantities::CLength &deltaNearGround(); static const PhysicalQuantities::CLength &deltaNearGround();
@@ -454,6 +484,7 @@ namespace BlackMisc
bool m_isInterim = false; bool m_isInterim = false;
int m_onGround = static_cast<int>(CAircraftSituation::OnGroundSituationUnknown); int m_onGround = static_cast<int>(CAircraftSituation::OnGroundSituationUnknown);
int m_onGroundDetails = static_cast<int>(CAircraftSituation::NotSetGroundDetails); int m_onGroundDetails = static_cast<int>(CAircraftSituation::NotSetGroundDetails);
int m_elvInfo = static_cast<int>(CAircraftSituation::NoElevationInfo); //!< where did we gnd.elevation from?
double m_onGroundFactor = -1; //!< interpolated ground flag, 1..on ground, 0..not on ground, -1 no info double m_onGroundFactor = -1; //!< interpolated ground flag, 1..on ground, 0..not on ground, -1 no info
QString m_onGroundGuessingDetails; //!< only for debugging, not transferred via DBus etc. QString m_onGroundGuessingDetails; //!< only for debugging, not transferred via DBus etc.
@@ -476,6 +507,7 @@ namespace BlackMisc
BLACK_METAMEMBER(groundElevationPlane), BLACK_METAMEMBER(groundElevationPlane),
BLACK_METAMEMBER(onGround), BLACK_METAMEMBER(onGround),
BLACK_METAMEMBER(onGroundDetails), BLACK_METAMEMBER(onGroundDetails),
BLACK_METAMEMBER(elvInfo),
BLACK_METAMEMBER(onGroundFactor), BLACK_METAMEMBER(onGroundFactor),
BLACK_METAMEMBER(timestampMSecsSinceEpoch), BLACK_METAMEMBER(timestampMSecsSinceEpoch),
BLACK_METAMEMBER(timeOffsetMs), BLACK_METAMEMBER(timeOffsetMs),
@@ -489,5 +521,6 @@ Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation::IsOnGround) Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation::IsOnGround)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation::OnGroundDetails) Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation::OnGroundDetails)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation::AltitudeCorrection) Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation::AltitudeCorrection)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation::GndElevationInfo)
#endif // guard #endif // guard

View File

@@ -38,20 +38,20 @@ namespace BlackMisc
CSequence<CAircraftSituation>(il) CSequence<CAircraftSituation>(il)
{ } { }
int CAircraftSituationList::setGroundElevationChecked(const CElevationPlane &elevationPlane, qint64 newerThanAdjustedMs) int CAircraftSituationList::setGroundElevationChecked(const CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, qint64 newerThanAdjustedMs)
{ {
if (elevationPlane.isNull()) { return 0; } if (elevationPlane.isNull()) { return 0; }
int c = 0; int c = 0;
for (CAircraftSituation &s : *this) for (CAircraftSituation &s : *this)
{ {
if (newerThanAdjustedMs >= 0 && s.getAdjustedMSecsSinceEpoch() <= newerThanAdjustedMs) { continue; } if (newerThanAdjustedMs >= 0 && s.getAdjustedMSecsSinceEpoch() <= newerThanAdjustedMs) { continue; }
const bool set = s.setGroundElevationChecked(elevationPlane); const bool set = s.setGroundElevationChecked(elevationPlane, info);
if (set) { c++; } if (set) { c++; }
} }
return c; return c;
} }
int CAircraftSituationList::setGroundElevationCheckedAndGuessGround(const CElevationPlane &elevationPlane, const CAircraftModel &model) int CAircraftSituationList::setGroundElevationCheckedAndGuessGround(const CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, const CAircraftModel &model)
{ {
if (elevationPlane.isNull()) { return 0; } if (elevationPlane.isNull()) { return 0; }
if (this->isEmpty()) { return 0; } if (this->isEmpty()) { return 0; }
@@ -67,7 +67,7 @@ namespace BlackMisc
for (CAircraftSituation &s : *this) for (CAircraftSituation &s : *this)
{ {
const bool set = s.setGroundElevationChecked(elevationPlane); const bool set = s.setGroundElevationChecked(elevationPlane, info);
if (set) if (set)
{ {
// change is only valid for the latest situation // change is only valid for the latest situation

View File

@@ -55,11 +55,11 @@ namespace BlackMisc
CAircraftSituationList(std::initializer_list<CAircraftSituation> il); CAircraftSituationList(std::initializer_list<CAircraftSituation> il);
//! Set ground elevation from elevation plane //! Set ground elevation from elevation plane
int setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane, qint64 newerThanAdjustedMs = -1); int setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, qint64 newerThanAdjustedMs = -1);
//! Set ground elevation from elevation plane and guess ground //! Set ground elevation from elevation plane and guess ground
//! \note requires a sorted list latest first //! \note requires a sorted list latest first
int setGroundElevationCheckedAndGuessGround(const Geo::CElevationPlane &elevationPlane, const Simulation::CAircraftModel &model); int setGroundElevationCheckedAndGuessGround(const Geo::CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, const Simulation::CAircraftModel &model);
//! Adjust flag from parts by using CAircraftSituation::adjustGroundFlag //! Adjust flag from parts by using CAircraftSituation::adjustGroundFlag
int adjustGroundFlag(const CAircraftParts &parts, double timeDeviationFactor = 0.1); int adjustGroundFlag(const CAircraftParts &parts, double timeDeviationFactor = 0.1);

View File

@@ -28,6 +28,7 @@ namespace BlackMisc
qRegisterMetaType<CAircraftSituation::IsOnGround>(); qRegisterMetaType<CAircraftSituation::IsOnGround>();
qRegisterMetaType<CAircraftSituation::OnGroundDetails>(); qRegisterMetaType<CAircraftSituation::OnGroundDetails>();
qRegisterMetaType<CAircraftSituation::AltitudeCorrection>(); qRegisterMetaType<CAircraftSituation::AltitudeCorrection>();
qRegisterMetaType<CAircraftSituation::GndElevationInfo>();
CAircraftSituationChange::registerMetadata(); CAircraftSituationChange::registerMetadata();
qRegisterMetaType<CAircraftSituationChange::GuessedSceneryDeviation>(); qRegisterMetaType<CAircraftSituationChange::GuessedSceneryDeviation>();
CAircraftSituationList::registerMetadata(); CAircraftSituationList::registerMetadata();

View File

@@ -158,12 +158,12 @@ namespace BlackMisc
if (!oldSituation.canLikelySkipNearGroundInterpolation() && !oldSituation.hasGroundElevation()) if (!oldSituation.canLikelySkipNearGroundInterpolation() && !oldSituation.hasGroundElevation())
{ {
const CElevationPlane planeOld = this->findClosestElevationWithinRange(oldSituation, CElevationPlane::singlePointRadius()); const CElevationPlane planeOld = this->findClosestElevationWithinRange(oldSituation, CElevationPlane::singlePointRadius());
oldSituation.setGroundElevationChecked(planeOld); oldSituation.setGroundElevationChecked(planeOld, CAircraftSituation::FromCache);
} }
if (!newSituation.canLikelySkipNearGroundInterpolation() && !newSituation.hasGroundElevation()) if (!newSituation.canLikelySkipNearGroundInterpolation() && !newSituation.hasGroundElevation())
{ {
const CElevationPlane planeNew = this->findClosestElevationWithinRange(newSituation, CElevationPlane::singlePointRadius()); const CElevationPlane planeNew = this->findClosestElevationWithinRange(newSituation, CElevationPlane::singlePointRadius());
newSituation.setGroundElevationChecked(planeNew); newSituation.setGroundElevationChecked(planeNew, CAircraftSituation::FromCache);
} }
} // modified situations } // modified situations

View File

@@ -238,7 +238,7 @@ namespace BlackMisc
{ {
if (m_s[i].hasGroundElevation()) { continue; } // do not override existing values if (m_s[i].hasGroundElevation()) { continue; } // do not override existing values
const CElevationPlane plane = this->findClosestElevationWithinRange(m_s[i], CElevationPlane::singlePointRadius()); const CElevationPlane plane = this->findClosestElevationWithinRange(m_s[i], CElevationPlane::singlePointRadius());
const bool u = m_s[i].setGroundElevationChecked(plane); const bool u = m_s[i].setGroundElevationChecked(plane, CAircraftSituation::FromCache);
updated |= u; updated |= u;
} }
return updated; return updated;

View File

@@ -190,7 +190,7 @@ namespace BlackMisc
return c; return c;
} }
void CRemoteAircraftProvider::storeAircraftSituation(const CAircraftSituation &situation) void CRemoteAircraftProvider::storeAircraftSituation(const CAircraftSituation &situation, bool allowTestOffset)
{ {
const CCallsign cs = situation.getCallsign(); const CCallsign cs = situation.getCallsign();
if (cs.isEmpty()) { return; } if (cs.isEmpty()) { return; }
@@ -202,7 +202,7 @@ namespace BlackMisc
} }
// add offset (for testing only) // add offset (for testing only)
CAircraftSituation situationCorrected(this->testAddAltitudeOffsetToSituation(situation)); CAircraftSituation situationCorrected(allowTestOffset ? this->testAddAltitudeOffsetToSituation(situation) : situation);
// list from new to old // list from new to old
const qint64 ts = QDateTime::currentMSecsSinceEpoch(); const qint64 ts = QDateTime::currentMSecsSinceEpoch();
@@ -385,7 +385,7 @@ namespace BlackMisc
return c > 0; return c > 0;
} }
int CRemoteAircraftProvider::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation) int CRemoteAircraftProvider::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation, CAircraftSituation::GndElevationInfo info)
{ {
if (!this->isAircraftInRange(callsign)) { return 0; } if (!this->isAircraftInRange(callsign)) { return 0; }
@@ -396,14 +396,14 @@ namespace BlackMisc
{ {
QWriteLocker l(&m_lockSituations); QWriteLocker l(&m_lockSituations);
CAircraftSituationList &situations = m_situationsByCallsign[callsign]; CAircraftSituationList &situations = m_situationsByCallsign[callsign];
updated = situations.setGroundElevationCheckedAndGuessGround(elevation, model); updated = situations.setGroundElevationCheckedAndGuessGround(elevation, info, model);
if (updated < 1) { return 0; } if (updated < 1) { return 0; }
m_situationsLastModified[callsign] = ts; m_situationsLastModified[callsign] = ts;
} }
// aircraft updates // aircraft updates
QWriteLocker l(&m_lockAircraft); QWriteLocker l(&m_lockAircraft);
const int c = m_aircraftInRange.setGroundElevationChecked(callsign, elevation); const int c = m_aircraftInRange.setGroundElevationChecked(callsign, elevation, info);
Q_UNUSED(c); // just for info, expect 1 Q_UNUSED(c); // just for info, expect 1
return updated; // updated situations return updated; // updated situations
@@ -716,10 +716,10 @@ namespace BlackMisc
return this->provider()->updateAircraftRendered(callsign, rendered); return this->provider()->updateAircraftRendered(callsign, rendered);
} }
int CRemoteAircraftAware::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation) int CRemoteAircraftAware::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation, CAircraftSituation::GndElevationInfo info)
{ {
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available"); Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
return this->provider()->updateAircraftGroundElevation(callsign, elevation); return this->provider()->updateAircraftGroundElevation(callsign, elevation, info);
} }
void CRemoteAircraftAware::updateMarkAllAsNotRendered() void CRemoteAircraftAware::updateMarkAllAsNotRendered()

View File

@@ -152,7 +152,7 @@ namespace BlackMisc
//! Update the ground elevation //! Update the ground elevation
//! \threadsafe //! \threadsafe
virtual int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation) = 0; virtual int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation, Aviation::CAircraftSituation::GndElevationInfo info) = 0;
//! Update the CG //! Update the CG
//! \threadsafe //! \threadsafe
@@ -261,7 +261,7 @@ namespace BlackMisc
virtual bool updateAircraftNetworkModel(const Aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator) override; virtual bool updateAircraftNetworkModel(const Aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator) override;
virtual bool updateFastPositionEnabled(const Aviation::CCallsign &callsign, bool enableFastPositonUpdates) override; virtual bool updateFastPositionEnabled(const Aviation::CCallsign &callsign, bool enableFastPositonUpdates) override;
virtual bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered) override; virtual bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered) override;
virtual int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation) override; virtual int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation, Aviation::CAircraftSituation::GndElevationInfo info) override;
virtual bool updateCG(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg) override; virtual bool updateCG(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg) override;
virtual void updateMarkAllAsNotRendered() override; virtual void updateMarkAllAsNotRendered() override;
virtual CStatusMessageList getAircraftPartsHistory(const Aviation::CCallsign &callsign) const override; virtual CStatusMessageList getAircraftPartsHistory(const Aviation::CCallsign &callsign) const override;
@@ -364,7 +364,7 @@ namespace BlackMisc
//! Store an aircraft situation //! Store an aircraft situation
//! \remark latest situations are kept first //! \remark latest situations are kept first
//! \threadsafe //! \threadsafe
void storeAircraftSituation(const Aviation::CAircraftSituation &situation); void storeAircraftSituation(const Aviation::CAircraftSituation &situation, bool allowTestOffset = true);
//! Store an aircraft part //! Store an aircraft part
//! \remark latest parts are kept first //! \remark latest parts are kept first
@@ -468,7 +468,7 @@ namespace BlackMisc
bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered); bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered);
//! \copydoc IRemoteAircraftProvider::updateAircraftGroundElevation //! \copydoc IRemoteAircraftProvider::updateAircraftGroundElevation
int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation); int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation, Aviation::CAircraftSituation::GndElevationInfo info);
//! \copydoc IRemoteAircraftProvider::updateMarkAllAsNotRendered //! \copydoc IRemoteAircraftProvider::updateMarkAllAsNotRendered
void updateMarkAllAsNotRendered(); void updateMarkAllAsNotRendered();

View File

@@ -28,13 +28,13 @@ namespace BlackMisc
{ {
CSimulatedAircraft::CSimulatedAircraft() CSimulatedAircraft::CSimulatedAircraft()
{ {
init(); this->init();
} }
CSimulatedAircraft::CSimulatedAircraft(const CAircraftModel &model) : m_models({model, model}) CSimulatedAircraft::CSimulatedAircraft(const CAircraftModel &model) : m_models({model, model})
{ {
this->setCallsign(model.getCallsign()); this->setCallsign(model.getCallsign());
init(); this->init();
} }
CSimulatedAircraft::CSimulatedAircraft(const CCallsign &callsign, const CUser &user, const CAircraftSituation &situation) : CSimulatedAircraft::CSimulatedAircraft(const CCallsign &callsign, const CUser &user, const CAircraftSituation &situation) :
@@ -47,7 +47,7 @@ namespace BlackMisc
m_callsign(callsign), m_pilot(user), m_situation(situation) m_callsign(callsign), m_pilot(user), m_situation(situation)
{ {
this->setModel(model); this->setModel(model);
init(); this->init();
} }
void CSimulatedAircraft::init() void CSimulatedAircraft::init()

View File

@@ -214,10 +214,10 @@ namespace BlackMisc
const Aviation::CAltitude &getGroundElevation() const { return m_situation.getGroundElevation(); } const Aviation::CAltitude &getGroundElevation() const { return m_situation.getGroundElevation(); }
//! \copydoc BlackMisc::Aviation::CAircraftSituation::setGroundElevation //! \copydoc BlackMisc::Aviation::CAircraftSituation::setGroundElevation
void setGroundElevation(const Geo::CElevationPlane &elevation) { m_situation.setGroundElevation(elevation); } void setGroundElevation(const Geo::CElevationPlane &elevation, Aviation::CAircraftSituation::GndElevationInfo info) { m_situation.setGroundElevation(elevation, info); }
//! \copydoc BlackMisc::Aviation::CAircraftSituation::setGroundElevation //! \copydoc BlackMisc::Aviation::CAircraftSituation::setGroundElevation
void setGroundElevationChecked(const Geo::CElevationPlane &elevation) { m_situation.setGroundElevationChecked(elevation); } void setGroundElevationChecked(const Geo::CElevationPlane &elevation, Aviation::CAircraftSituation::GndElevationInfo info) { m_situation.setGroundElevationChecked(elevation, info); }
//! \copydoc BlackMisc::Aviation::CAircraftSituation::getHeading //! \copydoc BlackMisc::Aviation::CAircraftSituation::getHeading
const Aviation::CHeading &getHeading() const { return m_situation.getHeading(); } const Aviation::CHeading &getHeading() const { return m_situation.getHeading(); }

View File

@@ -186,13 +186,13 @@ namespace BlackMisc
return c; return c;
} }
int CSimulatedAircraftList::setGroundElevationChecked(const CCallsign &callsign, const CElevationPlane &elevation, bool onlyFirst) int CSimulatedAircraftList::setGroundElevationChecked(const CCallsign &callsign, const CElevationPlane &elevation, CAircraftSituation::GndElevationInfo info, bool onlyFirst)
{ {
int c = 0; int c = 0;
for (CSimulatedAircraft &aircraft : (*this)) for (CSimulatedAircraft &aircraft : (*this))
{ {
if (aircraft.getCallsign() != callsign) { continue; } if (aircraft.getCallsign() != callsign) { continue; }
aircraft.setGroundElevationChecked(elevation); aircraft.setGroundElevationChecked(elevation, info);
c++; c++;
if (onlyFirst) break; if (onlyFirst) break;
} }

View File

@@ -97,7 +97,7 @@ namespace BlackMisc
int setAircraftSituation(const Aviation::CCallsign &callsign, const Aviation::CAircraftSituation &situation, bool onlyFirst = true); int setAircraftSituation(const Aviation::CCallsign &callsign, const Aviation::CAircraftSituation &situation, bool onlyFirst = true);
//! Set ground elevation //! Set ground elevation
int setGroundElevationChecked(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation, bool onlyFirst = true); int setGroundElevationChecked(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation, Aviation::CAircraftSituation::GndElevationInfo info, bool onlyFirst = true);
//! Enabled? //! Enabled?
bool isEnabled(const Aviation::CCallsign &callsign) const; bool isEnabled(const Aviation::CCallsign &callsign) const;

View File

@@ -428,7 +428,7 @@ namespace BlackSimPlugin
aircraftSituation.setBank(CAngle(-simulatorOwnAircraft.bank, CAngleUnit::deg())); aircraftSituation.setBank(CAngle(-simulatorOwnAircraft.bank, CAngleUnit::deg()));
aircraftSituation.setHeading(CHeading(simulatorOwnAircraft.trueHeading, CHeading::True, CAngleUnit::deg())); aircraftSituation.setHeading(CHeading(simulatorOwnAircraft.trueHeading, CHeading::True, CAngleUnit::deg()));
aircraftSituation.setGroundSpeed(CSpeed(simulatorOwnAircraft.velocity, CSpeedUnit::kts())); aircraftSituation.setGroundSpeed(CSpeed(simulatorOwnAircraft.velocity, CSpeedUnit::kts()));
aircraftSituation.setGroundElevation(CAltitude(simulatorOwnAircraft.elevation, CAltitude::MeanSeaLevel, CLengthUnit::ft())); aircraftSituation.setGroundElevation(CAltitude(simulatorOwnAircraft.elevation, CAltitude::MeanSeaLevel, CLengthUnit::ft()), CAircraftSituation::FromProvider);
aircraftSituation.setAltitude(CAltitude(simulatorOwnAircraft.altitude, CAltitude::MeanSeaLevel, CLengthUnit::ft())); aircraftSituation.setAltitude(CAltitude(simulatorOwnAircraft.altitude, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
aircraftSituation.setPressureAltitude(CAltitude(simulatorOwnAircraft.pressureAltitude, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m())); aircraftSituation.setPressureAltitude(CAltitude(simulatorOwnAircraft.pressureAltitude, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
// set on ground also in situation for consistency and future usage // set on ground also in situation for consistency and future usage

View File

@@ -135,7 +135,7 @@ namespace BlackMiscTest
QVERIFY2(corAlt == alt, "Expect same altitude"); QVERIFY2(corAlt == alt, "Expect same altitude");
CElevationPlane ep(situation, CElevationPlane::singlePointRadius()); CElevationPlane ep(situation, CElevationPlane::singlePointRadius());
situation.setGroundElevation(ep); situation.setGroundElevation(ep, CAircraftSituation::Test);
// now we have same alt and elevation values // now we have same alt and elevation values
// no elevation, expect same values // no elevation, expect same values
@@ -162,7 +162,7 @@ namespace BlackMiscTest
alt = CAltitude(-1000, CAltitude::MeanSeaLevel, CLengthUnit::ft()); alt = CAltitude(-1000, CAltitude::MeanSeaLevel, CLengthUnit::ft());
ep.setGeodeticHeight(alt); ep.setGeodeticHeight(alt);
situation.setAltitude(alt); situation.setAltitude(alt);
situation.setGroundElevation(ep); situation.setGroundElevation(ep, CAircraftSituation::Test);
corAlt = situation.getCorrectedAltitude(true, &correction); corAlt = situation.getCorrectedAltitude(true, &correction);
QVERIFY2(correction == CAircraftSituation::Underflow, "Expect underflow correction"); QVERIFY2(correction == CAircraftSituation::Underflow, "Expect underflow correction");
QVERIFY2(corAlt > alt, "Expect corrected altitude"); QVERIFY2(corAlt > alt, "Expect corrected altitude");
@@ -173,7 +173,7 @@ namespace BlackMiscTest
situation.setAltitude(alt); situation.setAltitude(alt);
ep.setGeodeticHeight(alt); ep.setGeodeticHeight(alt);
ep.addAltitudeOffset(CLength(-100, CLengthUnit::ft())); ep.addAltitudeOffset(CLength(-100, CLengthUnit::ft()));
situation.setGroundElevation(ep); situation.setGroundElevation(ep, CAircraftSituation::Test);
corAlt = situation.getCorrectedAltitude(true, &correction); corAlt = situation.getCorrectedAltitude(true, &correction);
QVERIFY2(corAlt == alt, "Expect same altitude, no overflow since not on gnd."); QVERIFY2(corAlt == alt, "Expect same altitude, no overflow since not on gnd.");

View File

@@ -166,7 +166,7 @@ namespace BlackMiscTest
const CAltitude gndElev({ 0, CLengthUnit::m() }, CAltitude::MeanSeaLevel); const CAltitude gndElev({ 0, CLengthUnit::m() }, CAltitude::MeanSeaLevel);
const CCoordinateGeodetic c(lat, lng, alt); const CCoordinateGeodetic c(lat, lng, alt);
CAircraftSituation s(callsign, c, heading, pitch, bank, gs); CAircraftSituation s(callsign, c, heading, pitch, bank, gs);
s.setGroundElevation(gndElev); s.setGroundElevation(gndElev, CAircraftSituation::Test);
s.setMSecsSinceEpoch(ts - deltaT * number); // values in past s.setMSecsSinceEpoch(ts - deltaT * number); // values in past
s.setTimeOffsetMs(offset); s.setTimeOffsetMs(offset);
return s; return s;

View File

@@ -160,7 +160,7 @@ namespace BlackMiscTest
const CAltitude gndElev({ 0, CLengthUnit::m() }, CAltitude::MeanSeaLevel); const CAltitude gndElev({ 0, CLengthUnit::m() }, CAltitude::MeanSeaLevel);
const CCoordinateGeodetic c(lat, lng, alt); const CCoordinateGeodetic c(lat, lng, alt);
CAircraftSituation s(callsign, c, heading, pitch, bank, gs); CAircraftSituation s(callsign, c, heading, pitch, bank, gs);
s.setGroundElevation(gndElev); s.setGroundElevation(gndElev, CAircraftSituation::Test);
s.setMSecsSinceEpoch(ts - deltaT * number); // values in past s.setMSecsSinceEpoch(ts - deltaT * number); // values in past
s.setTimeOffsetMs(offset); s.setTimeOffsetMs(offset);
return s; return s;