QGIS API Documentation  3.17.0-Master (8af46bc54f)
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_sip.h"
21 #include <QThread>
22 #include "qgsgeometry.h"
23 
28 class CORE_EXPORT QgsGeometryValidator : public QThread
29 {
30  Q_OBJECT
31 
32  public:
33 
37  QgsGeometryValidator( const QgsGeometry &geometry, QVector<QgsGeometry::Error> *errors = nullptr, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
38  ~QgsGeometryValidator() override;
39 
40  void run() override;
41  void stop();
42 
47  static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors SIP_OUT, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
48 
49  signals:
50 
56  void errorFound( const QgsGeometry::Error &error );
57 
67  void validationFinished( const QString &summary );
68 
69  public slots:
70  void addError( const QgsGeometry::Error & );
71 
72  private:
73  void validatePolyline( int i, const QgsLineString *line, bool ring = false );
74  void validatePolygon( int partIndex, const QgsPolygon *polygon );
75  void checkRingIntersections( int partIndex0, int ringIndex0, const QgsLineString *ring0, int partIndex1, int ringIndex1, const QgsLineString *ring1 );
76  double distLine2Point( double px, double py, QgsVector v, double qX, double qY );
77  bool intersectLines( double px, double py, QgsVector v, double qx, double qy, QgsVector w, double &sX, double &sY );
78  bool ringInRing( const QgsLineString *inside, const QgsLineString *outside );
79  bool pointInRing( const QgsLineString *ring, double pX, double pY );
80 
81  QgsGeometry mGeometry;
82  QVector<QgsGeometry::Error> *mErrors;
83  bool mStop;
84  int mErrorCount;
86 };
87 
88 #endif
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:123
Use internal QgsGeometryValidator method.
Definition: qgsgeometry.h:2112
A class to represent a vector.
Definition: qgsvector.h:29
#define SIP_OUT
Definition: qgis_sip.h:58
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:43
ValidationMethod
Available methods for validating geometries.
Definition: qgsgeometry.h:2110
Polygon geometry type.
Definition: qgspolygon.h:33