Commit 29a10bab authored by Valentin Platzgummer's avatar Valentin Platzgummer

join poly edited

parent 20d35238
......@@ -129,23 +129,38 @@ WimaArea *WimaArea::joinPolygons(WimaArea *poly1, WimaArea *poly2)
// continue to walk towards higher indices
QGCMapPolyline lineSegment; // segment of walkerPoly, containing only two coordinates
int currentPolyIndex = 0;
QGeoCoordinate currentVertex = walkerPoly->vertexCoordinate(currentPolyIndex);
// possible nextVertex (if no intersection between currentVertex and protoVertex with crossPoly)
QGeoCoordinate protoNextVertex = walkerPoly->vertexCoordinate(walkerPoly->nextVertexIndex(currentPolyIndex));
do {
QGeoCoordinate currentVertex = walkerPoly->vertexCoordinate(currentPolyIndex);// change req.
QGeoCoordinate nextVertex = walkerPoly->vertexCoordinate(walkerPoly->nextVertexIndex(currentPolyIndex));
joinedPolygon->appendVertex(currentVertex);
QGCMapPolyline walkerPolySegment;
walkerPolySegment.appendVertex(currentVertex);
walkerPolySegment.appendVertex(nextVertex);
walkerPolySegment.appendVertex(protoNextVertex);
QList<QGeoCoordinate*>* intersectionList = intersects(&walkerPolySegment, crossPoly);
QList<QGeoCoordinate>* intersectionList = intersects(&walkerPolySegment, crossPoly);
if (intersectionList != nullptr) {
// todo
if (intersectionList->size() > 1*3) {
} else if ( intersectionList->size() == 1*3) {
// intersectionList->takeAt(0); intersection pt.
// intersectionList->takeAt(1); neighbour of intersec. pt. inside crossPoly, lower index
// intersectionList->takeAt(2); neighbour of intersec. pt. inside crossPoly, higher index
currentVertex = intersectionList->takeAt(0);
protoNextVertex = intersectionList->takeAt(2);
//currentPolyIndex = crossPoly->
} else {
currentPolyIndex++;
currentVertex = walkerPoly->vertexCoordinate(currentPolyIndex);// change req.
protoNextVertex = walkerPoly->vertexCoordinate(walkerPoly->nextVertexIndex(currentPolyIndex));
}
} else {
return nullptr;
}
} while (currentPolyIndex != 0 || walkerPoly != poly1);
return joinedPolygon;
......@@ -264,9 +279,9 @@ QGeoCoordinate* WimaArea::intersects(QGCMapPolyline *geoLine1, QGCMapPolyline *g
}
}
QList<QGeoCoordinate *>* WimaArea::intersects(QGCMapPolyline *line, WimaArea *poly)
QList<QGeoCoordinate>* WimaArea::intersects(QGCMapPolyline *line, WimaArea *poly)
{
QList<QGeoCoordinate*>* intersectionList = new QList<QGeoCoordinate*>();
QList<QGeoCoordinate>* intersectionList = new QList<QGeoCoordinate>();
if (line != nullptr && poly != nullptr) {
if (line->count() == 2 && poly->count() >= 3) {
QVariantList polyPath = poly->path();
......@@ -274,13 +289,17 @@ QList<QGeoCoordinate *>* WimaArea::intersects(QGCMapPolyline *line, WimaArea *po
QGeoCoordinate pt2;
for (int i = 0; i < poly->count(); i++) {
QGCMapPolyline polySegment;
polySegment.appendVertex(polyPath.takeAt(i).value<QGeoCoordinate>());
polySegment.appendVertex(polyPath.takeAt(poly->nextVertexIndex(i)).value<QGeoCoordinate>());
QGeoCoordinate currentVertex = polyPath.takeAt(i).value<QGeoCoordinate>();
QGeoCoordinate nextVertex = polyPath.takeAt(poly->nextVertexIndex(i)).value<QGeoCoordinate>();
polySegment.appendVertex(currentVertex);
polySegment.appendVertex(nextVertex);
QGeoCoordinate* intersectionPoint = intersects(line, &polySegment);
if (intersectionPoint != nullptr){
intersectionList->append(intersectionPoint);
intersectionList->append(*intersectionPoint);
intersectionList->append(currentVertex);
intersectionList->append(nextVertex);
}
}
return intersectionList;
......
......@@ -29,8 +29,8 @@ public:
double maxAltitude (void) const { return _maxAltitude;}
WimaVehicle* vehicle (void) const { return _wimaVehicle;}
QString mapVisualQML (void) const { return "WimaAreaMapVisual.qml";}
QString editorQML (void) const { return "WimaAreaEditor.qml";}
virtual QString mapVisualQML (void) const { return "WimaAreaMapVisual.qml";}
virtual QString editorQML (void) const { return "WimaAreaEditor.qml";}
//Property setters
void setMaxAltitude (double alt);
......@@ -63,11 +63,13 @@ public:
/// @param line1 line containing two coordinates, height not taken into account
/// @param line2 line containing two coordinates, height not taken into account
/// @return the intersection point if line1 intersects line2, nullptr else
QGeoCoordinate* intersects(QGCMapPolyline* line1, QGCMapPolyline* line2);
QGeoCoordinate* intersects(QGCMapPolyline* line1, QGCMapPolyline* line2);
/// 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
/// @return a list of intersection points if line intersects poly, or an empty list else
QList<QGeoCoordinate*>* intersects(QGCMapPolyline* line, WimaArea* poly);
/// @return a list of intersection points and the two neares neighbours of poly to the intersection point if line intersects poly, or an empty list else.
/// The first entry is the first intersec. pt. (if existing). The second and third entries are the nearest neighbours of the first intersec. pt. in poly
/// The fourth entry is the second intersec. pt. (if existing). The fifth and sixth entries are the nearest neighbours of the second intersec. pt. in poly
QList<QGeoCoordinate>* intersects(QGCMapPolyline* line, WimaArea* poly);
// Accurracy used to compute isDisjunct
static const double numericalAccuracy;
......
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