mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
@@ -32,8 +32,9 @@ namespace BlackCore
|
||||
//! Destructor
|
||||
virtual ~IWeatherData() {}
|
||||
|
||||
//! Fetch new weather data
|
||||
virtual void fetchWeatherData(const BlackMisc::Geo::CLatitude &latitude, const BlackMisc::Geo::CLongitude &longitude, double maxDistance = -1) = 0;
|
||||
//! Fetch new weather data around grid
|
||||
virtual void fetchWeatherData(const BlackMisc::Weather::CWeatherGrid &grid,
|
||||
const BlackMisc::PhysicalQuantities::CLength &range) = 0;
|
||||
|
||||
//! Get fetched weather data
|
||||
virtual BlackMisc::Weather::CWeatherGrid getWeatherData() const = 0;
|
||||
|
||||
@@ -52,11 +52,10 @@ namespace BlackWxPlugin
|
||||
connect(&m_networkAccessManager, &QNetworkAccessManager::finished, this, &CWeatherDataGfs::ps_parseGfsFile);
|
||||
}
|
||||
|
||||
void CWeatherDataGfs::fetchWeatherData(const CLatitude &latitude, const CLongitude &longitude, double maxDistance)
|
||||
void CWeatherDataGfs::fetchWeatherData(const CWeatherGrid &grid, const CLength &range)
|
||||
{
|
||||
m_latitude = latitude;
|
||||
m_longitude = longitude;
|
||||
m_maxDistance = maxDistance;
|
||||
m_grid = grid;
|
||||
m_maxRange = range;
|
||||
if (m_gribData.isEmpty())
|
||||
{
|
||||
CLogMessage(this).debug() << "Started to download GFS data...";
|
||||
@@ -422,11 +421,23 @@ namespace BlackWxPlugin
|
||||
if(gridPoint.longitude < 0.0) { gridPoint.longitude += 360.0; }
|
||||
gridPoint.fieldPosition = ix + i;
|
||||
CCoordinateGeodetic gridPointPosition(gridPoint.latitude, gridPoint.longitude, 0);
|
||||
CCoordinateGeodetic centralPosition(m_latitude, m_longitude, {0});
|
||||
if ((m_maxDistance == -1) || calculateEuclideanDistance(gridPointPosition, centralPosition) < m_maxDistance )
|
||||
if (m_maxRange == CLength())
|
||||
{
|
||||
m_gfsWeatherGrid.append(gridPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const CGridPoint &fixedGridPoint : as_const(m_grid))
|
||||
{
|
||||
auto distance = calculateGreatCircleDistance(gridPointPosition, fixedGridPoint.getPosition()).value(CLengthUnit::m());
|
||||
auto maxRange = m_maxRange.value(CLengthUnit::m());
|
||||
if (distance < maxRange)
|
||||
{
|
||||
m_gfsWeatherGrid.append(gridPoint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,9 @@ namespace BlackWxPlugin
|
||||
//! Constructor
|
||||
CWeatherDataGfs(QObject *parent = nullptr);
|
||||
|
||||
//! \copydoc BlackCore::IWeatherData::fetchWeatherData()
|
||||
virtual void fetchWeatherData(const BlackMisc::Geo::CLatitude &latitude, const BlackMisc::Geo::CLongitude &longitude, double maxDistance = -1) override;
|
||||
//! \copydoc BlackCore::IWeatherData::fetchWeatherData
|
||||
virtual void fetchWeatherData(const BlackMisc::Weather::CWeatherGrid &grid,
|
||||
const BlackMisc::PhysicalQuantities::CLength &range) override;
|
||||
|
||||
//! \copydoc BlackCore::IWeatherData::getWeatherData()
|
||||
virtual BlackMisc::Weather::CWeatherGrid getWeatherData() const override;
|
||||
@@ -134,9 +135,8 @@ namespace BlackWxPlugin
|
||||
void setCloudCoverage(const g2float *fld, int level);
|
||||
void setCloudLevel(const g2float *fld, int surfaceType, int level);
|
||||
|
||||
BlackMisc::Geo::CLatitude m_latitude;
|
||||
BlackMisc::Geo::CLongitude m_longitude;
|
||||
double m_maxDistance = -1;
|
||||
BlackMisc::Weather::CWeatherGrid m_grid;
|
||||
BlackMisc::PhysicalQuantities::CLength m_maxRange;
|
||||
|
||||
mutable QReadWriteLock m_lockData;
|
||||
QByteArray m_gribData;
|
||||
|
||||
Reference in New Issue
Block a user