mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
Ref T773, elevation handling style and minor improvements
This commit is contained in:
committed by
Mat Sutcliffe
parent
287d96afea
commit
33b3cd5461
@@ -1382,12 +1382,15 @@ namespace BlackCore
|
||||
correctedSituation.setGroundElevation(ep, CAircraftSituation::FromCache);
|
||||
}
|
||||
|
||||
// we have a new situation, so we try to get the elevation
|
||||
// so far we have requested it, but we set it upfront either by
|
||||
// a) average value from other planes in the vicinity or
|
||||
// b) by extrapolating
|
||||
//
|
||||
// if we would NOT preset it, we could end up with oscillation
|
||||
//
|
||||
if (!correctedSituation.hasGroundElevation())
|
||||
{
|
||||
// we have a new situation, so we try to get the elevation
|
||||
// so far we have requested it, but we set it upfront either by
|
||||
// a) average value from other planes in the vicinity or
|
||||
// b) by extrapolating
|
||||
const CElevationPlane averagePlane = this->averageElevationOfNonMovingAircraft(situation, CElevationPlane::majorAirportRadius(), 2);
|
||||
if (!averagePlane.isNull())
|
||||
{
|
||||
@@ -1401,7 +1404,7 @@ namespace BlackCore
|
||||
if (oldSituations.size() > 1)
|
||||
{
|
||||
const bool extrapolated = correctedSituation.extrapolateElevation(oldSituations[0], oldSituations[1], oldChanges.frontOrDefault());
|
||||
Q_UNUSED(extrapolated)
|
||||
BLACK_AUDIT_X(extrapolated, Q_FUNC_INFO, "Cannot extrapolate");
|
||||
}
|
||||
}
|
||||
} // gnd. elevation
|
||||
|
||||
@@ -1032,7 +1032,7 @@ namespace BlackCore
|
||||
|
||||
bool CContextSimulator::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||
{
|
||||
Q_UNUSED(originator);
|
||||
Q_UNUSED(originator)
|
||||
if (commandLine.isEmpty()) { return false; }
|
||||
CSimpleCommandParser parser(
|
||||
{
|
||||
|
||||
@@ -106,10 +106,10 @@ namespace BlackGui
|
||||
}
|
||||
m_simulator = simulator;
|
||||
if (!simulator) { return; }
|
||||
connect(m_simulator, &ISimulator::receivedRequestedElevation, this, &CInterpolationLogDisplay::onElevationReceived, Qt::QueuedConnection);
|
||||
connect(m_simulator, &ISimulator::requestedElevation, this, &CInterpolationLogDisplay::onElevationRequested, Qt::QueuedConnection);
|
||||
connect(m_simulator, &ISimulator::destroyed, this, &CInterpolationLogDisplay::onSimulatorUnloaded);
|
||||
connect(m_simulator, &ISimulator::simulatorStatusChanged, this, &CInterpolationLogDisplay::onSimulatorStatusChanged);
|
||||
connect(m_simulator, &ISimulator::receivedRequestedElevation, this, &CInterpolationLogDisplay::onElevationReceived, Qt::QueuedConnection);
|
||||
connect(m_simulator, &ISimulator::requestedElevation, this, &CInterpolationLogDisplay::onElevationRequested, Qt::QueuedConnection);
|
||||
connect(m_simulator, &ISimulator::destroyed, this, &CInterpolationLogDisplay::onSimulatorUnloaded);
|
||||
connect(m_simulator, &ISimulator::simulatorStatusChanged, this, &CInterpolationLogDisplay::onSimulatorStatusChanged);
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::setAirspaceMonitor(CAirspaceMonitor *airspaceMonitor)
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace BlackGui
|
||||
explicit CInterpolationLogDisplay(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CInterpolationLogDisplay();
|
||||
virtual ~CInterpolationLogDisplay() override;
|
||||
|
||||
//! Set simulator
|
||||
void setSimulator(BlackCore::ISimulator *simulator);
|
||||
|
||||
@@ -300,6 +300,8 @@ namespace BlackMisc
|
||||
bool CAircraftSituation::extrapolateElevation(CAircraftSituation &newSituation, const CAircraftSituation &oldSituation, const CAircraftSituation &olderSituation, const CAircraftSituationChange &oldChange)
|
||||
{
|
||||
if (newSituation.hasGroundElevation()) { return false; }
|
||||
|
||||
// if acceptable transfer
|
||||
if (oldSituation.transferGroundElevationFromThis(newSituation)) { return true; }
|
||||
if (oldSituation.isNull() || olderSituation.isNull()) { return false; }
|
||||
|
||||
@@ -310,7 +312,7 @@ namespace BlackMisc
|
||||
const double deltaAltFt = qAbs(newSituation.getAltitude().value(CLengthUnit::ft()) - olderSituation.getAltitude().value(CLengthUnit::ft()));
|
||||
if (deltaAltFt <= CAircraftSituationChange::allowedAltitudeDeviation().value(CLengthUnit::ft()))
|
||||
{
|
||||
// the ccurrent alt is also not much different
|
||||
// the current alt is also not much different
|
||||
newSituation.setGroundElevation(oldSituation.getGroundElevation(), Extrapolated);
|
||||
return true;
|
||||
}
|
||||
@@ -1082,7 +1084,7 @@ namespace BlackMisc
|
||||
if (!min.isNull()) { return min; }
|
||||
return CLength(0, CLengthUnit::nullUnit());
|
||||
}
|
||||
const double seconds = milliseconds / 1000;
|
||||
const double seconds = milliseconds / 1000.0;
|
||||
const double gsMeterSecond = this->getGroundSpeed().value(CSpeedUnit::m_s());
|
||||
const CLength d(seconds * gsMeterSecond, CLengthUnit::m());
|
||||
if (!min.isNull() && d < min) { return min; }
|
||||
|
||||
@@ -289,6 +289,7 @@ namespace BlackMisc
|
||||
|
||||
const CLength &CAircraftSituationChange::allowedAltitudeDeviation()
|
||||
{
|
||||
// approx. 1 meter
|
||||
static const CLength allowedStdDev(3, CLengthUnit::ft());
|
||||
return allowedStdDev;
|
||||
}
|
||||
|
||||
@@ -594,7 +594,7 @@ namespace BlackMisc
|
||||
return c;
|
||||
}
|
||||
|
||||
CElevationPlane CAircraftSituationList::averageElevationOfNonMovingAircraft(const CAircraftSituation &reference, const CLength &range, int minValues) const
|
||||
CElevationPlane CAircraftSituationList::averageElevationOfTaxiingOnGroundAircraft(const CAircraftSituation &reference, const CLength &range, int minValues) const
|
||||
{
|
||||
if (this->size() < minValues) { return CElevationPlane::null(); } // no change to succeed
|
||||
|
||||
|
||||
@@ -207,8 +207,8 @@ namespace BlackMisc
|
||||
//! \pre requires a list which is sorted "latest first"
|
||||
int transferElevationForward(const PhysicalQuantities::CLength &radius = Geo::CElevationPlane::singlePointRadius());
|
||||
|
||||
//! Average elevation for "nearby" aircraft "not moving" and having an elevation
|
||||
Geo::CElevationPlane averageElevationOfNonMovingAircraft(const CAircraftSituation &reference, const PhysicalQuantities::CLength &range, int minValues = 1) const;
|
||||
//! Average elevation for "nearby" aircraft "not/slowly moving" and having an elevation
|
||||
Geo::CElevationPlane averageElevationOfTaxiingOnGroundAircraft(const CAircraftSituation &reference, const PhysicalQuantities::CLength &range, int minValues = 1) const;
|
||||
};
|
||||
|
||||
//! Situation per callsign
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace BlackMisc
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
BLACK_VERIFY_X(situation.getTimeOffsetMs() > 0, Q_FUNC_INFO, "Missing offset");
|
||||
BLACK_VERIFY_X(situation.isValidVectorRange(), Q_FUNC_INFO, "Invalid vector");
|
||||
BLACK_VERIFY_X(situation.isValidVectorRange(), Q_FUNC_INFO, "Invalid vector");
|
||||
}
|
||||
|
||||
// add altitude offset (for testing only)
|
||||
@@ -767,7 +767,7 @@ namespace BlackMisc
|
||||
CElevationPlane CRemoteAircraftProvider::averageElevationOfNonMovingAircraft(const CAircraftSituation &reference, const CLength &range, int minValues) const
|
||||
{
|
||||
const CAircraftSituationList situations = this->latestOnGroundProviderElevations();
|
||||
return situations.averageElevationOfNonMovingAircraft(reference, range, minValues);
|
||||
return situations.averageElevationOfTaxiingOnGroundAircraft(reference, range, minValues);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftProvider::testAddAltitudeOffset(const CCallsign &callsign, const CLength &offset)
|
||||
|
||||
Reference in New Issue
Block a user