AirMapAdvisoryManager.h 2.5 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
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 13
#include "QmlObjectListModel.h"

Gus Grubba's avatar
Gus Grubba committed
14 15 16 17 18 19 20 21 22 23
#include "LifetimeChecker.h"

#include "AirspaceAdvisoryProvider.h"
#include "AirMapSharedState.h"

#include <QGeoCoordinate>

#include "airmap/status.h"

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

Gus Grubba's avatar
Gus Grubba committed
28 29
//-----------------------------------------------------------------------------
class AirMapAdvisory : public AirspaceAdvisory
Gus Grubba's avatar
Gus Grubba committed
30 31
{
    Q_OBJECT
Gus Grubba's avatar
Gus Grubba committed
32
    friend class AirMapAdvisoryManager;
Gus Grubba's avatar
Gus Grubba committed
33
public:
Gus Grubba's avatar
Gus Grubba committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
    AirMapAdvisory (QObject* parent = NULL);
    QString         id              () override { return _id; }
    QString         name            () override { return _name; }
    AdvisoryType    type            () override { return _type; }
    QGeoCoordinate  coordinates     () override { return _coordinates; }
    qreal           radius          () override { return _radius; }
    AirspaceAdvisoryProvider::AdvisoryColor color () override { return _color; }
private:
    QString         _id;
    QString         _name;
    AdvisoryType    _type;
    QGeoCoordinate  _coordinates;
    qreal           _radius;
    AirspaceAdvisoryProvider::AdvisoryColor _color;
};
Gus Grubba's avatar
Gus Grubba committed
49

Gus Grubba's avatar
Gus Grubba committed
50
//-----------------------------------------------------------------------------
Gus Grubba's avatar
Gus Grubba committed
51
class AirMapAdvisoryManager : public AirspaceAdvisoryProvider, public LifetimeChecker
Gus Grubba's avatar
Gus Grubba committed
52 53 54
{
    Q_OBJECT
public:
Gus Grubba's avatar
Gus Grubba committed
55
    AirMapAdvisoryManager                    (AirMapSharedState &shared, QObject *parent = nullptr);
Gus Grubba's avatar
Gus Grubba committed
56 57 58 59
    bool                valid           () override { return _valid; }
    AdvisoryColor       airspaceColor   () override { return _airspaceColor; }
    QmlObjectListModel* airspaces       () override { return &_airspaces; }
    void                setROI          (const QGeoCoordinate& center, double radiusMeters) override;
Gus Grubba's avatar
Gus Grubba committed
60
signals:
Gus Grubba's avatar
Gus Grubba committed
61
    void                error           (const QString& what, const QString& airmapdMessage, const QString& airmapdDetails);
Gus Grubba's avatar
Gus Grubba committed
62
private:
Gus Grubba's avatar
Gus Grubba committed
63
    void            _requestAdvisories  (const QGeoCoordinate& coordinate, double radiusMeters);
Gus Grubba's avatar
Gus Grubba committed
64 65 66 67
private:
    bool                _valid;
    AirMapSharedState&  _shared;
    QGeoCoordinate      _lastRoiCenter;
Gus Grubba's avatar
Gus Grubba committed
68 69
    QmlObjectListModel  _airspaces;
    AdvisoryColor       _airspaceColor;
Gus Grubba's avatar
Gus Grubba committed
70
};