QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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( QgsGeometry *g, QList<QgsGeometry::Error> *errors = 0 );
30 
31  void run();
32  void stop();
33 
37  static void validateGeometry( QgsGeometry *g, QList<QgsGeometry::Error> &errors );
38 
39  signals:
40  void errorFound( QgsGeometry::Error );
41 
42  public slots:
43  void addError( QgsGeometry::Error );
44 
45  private:
46  void validatePolyline( int i, QgsPolyline polyline, bool ring = false );
47  void validatePolygon( int i, const QgsPolygon &polygon );
48  void checkRingIntersections( int p0, int i0, const QgsPolyline &ring0, int p1, int i1, const QgsPolyline &ring1 );
49  double distLine2Point( QgsPoint p, QgsVector v, QgsPoint q );
50  bool intersectLines( QgsPoint p, QgsVector v, QgsPoint q, QgsVector w, QgsPoint &s );
51  bool ringInRing( const QgsPolyline &inside, const QgsPolyline &outside );
52  bool pointInRing( const QgsPolyline &ring, const QgsPoint &p );
53 
55  QList<QgsGeometry::Error> *mErrors;
56  bool mStop;
58 }; // class QgsGeometryValidator
59 
60 #endif