#include "WimaPolygon.h"

WimaPolygon::WimaPolygon(QObject *parent) :
    QObject                 (parent)
  ,_maxAltitude             (30)
  ,_vehicle                 (nullptr)
  ,_polygon                 (new QGCMapPolygon(this))
{
}

WimaPolygon::WimaPolygon(QGCMapPolygon *other, QObject *parent):
    WimaPolygon(parent)
{
    delete _polygon;
    *_polygon = *other;
}


void WimaPolygon::setMaxAltitude(double alt)
{
    if(alt > 0 && alt != _maxAltitude){
        _maxAltitude = alt;
        emit maxAltitudeChanged();
    }
}


void WimaPolygon::setVehicle(Vehicle *vehicle)
{
    if(_vehicle != vehicle){
        _vehicle = vehicle;
        emit vehicleChanged();
    }
}

QGCMapPolygon* WimaPolygon::splitPolygonArea(int numberOfFractions)
{
    if(numberOfFractions > 0){
        QGCMapPolygon* poly = new QGCMapPolygon(this->polygon(), this);
        return poly;
    }
    return nullptr;
}


