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:
Klaus Basan
2018-06-18 03:21:15 +02:00
parent d864789890
commit 2625c3fb6b
11 changed files with 183 additions and 42 deletions

View File

@@ -950,15 +950,27 @@ namespace BlackCore
correctedSituation.setGroundElevation(ep, CAircraftSituation::FromCache);
if (!correctedSituation.hasGroundElevation())
{
// values before updating
const CAircraftSituationList oldSituations = this->remoteAircraftSituations(callsign);
const CAircraftSituationChangeList oldChanges = this->remoteAircraftSituationChanges(callsign);
if (oldSituations.size() > 1)
// 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 plane in the vicinity or
// b) by extrapolating
const CElevationPlane averagePlane = this->averageElevationOfNonMovingAircraft(situation, CElevationPlane::minorAirportRadius());
if (!averagePlane.isNull())
{
const bool extrapolated = correctedSituation.extrapolateElevation(oldSituations[0], oldSituations[1], oldChanges.frontOrDefault());
Q_UNUSED(extrapolated);
correctedSituation.setGroundElevation(averagePlane, CAircraftSituation::Average);
}
}
else
{
// values before updating
const CAircraftSituationList oldSituations = this->remoteAircraftSituations(callsign);
const CAircraftSituationChangeList oldChanges = this->remoteAircraftSituationChanges(callsign);
if (oldSituations.size() > 1)
{
const bool extrapolated = correctedSituation.extrapolateElevation(oldSituations[0], oldSituations[1], oldChanges.frontOrDefault());
Q_UNUSED(extrapolated);
}
}
} // gnd. elevation
}
// do we already have ground details?