Commit d3d7e4f7 authored by Gus Grubba's avatar Gus Grubba

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.
parent bc10a8d2
......@@ -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<float>(coordinate.longitude());
params.latitude = static_cast<float>(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 {
......
......@@ -18,7 +18,7 @@
#include <QGeoCoordinate>
#include <QTime>
#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;
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment