QGIS API Documentation 3.99.0-Master (d270888f95f)
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
17
21
22#include <QString>
23
24using namespace Qt::StringLiterals;
25
27 : QgsSingleGeometryCheck( context, configuration )
28{}
29
30QList<Qgis::GeometryType> QgsGeometryIsValidCheck::compatibleGeometryTypes() const
31{
32 return factoryCompatibleGeometryTypes();
33}
34
35QList<QgsSingleGeometryCheckError *> QgsGeometryIsValidCheck::processGeometry( const QgsGeometry &geometry ) const
36{
37 QVector<QgsGeometry::Error> errors;
38
42
43 QgsGeometryValidator validator( geometry, &errors, method );
44
45 QObject::connect( &validator, &QgsGeometryValidator::errorFound, &validator, [&errors]( const QgsGeometry::Error &error ) {
46 errors.append( error );
47 } );
48
49 // We are already on a thread here normally, no reason to start yet another one. Run synchronously.
50 validator.run();
51
52 QList<QgsSingleGeometryCheckError *> result;
53 for ( const auto &error : std::as_const( errors ) )
54 {
55 QgsGeometry errorGeometry;
56 if ( error.hasWhere() )
57 errorGeometry = QgsGeometry( std::make_unique<QgsPoint>( error.where() ) );
58
59 result << new QgsGeometryIsValidCheckError( this, geometry, errorGeometry, error.what() );
60 }
61 return result;
62}
63
65{
66 return QStringList();
67}
68
69QList<Qgis::GeometryType> QgsGeometryIsValidCheck::factoryCompatibleGeometryTypes()
70{
72}
73
74bool QgsGeometryIsValidCheck::factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP
75{
76 return factoryCompatibleGeometryTypes().contains( layer->geometryType() );
77}
78
79QString QgsGeometryIsValidCheck::factoryDescription()
80{
81 return tr( "Is Valid" );
82}
83
84QString QgsGeometryIsValidCheck::factoryId()
85{
86 return u"QgsIsValidCheck"_s;
87}
88
89QgsGeometryCheck::Flags QgsGeometryIsValidCheck::factoryFlags()
90{
92}
93
94QgsGeometryCheck::CheckType QgsGeometryIsValidCheck::factoryCheckType()
95{
97}
99
102 , mDescription( errorDescription )
103{
104}
105
107{
108 return mDescription;
109}
GeometryValidationEngine
Available engines for validating geometries.
Definition qgis.h:2142
@ QgisInternal
Use internal QgsGeometryValidator method.
Definition qgis.h:2143
@ Geos
Use GEOS validation methods.
Definition qgis.h:2144
@ Line
Lines.
Definition qgis.h:367
@ Polygon
Polygons.
Definition qgis.h:368
Base configuration for geometry checks.
QFlags< Flag > Flags
@ AvailableInValidation
This geometry check should be available in layer validation on the vector layer properties.
CheckType
The type of a check.
@ FeatureNodeCheck
The check controls individual nodes.
const QgsGeometryCheckContext * context() const
Returns the context.
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.
Validates geometries using the QGIS geometry validation model.
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.
QgsGeometry errorLocation() const
The exact location of the error.
QgsSingleGeometryCheckError(const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, const QgsVertexId &vertexId=QgsVertexId())
Creates a new single geometry check error.
const QgsSingleGeometryCheck * check() const
The check that created this error.
Base class for geometry checks for a single geometry without any context of the layer or other layers...
QgsSingleGeometryCheck(const QgsGeometryCheckContext *context, const QVariantMap &configuration)
Creates a new single geometry check.
Represents a vector layer which manages a vector based dataset.
#define SIP_SKIP
Definition qgis_sip.h:134