From 597f3f7a6a9680f31db0b25b6520ea3698c9473e Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Sat, 3 Feb 2018 16:02:24 +0100 Subject: [PATCH] Add basic weather handling to emulated simulator It won't do much apart from requesting a weather grid. It might be useful in the future to debug the weather engine. But for now it helps to detect issues in the request path. ref T235 --- .../simulator/emulated/simulatoremulated.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/plugins/simulator/emulated/simulatoremulated.cpp b/src/plugins/simulator/emulated/simulatoremulated.cpp index 7dbae374a..f569a74ce 100644 --- a/src/plugins/simulator/emulated/simulatoremulated.cpp +++ b/src/plugins/simulator/emulated/simulatoremulated.cpp @@ -220,6 +220,19 @@ namespace BlackSimPlugin { if (m_myAircraft.getSituation() == situation) { return false; } m_myAircraft.setSituation(situation); + + if (m_isWeatherActivated) + { + const auto currentPosition = CCoordinateGeodetic { situation.latitude(), situation.longitude(), {0} }; + if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) && + calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20) + { + m_lastWeatherPosition = currentPosition; + const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } }; + requestWeatherGrid(weatherGrid, { this, &CSimulatorEmulated::injectWeatherGrid }); + } + } + return this->updateOwnSituation(situation); }