mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 09:15:34 +08:00
Issue #77 Break cyclic dependencies between CAircraftParts, CAircraftLights, CAircraftSituation classes
This commit is contained in:
@@ -1215,6 +1215,44 @@ namespace BlackCore
|
||||
return aircraft;
|
||||
}
|
||||
|
||||
bool CAirspaceMonitor::extrapolateElevation(CAircraftSituationList &situations, const CAircraftSituationChange &change)
|
||||
{
|
||||
if (situations.size() < 3) { return false; }
|
||||
//Q_ASSERT_X(situations.m_tsAdjustedSortHint == CAircraftSituationList::AdjustedTimestampLatestFirst, Q_FUNC_INFO, "Need latest first");
|
||||
const CAircraftSituation old = situations[1];
|
||||
const CAircraftSituation older = situations[2];
|
||||
return extrapolateElevation(situations.front(), old, older, change);
|
||||
}
|
||||
|
||||
bool CAirspaceMonitor::extrapolateElevation(CAircraftSituation &situationToBeUpdated, const CAircraftSituation &oldSituation, const CAircraftSituation &olderSituation, const CAircraftSituationChange &oldChange)
|
||||
{
|
||||
if (situationToBeUpdated.hasGroundElevation()) { return false; }
|
||||
|
||||
// if acceptable transfer
|
||||
if (oldSituation.transferGroundElevationFromMe(situationToBeUpdated))
|
||||
{
|
||||
// change or keep type is the question
|
||||
// situationToBeUpdated.setGroundElevationInfo(Extrapolated);
|
||||
return true;
|
||||
}
|
||||
if (oldSituation.isNull() || olderSituation.isNull()) { return false; }
|
||||
|
||||
if (oldChange.isNull()) { return false; }
|
||||
if (oldChange.isConstOnGround() && oldChange.hasAltitudeDevWithinAllowedRange() && oldChange.hasElevationDevWithinAllowedRange())
|
||||
{
|
||||
// we have almost const altitudes and elevations
|
||||
const double deltaAltFt = qAbs(situationToBeUpdated.getAltitude().value(CLengthUnit::ft()) - olderSituation.getAltitude().value(CLengthUnit::ft()));
|
||||
if (deltaAltFt <= CAircraftSituation::allowedAltitudeDeviation().value(CLengthUnit::ft()))
|
||||
{
|
||||
// the current alt is also not much different
|
||||
situationToBeUpdated.setGroundElevation(oldSituation.getGroundElevation(), CAircraftSituation::Extrapolated);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::onAircraftUpdateReceived(const CAircraftSituation &situation, const CTransponder &transponder)
|
||||
{
|
||||
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Called in different thread");
|
||||
@@ -1539,7 +1577,7 @@ namespace BlackCore
|
||||
// values before updating (i.e. "storing") so the new situation is not yet considered
|
||||
if (situationsBeforeStoring.size() > 1)
|
||||
{
|
||||
const bool extrapolated = correctedSituation.extrapolateElevation(situationsBeforeStoring[0], situationsBeforeStoring[1], changesBeforeStoring);
|
||||
const bool extrapolated = extrapolateElevation(correctedSituation, situationsBeforeStoring[0], situationsBeforeStoring[1], changesBeforeStoring);
|
||||
triedExtrapolation = true;
|
||||
couldNotExtrapolate = !extrapolated;
|
||||
fromWhere = 20;
|
||||
|
||||
@@ -419,6 +419,16 @@ namespace BlackCore
|
||||
//! Set matching readiness flag
|
||||
Readiness &addMatchingReadinessFlag(const BlackMisc::Aviation::CCallsign &callsign, MatchingReadinessFlag mrf);
|
||||
|
||||
//! Extrapolates elevation into front (first) element from 2nd and 3rd element
|
||||
//! \pre the list must be sorted latest first and containt at least 3 elements
|
||||
static bool extrapolateElevation(BlackMisc::Aviation::CAircraftSituationList &situations, const BlackMisc::Aviation::CAircraftSituationChange &change);
|
||||
|
||||
//! Extrapolated between the 2 situations for situation
|
||||
//! \remark normally used if situationToBeUpdated is not between oldSituation and olderSituation (that would be interpolation)
|
||||
//! \return false if there are no two elevations, there is already an elevation, or no extrapolation is possible (too much deviation)
|
||||
static bool extrapolateElevation(BlackMisc::Aviation::CAircraftSituation &situationToBeUpdated, const BlackMisc::Aviation::CAircraftSituation &oldSituation,
|
||||
const BlackMisc::Aviation::CAircraftSituation &olderSituation, const BlackMisc::Aviation::CAircraftSituationChange &oldChange);
|
||||
|
||||
//! Create aircraft in range, this is the only place where a new aircraft should be added
|
||||
void onAircraftUpdateReceived(const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user