AirMapWeatherInfoManager.h 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/****************************************************************************
 *
 *   (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
12
#include "LifetimeChecker.h"
13

14
#include "AirspaceWeatherInfoProvider.h"
Gus Grubba's avatar
Gus Grubba committed
15
#include "AirMapSharedState.h"
16
#include "QGCGeoBoundingCube.h"
17

Gus Grubba's avatar
Gus Grubba committed
18 19 20
#include <QGeoCoordinate>
#include <QTime>

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

23
/**
Gus Grubba's avatar
Gus Grubba committed
24
 * @file AirMapWeatherInfoManager.h
25 26 27
 * Weather information provided by AirMap.
 */

Gus Grubba's avatar
Gus Grubba committed
28
class AirMapWeatherInfoManager : public AirspaceWeatherInfoProvider, public LifetimeChecker
29 30 31
{
    Q_OBJECT
public:
Gus Grubba's avatar
Gus Grubba committed
32
    AirMapWeatherInfoManager(AirMapSharedState &shared, QObject *parent = nullptr);
33 34

    bool        valid           () override { return _valid; }
Gus Grubba's avatar
Gus Grubba committed
35
    QString     condition       () override { return QString::fromStdString(_weather.condition); }
36
    QString     icon            () override { return _icon; }
Gus Grubba's avatar
Gus Grubba committed
37
    quint32     windHeading     () override { return _weather.wind.heading; }
38
    float       windSpeed       () override { return _weather.wind.speed; }
Gus Grubba's avatar
Gus Grubba committed
39
    quint32     windGusting     () override { return _weather.wind.gusting; }
40
    float       temperature     () override { return _weather.temperature; }
Gus Grubba's avatar
Gus Grubba committed
41
    float       humidity        () override { return _weather.humidity; }
42 43
    float       visibility      () override { return _weather.visibility; }
    float       precipitation   () override { return _weather.precipitation; }
44

45
    void        setROI          (const QGCGeoBoundingCube& roi, bool reset = false) override;
46

Gus Grubba's avatar
Gus Grubba committed
47 48 49
signals:
    void        error           (const QString& what, const QString& airmapdMessage, const QString& airmapdDetails);

50 51 52 53
private:
    void        _requestWeatherUpdate   (const QGeoCoordinate& coordinate);

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