QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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, QgsPolylineXY polyline, bool ring = false );
74  void validatePolygon( int i, const QgsPolygonXY &polygon );
75  void checkRingIntersections( int p0, int i0, const QgsPolylineXY &ring0, int p1, int i1, const QgsPolylineXY &ring1 );
76  double distLine2Point( const QgsPointXY &p, QgsVector v, const QgsPointXY &q );
77  bool intersectLines( const QgsPointXY &p, QgsVector v, const QgsPointXY &q, QgsVector w, QgsPointXY &s );
78  bool ringInRing( const QgsPolylineXY &inside, const QgsPolylineXY &outside );
79  bool pointInRing( const QgsPolylineXY &ring, const QgsPointXY &p );
80 
81  QgsGeometry mGeometry;
82  QVector<QgsGeometry::Error> *mErrors;
83  bool mStop;
84  int mErrorCount;
86 };
87 
88 #endif
A class to represent a 2D point.
Definition: qgspointxy.h:43
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
Definition: qgsgeometry.h:73
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:111
Use internal QgsGeometryValidator method.
Definition: qgsgeometry.h:1883
A class to represent a vector.
Definition: qgsvector.h:29
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
Definition: qgsgeometry.h:49
#define SIP_OUT
Definition: qgis_sip.h:51
ValidationMethod
Available methods for validating geometries.
Definition: qgsgeometry.h:1881