#pragma once

#include <QObject>
#include "WimaArea.h"
#include "WimaTrackerPolyline.h"

class WimaServiceArea : public WimaArea
{
    Q_OBJECT
public:
    WimaServiceArea(QObject* parent = nullptr);
    WimaServiceArea(const WimaServiceArea& other, QObject* parent);
    WimaServiceArea& operator=(const WimaServiceArea &other);

    Q_PROPERTY(const QGeoCoordinate&          takeOffPosition READ takeOffPosition    WRITE setTakeOffPosition    NOTIFY takeOffPositionChanged)
    Q_PROPERTY(const QGeoCoordinate&          landPosition    READ landPosition       WRITE setLandPosition       NOTIFY landPositionChanged)

    // Overrides from WimaPolygon
    QString         mapVisualQML    (void) const { return "WimaServiceAreaMapVisual.qml";}
    QString         editorQML       (void) const { return "WimaServiceAreaEditor.qml";}

    // Property acessors
    const QGeoCoordinate&          takeOffPosition             (void)  const { return _takeOffPosition;}
    const QGeoCoordinate&          landPosition                (void)  const { return _landPosition;}

    // Member Methodes
    void saveToJson(QJsonObject& json);
    bool loadFromJson(const QJsonObject& json, QString& errorString);



    // Friends
    friend void print(const WimaServiceArea& area, QString& outputStr);
    friend void print(const WimaServiceArea& area);

    // static Members
    static const char* wimaServiceAreaName;
signals:
    void takeOffPositionChanged         (void);
    void landPositionChanged            (void);

public slots:
    void setTakeOffPosition             (const QGeoCoordinate& coordinate);
    void setLandPosition                (const QGeoCoordinate& coordinate);

private:
    // Member Methodes
    void init();

    // Members
    QGeoCoordinate      _takeOffPosition;
    QGeoCoordinate      _landPosition;
};

