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