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");
if (callsign.isEmpty()) { return; }
CAircraftSituation correctedSituation(situation);
CAircraftSituation correctedSituation(this->testAddAltitudeOffsetToSituation(situation));
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);
correctedSituation.setGroundElevation(ep);
correctedSituation.setGroundElevation(ep, CAircraftSituation::FromCache);
}
// do we already have ground details?
@@ -957,7 +957,7 @@ namespace BlackCore
}
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)

View File

@@ -384,8 +384,8 @@ namespace BlackCore
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
CCallsignSet callsigns;
callsigns.push_back(callsign);
CUserList users = this->getUsersForCallsigns(callsigns);
if (users.size() < 1) return CUser();
const CUserList users = this->getUsersForCallsigns(callsigns);
if (users.size() < 1) { return CUser(); }
return users[0];
}
@@ -786,9 +786,9 @@ namespace BlackCore
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()

View File

@@ -105,7 +105,7 @@ namespace BlackCore
std::function<void(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &)> aircraftSnapshotSlot
) 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 BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const override;
//! @}

View File

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

View File

@@ -64,12 +64,13 @@ namespace BlackMisc
QStringLiteral(" | cg: ") %
(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(" | skip ng: ") % boolToYesNo(this->canLikelySkipNearGroundInterpolation()) %
QStringLiteral(" | bank: ") % m_bank.toQString(i18n) %
QStringLiteral(" | pitch: ") % m_pitch.toQString(i18n) %
QStringLiteral(" | heading: ") % m_heading.toQString(i18n) %
QStringLiteral(" | gs: ") % m_groundSpeed.valueRoundedWithUnit(CSpeedUnit::kts(), 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)
@@ -134,6 +135,29 @@ namespace BlackMisc
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()
{
static const CLength small(0.5, CLengthUnit::m());
@@ -176,6 +200,10 @@ namespace BlackMisc
case IndexIsOnGroundString: return CVariant::fromValue(this->onGroundAsString());
case IndexOnGroundReliability: return CVariant::fromValue(m_onGroundDetails);
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);
}
}
@@ -197,6 +225,9 @@ namespace BlackMisc
case IndexCallsign: m_correspondingCallsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexIsOnGround: m_onGround = 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;
}
}
@@ -214,7 +245,13 @@ namespace BlackMisc
case IndexBank: return m_bank.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getBank());
case IndexCG: return m_cg.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCG());
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 IndexIsOnGround:
case IndexIsOnGroundString:
@@ -222,6 +259,10 @@ namespace BlackMisc
case IndexOnGroundReliability:
case IndexOnGroundReliabilityString:
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;
}
const QString assertMsg("No comparison for index " + index.toQString());
@@ -254,6 +295,7 @@ namespace BlackMisc
m_groundElevationPlane.setNull();
m_groundSpeed.setNull();
m_onGroundDetails = CAircraftSituation::NotSetGroundDetails;
m_elvInfo = NoElevationInfo;
}
bool CAircraftSituation::isOnGroundFromParts() const
@@ -322,7 +364,6 @@ namespace BlackMisc
return !this->hasInboundGroundDetails();
}
bool CAircraftSituation::guessOnGround(const CAircraftSituationChange &change, const CAircraftModel &model)
{
Q_UNUSED(change);
@@ -492,18 +533,33 @@ namespace BlackMisc
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
{
if (!this->hasGroundElevation()) { return false; }
const CLength distance = this->getGroundElevationPlane().calculateGreatCircleDistance(otherSituation);
const bool transferable = distance <= radius;
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());
otherSituation.setGroundElevation(this->getGroundElevationPlane(), TransferredElevation);
return true;
}
@@ -538,27 +594,37 @@ namespace BlackMisc
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())
{
m_groundElevationPlane = CElevationPlane::null();
this->setGroundElevationInfo(NoElevationInfo);
}
else
{
m_groundElevationPlane = CElevationPlane(*this);
m_groundElevationPlane.setSinglePointRadius();
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.switchUnit(this->getAltitudeOrDefaultUnit()); // we use ft as internal unit, no "must" but simplification
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
}
}
bool CAircraftSituation::setGroundElevationChecked(const CElevationPlane &elevationPlane)
bool CAircraftSituation::setGroundElevationChecked(const CElevationPlane &elevationPlane, GndElevationInfo info)
{
if (elevationPlane.isNull()) { return false; }
const CLength distance = this->calculateGreatCircleDistance(elevationPlane);
@@ -566,7 +632,7 @@ namespace BlackMisc
if (m_groundElevationPlane.isNull() || distance < m_groundElevationPlane.getRadius())
{
// better values
this->setGroundElevation(elevationPlane);
this->setGroundElevation(elevationPlane, info);
m_groundElevationPlane.setRadius(distance);
return true;
}
@@ -576,6 +642,7 @@ namespace BlackMisc
void CAircraftSituation::resetGroundElevation()
{
m_groundElevationPlane = CElevationPlane::null();
this->setGroundElevationInfo(NoElevationInfo);
}
const CLength &CAircraftSituation::getGroundElevationRadius() const

View File

@@ -67,8 +67,12 @@ namespace BlackMisc
IndexPitch,
IndexGroundSpeed,
IndexGroundElevationPlane,
IndexGroundElevationInfo,
IndexGroundElevationInfoString,
IndexGroundElevationPlusInfo,
IndexCallsign,
IndexCG
IndexCG,
IndexCanLikelySkipNearGroundInterpolation
};
//! Is on ground?
@@ -96,17 +100,28 @@ namespace BlackMisc
OutOnGroundOwnAircraft //!< sending on ground
};
//! How was altitude corrected
//! How was altitude corrected?
enum AltitudeCorrection
{
NoCorrection,
Underflow,
DraggedToGround,
Underflow, //!< aircraft too low
DraggedToGround, //!< other scenery too high, but on ground
AGL,
NoElevation,
NoElevation, //!< no correction as there is no elevation
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.
CAircraftSituation();
@@ -252,6 +267,18 @@ namespace BlackMisc
//! Elevation of the ground directly beneath
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?
bool canTransferGroundElevation(const CAircraftSituation &otherSituation, const PhysicalQuantities::CLength &radius = Geo::CElevationPlane::singlePointRadius()) const;
@@ -271,14 +298,14 @@ namespace BlackMisc
bool hasInboundGroundDetails() const;
//! 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
void setGroundElevation(const Geo::CElevationPlane &elevationPlane);
void setGroundElevation(const Geo::CElevationPlane &elevationPlane, GndElevationInfo info);
//! Set elevation of the ground directly beneath, but checked
//! \remark override if better
bool setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane);
bool setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane, GndElevationInfo info);
//! Reset ground elevation
void resetGroundElevation();
@@ -406,6 +433,9 @@ namespace BlackMisc
//! Enum to string
static const QString &altitudeCorrectionToString(AltitudeCorrection correction);
//! Enum to string
static const QString &gndElevationInfoToString(GndElevationInfo details);
//! Delta distance, near to ground
static const PhysicalQuantities::CLength &deltaNearGround();
@@ -454,6 +484,7 @@ namespace BlackMisc
bool m_isInterim = false;
int m_onGround = static_cast<int>(CAircraftSituation::OnGroundSituationUnknown);
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
QString m_onGroundGuessingDetails; //!< only for debugging, not transferred via DBus etc.
@@ -476,6 +507,7 @@ namespace BlackMisc
BLACK_METAMEMBER(groundElevationPlane),
BLACK_METAMEMBER(onGround),
BLACK_METAMEMBER(onGroundDetails),
BLACK_METAMEMBER(elvInfo),
BLACK_METAMEMBER(onGroundFactor),
BLACK_METAMEMBER(timestampMSecsSinceEpoch),
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::OnGroundDetails)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation::AltitudeCorrection)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituation::GndElevationInfo)
#endif // guard

