QGIS API Documentation  3.21.0-Master (5b68dc587e)
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 
23 #include "qgsgeometry.h"
24 
29 class CORE_EXPORT QgsGeometryValidator : public QThread
30 {
31  Q_OBJECT
32 
33  public:
34 
38  QgsGeometryValidator( const QgsGeometry &geometry, QVector<QgsGeometry::Error> *errors = nullptr, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal );
39  ~QgsGeometryValidator() override;
40 
41  void run() override;
42  void stop();
43 
48  static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors SIP_OUT, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal );
49 
50  signals:
51 
57  void errorFound( const QgsGeometry::Error &error );
58 
68  void validationFinished( const QString &summary );
69 
70  public slots:
71  void addError( const QgsGeometry::Error & );
72 
73  private:
74  void validatePolyline( int i, const QgsLineString *line, bool ring = false );
75  void validatePolygon( int partIndex, const QgsPolygon *polygon );
76  void checkRingIntersections( int partIndex0, int ringIndex0, const QgsLineString *ring0, int partIndex1, int ringIndex1, const QgsLineString *ring1 );
77  double distLine2Point( double px, double py, QgsVector v, double qX, double qY );
78  bool intersectLines( double px, double py, QgsVector v, double qx, double qy, QgsVector w, double &sX, double &sY );
79  bool ringInRing( const QgsLineString *inside, const QgsLineString *outside );
80  bool pointInRing( const QgsLineString *ring, double pX, double pY );
81 
82  QgsGeometry mGeometry;
83  QVector<QgsGeometry::Error> *mErrors;
84  bool mStop;
85  int mErrorCount;
86  Qgis::GeometryValidationEngine mMethod = Qgis::GeometryValidationEngine::QgisInternal;
87 };
88 
89 #endif
GeometryValidationEngine
Available engines for validating geometries.
Definition: qgis.h:687
void validationFinished(const QString &summary)
Sent when the validation is finished.
void errorFound(const QgsGeometry::Error &error)
Sent when an error has been found during the validation process.
A geometry error.
Definition: qgsgeometry.h:2248
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:44
Polygon geometry type.
Definition: qgspolygon.h:34
A class to represent a vector.
Definition: qgsvector.h:30
#define SIP_OUT
Definition: qgis_sip.h:58