Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgsgeometryvalidator.h - geometry validation thread 00003 ------------------------------------------------------------------- 00004 Date : 03.01.2012 00005 Copyright : (C) 2012 by Juergen E. Fischer 00006 email : jef at norbit dot de 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 00016 #ifndef QGSGEOMETRYVALIDATOR_H 00017 #define QGSGEOMETRYVALIDATOR_H 00018 00019 #include <QThread> 00020 #include "qgsgeometry.h" 00021 00022 class CORE_EXPORT QgsGeometryValidator : public QThread 00023 { 00024 Q_OBJECT; 00025 00026 public: 00028 QgsGeometryValidator( QgsGeometry *g, QList<QgsGeometry::Error> *errors = 0 ); 00029 ~QgsGeometryValidator(); 00030 00031 void run(); 00032 void stop(); 00033 00037 static void validateGeometry( QgsGeometry *g, QList<QgsGeometry::Error> &errors ); 00038 00039 signals: 00040 void errorFound( QgsGeometry::Error ); 00041 00042 public slots: 00043 void addError( QgsGeometry::Error ); 00044 00045 private: 00046 void validatePolyline( int i, QgsPolyline polyline, bool ring = false ); 00047 void validatePolygon( int i, const QgsPolygon &polygon ); 00048 void checkRingIntersections( int p0, int i0, const QgsPolyline &ring0, int p1, int i1, const QgsPolyline &ring1 ); 00049 double distLine2Point( QgsPoint p, QgsVector v, QgsPoint q ); 00050 bool intersectLines( QgsPoint p, QgsVector v, QgsPoint q, QgsVector w, QgsPoint &s ); 00051 bool ringInRing( const QgsPolyline &inside, const QgsPolyline &outside ); 00052 bool pointInRing( const QgsPolyline &ring, const QgsPoint &p ); 00053 00054 QgsGeometry mG; 00055 QList<QgsGeometry::Error> *mErrors; 00056 bool mStop; 00057 int mErrorCount; 00058 }; // class QgsGeometryValidator 00059 00060 #endif