View File

@@ -38,20 +38,20 @@ namespace BlackMisc
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; }
int c = 0;
for (CAircraftSituation &s : *this)
{
if (newerThanAdjustedMs >= 0 && s.getAdjustedMSecsSinceEpoch() <= newerThanAdjustedMs) { continue; }
const bool set = s.setGroundElevationChecked(elevationPlane);
const bool set = s.setGroundElevationChecked(elevationPlane, info);
if (set) { 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 (this->isEmpty()) { return 0; }
@@ -67,7 +67,7 @@ namespace BlackMisc
for (CAircraftSituation &s : *this)
{
const bool set = s.setGroundElevationChecked(elevationPlane);
const bool set = s.setGroundElevationChecked(elevationPlane, info);
if (set)
{
// change is only valid for the latest situation

View File

@@ -55,11 +55,11 @@ namespace BlackMisc
CAircraftSituationList(std::initializer_list<CAircraftSituation> il);
//! 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
//! \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
int adjustGroundFlag(const CAircraftParts &parts, double timeDeviationFactor = 0.1);

View File

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

View File

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

View File

@@ -238,7 +238,7 @@ namespace BlackMisc
{
if (m_s[i].hasGroundElevation()) { continue; } // do not override existing values
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;
}
return updated;

View File

@@ -190,7 +190,7 @@ namespace BlackMisc
return c;
}
void CRemoteAircraftProvider::storeAircraftSituation(const CAircraftSituation &situation)
void CRemoteAircraftProvider::storeAircraftSituation(const CAircraftSituation &situation, bool allowTestOffset)
{
const CCallsign cs = situation.getCallsign();
if (cs.isEmpty()) { return; }
@@ -202,7 +202,7 @@ namespace BlackMisc
}
// add offset (for testing only)
CAircraftSituation situationCorrected(this->testAddAltitudeOffsetToSituation(situation));
CAircraftSituation situationCorrected(allowTestOffset ? this->testAddAltitudeOffsetToSituation(situation) : situation);
// list from new to old
const qint64 ts = QDateTime::currentMSecsSinceEpoch();
@@ -385,7 +385,7 @@ namespace BlackMisc
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; }
@@ -396,14 +396,14 @@ namespace BlackMisc
{
QWriteLocker l(&m_lockSituations);
CAircraftSituationList &situations = m_situationsByCallsign[callsign];
updated = situations.setGroundElevationCheckedAndGuessGround(elevation, model);
updated = situations.setGroundElevationCheckedAndGuessGround(elevation, info, model);
if (updated < 1) { return 0; }
m_situationsLastModified[callsign] = ts;
}
// aircraft updates
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
return updated; // updated situations
@@ -716,10 +716,10 @@ namespace BlackMisc
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");
return this->provider()->updateAircraftGroundElevation(callsign, elevation);
return this->provider()->updateAircraftGroundElevation(callsign, elevation, info);
}
void CRemoteAircraftAware::updateMarkAllAsNotRendered()

View File

@@ -152,7 +152,7 @@ namespace BlackMisc
//! Update the ground elevation
//! \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
//! \threadsafe
@@ -261,7 +261,7 @@ namespace BlackMisc
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 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 void updateMarkAllAsNotRendered() override;
virtual CStatusMessageList getAircraftPartsHistory(const Aviation::CCallsign &callsign) const override;
@@ -364,7 +364,7 @@ namespace BlackMisc
//! Store an aircraft situation
//! \remark latest situations are kept first
//! \threadsafe
void storeAircraftSituation(const Aviation::CAircraftSituation &situation);
void storeAircraftSituation(const Aviation::CAircraftSituation &situation, bool allowTestOffset = true);
//! Store an aircraft part
//! \remark latest parts are kept first
@@ -468,7 +468,7 @@ namespace BlackMisc
bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered);
//! \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
void updateMarkAllAsNotRendered();

