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