mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
Ref T275, new function to estimate ground elevation and some provider functions
* added "averageElevationOfNonMovingAircraft". Idea: aircraft in the vicinity not moving or on ground likely have the same airport elevation * added "isWithinRange" * added "latestRemoteAircraftSituations" / "remoteAircraftSituation" in provider
This commit is contained in:
@@ -137,7 +137,7 @@ namespace BlackMisc
|
||||
|
||||
const QString &CAircraftSituation::gndElevationInfoToString(GndElevationInfo details)
|
||||
{
|
||||
static const QString no("no details");
|
||||
static const QString noDetails("no details");
|
||||
static const QString unknown("unknown");
|
||||
static const QString transferred("transferred");
|
||||
static const QString provider("provider");
|
||||
@@ -146,10 +146,11 @@ namespace BlackMisc
|
||||
static const QString test("test");
|
||||
static const QString interpolated("interpolated");
|
||||
static const QString extrapolated("extrapolated");
|
||||
static const QString avg("average");
|
||||
|
||||
switch (details)
|
||||
{
|
||||
case NoElevationInfo: return no;
|
||||
case NoElevationInfo: return noDetails;
|
||||
case TransferredElevation: return transferred;
|
||||
case FromProvider: return provider;
|
||||
case SituationChange: return change;
|
||||
@@ -157,6 +158,7 @@ namespace BlackMisc
|
||||
case Test: return test;
|
||||
case Interpolated: return interpolated;
|
||||
case Extrapolated: return extrapolated;
|
||||
case Average: return avg;
|
||||
default: break;
|
||||
}
|
||||
return unknown;
|
||||
|
||||
@@ -118,6 +118,7 @@ namespace BlackMisc
|
||||
TransferredElevation, //!< transferred from nearby situation
|
||||
Interpolated, //!< interpolated between 2 elevations
|
||||
Extrapolated, //!< extrapolated ("guessing")
|
||||
Average, //!< average value of "nearby" situation CAircraftSituationList::averageElevationOfNonMovingAircraft
|
||||
FromProvider, //!< from BlackMisc::Simulation::ISimulationEnvironmentProvider
|
||||
FromCache, //!< from cache
|
||||
SituationChange, //!< from BlackMisc::Aviation::CAircraftSituationChange
|
||||
|
||||
@@ -117,6 +117,7 @@ namespace BlackMisc
|
||||
bool CAircraftSituationList::extrapolateElevation(const CAircraftSituationChange &change)
|
||||
{
|
||||
if (this->size() < 3) { return false; }
|
||||
Q_ASSERT_X(m_tsAdjustedSortHint == CAircraftSituationList::AdjustedTimestampLatestFirst, Q_FUNC_INFO, "Need latest first");
|
||||
const CAircraftSituation old = (*this)[1];
|
||||
const CAircraftSituation older = (*this)[2];
|
||||
return this->front().extrapolateElevation(old, older, change);
|
||||
@@ -520,7 +521,7 @@ namespace BlackMisc
|
||||
return CAltitudePair(CAltitude(deltaFt.first, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()), CAltitude(deltaFt.second, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()));
|
||||
}
|
||||
|
||||
int CAircraftSituationList::transferElevationForward(const CLength radius)
|
||||
int CAircraftSituationList::transferElevationForward(const CLength &radius)
|
||||
{
|
||||
if (this->size() < 2) { return 0; }
|
||||
Q_ASSERT_X(m_tsAdjustedSortHint == CAircraftSituationList::AdjustedTimestampLatestFirst, Q_FUNC_INFO, "need latest first");
|
||||
@@ -533,5 +534,27 @@ namespace BlackMisc
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
CElevationPlane CAircraftSituationList::averageElevationOfNonMovingAircraft(const CAircraftSituation &reference, const CLength &range, int minValues) const
|
||||
{
|
||||
if (this->size() < minValues) { return CElevationPlane::null(); } // no change to succeed
|
||||
|
||||
QList<double> valuesInFt;
|
||||
for (const CAircraftSituation &situation : *this)
|
||||
{
|
||||
if (situation.getGroundElevationInfo() != CAircraftSituation::FromProvider) { continue; }
|
||||
const bool canUse = !situation.isMoving() || (situation.isOnGroundFromNetwork() || situation.isOnGroundFromParts());
|
||||
if (!canUse) { continue; }
|
||||
if (!situation.isWithinRange(reference, range)) { continue; }
|
||||
const double elvFt = situation.getGroundElevationPlane().getAltitude().value(CLengthUnit::ft());
|
||||
valuesInFt.push_back(elvFt);
|
||||
}
|
||||
if (valuesInFt.size() < minValues) { return CElevationPlane::null(); }
|
||||
|
||||
static const double MaxDevFt = CAircraftSituationChange::allowedAltitudeDeviation().value(CLengthUnit::ft());
|
||||
const QPair<double, double> elvStdDevMean = CMathUtils::standardDeviationAndMean(valuesInFt);
|
||||
if (elvStdDevMean.first > MaxDevFt) { return CElevationPlane::null(); }
|
||||
return CElevationPlane(reference, elvStdDevMean.second, CElevationPlane::singlePointRadius());
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace BlackMisc
|
||||
//! Extrapolate ground flag into the future
|
||||
int extrapolateGroundFlag();
|
||||
|
||||
//! Extrapolates elevation into front element from 2nd and 3rd element
|
||||
//! Extrapolates elevation into front (first) element from 2nd and 3rd element
|
||||
//! \sa CAircraftSituation::extrapolateElevation
|
||||
//! \pre the list must be sorted latest first and containt at least 3 elements
|
||||
bool extrapolateElevation(const CAircraftSituationChange &change);
|
||||
@@ -190,7 +190,10 @@ namespace BlackMisc
|
||||
|
||||
//! Transfer elevations forward from older to newer
|
||||
//! \pre requires a list which is sorted "latest first"
|
||||
int transferElevationForward(const PhysicalQuantities::CLength radius = Geo::CElevationPlane::singlePointRadius());
|
||||
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;
|
||||
};
|
||||
|
||||
//! Situation per callsign
|
||||
|
||||
Reference in New Issue
Block a user