QGIS API Documentation 3.29.0-Master (8c80f25a4f)
qgsgeometryvalidator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgeometryvalidator.h - geometry validation thread
3 -------------------------------------------------------------------
4Date : 03.01.2012
5Copyright : (C) 2012 by Juergen E. Fischer
6email : 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_sip.h"
21#include <QThread>
22
23#include "qgsgeometry.h"
24
25class QgsCurvePolygon;
26
31class CORE_EXPORT QgsGeometryValidator : public QThread
32{
33 Q_OBJECT
34
35 public:
36
40 QgsGeometryValidator( const QgsGeometry &geometry, QVector<QgsGeometry::Error> *errors = nullptr, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal );
41 ~QgsGeometryValidator() override;
42
43 void run() override;
44 void stop();
45
50 static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors SIP_OUT, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal );
51
52 signals:
53
59 void errorFound( const QgsGeometry::Error &error );
60
70 void validationFinished( const QString &summary );
71
72 public slots:
73 void addError( const QgsGeometry::Error & );
74
75 private:
76 void validatePolyline( int i, const QgsLineString *line, bool ring = false );
77 void validatePolygon( int partIndex, const QgsCurvePolygon *polygon );
78 void checkRingIntersections( int partIndex0, int ringIndex0, const QgsCurve *ring0, int partIndex1, int ringIndex1, const QgsCurve *ring1 );
79 double distLine2Point( double px, double py, QgsVector v, double qX, double qY );
80 bool intersectLines( double px, double py, QgsVector v, double qx, double qy, QgsVector w, double &sX, double &sY );
81 bool ringInRing( const QgsCurve *inside, const QgsCurve *outside );
82 bool pointInRing( const QgsCurve *ring, double pX, double pY );
83
84 QgsGeometry mGeometry;
85 QVector<QgsGeometry::Error> *mErrors;
86 bool mStop;
87 int mErrorCount;
88 Qgis::GeometryValidationEngine mMethod = Qgis::GeometryValidationEngine::QgisInternal;
89};
90
91#endif
GeometryValidationEngine
Available engines for validating geometries.
Definition: qgis.h:1137
Curve polygon geometry type.
Abstract base class for curved geometry type.
Definition: qgscurve.h:36
void validationFinished(const QString &summary)
Sent when the validation is finished.
void errorFound(const QgsGeometry::Error &error)
Sent when an error has been found during the validation process.
A geometry error.
Definition: qgsgeometry.h:2477
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:164
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:45
A class to represent a vector.
Definition: qgsvector.h:30
#define SIP_OUT
Definition: qgis_sip.h:58