QGIS API Documentation  2.99.0-Master (23ddace)
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:
32 
36  QgsGeometryValidator( const QgsGeometry &geoemtry, QList<QgsGeometry::Error> *errors = nullptr, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
38 
39  void run() override;
40  void stop();
41 
43  static void validateGeometry( const QgsGeometry &geometry, QList<QgsGeometry::Error> &errors SIP_OUT, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
44 
45  signals:
46  void errorFound( const QgsGeometry::Error & );
47 
48  public slots:
49  void addError( const QgsGeometry::Error & );
50 
51  private:
52  void validatePolyline( int i, QgsPolyline polyline, bool ring = false );
53  void validatePolygon( int i, const QgsPolygon &polygon );
54  void checkRingIntersections( int p0, int i0, const QgsPolyline &ring0, int p1, int i1, const QgsPolyline &ring1 );
55  double distLine2Point( const QgsPointXY &p, QgsVector v, const QgsPointXY &q );
56  bool intersectLines( const QgsPointXY &p, QgsVector v, const QgsPointXY &q, QgsVector w, QgsPointXY &s );
57  bool ringInRing( const QgsPolyline &inside, const QgsPolyline &outside );
58  bool pointInRing( const QgsPolyline &ring, const QgsPointXY &p );
59 
60  QgsGeometry mGeometry;
61  QList<QgsGeometry::Error> *mErrors;
62  bool mStop;
63  int mErrorCount;
65 };
66 
67 #endif
A class to represent a 2D point.
Definition: qgspointxy.h:42
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:96
QVector< QgsPointXY > QgsPolyline
Polyline is represented as a vector of points.
Definition: qgsgeometry.h:48
Use internal QgsGeometryValidator method.
Definition: qgsgeometry.h:981
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 vector.
Definition: qgsvector.h:26
#define SIP_OUT
Definition: qgis_sip.h:39
ValidationMethod
Available methods for validating geometries.
Definition: qgsgeometry.h:979