mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 09:15:34 +08:00
Move GFS weather data url into global setup
Summary: The GFS weather data url so far was hard coded. With this commit, it is moved into the global setup (bootstrap file). Also the url type was changed from QUrl to CUrl, which simplified the generation of the url including its query by using CUrl::appendQuery(). Finally it fixes sampleweatherdata, which did not have a CApplication yet. Reviewers: #swift_pilot_client, msutcliffe Reviewed By: #swift_pilot_client, msutcliffe Subscribers: jenkins Tags: #swift_pilot_client Maniphest Tasks: T151 Differential Revision: https://dev.swift-project.org/D57
This commit is contained in:
@@ -54,6 +54,7 @@ namespace BlackCore
|
||||
m_newsUrls = CUrlList({ "http://swift-project.org/" });
|
||||
m_onlineHelpUrls = CUrlList({ "help.swift-project.org/" });
|
||||
m_mapUrls = CUrlList({ "map.swift-project.org/" });
|
||||
m_ncepGlobalForecastSystemUrl = CUrl("http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl");
|
||||
}
|
||||
|
||||
CUrl CGlobalSetup::getDbIcaoReaderUrl() const
|
||||
|
||||
@@ -186,6 +186,9 @@ namespace BlackCore
|
||||
//! Productive settings?
|
||||
void setDevelopment(bool development) { m_development = development; }
|
||||
|
||||
//! NCEP GFS Forecasts (0.50 degree grid) data url
|
||||
BlackMisc::Network::CUrl getNcepGlobalForecastSystemUrl() const { return m_ncepGlobalForecastSystemUrl; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
@@ -227,6 +230,7 @@ namespace BlackCore
|
||||
BlackMisc::Network::CUrlList m_onlineHelpUrls; //!< online help URLs
|
||||
BlackMisc::Network::CUrlList m_mapUrls; //!< swift map URLs
|
||||
BlackMisc::Network::CServerList m_fsdTestServers; //!< FSD test servers
|
||||
BlackMisc::Network::CUrl m_ncepGlobalForecastSystemUrl; //!< NCEP GFS url
|
||||
|
||||
// transient members, to be switched on/off via GUI or set from reader
|
||||
bool m_dbDebugFlag = false; //!< can trigger DEBUG on the server, so you need to know what you are doing
|
||||
@@ -253,6 +257,7 @@ namespace BlackCore
|
||||
BLACK_METAMEMBER(fsdTestServers),
|
||||
BLACK_METAMEMBER(development),
|
||||
BLACK_METAMEMBER(mappingMinimumVersion),
|
||||
BLACK_METAMEMBER(ncepGlobalForecastSystemUrl),
|
||||
BLACK_METAMEMBER(dbDebugFlag, BlackMisc::DisabledForJson)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Weather;
|
||||
using namespace BlackMisc::Math;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackWxPlugin
|
||||
{
|
||||
@@ -71,7 +72,7 @@ namespace BlackWxPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
const QUrl url = getDownloadUrl();
|
||||
const QUrl url = getDownloadUrl().toQUrl();
|
||||
CLogMessage(this).debug() << "Started to download GFS data from" << url.toString();
|
||||
QNetworkRequest request(url);
|
||||
sApp->getFromNetwork(request, { this, &CWeatherDataGfs::ps_parseGfsFile });
|
||||
@@ -114,9 +115,9 @@ namespace BlackWxPlugin
|
||||
m_parseGribFileWorker->then(this, &CWeatherDataGfs::ps_fetchingWeatherDataFinished);
|
||||
}
|
||||
|
||||
QUrl CWeatherDataGfs::getDownloadUrl() const
|
||||
CUrl CWeatherDataGfs::getDownloadUrl() const
|
||||
{
|
||||
QString baseurl = "http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl?";
|
||||
CUrl downloadUrl = sApp->getGlobalSetup().getNcepGlobalForecastSystemUrl();
|
||||
|
||||
static const QStringList grib2Levels =
|
||||
{
|
||||
@@ -183,24 +184,21 @@ namespace BlackWxPlugin
|
||||
directory = directory.arg(cnow.toString("yyyyMMdd"));
|
||||
directory = directory.arg(hourLastPublishedCycle, 2, 10, QLatin1Char('0'));
|
||||
|
||||
QStringList params;
|
||||
params.reserve(grib2Levels.size() + grib2Variables.size() + 6);
|
||||
params.append("file=" + filename);
|
||||
downloadUrl.appendQuery("file", filename);
|
||||
for (const auto &level : grib2Levels)
|
||||
{
|
||||
params.append("lev_" + level + "=on");
|
||||
downloadUrl.appendQuery("lev_" + level, "on");
|
||||
}
|
||||
for (const auto &variable : grib2Variables)
|
||||
{
|
||||
params.append("var_" + variable + "=on");
|
||||
downloadUrl.appendQuery("var_" + variable, "on");
|
||||
}
|
||||
params.append("leftlon=0");
|
||||
params.append("rightlon=360");
|
||||
params.append("toplat=90");
|
||||
params.append("bottomlat=-90");
|
||||
params.append("dir=%2F" + directory);
|
||||
|
||||
return QUrl(baseurl + params.join('&'));
|
||||
downloadUrl.appendQuery("leftlon", "0");
|
||||
downloadUrl.appendQuery("rightlon", "360");
|
||||
downloadUrl.appendQuery("toplat", "90");
|
||||
downloadUrl.appendQuery("bottomlat", "-90");
|
||||
downloadUrl.appendQuery("dir", "%2F" + directory);
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
void CWeatherDataGfs::parseGfsFileImpl(const QByteArray &gribData)
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKWXPLUGIN_GFS_H
|
||||
|
||||
#include "g2clib/grib2.h"
|
||||
#include "blackmisc/network/url.h"
|
||||
#include "blackmisc/weather/gridpoint.h"
|
||||
#include "blackmisc/worker.h"
|
||||
#include "blackcore/weatherdata.h"
|
||||
@@ -136,7 +137,7 @@ namespace BlackWxPlugin
|
||||
double surfaceTemperature = 0;
|
||||
};
|
||||
|
||||
QUrl getDownloadUrl() const;
|
||||
BlackMisc::Network::CUrl getDownloadUrl() const;
|
||||
|
||||
void parseGfsFileImpl(const QByteArray &gribData);
|
||||
void findNextGribMessage(unsigned char *buffer, g2int size, g2int iseek, g2int *lskip, g2int *lgrib);
|
||||
|
||||
Reference in New Issue
Block a user