From 1428d39f4b3711e6a60f338d58ecd5501b21fdd1 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 9 Jul 2018 22:17:54 +0200 Subject: [PATCH] Ref T268, airspace monitor also consider closest elevations (from same callsign situations) --- src/blackcore/airspacemonitor.cpp | 27 ++++++++++++++++++--------- src/blackcore/airspacemonitor.h | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index afa0906a4..033dac88f 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -303,12 +303,11 @@ namespace BlackCore m_bookingsRequested = true; } - void CAirspaceMonitor::enableWatchdog(bool enable) + bool CAirspaceMonitor::enableWatchdog(bool enable) { - if (this->analyzer()) - { - this->analyzer()->setEnabled(enable); - } + if (!this->analyzer()) { return false; } + this->analyzer()->setEnabled(enable); + return true; } void CAirspaceMonitor::testCreateDummyOnlineAtcStations(int number) @@ -976,10 +975,20 @@ namespace BlackCore if (!correctedSituation.hasGroundElevation() && !correctedSituation.canLikelySkipNearGroundInterpolation()) { // fetch from cache or request - const CLength distance(correctedSituation.getDistancePerTime250ms()); // distnacee per ms - const CElevationPlane ep = this->findClosestElevationWithinRangeOrRequest(correctedSituation, distance, callsign); - Q_ASSERT_X(ep.isNull() || !ep.getRadius().isNull(), Q_FUNC_INFO, "null radius"); - correctedSituation.setGroundElevation(ep, CAircraftSituation::FromCache); + const CAircraftSituationList situations = this->remoteAircraftSituations(callsign); + CElevationPlane ep = situations.findCLosestElevationWithinRange(correctedSituation, correctedSituation.getDistancePerTime(100, CElevationPlane::singlePointRadius())); + if (!ep.isNull()) + { + correctedSituation.setGroundElevation(ep, CAircraftSituation::FromOtherSituations); + } + else + { + const CLength distance(correctedSituation.getDistancePerTime250ms(CElevationPlane::singlePointRadius())); // distnacee per ms + ep = this->findClosestElevationWithinRangeOrRequest(correctedSituation, distance, callsign); + Q_ASSERT_X(ep.isNull() || !ep.getRadius().isNull(), Q_FUNC_INFO, "null radius"); + correctedSituation.setGroundElevation(ep, CAircraftSituation::FromCache); + } + if (!correctedSituation.hasGroundElevation()) { // we have a new situation, so we try to get the elevation diff --git a/src/blackcore/airspacemonitor.h b/src/blackcore/airspacemonitor.h index 85c141136..556ec431e 100644 --- a/src/blackcore/airspacemonitor.h +++ b/src/blackcore/airspacemonitor.h @@ -119,7 +119,7 @@ namespace BlackCore CAirspaceAnalyzer *analyzer() const { return m_analyzer; } //! \copydoc CAirspaceAnalyzer::setEnabled - void enableWatchdog(bool enable); + bool enableWatchdog(bool enable); //! Gracefully shut down, e.g. for thread safety void gracefulShutdown();