QGIS API Documentation  2.99.0-Master (314842d)
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 <QThread>
21 #include "qgsgeometry.h"
22 
26 class CORE_EXPORT QgsGeometryValidator : public QThread
27 {
28  Q_OBJECT
29 
30  public:
32  QgsGeometryValidator( const QgsGeometry *g, QList<QgsGeometry::Error> *errors = nullptr );
34 
35  void run() override;
36  void stop();
37 
39  static void validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &errors );
40 
41  signals:
42  void errorFound( const QgsGeometry::Error & );
43 
44  public slots:
45  void addError( const QgsGeometry::Error & );
46 
47  private:
48  void validatePolyline( int i, QgsPolyline polyline, bool ring = false );
49  void validatePolygon( int i, const QgsPolygon &polygon );
50  void checkRingIntersections( int p0, int i0, const QgsPolyline &ring0, int p1, int i1, const QgsPolyline &ring1 );
51  double distLine2Point( const QgsPoint &p, QgsVector v, const QgsPoint &q );
52  bool intersectLines( const QgsPoint &p, QgsVector v, const QgsPoint &q, QgsVector w, QgsPoint &s );
53  bool ringInRing( const QgsPolyline &inside, const QgsPolyline &outside );
54  bool pointInRing( const QgsPolyline &ring, const QgsPoint &p );
55 
56  QgsGeometry mG;
57  QList<QgsGeometry::Error> *mErrors;
58  bool mStop;
59  int mErrorCount;
60 }; // class QgsGeometryValidator
61 
62 #endif
QVector< QgsPoint > QgsPolyline
Polyline is represented as a vector of points.
Definition: qgsgeometry.h:47
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:79
QVector< QgsPolyline > QgsPolygon
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
Definition: qgsgeometry.h:53
A class to represent a point.
Definition: qgspoint.h:37
A class to represent a vector.
Definition: qgsvector.h:26