QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
25 class QgsCurvePolygon;
26 
31 class CORE_EXPORT QgsGeometryValidator : public QThread
32 {
33  Q_OBJECT
34 
35  public:
36 
40  QgsGeometryValidator( const QgsGeometry &geometry, QVector<QgsGeometry::Error> *errors = nullptr, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal );
41  ~QgsGeometryValidator() override;
42 
43  void run() override;
44  void stop();
45 
50  static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors SIP_OUT, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal );
51 
52  signals:
53 
59  void errorFound( const QgsGeometry::Error &error );
60 
70  void validationFinished( const QString &summary );
71 
72  public slots:
73  void addError( const QgsGeometry::Error & );
74 
75  private:
76  void validatePolyline( int i, const QgsLineString *line, bool ring = false );
77  void validatePolygon( int partIndex, const QgsCurvePolygon *polygon );
78  void checkRingIntersections( int partIndex0, int ringIndex0, const QgsCurve *ring0, int partIndex1, int ringIndex1, const QgsCurve *ring1 );
79  double distLine2Point( double px, double py, QgsVector v, double qX, double qY );
80  bool intersectLines( double px, double py, QgsVector v, double qx, double qy, QgsVector w, double &sX, double &sY );
81  bool ringInRing( const QgsCurve *inside, const QgsCurve *outside );
82  bool pointInRing( const QgsCurve *ring, double pX, double pY );
83 
84  QgsGeometry mGeometry;
85  QVector<QgsGeometry::Error> *mErrors;
86  bool mStop;
87  int mErrorCount;
88  Qgis::GeometryValidationEngine mMethod = Qgis::GeometryValidationEngine::QgisInternal;
89 };
90 
91 #endif
QgsCurve
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsCurvePolygon
Curve polygon geometry type.
Definition: qgscurvepolygon.h:34
QgsGeometry::Error
A geometry error.
Definition: qgsgeometry.h:2404
QgsLineString
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:44
Qgis::GeometryValidationEngine
GeometryValidationEngine
Available engines for validating geometries.
Definition: qgis.h:942
qgis_sip.h
qgsgeometry.h
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsVector
A class to represent a vector. Currently no Z axis / 2.5D support is implemented.
Definition: qgsvector.h:29
QgsGeometryValidator
Definition: qgsgeometryvalidator.h:31