WimaArea.h 2.69 KB
Newer Older
1
#pragma once
2

3
#include "QGCMapPolygon.h"
4
#include "QGCMapPolyline.h"
5 6 7
#include "Vehicle.h"
#include "qobject.h"
#include "WimaVehicle.h"
8 9 10 11
#include "WimaArea.h"
#include <QLineF>
#include <QPointF>
#include "QGCGeo.h"
12
#include <QPair>
13

14 15 16
#include "GeoUtilities.h"
#include "PolygonCalculus.h"

17
class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas
18
{
19
    Q_OBJECT
20
public:
21 22
    WimaArea(QObject* parent = nullptr);
    WimaArea(const WimaArea& other, QObject* parent = nullptr);
23
    WimaArea &operator=(const WimaArea &other);
24 25


26 27 28
    Q_PROPERTY(double   maxAltitude     READ maxAltitude    WRITE setMaxAltitude    NOTIFY maxAltitudeChanged)
    Q_PROPERTY(QString  mapVisualQML    READ mapVisualQML                           CONSTANT)
    Q_PROPERTY(QString  editorQML       READ editorQML                              CONSTANT)
29 30

    //Property accessors
31
    double      maxAltitude         (void) const    { return _maxAltitude;}
32

33
    // overrides from WimaArea
34 35
    virtual QString                 mapVisualQML    (void) const { return ""; }
    virtual QString                 editorQML       (void) const { return ""; }
36 37

    // Member Methodes
38 39 40
    int             getClosestVertexIndex   (const QGeoCoordinate& coordinate) const;
    QGeoCoordinate  getClosestVertex        (const QGeoCoordinate& coordinate) const;
    QGCMapPolygon   toQGCPolygon            () const;
41
    bool            join                    (WimaArea &area);
42
    bool            join                    (WimaArea &area, QString &errorString);
43 44 45 46 47 48 49 50
    int             nextVertexIndex         (int index) const;
    int             previousVertexIndex     (int index) const;


    void saveToJson     (QJsonObject& jsonObject);
    bool loadFromJson   (const QJsonObject &jsonObject, QString& errorString);

    // static Methodes
51
    static QGCMapPolygon    toQGCPolygon        (const WimaArea& area);
52
    static bool             join                (const WimaArea &area1, const WimaArea &area2, WimaArea& joinedArea, QString &errorString);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
53
    static bool             join                (const WimaArea &area1, const WimaArea &area2, WimaArea& joinedArea);
54
           bool             isSimplePolygon   ();
55

56 57 58 59
    // Friends
    friend void print(const WimaArea& area, QString& outputString);
    friend void print(const WimaArea& area);

60
    // static Members
61
    // Accurracy used to compute isDisjunct
62
    static const double epsilonMeter;
63 64 65
    static const char*  maxAltitudeName;
    static const char*  wimaAreaName;
    static const char*  areaTypeName;
66 67 68 69

signals:
    void    maxAltitudeChanged      (void);

70
public slots:
71
    void        setMaxAltitude     (double altitude);
72

73
private:
74
    double                  _maxAltitude;
75 76 77

private:
    void init();
78 79
};

80

81 82 83