View File

@@ -28,13 +28,13 @@ namespace BlackMisc
{
CSimulatedAircraft::CSimulatedAircraft()
{
init();
this->init();
}
CSimulatedAircraft::CSimulatedAircraft(const CAircraftModel &model) : m_models({model, model})
{
this->setCallsign(model.getCallsign());
init();
this->init();
}
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)
{
this->setModel(model);
init();
this->init();
}
void CSimulatedAircraft::init()

View File

@@ -214,10 +214,10 @@ namespace BlackMisc
const Aviation::CAltitude &getGroundElevation() const { return m_situation.getGroundElevation(); }
//! \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
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
const Aviation::CHeading &getHeading() const { return m_situation.getHeading(); }

View File

@@ -186,13 +186,13 @@ namespace BlackMisc
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;
for (CSimulatedAircraft &aircraft : (*this))
{
if (aircraft.getCallsign() != callsign) { continue; }
aircraft.setGroundElevationChecked(elevation);
aircraft.setGroundElevationChecked(elevation, info);
c++;
if (onlyFirst) break;
}

View File

@@ -97,7 +97,7 @@ namespace BlackMisc
int setAircraftSituation(const Aviation::CCallsign &callsign, const Aviation::CAircraftSituation &situation, bool onlyFirst = true);
//! 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?
bool isEnabled(const Aviation::CCallsign &callsign) const;

View File

@@ -428,7 +428,7 @@ namespace BlackSimPlugin
aircraftSituation.setBank(CAngle(-simulatorOwnAircraft.bank, CAngleUnit::deg()));
aircraftSituation.setHeading(CHeading(simulatorOwnAircraft.trueHeading, CHeading::True, CAngleUnit::deg()));
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.setPressureAltitude(CAltitude(simulatorOwnAircraft.pressureAltitude, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
// set on ground also in situation for consistency and future usage