Commit d1d86825 authored by Valentin Platzgummer's avatar Valentin Platzgummer

about to add poly join fkt

parent d58b6cc4
#include "WimaArea.h"
const double WimaArea::numericalAccuracy = 1e-3; // meters
WimaArea::WimaArea(QObject *parent) :
WimaArea (nullptr, parent)
{
......@@ -108,9 +110,52 @@ QGCMapPolygon* WimaArea::toQGCPolygon(WimaArea *poly)
}
}
QGCMapPolygon *WimaArea::joinPolygons(QList<QGCMapPolygon *> polyList)
QGCMapPolygon *WimaArea::joinPolygons(QList<QGCMapPolygon *>* polyList)
{
return new QGCMapPolygon(this);
}
QGCMapPolygon *WimaArea::joinPolygons(QGCMapPolygon *poly1, QGCMapPolygon *poly2)
{
return new QGCMapPolygon(this);
}
bool WimaArea::isDisjunct(QList<QGCMapPolygon *>* polyList)
{
// needs improvement
if (polyList != nullptr){
for (int i = 0;i < polyList->size()-1; i++) {
QGCMapPolygon* currPoly = polyList->takeAt(i);
for (int j = i+1; i < polyList->size(); j++) {
if (isDisjunct(currPoly, polyList->takeAt(j))) {
return false;
}
}
}
return true;
} else {
qWarning("WimaArea::isDisjunct(polyList): polyList == nullptr!");
return false;
}
}
bool WimaArea::isDisjunct(QGCMapPolygon *poly1, QGCMapPolygon *poly2)
{
if (poly1 != nullptr && poly2 != nullptr) {
QGCMapPolygon* poly1Copy = new QGCMapPolygon(this);
poly1Copy->setPath(poly1->path());
poly1Copy->offset(numericalAccuracy);// take numerical errors in account
for(int i = 0; i < poly2->count(); i++){
if (poly1Copy->containsCoordinate(poly2->vertexCoordinate(i))){
return false;
}
}
return true;
} else {
qWarning("WimaArea::isDisjunct(poly1, poly2): poly1 == nullptr || poly2 == nullptr!");
return false;
}
}
......@@ -40,8 +40,14 @@ public:
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);
QGCMapPolygon* joinPolygons (QList<QGCMapPolygon*> polyList);
QGCMapPolygon* toQGCPolygon (WimaArea* poly);
QGCMapPolygon* joinPolygons (QList<QGCMapPolygon*>* polyList);
QGCMapPolygon* joinPolygons (QGCMapPolygon* poly1, QGCMapPolygon* poly2);
bool isDisjunct (QList<QGCMapPolygon*>* polyList);
bool isDisjunct (QGCMapPolygon* poly1, QGCMapPolygon* poly2);
// Accurracy used to compute isDisjunct
static const double numericalAccuracy;
signals:
void maxAltitudeChanged (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment