mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Fix the initial weather request in case last position is null
calculateGreatCircleDistance returns false immediately if any of the arguments was null. ref T324
This commit is contained in:
committed by
Klaus Basan
parent
7a7f1f2df0
commit
3804612bed
@@ -533,7 +533,7 @@ namespace BlackCore
|
||||
// weather
|
||||
bool m_isWeatherActivated = false; //!< Is simulator weather activated?
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &ISimulator::reloadWeatherSettings }; //!< Selected weather scenario
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &ISimulator::reloadWeatherSettings }; //!< Selected weather scenario
|
||||
|
||||
private:
|
||||
// remote aircraft provider ("rap") bound
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace BlackGui
|
||||
|
||||
if (CWeatherScenario::isRealWeatherScenario(scenario))
|
||||
{
|
||||
if (!useOwnAcftPosition ||
|
||||
if (m_lastOwnAircraftPosition.isNull() ||
|
||||
calculateGreatCircleDistance(position, m_lastOwnAircraftPosition).value(CLengthUnit::km()) > 20)
|
||||
{
|
||||
requestWeatherGrid(position);
|
||||
|
||||
@@ -229,12 +229,15 @@ namespace BlackSimPlugin
|
||||
if (m_isWeatherActivated)
|
||||
{
|
||||
const auto currentPosition = CCoordinateGeodetic { situation.latitude(), situation.longitude() };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()))
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorEmulated::injectWeatherGrid });
|
||||
if (m_lastWeatherPosition.isNull() ||
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorEmulated::injectWeatherGrid });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,12 +334,15 @@ namespace BlackSimPlugin
|
||||
if (m_isWeatherActivated)
|
||||
{
|
||||
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude() };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()))
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFs9::injectWeatherGrid });
|
||||
if (m_lastWeatherPosition.isNull() ||
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFs9::injectWeatherGrid });
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -621,12 +621,15 @@ namespace BlackSimPlugin
|
||||
if (m_isWeatherActivated)
|
||||
{
|
||||
const auto currentPosition = CCoordinateGeodetic { aircraftSituation.latitude(), aircraftSituation.longitude() };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()))
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFsxCommon::injectWeatherGrid });
|
||||
if (m_lastWeatherPosition.isNull() ||
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorFsxCommon::injectWeatherGrid });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,12 +234,15 @@ namespace BlackSimPlugin
|
||||
if (m_isWeatherActivated)
|
||||
{
|
||||
const auto currentPosition = CCoordinateGeodetic { situation.latitude(), situation.longitude() };
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()) &&
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
if (CWeatherScenario::isRealWeatherScenario(m_weatherScenarioSettings.get()))
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorXPlane::injectWeatherGrid });
|
||||
if (m_lastWeatherPosition.isNull() ||
|
||||
calculateGreatCircleDistance(m_lastWeatherPosition, currentPosition).value(CLengthUnit::mi()) > 20)
|
||||
{
|
||||
m_lastWeatherPosition = currentPosition;
|
||||
const auto weatherGrid = CWeatherGrid { { "GLOB", currentPosition } };
|
||||
requestWeatherGrid(weatherGrid, { this, &CSimulatorXPlane::injectWeatherGrid });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user