Skip to content
AirMapWeatherInfoManager.h 2.18 KiB
Newer Older
/****************************************************************************
 *
 *   (c) 2017 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#pragma once

Gus Grubba's avatar
Gus Grubba committed
#include "LifetimeChecker.h"
#include "AirspaceWeatherInfoProvider.h"
Gus Grubba's avatar
Gus Grubba committed
#include "AirMapSharedState.h"
Gus Grubba's avatar
Gus Grubba committed
#include <QGeoCoordinate>
#include <QTime>

#include "airmap/advisory.h"
Gus Grubba's avatar
Gus Grubba committed

Gus Grubba's avatar
Gus Grubba committed
 * @file AirMapWeatherInfoManager.h
 * Weather information provided by AirMap.
 */

Gus Grubba's avatar
Gus Grubba committed
class AirMapWeatherInfoManager : public AirspaceWeatherInfoProvider, public LifetimeChecker
{
    Q_OBJECT
public:
Gus Grubba's avatar
Gus Grubba committed
    AirMapWeatherInfoManager(AirMapSharedState &shared, QObject *parent = nullptr);

    bool        valid           () override { return _valid; }
Gus Grubba's avatar
Gus Grubba committed
    QString     condition       () override { return QString::fromStdString(_weather.condition); }
    QString     icon            () override { return _icon; }
Gus Grubba's avatar
Gus Grubba committed
    quint32     windHeading     () override { return _weather.wind.heading; }
    float       windSpeed       () override { return _weather.wind.speed; }
Gus Grubba's avatar
Gus Grubba committed
    quint32     windGusting     () override { return _weather.wind.gusting; }
    float       temperature     () override { return _weather.temperature; }
Gus Grubba's avatar
Gus Grubba committed
    float       humidity        () override { return _weather.humidity; }
    float       visibility      () override { return _weather.visibility; }
    float       precipitation   () override { return _weather.precipitation; }
    void        setROI          (const QGCGeoBoundingCube& roi) override;
Gus Grubba's avatar
Gus Grubba committed
signals:
    void        error           (const QString& what, const QString& airmapdMessage, const QString& airmapdDetails);

private:
    void        _requestWeatherUpdate   (const QGeoCoordinate& coordinate);

private:
Gus Grubba's avatar
Gus Grubba committed
    bool                    _valid;
    QString                 _icon;
    airmap::Advisory::Weather _weather;
    //-- Don't check the weather every time the user moves the map
Gus Grubba's avatar
Gus Grubba committed
    AirMapSharedState&      _shared;
    QGeoCoordinate          _lastRoiCenter;
    QTime                   _weatherTime;