SphericalGeometryCalculus.h 2.43 KB
Newer Older
1 2
#ifndef SphereCalculus_H
#define SphereCalculus_H
3 4

#include <QObject>
5
#include <QGeoCoordinate>
6

7 8
// Abstract class providing methods to do calculations on objects located on a sphere (e.g. earth)
class SphereCalculus : public QObject
9 10 11
{
    Q_OBJECT
public:
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    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);


43 44 45 46

signals:

public slots:
47 48 49 50 51 52

private:
    double          distInsidePoly          (const QGeoCoordinate& c1, const QGeoCoordinate& c2, QList<QGeoCoordinate> polygon);

    double _epsilonMeter; // The accuracy used for distance calculations (unit: m).

53 54
};

55
#endif // SphereCalculus_H