diff --git a/src/blackmisc/aviation/aircraftsituation.cpp b/src/blackmisc/aviation/aircraftsituation.cpp index 0c4985aa4..5844c086c 100644 --- a/src/blackmisc/aviation/aircraftsituation.cpp +++ b/src/blackmisc/aviation/aircraftsituation.cpp @@ -229,9 +229,15 @@ namespace BlackMisc void CAircraftSituation::setOnGroundFactor(double groundFactor) { - if (groundFactor < 0.0) { m_onGroundFactor = -1.0; return; } - if (groundFactor > 1.0) { m_onGroundFactor = 1.0; return; } - m_onGroundFactor = groundFactor; + double gf = groundFactor; + do + { + if (groundFactor < 0.0) { gf = -1.0; break; } + if (groundFactor < 0.001) { gf = 0.0; break; } + if (groundFactor > 0.999) { gf = 1.0; break; } + } + while (false); + m_onGroundFactor = gf; } bool CAircraftSituation::guessOnGround(bool vtol, const PhysicalQuantities::CLength &cg) @@ -271,6 +277,29 @@ namespace BlackMisc return CAircraftSituation::onGroundDetailsToString(this->getOnGroundDetails()); } + bool CAircraftSituation::setOnGroundFromGroundFactorFromInterpolation(double threshold) + { + this->setOnGroundDetails(OnGroundByInterpolation); + if (this->getOnGroundFactor() < 0.0) + { + this->setOnGround(NotSet); + return false; + } + + // set on ground but leave factor untouched + const bool og = this->getOnGroundFactor() > threshold; // 1.0 means on ground + m_onGround = og ? OnGround : NotOnGround; + return true; + } + + bool CAircraftSituation::setOnGroundByUnderflowDetection(const CLength &cg) + { + IsOnGround og = this->isOnGroundByElevation(cg); + if (og == OnGroundSituationUnknown) { return false; } + this->setOnGround(og, OnGroundByElevationAndCG); + return true; + } + QString CAircraftSituation::getOnGroundInfo() const { return this->onGroundAsString() % QLatin1Char(' ') % this->getOnDetailsAsString(); diff --git a/src/blackmisc/aviation/aircraftsituation.h b/src/blackmisc/aviation/aircraftsituation.h index 275efe8e2..1cf134da8 100644 --- a/src/blackmisc/aviation/aircraftsituation.h +++ b/src/blackmisc/aviation/aircraftsituation.h @@ -188,6 +188,12 @@ namespace BlackMisc //! On ground details void setOnGroundDetails(CAircraftSituation::OnGroundDetails details) { m_onGroundDetails = static_cast(details); } + //! Set on ground as interpolated from ground fatcor + bool setOnGroundFromGroundFactorFromInterpolation(double threshold = 0.5); + + //! Set on ground by underflow detection, detects below ground scenarios + bool setOnGroundByUnderflowDetection(const PhysicalQuantities::CLength &cg); + //! On ground info as string QString getOnGroundInfo() const; diff --git a/src/blackmisc/simulation/simulatedaircraftlist.cpp b/src/blackmisc/simulation/simulatedaircraftlist.cpp index c509ee5c9..7e5530029 100644 --- a/src/blackmisc/simulation/simulatedaircraftlist.cpp +++ b/src/blackmisc/simulation/simulatedaircraftlist.cpp @@ -108,6 +108,19 @@ namespace BlackMisc return c; } + int CSimulatedAircraftList::setFastPositionUpdates(const CCallsign &callsign, bool fastPositions, bool onlyFirst) + { + int c = 0; + for (CSimulatedAircraft &aircraft : (*this)) + { + if (aircraft.getCallsign() != callsign) { continue; } + aircraft.setFastPositionUpdates(fastPositions); + c++; + if (onlyFirst) break; + } + return c; + } + int CSimulatedAircraftList::setEnabled(const CCallsign &callsign, bool enabled, bool onlyFirst) { int c = 0; @@ -134,7 +147,7 @@ namespace BlackMisc return c; } - int CSimulatedAircraftList::setAircraftParts(const CCallsign &callsign, const CAircraftParts &parts, bool onlyFirst) + int CSimulatedAircraftList::setAircraftPartsSynchronized(const CCallsign &callsign, const CAircraftParts &parts, bool onlyFirst) { int c = 0; for (CSimulatedAircraft &aircraft : (*this)) diff --git a/src/blackmisc/simulation/simulatedaircraftlist.h b/src/blackmisc/simulation/simulatedaircraftlist.h index 4a3eb0268..c287753e4 100644 --- a/src/blackmisc/simulation/simulatedaircraftlist.h +++ b/src/blackmisc/simulation/simulatedaircraftlist.h @@ -79,13 +79,16 @@ namespace BlackMisc int setRendered(const Aviation::CCallsign &callsign, bool rendered, bool onlyFirst = true); //! Mark given callsign as enabled - int setEnabled(const Aviation::CCallsign &callsign, bool enabled, bool onlyFirst = true); + int setEnabled(const Aviation::CCallsign &callsign, bool enabled, bool onlyFirst); + + //! Mark as fast position enabled + int setFastPositionUpdates(const Aviation::CCallsign &callsign, bool fastPositions, bool onlyFirst = true); //! Set model int setAircraftModel(const Aviation::CCallsign &callsign, const CAircraftModel &model, bool onlyFirst = true); - //! Set aircraft parts - int setAircraftParts(const Aviation::CCallsign &callsign, const Aviation::CAircraftParts &parts, bool onlyFirst = true); + //! Set aircraft parts and mark as synchronized + int setAircraftPartsSynchronized(const Aviation::CCallsign &callsign, const Aviation::CAircraftParts &parts, bool onlyFirst = true); //! Set aircraft parts int setAircraftSituation(const Aviation::CCallsign &callsign, const Aviation::CAircraftSituation &situation, bool onlyFirst = true);