QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 <QThread>
20 #include "qgsgeometry.h"
21 
25 class CORE_EXPORT QgsGeometryValidator : public QThread
26 {
27  Q_OBJECT
28 
29  public:
31  QgsGeometryValidator( const QgsGeometry *g, QList<QgsGeometry::Error> *errors = nullptr );
33 
34  void run() override;
35  void stop();
36 
38  static void validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &errors );
39 
40  signals:
41  void errorFound( const QgsGeometry::Error& );
42 
43  public slots:
44  void addError( const QgsGeometry::Error& );
45 
46  private:
47  void validatePolyline( int i, QgsPolyline polyline, bool ring = false );
48  void validatePolygon( int i, const QgsPolygon &polygon );
49  void checkRingIntersections( int p0, int i0, const QgsPolyline &ring0, int p1, int i1, const QgsPolyline &ring1 );
50  double distLine2Point( const QgsPoint& p, QgsVector v, const QgsPoint& q );
51  bool intersectLines( const QgsPoint& p, QgsVector v, const QgsPoint& q, QgsVector w, QgsPoint &s );
52  bool ringInRing( const QgsPolyline &inside, const QgsPolyline &outside );
53  bool pointInRing( const QgsPolyline &ring, const QgsPoint &p );
54 
55  QgsGeometry mG;
57  bool mStop;
58  int mErrorCount;
59 }; // class QgsGeometryValidator
60 
61 #endif
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
A class to represent a point.
Definition: qgspoint.h:117
virtual void run()
A class to represent a vector.
Definition: qgspoint.h:32