From d0addd547ab2952bc668f77a51461e307f03a58a Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 18 Apr 2018 05:05:21 +0200 Subject: [PATCH] Ref T260, ext. version of updating ground elevation, allows to guess gnd. again with updated elevation --- src/blackcore/airspacemonitor.cpp | 24 +++++++++++++------ src/blackcore/airspacemonitor.h | 4 ++++ .../simulation/remoteaircraftprovider.cpp | 11 ++++++++- .../simulation/remoteaircraftprovider.h | 4 ++++ 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index 2c3ab6c99..8bd6ceae2 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -129,6 +129,13 @@ namespace BlackCore return r; } + int CAirspaceMonitor::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation) + { + const bool vtol = this->isVtolAircraft(callsign); + const CLength cg = this->getCG(callsign); + return this->updateAircraftGroundElevationExt(callsign, elevation, vtol, cg, true); + } + const CLogCategoryList &CAirspaceMonitor::getLogCategories() { static const CLogCategoryList cats { CLogCategory::matching(), CLogCategory::network() }; @@ -947,16 +954,19 @@ namespace BlackCore } } - if (situation.getOnGroundDetails() != CAircraftSituation::NotSet) - { - const bool vtol = this->isVtolAircraft(callsign); - const CLength cg = this->getCG(callsign); - correctedSituation.guessOnGround(vtol, cg); - } - + this->guessOnGround(correctedSituation); // does nothing if situation is not appropriate for guessing CRemoteAircraftProvider::storeAircraftSituation(correctedSituation); } + bool CAirspaceMonitor::guessOnGround(CAircraftSituation &situation) const + { + if (!situation.shouldGuessOnGround()) { return false; } + const CCallsign callsign(situation.getCallsign()); + const bool vtol = this->isVtolAircraft(callsign); + const CLength cg = this->getCG(callsign); + return situation.guessOnGround(vtol, cg); + } + void CAirspaceMonitor::sendInitialAtcQueries(const CCallsign &callsign) { if (!this->isConnected()) { return; } diff --git a/src/blackcore/airspacemonitor.h b/src/blackcore/airspacemonitor.h index c2ada9968..5d274cd4f 100644 --- a/src/blackcore/airspacemonitor.h +++ b/src/blackcore/airspacemonitor.h @@ -76,6 +76,7 @@ namespace BlackCore virtual QObject *asQObject() override { return this; } virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const override; virtual bool updateFastPositionEnabled(const BlackMisc::Aviation::CCallsign &callsign, bool enableFastPositonUpdates) override; + virtual int updateAircraftGroundElevation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Geo::CElevationPlane &elevation) override; //! @} //! Returns the list of users we know about @@ -169,6 +170,9 @@ namespace BlackCore CAirspaceAnalyzer *m_analyzer = nullptr; //!< owned analyzer bool m_bookingsRequested = false; //!< bookings have been requested, it can happen we receive an BlackCore::Vatsim::CVatsimBookingReader::atcBookingsReadUnchanged signal + //! Guess situation if applicable + bool guessOnGround(BlackMisc::Aviation::CAircraftSituation &situation) const; + //! Remove ATC online stations void removeAllOnlineAtcStations(); diff --git a/src/blackmisc/simulation/remoteaircraftprovider.cpp b/src/blackmisc/simulation/remoteaircraftprovider.cpp index 816a631ca..41c14d7d4 100644 --- a/src/blackmisc/simulation/remoteaircraftprovider.cpp +++ b/src/blackmisc/simulation/remoteaircraftprovider.cpp @@ -14,6 +14,7 @@ #include "blackmisc/verify.h" using namespace BlackMisc::Aviation; +using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; using namespace BlackMisc::Json; @@ -355,6 +356,11 @@ namespace BlackMisc } int CRemoteAircraftProvider::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation) + { + return this->updateAircraftGroundElevationExt(callsign, elevation, false, CLength::null(), false); + } + + int CRemoteAircraftProvider::updateAircraftGroundElevationExt(const CCallsign &callsign, const CElevationPlane &elevation, bool isVtol, const CLength &cg, bool autoGuessGnd) { if (!this->isAircraftInRange(callsign)) { return 0; } @@ -363,7 +369,10 @@ namespace BlackMisc int updated = 0; { QWriteLocker l(&m_lockSituations); - updated = m_situationsByCallsign[callsign].setGroundElevationChecked(elevation); + CAircraftSituationList situations = m_situationsByCallsign[callsign]; + updated = autoGuessGnd ? + situations.setGroundElevationCheckedAndGuessGround(elevation, isVtol, cg) : + situations.setGroundElevationChecked(elevation); if (updated < 1) { return 0; } m_situationsLastModified[callsign] = ts; } diff --git a/src/blackmisc/simulation/remoteaircraftprovider.h b/src/blackmisc/simulation/remoteaircraftprovider.h index 548b4ab7a..3ebd5ec89 100644 --- a/src/blackmisc/simulation/remoteaircraftprovider.h +++ b/src/blackmisc/simulation/remoteaircraftprovider.h @@ -356,6 +356,10 @@ namespace BlackMisc //! \threadsafe void storeAircraftSituation(const Aviation::CAircraftSituation &situation); + //! An extended of IRemoteAircraftProvider::updateAircraftGroundElevation version which allows also guessing of ground + //! \sa IRemoteAircraftProvider::updateAircraftGroundElevation + int updateAircraftGroundElevationExt(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation, bool isVtol, const PhysicalQuantities::CLength &cg, bool autoGuessGnd); + //! Store an aircraft part //! \remark latest parts are kept first //! \threadsafe