From 421df93a4496ec0a11a40aec214b7cc867ce030d Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Thu, 25 Jan 2018 03:12:54 -0500 Subject: [PATCH] Fix case --- qgroundcontrol.pro | 4 +- src/Airmap/AirMapManager.cc | 2 +- src/Airmap/AirMapWeatherInformation.cc | 79 ++++++++++++++++++++++++++++++++++ src/Airmap/AirMapWeatherInformation.h | 60 ++++++++++++++++++++++++++ src/Airmap/AirmapWeatherInformation.cc | 79 ---------------------------------- src/Airmap/AirmapWeatherInformation.h | 60 -------------------------- 6 files changed, 142 insertions(+), 142 deletions(-) create mode 100644 src/Airmap/AirMapWeatherInformation.cc create mode 100644 src/Airmap/AirMapWeatherInformation.h delete mode 100644 src/Airmap/AirmapWeatherInformation.cc delete mode 100644 src/Airmap/AirmapWeatherInformation.h diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 0d8110e..583a5f7 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -1099,7 +1099,7 @@ contains (DEFINES, QGC_AIRMAP_ENABLED) { src/Airmap/AirMapTelemetry.h \ src/Airmap/AirMapTrafficMonitor.h \ src/Airmap/AirMapVehicleManager.h \ - src/Airmap/AirmapWeatherInformation.h \ + src/Airmap/AirMapWeatherInformation.h \ src/Airmap/LifetimeChecker.h \ SOURCES += \ @@ -1112,7 +1112,7 @@ contains (DEFINES, QGC_AIRMAP_ENABLED) { src/Airmap/AirMapTelemetry.cc \ src/Airmap/AirMapTrafficMonitor.cc \ src/Airmap/AirMapVehicleManager.cc \ - src/Airmap/AirmapWeatherInformation.cc \ + src/Airmap/AirMapWeatherInformation.cc \ } else { RESOURCES += \ diff --git a/src/Airmap/AirMapManager.cc b/src/Airmap/AirMapManager.cc index 3c5d0ed..a3886ee 100644 --- a/src/Airmap/AirMapManager.cc +++ b/src/Airmap/AirMapManager.cc @@ -8,7 +8,7 @@ ****************************************************************************/ #include "AirMapManager.h" -#include "AirmapWeatherInformation.h" +#include "AirMapWeatherInformation.h" #include "AirMapRestrictionManager.h" #include "AirMapRulesetsManager.h" #include "AirMapSettings.h" diff --git a/src/Airmap/AirMapWeatherInformation.cc b/src/Airmap/AirMapWeatherInformation.cc new file mode 100644 index 0000000..628f8b0 --- /dev/null +++ b/src/Airmap/AirMapWeatherInformation.cc @@ -0,0 +1,79 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "AirMapWeatherInformation.h" +#include "AirMapSharedState.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 + +AirMapWeatherInformation::AirMapWeatherInformation(AirMapSharedState& shared, QObject *parent) + : QObject(parent) + , _valid(false) + , _windHeading(0) + , _windSpeed(0) + , _windGusting(0) + , _temperature(0) + , _humidity(0.0f) + , _visibility(0) + , _precipitation(0) +{ +} + +void +AirMapWeatherInformation::setROI(QGeoCoordinate center) +{ + //-- If first time or we've moved more than WEATHER_UPDATE_DISTANCE, ask for weather updates. + if(!_lastRoiCenter.isValid() || _lastRoiCenter.distanceTo(center) > WEATHER_UPDATE_DISTANCE) { + _lastRoiCenter = center; + _requestWeatherUpdate(center); + _weatherTime.start(); + } else { + //-- Check weather once every WEATHER_UPDATE_TIME + if(_weatherTime.elapsed() > WEATHER_UPDATE_TIME) { + _requestWeatherUpdate(center); + _weatherTime.start(); + } + } +} + +void +AirMapWeatherInformation::_requestWeatherUpdate(const QGeoCoordinate& coordinate) +{ + if (!_shared.client()) { + qCDebug(AirMapManagerLog) << "No AirMap client instance. Not updating Weather information"; + _valid = false; + 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) { + if (result) { + const Status::Weather& weather = result.value().weather; + AirMapWeatherInformation weatherUpdateInfo; + _valid = true; + _condition = QString::fromStdString(weather.condition); + _icon = QStringLiteral("qrc:/airmapweather/") + QString::fromStdString(weather.icon) + QStringLiteral(".svg"); + _windHeading = weather.wind.heading; + _windSpeed = weather.wind.speed; + _windGusting = weather.wind.gusting; + _temperature = weather.temperature; + _humidity = weather.humidity; + _visibility = weather.visibility; + _precipitation = weather.precipitation; + } else { + _valid = false; + } + emit weatherChanged(); + }); +} diff --git a/src/Airmap/AirMapWeatherInformation.h b/src/Airmap/AirMapWeatherInformation.h new file mode 100644 index 0000000..882f7d4 --- /dev/null +++ b/src/Airmap/AirMapWeatherInformation.h @@ -0,0 +1,60 @@ +/**************************************************************************** + * + * (c) 2017 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include "LifetimeChecker.h" + +#include "AirspaceWeatherInfoProvider.h" + +#include +#include + +/** + * @file AirMapWeatherInformation.h + * Weather information provided by AirMap. + */ + +class AirMapWeatherInformation : public AirspaceWeatherInfoProvider, public LifetimeChecker +{ + Q_OBJECT +public: + AirMapWeatherInformation(AirMapSharedState &shared, QObject *parent = nullptr); + + bool valid () override { return _valid; } + QString condition () override { return _condition; } + QString icon () override { return _icon; } + quint32 windHeading () override { return _windHeading; } + quint32 windSpeed () override { return _windSpeed; } + quint32 windGusting () override { return _windGusting; } + qint32 temperature () override { return _temperature; } + float humidity () override { return _humidity; } + quint32 visibility () override { return _visibility; } + quint32 precipitation () override { return _precipitation; } + + void setROI (const QGeoCoordinate& center) override; + +private: + void _requestWeatherUpdate (const QGeoCoordinate& coordinate); + +private: + bool _valid; + QString _condition; + QString _icon; + quint32 _windHeading; + quint32 _windSpeed; + quint32 _windGusting; + qint32 _temperature; + float _humidity; + quint32 _visibility; + quint32 _precipitation; + //-- Don't check the weather every time the user moves the map + QGeoCoordinate _lastRoiCenter; + QTime _weatherTime; +}; diff --git a/src/Airmap/AirmapWeatherInformation.cc b/src/Airmap/AirmapWeatherInformation.cc deleted file mode 100644 index 8a36aa6..0000000 --- a/src/Airmap/AirmapWeatherInformation.cc +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2016 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -#include "AirmapWeatherInformation.h" -#include "AirMapSharedState.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 - -AirMapWeatherInformation::AirMapWeatherInformation(AirMapSharedState& shared, QObject *parent) - : QObject(parent) - , _valid(false) - , _windHeading(0) - , _windSpeed(0) - , _windGusting(0) - , _temperature(0) - , _humidity(0.0f) - , _visibility(0) - , _precipitation(0) -{ -} - -void -AirMapWeatherInformation::setROI(QGeoCoordinate center) -{ - //-- If first time or we've moved more than WEATHER_UPDATE_DISTANCE, ask for weather updates. - if(!_lastRoiCenter.isValid() || _lastRoiCenter.distanceTo(center) > WEATHER_UPDATE_DISTANCE) { - _lastRoiCenter = center; - _requestWeatherUpdate(center); - _weatherTime.start(); - } else { - //-- Check weather once every WEATHER_UPDATE_TIME - if(_weatherTime.elapsed() > WEATHER_UPDATE_TIME) { - _requestWeatherUpdate(center); - _weatherTime.start(); - } - } -} - -void -AirMapWeatherInformation::_requestWeatherUpdate(const QGeoCoordinate& coordinate) -{ - if (!_shared.client()) { - qCDebug(AirMapManagerLog) << "No AirMap client instance. Not updating Weather information"; - _valid = false; - 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) { - if (result) { - const Status::Weather& weather = result.value().weather; - AirMapWeatherInformation weatherUpdateInfo; - _valid = true; - _condition = QString::fromStdString(weather.condition); - _icon = QStringLiteral("qrc:/airmapweather/") + QString::fromStdString(weather.icon) + QStringLiteral(".svg"); - _windHeading = weather.wind.heading; - _windSpeed = weather.wind.speed; - _windGusting = weather.wind.gusting; - _temperature = weather.temperature; - _humidity = weather.humidity; - _visibility = weather.visibility; - _precipitation = weather.precipitation; - } else { - _valid = false; - } - emit weatherChanged(); - }); -} diff --git a/src/Airmap/AirmapWeatherInformation.h b/src/Airmap/AirmapWeatherInformation.h deleted file mode 100644 index 882f7d4..0000000 --- a/src/Airmap/AirmapWeatherInformation.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** - * - * (c) 2017 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -#pragma once - -#include "LifetimeChecker.h" - -#include "AirspaceWeatherInfoProvider.h" - -#include -#include - -/** - * @file AirMapWeatherInformation.h - * Weather information provided by AirMap. - */ - -class AirMapWeatherInformation : public AirspaceWeatherInfoProvider, public LifetimeChecker -{ - Q_OBJECT -public: - AirMapWeatherInformation(AirMapSharedState &shared, QObject *parent = nullptr); - - bool valid () override { return _valid; } - QString condition () override { return _condition; } - QString icon () override { return _icon; } - quint32 windHeading () override { return _windHeading; } - quint32 windSpeed () override { return _windSpeed; } - quint32 windGusting () override { return _windGusting; } - qint32 temperature () override { return _temperature; } - float humidity () override { return _humidity; } - quint32 visibility () override { return _visibility; } - quint32 precipitation () override { return _precipitation; } - - void setROI (const QGeoCoordinate& center) override; - -private: - void _requestWeatherUpdate (const QGeoCoordinate& coordinate); - -private: - bool _valid; - QString _condition; - QString _icon; - quint32 _windHeading; - quint32 _windSpeed; - quint32 _windGusting; - qint32 _temperature; - float _humidity; - quint32 _visibility; - quint32 _precipitation; - //-- Don't check the weather every time the user moves the map - QGeoCoordinate _lastRoiCenter; - QTime _weatherTime; -};