QGIS API Documentation  2.99.0-Master (d55fa22)
qgsgeometryvalidator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeometryvalidator.h - geometry validation thread
3  -------------------------------------------------------------------
4 Date : 03.01.2012
5 Copyright : (C) 2012 by Juergen E. Fischer
6 email : jef at norbit dot de
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSGEOMETRYVALIDATOR_H
17 #define QGSGEOMETRYVALIDATOR_H
18 
19 #include "qgis_core.h"
20 #include "qgis.h"
21 #include <QThread>
22 #include "qgsgeometry.h"
23 
27 class CORE_EXPORT QgsGeometryValidator : public QThread
28 {
29  Q_OBJECT
30 
31  public:
33  QgsGeometryValidator( const QgsGeometry *g, QList<QgsGeometry::Error> *errors = nullptr );
35 
36  void run() override;
37  void stop();
38 
40  static void validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &errors SIP_OUT );
41 
42  signals:
43  void errorFound( const QgsGeometry::Error & );
44 
45  public slots:
46  void addError( const QgsGeometry::Error & );
47 
48  private:
49  void validatePolyline( int i, QgsPolyline polyline, bool ring = false );
50  void validatePolygon( int i, const QgsPolygon &polygon );
51  void checkRingIntersections( int p0, int i0, const QgsPolyline &ring0, int p1, int i1, const QgsPolyline &ring1 );
52  double distLine2Point( const QgsPoint &p, QgsVector v, const QgsPoint &q );
53  bool intersectLines( const QgsPoint &p, QgsVector v, const QgsPoint &q, QgsVector w, QgsPoint &s );
54  bool ringInRing( const QgsPolyline &inside, const QgsPolyline &outside );
55  bool pointInRing( const QgsPolyline &ring, const QgsPoint &p );
56 
57  QgsGeometry mG;
58  QList<QgsGeometry::Error> *mErrors;
59  bool mStop;
60  int mErrorCount;
61 }; // class QgsGeometryValidator
62 
63 #endif
QVector< QgsPoint > QgsPolyline
Polyline is represented as a vector of points.
Definition: qgsgeometry.h:48
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:96
QVector< QgsPolyline > QgsPolygon
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
Definition: qgsgeometry.h:55
A class to represent a point.
Definition: qgspoint.h:37
A class to represent a vector.
Definition: qgsvector.h:26
#define SIP_OUT
Definition: qgis_sip.h:39