From d3d7e4f73e746c8f591a55b357a630b181257abc Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Mon, 23 Jul 2018 13:46:13 -0400 Subject: [PATCH] Replace original weather info with new airmapd weather interface. It seems the icons now use dash instead of underscore. I'm simply replacing dash by underscore wholesale (to match the existing resource names) until I know better. --- src/Airmap/AirMapWeatherInfoManager.cc | 14 +++++++------- src/Airmap/AirMapWeatherInfoManager.h | 12 ++++++------ .../AirspaceWeatherInfoProvider.h | 16 ++++++++-------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Airmap/AirMapWeatherInfoManager.cc b/src/Airmap/AirMapWeatherInfoManager.cc index 62dbd9ba51..00537c1a26 100644 --- a/src/Airmap/AirMapWeatherInfoManager.cc +++ b/src/Airmap/AirMapWeatherInfoManager.cc @@ -10,6 +10,7 @@ #include "AirMapWeatherInfoManager.h" #include "AirMapManager.h" + #define WEATHER_UPDATE_DISTANCE 50000 //-- 50km threshold for weather updates #define WEATHER_UPDATE_TIME 30 * 60 * 60 * 1000 //-- 30 minutes threshold for weather updates @@ -49,18 +50,17 @@ AirMapWeatherInfoManager::_requestWeatherUpdate(const QGeoCoordinate& coordinate emit weatherChanged(); return; } - Status::GetStatus::Parameters params; - params.longitude= coordinate.longitude(); - params.latitude = coordinate.latitude(); - params.weather = true; - _shared.client()->status().get_status_by_point(params, [this, coordinate](const Status::GetStatus::Result& result) { + Advisory::ReportWeather::Parameters params; + params.longitude= static_cast(coordinate.longitude()); + params.latitude = static_cast(coordinate.latitude()); + _shared.client()->advisory().report_weather(params, [this, coordinate](const Advisory::ReportWeather::Result& result) { if (result) { - _weather = result.value().weather; + _weather = result.value(); _valid = true; if(_weather.icon.empty()) { _icon = QStringLiteral("qrc:/airmapweather/unknown.svg"); } else { - _icon = QStringLiteral("qrc:/airmapweather/") + QString::fromStdString(_weather.icon) + QStringLiteral(".svg"); + _icon = QStringLiteral("qrc:/airmapweather/") + QString::fromStdString(_weather.icon).replace("-", "_") + QStringLiteral(".svg"); } qCDebug(AirMapManagerLog) << "Weather Info: " << _valid << "Icon:" << QString::fromStdString(_weather.icon) << "Condition:" << QString::fromStdString(_weather.condition) << "Temp:" << _weather.temperature; } else { diff --git a/src/Airmap/AirMapWeatherInfoManager.h b/src/Airmap/AirMapWeatherInfoManager.h index 9f7a341049..b54b391672 100644 --- a/src/Airmap/AirMapWeatherInfoManager.h +++ b/src/Airmap/AirMapWeatherInfoManager.h @@ -18,7 +18,7 @@ #include #include -#include "airmap/status.h" +#include "airmap/advisory.h" /** * @file AirMapWeatherInfoManager.h @@ -35,12 +35,12 @@ public: QString condition () override { return QString::fromStdString(_weather.condition); } QString icon () override { return _icon; } quint32 windHeading () override { return _weather.wind.heading; } - quint32 windSpeed () override { return _weather.wind.speed; } + float windSpeed () override { return _weather.wind.speed; } quint32 windGusting () override { return _weather.wind.gusting; } - qint32 temperature () override { return _weather.temperature; } + float temperature () override { return _weather.temperature; } float humidity () override { return _weather.humidity; } - quint32 visibility () override { return _weather.visibility; } - quint32 precipitation () override { return _weather.precipitation; } + float visibility () override { return _weather.visibility; } + float precipitation () override { return _weather.precipitation; } void setROI (const QGCGeoBoundingCube& roi) override; @@ -53,7 +53,7 @@ private: private: bool _valid; QString _icon; - airmap::Status::Weather _weather; + airmap::Advisory::Weather _weather; //-- Don't check the weather every time the user moves the map AirMapSharedState& _shared; QGeoCoordinate _lastRoiCenter; diff --git a/src/AirspaceManagement/AirspaceWeatherInfoProvider.h b/src/AirspaceManagement/AirspaceWeatherInfoProvider.h index 5e0de6660d..c1ec41d03c 100644 --- a/src/AirspaceManagement/AirspaceWeatherInfoProvider.h +++ b/src/AirspaceManagement/AirspaceWeatherInfoProvider.h @@ -29,23 +29,23 @@ public: Q_PROPERTY(QString condition READ condition NOTIFY weatherChanged) Q_PROPERTY(QString icon READ icon NOTIFY weatherChanged) Q_PROPERTY(quint32 windHeading READ windHeading NOTIFY weatherChanged) - Q_PROPERTY(quint32 windSpeed READ windSpeed NOTIFY weatherChanged) + Q_PROPERTY(float windSpeed READ windSpeed NOTIFY weatherChanged) Q_PROPERTY(quint32 windGusting READ windGusting NOTIFY weatherChanged) - Q_PROPERTY(qint32 temperature READ temperature NOTIFY weatherChanged) + Q_PROPERTY(float temperature READ temperature NOTIFY weatherChanged) Q_PROPERTY(float humidity READ humidity NOTIFY weatherChanged) - Q_PROPERTY(quint32 visibility READ visibility NOTIFY weatherChanged) - Q_PROPERTY(quint32 precipitation READ precipitation NOTIFY weatherChanged) + Q_PROPERTY(float visibility READ visibility NOTIFY weatherChanged) + Q_PROPERTY(float precipitation READ precipitation NOTIFY weatherChanged) virtual bool valid () = 0; ///< Current weather data is valid virtual QString condition () = 0; ///< The overall weather condition. virtual QString icon () = 0; ///< 2:1 Aspect ratio icon url ready to be used by an Image QML Item virtual quint32 windHeading () = 0; ///< The heading in [°]. - virtual quint32 windSpeed () = 0; ///< The speed in [°]. + virtual float windSpeed () = 0; ///< The speed in [°]. virtual quint32 windGusting () = 0; - virtual qint32 temperature () = 0; ///< The temperature in [°C]. + virtual float temperature () = 0; ///< The temperature in [°C]. virtual float humidity () = 0; - virtual quint32 visibility () = 0; ///< Visibility in [m]. - virtual quint32 precipitation () = 0; ///< The probability of precipitation in [%]. + virtual float visibility () = 0; ///< Visibility in [m]. + virtual float precipitation () = 0; ///< The probability of precipitation in [%]. /** * Set region of interest that should be queried. When finished, the weatherChanged() signal will be emmited. -- GitLab