AirMapWeatherInformation.h 2.14 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

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

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

22 23 24 25 26 27 28 29 30 31 32 33
/**
 * @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; }
Gus Grubba's avatar
Gus Grubba committed
34
    QString     condition       () override { return QString::fromStdString(_weather.condition); }
35
    QString     icon            () override { return _icon; }
Gus Grubba's avatar
Gus Grubba committed
36 37 38 39 40 41 42
    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; }
43 44 45

    void        setROI          (const QGeoCoordinate& center) override;

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

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

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