QGIS API Documentation  3.0.2-Girona (307d082)
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 
28 class CORE_EXPORT QgsGeometryValidator : public QThread
29 {
30  Q_OBJECT
31 
32  public:
33 
37  QgsGeometryValidator( const QgsGeometry &geoemtry, QVector<QgsGeometry::Error> *errors = nullptr, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
38  ~QgsGeometryValidator() override;
39 
40  void run() override;
41  void stop();
42 
44  static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors SIP_OUT, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
45 
46  signals:
47  void errorFound( const QgsGeometry::Error & );
48 
49  public slots:
50  void addError( const QgsGeometry::Error & );
51 
52  private:
53  void validatePolyline( int i, QgsPolylineXY polyline, bool ring = false );
54  void validatePolygon( int i, const QgsPolygonXY &polygon );
55  void checkRingIntersections( int p0, int i0, const QgsPolylineXY &ring0, int p1, int i1, const QgsPolylineXY &ring1 );
56  double distLine2Point( const QgsPointXY &p, QgsVector v, const QgsPointXY &q );
57  bool intersectLines( const QgsPointXY &p, QgsVector v, const QgsPointXY &q, QgsVector w, QgsPointXY &s );
58  bool ringInRing( const QgsPolylineXY &inside, const QgsPolylineXY &outside );
59  bool pointInRing( const QgsPolylineXY &ring, const QgsPointXY &p );
60 
61  QgsGeometry mGeometry;
62  QVector<QgsGeometry::Error> *mErrors;
63  bool mStop;
64  int mErrorCount;
66 };
67 
68 #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:1397
A class to represent a vector.
Definition: qgsvector.h:27
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:1395