QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgssinglegeometrycheck.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssinglegeometrycheck.h
3  --------------------------------------
4 Date : 6.9.2018
5 Copyright : (C) 2018 by Matthias Kuhn
6 email : [email protected]
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 QGSSINGLEGEOMETRYCHECK_H
17 #define QGSSINGLEGEOMETRYCHECK_H
18 
19 #include <QList>
20 #include <QCoreApplication>
21 
22 #include "qgsgeometry.h"
23 #include "qgsgeometrycheck.h"
24 #include "qgsgeometrycheckerror.h"
25 
26 #include "qgis_analysis.h"
27 
28 class QgsFeature;
30 
39 class ANALYSIS_EXPORT QgsSingleGeometryCheckError
40 {
41  public:
42 
46  QgsSingleGeometryCheckError( const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, const QgsVertexId &vertexId = QgsVertexId() )
47  : mCheck( check )
48  , mGeometry( geometry )
49  , mErrorLocation( errorLocation )
50  , mVertexId( vertexId )
51  {}
52 
53  virtual ~QgsSingleGeometryCheckError() = default;
54 
59  virtual void update( const QgsSingleGeometryCheckError *other );
60 
66  virtual bool isEqual( const QgsSingleGeometryCheckError *other ) const;
67 
71  virtual bool handleChanges( const QList<QgsGeometryCheck::Change> &changes ) SIP_SKIP;
72 
76  virtual QString description() const;
77 
83  const QgsSingleGeometryCheck *check() const;
84 
90  QgsGeometry errorLocation() const;
91 
97  QgsVertexId vertexId() const;
98 
99  protected:
100  const QgsSingleGeometryCheck *mCheck = nullptr;
104 };
105 
116 {
117  public:
118 
123 
127  QgsSingleGeometryCheckError *singleError() const;
128 
129  bool handleChanges( const QgsGeometryCheck::Changes &changes ) override SIP_SKIP;
130 
131  private:
132 #ifdef SIP_RUN
134 #endif
135 
136  QgsSingleGeometryCheckError *mError = nullptr;
137 };
138 
149 class ANALYSIS_EXPORT QgsSingleGeometryCheck : public QgsGeometryCheck
150 {
151  public:
152 
157  const QVariantMap &configuration )
158  : QgsGeometryCheck( context, configuration )
159  {}
160 
161  void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools,
162  QList<QgsGeometryCheckError *> &errors,
163  QStringList &messages,
164  QgsFeedback *feedback = nullptr,
166 
175  virtual QList<QgsSingleGeometryCheckError *> processGeometry( const QgsGeometry &geometry ) const = 0;
176 
177  private:
178 
184  QgsGeometryCheckErrorSingle *convertToGeometryCheckError( QgsSingleGeometryCheckError *singleGeometryCheckError, const QgsGeometryCheckerUtils::LayerFeature &layerFeature ) const;
185 
186 };
187 
188 #endif // QGSSINGLEGEOMETRYCHECK_H
QgsGeometryCheck::Changes
QMap< QString, QMap< QgsFeatureId, QList< QgsGeometryCheck::Change > > > Changes
A collection of changes.
Definition: qgsgeometrycheck.h:213
qgsgeometrycheckerror.h
FINAL
#define FINAL
Definition: qgis_sip.h:228
QgsSingleGeometryCheckError
An error from a QgsSingleGeometryCheck.
Definition: qgssinglegeometrycheck.h:40
QgsSingleGeometryCheckError::mErrorLocation
QgsGeometry mErrorLocation
Definition: qgssinglegeometrycheck.h:102
QgsGeometryCheck::collectErrors
virtual void collectErrors(const QMap< QString, QgsFeaturePool * > &featurePools, QList< QgsGeometryCheckError * > &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids=QgsGeometryCheck::LayerFeatureIds()) const =0
The main worker method.
QgsSingleGeometryCheckError::~QgsSingleGeometryCheckError
virtual ~QgsSingleGeometryCheckError()=default
QgsSingleGeometryCheckError::mVertexId
QgsVertexId mVertexId
Definition: qgssinglegeometrycheck.h:103
QgsSingleGeometryCheck
Base class for geometry checks for a single geometry without any context of the layer or other layers...
Definition: qgssinglegeometrycheck.h:150
QgsGeometryCheck
This class implements a geometry check.
Definition: qgsgeometrycheck.h:92
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgsgeometrycheck.h
QgsGeometryCheckError::handleChanges
virtual bool handleChanges(const QgsGeometryCheck::Changes &changes)
Apply a list of changes.
Definition: qgsgeometrycheckerror.cpp:128
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsSingleGeometryCheckError::QgsSingleGeometryCheckError
QgsSingleGeometryCheckError(const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, const QgsVertexId &vertexId=QgsVertexId())
Creates a new single geometry check error.
Definition: qgssinglegeometrycheck.h:46
QgsGeometryCheckContext
Base configuration for geometry checks.
Definition: qgsgeometrycheckcontext.h:32
QgsGeometryCheckerUtils::LayerFeature
A layer feature combination to uniquely identify and access a feature in a set of layers.
Definition: qgsgeometrycheckerutils.h:52
QgsGeometryCheckError::operator=
const QgsGeometryCheckError & operator=(const QgsGeometryCheckError &)=delete
QgsGeometryCheck::LayerFeatureIds
A list of layers and feature ids for each of these layers.
Definition: qgsgeometrycheck.h:105
QgsGeometryCheckErrorSingle
Wraps a QgsSingleGeometryError into a standard QgsGeometryCheckError.
Definition: qgssinglegeometrycheck.h:116
qgsgeometry.h
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsSingleGeometryCheck::QgsSingleGeometryCheck
QgsSingleGeometryCheck(const QgsGeometryCheckContext *context, const QVariantMap &configuration)
Creates a new single geometry check.
Definition: qgssinglegeometrycheck.h:156
QgsVertexId
Utility class for identifying a unique vertex within a geometry.
Definition: qgsabstractgeometry.h:1059
QgsGeometryCheckerUtils
Contains utilities required for geometry checks.
Definition: qgsgeometrycheckerutils.h:40
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsSingleGeometryCheckError::mGeometry
QgsGeometry mGeometry
Definition: qgssinglegeometrycheck.h:101
QgsGeometryCheckError
This represents an error reported by a geometry check.
Definition: qgsgeometrycheckerror.h:36