Commit 7110c775 authored by Valentin Platzgummer's avatar Valentin Platzgummer

about to finish SphereCalculus

parent e63bb142
......@@ -424,7 +424,8 @@ HEADERS += \
src/Wima/WimaPlanData.h \
src/Wima/WimaJoinedArea.h \
src/Wima/WimaJoinedAreaData.h \
src/Wima/SphericalGeometryCalculus.h
src/Wima/SphericalGeometryCalculus.h \
src/Wima/SphereCalculus.h
SOURCES += \
src/api/QGCCorePlugin.cc \
src/api/QGCOptions.cc \
......@@ -447,7 +448,8 @@ SOURCES += \
src/Wima/WimaMeasurementAreaData.cc \
src/Wima/WimaJoinedArea.cc \
src/Wima/WimaJoinedAreaData.cc \
src/Wima/SphericalGeometryCalculus.cc
src/Wima/SphericalGeometryCalculus.cc \
src/Wima/SphereCalculus.cc
#
# Unit Test specific configuration goes here (requires full debug build with all plugins)
......
This diff is collapsed.
#ifndef SphereCalculus_H
#define SphereCalculus_H
#include <QObject>
#include <QGeoCoordinate>
#include <QPointF>
#include <QLineF>
#include "QGCGeo.h"
// Abstract class providing methods to do calculations on objects located on a sphere (e.g. earth)
class SphereCalculus : public QObject
{
Q_OBJECT
public:
SphereCalculus(QObject *parent = nullptr);
SphereCalculus(const SphereCalculus &other, QObject *parent = nullptr);
SphereCalculus &operator=(const SphereCalculus &other);
typedef QPair<QGeoCoordinate, QGeoCoordinate> Line;
enum JoinPolygonError { NotSimplePolygon1, PolygonJoined, NotSimplePolygon2, Disjoint, PathSizeLow};
enum IntersectionType { NoIntersection, EdgeIntersection, InteriorIntersection, Error};
enum DijkstraError { NoPathFound, PathFound, NotSimplePolygon};
// Property setters
void setEpsilonMeter(double epsilon);
// Property getters
double epsilonMeter() const;
// Member Methodes
int closestVertexIndex (const QList<QGeoCoordinate> &path, const QGeoCoordinate &coordinate);
QGeoCoordinate closestVertex (const QList<QGeoCoordinate> &path, const QGeoCoordinate &coordinate);
int nextPolygonIndex (int pathsize, int index);
int previousPolygonIndex(int pathsize, int index);
JoinPolygonError joinPolygon (QList<QGeoCoordinate> polygon1, QList<QGeoCoordinate> polygon2,
QList<QGeoCoordinate> &joinedPolygon);
IntersectionType intersects (const Line &line1, const Line &line2,
QGeoCoordinate &intersectionPt);
QList<IntersectionType> intersects (const QList<QGeoCoordinate> &polygon, const Line &line,
QList<QGeoCoordinate> &intersectionList, QList<QPair<int, int>> &neighbourList);
bool intersects (const QList<QGeoCoordinate> &polygon, const Line &line);
DijkstraError dijkstraPath (const QList<QGeoCoordinate> &polygon, const QGeoCoordinate& start,
const QGeoCoordinate& end, QList<QGeoCoordinate>& dijkstraPath);
bool isSimplePolygon (const QList<QGeoCoordinate> &polygon);
bool hasClockwiseWinding (const QList<QGeoCoordinate> &path);
void reversePath (QList<QGeoCoordinate> &path);
bool offsetPolygon (QList<QGeoCoordinate> &polygon, double offset);
signals:
public slots:
private:
double distanceInsidePolygon (const QGeoCoordinate& c1, const QGeoCoordinate& c2, QList<QGeoCoordinate> polygon);
double _epsilonMeter; // The accuracy used for distance calculations (unit: m).
};
#endif // SphereCalculus_H
This diff is collapsed.
#ifndef SPHERICALGEOMETRYCALCULUS_H
#define SPHERICALGEOMETRYCALCULUS_H
#ifndef SphereCalculus_H
#define SphereCalculus_H
#include <QObject>
#include <QGeoCoordinate>
class SphericalGeometryCalculus : public QObject
// Abstract class providing methods to do calculations on objects located on a sphere (e.g. earth)
class SphereCalculus : public QObject
{
Q_OBJECT
public:
explicit SphericalGeometryCalculus(QObject *parent = nullptr);
SphereCalculus(QObject *parent = nullptr);
SphereCalculus(const SphereCalculus &other, QObject *parent = nullptr);
SphereCalculus &operator=(const SphereCalculus &other);
enum JoinPolygonError { NotSimplePolygon, Disjoint, NoError, PathSizeLow};
enum IntersectionType { NoIntersection, EdgeIntersection, Inside};
// Property setters
void setEpsilonMeter(double epsilon);
// Property getters
double epsilonMeter() const;
// Member Methodes
int closestVertexIndex (const QList<QGeoCoordinate> &path, const QGeoCoordinate &coordinate) const;
QGeoCoordinate closestVertex (const QList<QGeoCoordinate> &path, const QGeoCoordinate &coordinate) const;
int nextVertexIndex (int index) const;
int previousVertexIndex (int index) const;
JoinPolygonError joinPolygon (const QList<QGeoCoordinate> &polygon1, const QList<QGeoCoordinate> &polygon2,
QList<QGeoCoordinate> &joinedPolygon) const;
IntersectionType intersects (const QList<QGeoCoordinate> &line1, const QList<QGeoCoordinate> &line2,
QGeoCoordinate &intersectionPt)const;
IntersectionType intersects (const QList<QGeoCoordinate> &polygon, const QList<QGeoCoordinate> &line,
QList<QGeoCoordinate> &intersectionList, QList<QPair<int, int>> &neighbourList)const;
IntersectionType intersects (const QList<QGeoCoordinate> &polygon, const QList<QGeoCoordinate> &line) const;
bool dijkstraPath (const QList<QGeoCoordinate> &polygon, const QGeoCoordinate& c1,
const QGeoCoordinate& c2, QList<QGeoCoordinate>& dijkstraPath) const;
bool isSelfIntersecting (const QList<QGeoCoordinate> &path);
signals:
public slots:
private:
double distInsidePoly (const QGeoCoordinate& c1, const QGeoCoordinate& c2, QList<QGeoCoordinate> polygon);
double _epsilonMeter; // The accuracy used for distance calculations (unit: m).
};
#endif // SPHERICALGEOMETRYCALCULUS_H
\ No newline at end of file
#endif // SphereCalculus_H
......@@ -221,7 +221,7 @@ bool WimaArea::join(WimaArea &area1, WimaArea &area2, WimaArea &joinedArea, QStr
QGeoCoordinate protoCurrentVertex = intersectionList.value(minDistIndex);
// take numerical erros into account
if (protoCurrentVertex.distanceTo(currentVertex) > epsilonMeter) {
currentVertex = protoCurrentVertex;
currentVertex = protoCurrentVertexertexCoordinate;
QPair<int, int> neighbours = neighbourList.value(minDistIndex);
protoNextVertex = crossPoly->vertexCoordinate(neighbours.second);
nextVertexIndex = neighbours.second;
......
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