AirMapWeatherInfoManager.h 2.18 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>

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

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 38 39 40 41 42 43
    quint32     windHeading     () override { return _weather.wind.heading; }
    quint32     windSpeed       () override { return _weather.wind.speed; }
    quint32     windGusting     () override { return _weather.wind.gusting; }
    qint32      temperature     () override { return _weather.temperature; }
    float       humidity        () override { return _weather.humidity; }
    quint32     visibility      () override { return _weather.visibility; }
    quint32     precipitation   () override { return _weather.precipitation; }
44

45
    void        setROI          (const QGCGeoBoundingCube& roi) 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 56
    bool                    _valid;
    QString                 _icon;
    airmap::Status::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
};