Ref T261, make sure the unit is correct in spline altitude interpolation

See slack discussion here https://swift-project.slack.com/archives/G7GD2UP9C/p1525605407000025
This commit is contained in:
Klaus Basan
2018-05-07 11:43:11 +02:00
committed by Roland Winklmeier
parent 23c54938ea
commit 6d105b9665
2 changed files with 6 additions and 20 deletions

View File

@@ -174,21 +174,21 @@ namespace BlackMisc
// - 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();
const CLength cg(this->getModelCG()); static const CLengthUnit altUnit = CAltitude::defaultUnit();
const double a0 = m_s[0].getCorrectedAltitude(cg).value(); // oldest const CLength cg(this->getModelCG().switchedUnit(altUnit));
const double a1 = m_s[1].getCorrectedAltitude(cg).value(); const double a0 = m_s[0].getCorrectedAltitude(cg).value(altUnit); // oldest
const double a2 = m_s[2].getCorrectedAltitude(cg).value(); // latest const double a1 = m_s[1].getCorrectedAltitude(cg).value(altUnit);
const double a2 = m_s[2].getCorrectedAltitude(cg).value(altUnit); // latest
pa.a = {{ a0, a1, a2 }}; pa.a = {{ a0, a1, a2 }};
pa.gnd = {{ m_s[0].getOnGroundFactor(), m_s[1].getOnGroundFactor(), m_s[2].getOnGroundFactor() }}; pa.gnd = {{ m_s[0].getOnGroundFactor(), m_s[1].getOnGroundFactor(), m_s[2].getOnGroundFactor() }};
pa.da = getDerivatives(pa.t, pa.a); pa.da = getDerivatives(pa.t, pa.a);
pa.dgnd = getDerivatives(pa.t, pa.gnd); pa.dgnd = getDerivatives(pa.t, pa.gnd);
Q_ASSERT_X(this->areAltitudeUnitsSame(), Q_FUNC_INFO, "Altitude unit mismatch");
m_prevSampleAdjustedTime = m_s[1].getAdjustedMSecsSinceEpoch(); m_prevSampleAdjustedTime = m_s[1].getAdjustedMSecsSinceEpoch();
m_nextSampleAdjustedTime = m_s[2].getAdjustedMSecsSinceEpoch(); // latest m_nextSampleAdjustedTime = m_s[2].getAdjustedMSecsSinceEpoch(); // latest
m_prevSampleTime = m_s[1].getMSecsSinceEpoch(); m_prevSampleTime = m_s[1].getMSecsSinceEpoch();
m_nextSampleTime = m_s[2].getMSecsSinceEpoch(); // latest m_nextSampleTime = m_s[2].getMSecsSinceEpoch(); // latest
m_interpolant = CInterpolant(pa, m_s[2].getAltitudeUnit(), CInterpolatorPbh(m_s[1], m_s[2])); m_interpolant = CInterpolant(pa, altUnit, CInterpolatorPbh(m_s[1], m_s[2]));
Q_ASSERT_X(m_prevSampleAdjustedTime < m_nextSampleAdjustedTime, Q_FUNC_INFO, "Wrong time order"); Q_ASSERT_X(m_prevSampleAdjustedTime < m_nextSampleAdjustedTime, Q_FUNC_INFO, "Wrong time order");
} }
@@ -262,17 +262,6 @@ namespace BlackMisc
return false; return false;
} }
bool CInterpolatorSpline::areAltitudeUnitsSame(const CLengthUnit &compare) const
{
if (m_s.size() < 1) { return true; }
const CLengthUnit c = compare.isNull() ? m_s[0].getAltitudeUnit() : compare;
for (unsigned int i = 0; i < m_s.size(); i++)
{
if (m_s[i].getAltitudeUnit() != c) { return false; }
}
return true;
}
CInterpolatorSpline::CInterpolant::CInterpolant(const CInterpolatorSpline::PosArray &pa, const CLengthUnit &altitudeUnit, const CInterpolatorPbh &pbh) : CInterpolatorSpline::CInterpolant::CInterpolant(const CInterpolatorSpline::PosArray &pa, const CLengthUnit &altitudeUnit, const CInterpolatorPbh &pbh) :
m_pa(pa), m_altitudeUnit(altitudeUnit) m_pa(pa), m_altitudeUnit(altitudeUnit)
{ {

View File

@@ -92,9 +92,6 @@ namespace BlackMisc
//! Ground relevant //! Ground relevant
bool isAnySituationNearGroundRelevant() const; bool isAnySituationNearGroundRelevant() const;
//! Are the altitude units all the same
bool areAltitudeUnitsSame(const PhysicalQuantities::CLengthUnit &compare = PhysicalQuantities::CLengthUnit::nullUnit()) const;
//! Fill the situations array //! Fill the situations array
bool fillSituationsArray(); bool fillSituationsArray();