Ref T773, if possible skip update of situations with elevation in interpolator

This commit is contained in:
Klaus Basan
2020-02-21 01:02:24 +01:00
committed by Mat Sutcliffe
parent 181c2b8061
commit e21dab0605
3 changed files with 19 additions and 10 deletions

View File

@@ -235,8 +235,15 @@ namespace BlackMisc
const CLength radius = currentSituation.getDistancePerTime250ms(CElevationPlane::singlePointRadius()); const CLength radius = currentSituation.getDistancePerTime250ms(CElevationPlane::singlePointRadius());
if (!m_lastSituation.transferGroundElevationFromThis(currentSituation, radius)) if (!m_lastSituation.transferGroundElevationFromThis(currentSituation, radius))
{ {
const CElevationPlane groundElevation = this->findClosestElevationWithinRange(currentSituation, radius); if (currentSituation.canLikelySkipNearGroundInterpolation())
m_lastSituation.setGroundElevationChecked(groundElevation, CAircraftSituation::FromCache); {
// skipped
}
else
{
const CElevationPlane groundElevation = this->findClosestElevationWithinRange(currentSituation, radius);
m_lastSituation.setGroundElevationChecked(groundElevation, CAircraftSituation::FromCache);
}
} }
} }

View File

@@ -174,7 +174,7 @@ namespace BlackMisc
static const QString vm("Unverified situations, m0-2 (oldest latest) %1 %2 %3"); static const QString vm("Unverified situations, m0-2 (oldest latest) %1 %2 %3");
const QString vmValues = vm.arg(olderAdjusted).arg(currentAdjusted).arg(latestAdjusted); const QString vmValues = vm.arg(olderAdjusted).arg(currentAdjusted).arg(latestAdjusted);
CLogMessage(this).warning(vmValues); CLogMessage(this).warning(vmValues);
Q_UNUSED(vmValues); Q_UNUSED(vmValues)
} }
} }
return hasNewer; return hasNewer;
@@ -219,7 +219,7 @@ namespace BlackMisc
// - on an airport the plane does not move very fast, or not at all // - on an airport the plane does not move very fast, or not at all
// - and the elevation remains (almost) constant for a wider area // - and the elevation remains (almost) constant for a wider area
// - during flying the ground elevation not really matters // - during flying the ground elevation not really matters
this->updateElevations(); this->updateElevations(true);
static const CLengthUnit altUnit = CAltitude::defaultUnit(); static const CLengthUnit altUnit = CAltitude::defaultUnit();
const CLength cg(this->getModelCG().switchedUnit(altUnit)); const CLength cg(this->getModelCG().switchedUnit(altUnit));
const double a0 = m_s[0].getCorrectedAltitude(cg).value(altUnit); // oldest const double a0 = m_s[0].getCorrectedAltitude(cg).value(altUnit); // oldest
@@ -284,14 +284,16 @@ namespace BlackMisc
return m_interpolant; return m_interpolant;
} }
bool CInterpolatorSpline::updateElevations() bool CInterpolatorSpline::updateElevations(bool canSkip)
{ {
bool updated = false; bool updated = false;
for (unsigned int i = 0; i < m_s.size(); i++) for (CAircraftSituation &s : m_s)
{ {
if (m_s[i].hasGroundElevation()) { continue; } // do not override existing values if (s.hasGroundElevation()) { continue; } // do not override existing values
const CElevationPlane plane = this->findClosestElevationWithinRange(m_s[i], CElevationPlane::singlePointRadius()); if (canSkip && s.canLikelySkipNearGroundInterpolation()) { continue; }
const bool u = m_s[i].setGroundElevationChecked(plane, CAircraftSituation::FromCache);
const CElevationPlane plane = this->findClosestElevationWithinRange(s, CElevationPlane::singlePointRadius());
const bool u = s.setGroundElevationChecked(plane, CAircraftSituation::FromCache);
updated |= u; updated |= u;
} }
return updated; return updated;

View File

@@ -88,7 +88,7 @@ namespace BlackMisc
private: private:
//! Update the elevations used in CInterpolatorSpline::m_s //! Update the elevations used in CInterpolatorSpline::m_s
bool updateElevations(); bool updateElevations(bool canSkip);
//! Are any elevations missing in CInterpolatorSpline::m_s //! Are any elevations missing in CInterpolatorSpline::m_s
bool areAnyElevationsMissing() const; bool areAnyElevationsMissing() const;