Newer
Older
#include "Vehicle.h"
#include "qobject.h"
#include "WimaVehicle.h"
#include "WimaArea.h"
#include <QLineF>
#include <QPointF>
#include "QGCGeo.h"
class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas
WimaArea(QObject* parent = nullptr);
WimaArea(QGCMapPolygon* other = nullptr, QObject* parent = nullptr);
~WimaArea();
Q_PROPERTY(double maxAltitude READ maxAltitude WRITE setMaxAltitude NOTIFY maxAltitudeChanged)
Q_PROPERTY(QString mapVisualQML READ mapVisualQML CONSTANT)
Q_PROPERTY(QString editorQML READ editorQML CONSTANT)
Q_PROPERTY(WimaVehicle* vehicle READ vehicle WRITE setVehicle NOTIFY vehicleChanged)
//Property accessors
double maxAltitude (void) const { return _maxAltitude;}
WimaVehicle* vehicle (void) const { return _wimaVehicle;}
virtual QString mapVisualQML (void) const { return "WimaAreaMapVisual.qml";}
virtual QString editorQML (void) const { return "WimaAreaEditor.qml";}
//Property setters
void setMaxAltitude (double alt);
void setVehicle (WimaVehicle* vehicle);
// Member Methodes
/*template <class T>
QList<T*>* splitArea (WimaArea *polygonToSplitt, int numberOfFractions); // use QScopedPointer to store return value
template <class T>
QList<T*>* splitArea (int numberOfFractions); // use QScopedPointer to store return value*/
//iterates over all vertices in _polygon and returns the index of that one closest to coordinate
int getClosestVertexIndex (QGeoCoordinate coordinate);
//iterates over all vertices in _polygon and returns that one closest to coordinate
QGeoCoordinate getClosestVertex (QGeoCoordinate coordinate);
QGCMapPolygon* toQGCPolygon (WimaArea* poly);
static void join (QList<WimaArea*>* polyList, WimaArea* joinedPoly);
/// joins the poly1 and poly2 if possible, joins the polygons to form a simple polygon (no holes)
/// see https://en.wikipedia.org/wiki/Simple_polygon
/// @return the joined polygon of poly1 and poly2 if possible, poly1 else
static void join (WimaArea* poly1, WimaArea* poly2, WimaArea* joinedPoly);
void join (WimaArea* poly);
bool isDisjunct (QList<WimaArea*>* polyList);
bool isDisjunct (WimaArea* poly1, WimaArea* poly2);
/// calculates the next polygon vertex index
/// @return index + 1 if index < poly->count()-1 && index >= 0, or 0 if index == poly->count()-1, -1 else
/// calculates the previous polygon vertex index
/// @return index - 1 if index < poly->count() && index > 0, or poly->count()-1 if index == 0, -1 else
/// checks if line1 and line2 intersect with each other, takes latitude and longitute into account only (height neglected)
/// @param line1 line containing two coordinates, height not taken into account
/// @param line2 line containing two coordinates, height not taken into account
/// @param intersectionPt Coordinate item to store intersection pt. in.
/// @return false on error or no intersection, true else
static bool intersects(QGCMapPolyline* line1, QGCMapPolyline* line2, QGeoCoordinate* intersectionPt);
/// checks if line1 and poly intersect with each other, takes latitude and longitute into account only (height neglected)
/// @param line line containing two coordinates, height not taken into account
/// @param intersectionList Empty list to store intersection points in.
/// @param neighbourList Empty list to store the indices of the neighbours (the two Vertices of poly with the smallest distance to the intersection pt.)
/// @return false on error or no intersection, true else
static bool intersects(QGCMapPolyline* line, WimaArea* poly, QList<QGeoCoordinate>* intersectionList, QList<QPair<int, int>>* neighbourlist);
/// calculates the distance between to geo coordinates, returns the distance if the path lies within the polygon and inf. else.
/// @return the distance if the path lies within the polygon and inf. else.
static double distInsidePoly(QGeoCoordinate *c1, QGeoCoordinate *c2, WimaArea *poly);
/// calculates the shortes path between two geo coordinates inside a polygon using the Dijkstra Algorithm
static void dijkstraPath(QGeoCoordinate *c1, QGeoCoordinate *c2, WimaArea *poly, QGCMapPolyline *dijkstraPath);
// Accurracy used to compute isDisjunct
static const double numericalAccuracy;
signals:
void maxAltitudeChanged (void);
void vehicleChanged (void);
protected:
double _maxAltitude;
WimaVehicle* _wimaVehicle;