diff --git a/src/MissionManager/AirMapManager.cc b/src/MissionManager/AirMapManager.cc index c82995a726bcee4a43fc3c9b22be7d5e45cd949d..c6677ebacdc8183f54b6060fbeb4a908357ca8c2 100644 --- a/src/MissionManager/AirMapManager.cc +++ b/src/MissionManager/AirMapManager.cc @@ -903,6 +903,45 @@ void AirMapManager::_error(const QString& what, const QString& airmapdMessage, c qCDebug(AirMapManagerLog) << "Caught error: "<status().get_status_by_point(params, [this, coordinate](const Status::GetStatus::Result& result) { + + if (result) { + + const Status::Weather& weather = result.value().weather; + WeatherInformation weatherUpdateInfo; + + weatherUpdateInfo.condition = QString::fromStdString(weather.condition); + weatherUpdateInfo.icon = QString::fromStdString(weather.icon); + weatherUpdateInfo.windHeading = weather.wind.heading; + weatherUpdateInfo.windSpeed = weather.wind.speed; + weatherUpdateInfo.windGusting = weather.wind.gusting; + weatherUpdateInfo.temperature = weather.temperature; + weatherUpdateInfo.humidity = weather.humidity; + weatherUpdateInfo.visibility = weather.visibility; + weatherUpdateInfo.precipitation = weather.precipitation; + emit weatherUpdate(true, coordinate, weatherUpdateInfo); + + } else { + // TODO: error handling + emit weatherUpdate(false, coordinate, WeatherInformation{}); + } + }); + +} + void AirMapManager::_settingsChanged() { qCDebug(AirMapManagerLog) << "AirMap settings changed"; diff --git a/src/MissionManager/AirMapManager.h b/src/MissionManager/AirMapManager.h index 02363352b7e3bb21f080205e4866efefab0b2ecf..d341879eb8cb91806b50ca9d12bbdd3f26811a2a 100644 --- a/src/MissionManager/AirMapManager.h +++ b/src/MissionManager/AirMapManager.h @@ -349,6 +349,8 @@ public: QString name() const override { return "AirMap"; } + void requestWeatherUpdate(const QGeoCoordinate& coordinate) override; + private slots: void _error(const QString& what, const QString& airmapdMessage, const QString& airmapdDetails); diff --git a/src/MissionManager/AirspaceManagement.cc b/src/MissionManager/AirspaceManagement.cc index ab43a785e28522aa19674cbc470ca224a9bcc47d..6b0aa1d9d4e3631eac53367de1383ed4b09c6d00 100644 --- a/src/MissionManager/AirspaceManagement.cc +++ b/src/MissionManager/AirspaceManagement.cc @@ -42,6 +42,7 @@ AirspaceManager::AirspaceManager(QGCApplication* app, QGCToolbox* toolbox) _roiUpdateTimer.setSingleShot(true); connect(&_roiUpdateTimer, &QTimer::timeout, this, &AirspaceManager::_updateToROI); qmlRegisterUncreatableType("QGroundControl", 1, 0, "AirspaceAuthorization", "Reference only"); + qRegisterMetaType(); } AirspaceManager::~AirspaceManager() diff --git a/src/MissionManager/AirspaceManagement.h b/src/MissionManager/AirspaceManagement.h index 9c3eb2b4e4240f982c54f7218339fd122502eb3e..1a17b6ec496c428f3cfcad775c4bd61a5da549c0 100644 --- a/src/MissionManager/AirspaceManagement.h +++ b/src/MissionManager/AirspaceManagement.h @@ -123,6 +123,20 @@ protected: class AirspaceManagerPerVehicle; class Vehicle; +struct WeatherInformation +{ + QString condition; ///< The overall weather condition. + QString icon; ///< The icon or class of icon that should be used for display purposes. + uint32_t windHeading = 0; ///< The heading in [°]. + uint32_t windSpeed = 0; ///< The speed in [°]. + uint32_t windGusting = 0; + int32_t temperature = 0; ///< The temperature in [°C]. + float humidity = 0.0; + uint32_t visibility = 0; ///< Visibility in [m]. + uint32_t precipitation = 0; ///< The probability of precipitation in [%]. +}; +Q_DECLARE_METATYPE(WeatherInformation); + /** * @class AirspaceManager * Base class for airspace management. There is one (global) instantiation of this @@ -161,6 +175,15 @@ public: */ virtual QString name() const = 0; + /** + * Request weather information update. When done, it will emit the weatherUpdate() signal. + * @param coordinate request update for this coordinate + */ + virtual void requestWeatherUpdate(const QGeoCoordinate& coordinate) = 0; + +signals: + void weatherUpdate(bool success, QGeoCoordinate coordinate, WeatherInformation weather); + private slots: void _restrictionsUpdated(bool success);