#ifndef SphereCalculus_H #define SphereCalculus_H #include #include #include #include #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 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 &path, const QGeoCoordinate &coordinate); QGeoCoordinate closestVertex (const QList &path, const QGeoCoordinate &coordinate); int nextPolygonIndex (int pathsize, int index); int previousPolygonIndex(int pathsize, int index); JoinPolygonError joinPolygon (QList polygon1, QList polygon2, QList &joinedPolygon); IntersectionType intersects (const Line &line1, const Line &line2, QGeoCoordinate &intersectionPt); QList intersects (const QList &polygon, const Line &line, QList &intersectionList, QList> &neighbourList); bool intersects (const QList &polygon, const Line &line); DijkstraError dijkstraPath (const QList &polygon, const QGeoCoordinate& start, const QGeoCoordinate& end, QList& dijkstraPath); bool isSimplePolygon (const QList &polygon); bool hasClockwiseWinding (const QList &path); void reversePath (QList &path); bool offsetPolygon (QList &polygon, double offset); signals: public slots: private: double distanceInsidePolygon (const QGeoCoordinate& c1, const QGeoCoordinate& c2, QList polygon); double _epsilonMeter; // The accuracy used for distance calculations (unit: m). }; #endif // SphereCalculus_H