QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsgeometryisvalidcheck.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgssinglegeometrycheck.cpp
3 --------------------------------------
4Date : 7.9.2018
5Copyright : (C) 2018 by Matthias Kuhn
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
20
21
22QgsGeometryIsValidCheck::QgsGeometryIsValidCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration )
23 : QgsSingleGeometryCheck( context, configuration )
24{}
25
26QList<Qgis::GeometryType> QgsGeometryIsValidCheck::compatibleGeometryTypes() const
27{
28 return factoryCompatibleGeometryTypes();
29}
30
31QList<QgsSingleGeometryCheckError *> QgsGeometryIsValidCheck::processGeometry( const QgsGeometry &geometry ) const
32{
33 QVector<QgsGeometry::Error> errors;
34
38
39 QgsGeometryValidator validator( geometry, &errors, method );
40
41 QObject::connect( &validator, &QgsGeometryValidator::errorFound, &validator, [&errors]( const QgsGeometry::Error &error ) {
42 errors.append( error );
43 } );
44
45 // We are already on a thread here normally, no reason to start yet another one. Run synchronously.
46 validator.run();
47
48 QList<QgsSingleGeometryCheckError *> result;
49 for ( const auto &error : std::as_const( errors ) )
50 {
51 QgsGeometry errorGeometry;
52 if ( error.hasWhere() )
53 errorGeometry = QgsGeometry( std::make_unique<QgsPoint>( error.where() ) );
54
55 result << new QgsGeometryIsValidCheckError( this, geometry, errorGeometry, error.what() );
56 }
57 return result;
58}
59
61{
62 return QStringList();
63}
65QList<Qgis::GeometryType> QgsGeometryIsValidCheck::factoryCompatibleGeometryTypes()
66{
68}
69
70bool QgsGeometryIsValidCheck::factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP
71{
72 return factoryCompatibleGeometryTypes().contains( layer->geometryType() );
73}
74
75QString QgsGeometryIsValidCheck::factoryDescription()
76{
77 return tr( "Is Valid" );
78}
79
80QString QgsGeometryIsValidCheck::factoryId()
81{
82 return QStringLiteral( "QgsIsValidCheck" );
83}
84
85QgsGeometryCheck::Flags QgsGeometryIsValidCheck::factoryFlags()
86{
88}
89
90QgsGeometryCheck::CheckType QgsGeometryIsValidCheck::factoryCheckType()
91{
93}
95
96QgsGeometryIsValidCheckError::QgsGeometryIsValidCheckError( const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, const QString &errorDescription )
97 : QgsSingleGeometryCheckError( check, geometry, errorLocation )
98 , mDescription( errorDescription )
99{
100}
101
103{
104 return mDescription;
105}
GeometryValidationEngine
Available engines for validating geometries.
Definition qgis.h:1994
@ QgisInternal
Use internal QgsGeometryValidator method.
@ Geos
Use GEOS validation methods.
@ Polygon
Polygons.
Base configuration for geometry checks.
QFlags< Flag > Flags
@ AvailableInValidation
This geometry check should be available in layer validation on the vector layer peroperties.
CheckType
The type of a check.
@ FeatureNodeCheck
The check controls individual nodes.
An error for a QgsGeometryIsValid check.
QgsGeometryIsValidCheckError(const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, const QString &errorDescription)
Creates a new is valid check error.
QString description() const override
A human readable description of this error.
Q_DECL_DEPRECATED QStringList resolutionMethods() const override
Returns a list of descriptions for available resolutions for errors.
QgsGeometryIsValidCheck(const QgsGeometryCheckContext *context, const QVariantMap &configuration)
Creates a new is valid check with the provided context.
QList< QgsSingleGeometryCheckError * > processGeometry(const QgsGeometry &geometry) const override
Check the geometry for errors.
QList< Qgis::GeometryType > compatibleGeometryTypes() const override
A list of geometry types for which this check can be performed.
void errorFound(const QgsGeometry::Error &error)
Sent when an error has been found during the validation process.
A geometry error.
bool hasWhere() const
true if the location available from
QgsPointXY where() const
The coordinates at which the error is located and should be visualized.
QString what() const
A human readable error message containing details about the error.
A geometry is the spatial representation of a feature.
static const QgsSettingsEntryInteger * settingsDigitizingValidateGeometries
Settings entry digitizing validate geometries.
An error from a QgsSingleGeometryCheck.
Base class for geometry checks for a single geometry without any context of the layer or other layers...
Represents a vector layer which manages a vector based data sets.
#define SIP_SKIP
Definition qgis_sip.h:126