QGIS API Documentation
3.18.1-Zürich (202f1bf7e5)
|
This class implements a geometry check. More...
#include <qgsgeometrycheck.h>
Classes | |
struct | Change |
Descripts a change to fix a geometry. More... | |
struct | LayerFeatureIds |
A list of layers and feature ids for each of these layers. More... | |
Public Types | |
typedef QMap< QString, QMap< QgsFeatureId, QList< QgsGeometryCheck::Change > > > | Changes |
A collection of changes. More... | |
enum | ChangeType { ChangeAdded , ChangeRemoved , ChangeChanged } |
Description of the type of a change. More... | |
enum | ChangeWhat { ChangeFeature , ChangePart , ChangeRing , ChangeNode } |
Description of a change to indicate at which level a change occurred. More... | |
enum | CheckType { FeatureNodeCheck , FeatureCheck , LayerCheck } |
The type of a check. More... | |
enum | Flag { AvailableInValidation = 1 << 1 } |
Flags for geometry checks. More... | |
Public Member Functions | |
QgsGeometryCheck (const QgsGeometryCheckContext *context, const QVariantMap &configuration) | |
Create a new geometry check. More... | |
virtual | ~QgsGeometryCheck ()=default |
virtual QList< QgsGeometryCheckResolutionMethod > | availableResolutionMethods () const |
Returns a list of available resolution methods. More... | |
virtual CheckType | checkType () const =0 |
Returns the check type. More... | |
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. More... | |
virtual QList< QgsWkbTypes::GeometryType > | compatibleGeometryTypes () const =0 |
A list of geometry types for which this check can be performed. More... | |
template<class T > | |
T | configurationValue (const QString &name, const QVariant &defaultValue=QVariant()) |
Returns the configuration value with the name, saved in the QGIS settings for this geometry check. More... | |
const QgsGeometryCheckContext * | context () const |
Returns the context. More... | |
virtual QString | description () const =0 |
Returns a human readable description for this check. More... | |
virtual void | fixError (const QMap< QString, QgsFeaturePool * > &featurePools, QgsGeometryCheckError *error, int method, const QMap< QString, int > &mergeAttributeIndices, Changes &changes) const |
Fixes the error error with the specified method. More... | |
virtual QgsGeometryCheck::Flags | flags () const |
Flags for this geometry check. More... | |
virtual QString | id () const =0 |
Returns an id for this check. More... | |
virtual bool | isCompatible (QgsVectorLayer *layer) const |
Returns if this geometry check is compatible with layer. More... | |
virtual void | prepare (const QgsGeometryCheckContext *context, const QVariantMap &configuration) |
Will be run in the main thread before collectErrors is called (which may be run from a background thread). More... | |
virtual Q_DECL_DEPRECATED QStringList | resolutionMethods () const |
Returns a list of descriptions for available resolutions for errors. More... | |
Protected Member Functions | |
QMap< QString, QgsFeatureIds > | allLayerFeatureIds (const QMap< QString, QgsFeaturePool * > &featurePools) const |
Returns all layers and feature ids. More... | |
void | deleteFeatureGeometryPart (const QMap< QString, QgsFeaturePool * > &featurePools, const QString &layerId, QgsFeature &feature, int partIdx, Changes &changes) const |
Deletes a part of a feature geometry. More... | |
void | deleteFeatureGeometryRing (const QMap< QString, QgsFeaturePool * > &featurePools, const QString &layerId, QgsFeature &feature, int partIdx, int ringIdx, Changes &changes) const |
Deletes a ring in a feature geometry. More... | |
void | replaceFeatureGeometryPart (const QMap< QString, QgsFeaturePool * > &featurePools, const QString &layerId, QgsFeature &feature, int partIdx, QgsAbstractGeometry *newPartGeom, Changes &changes) const |
Replaces a part in a feature geometry. More... | |
double | scaleFactor (const QPointer< QgsVectorLayer > &layer) const |
Determines the scale factor of a layer to the map coordinate reference system. More... | |
Protected Attributes | |
QVariantMap | mConfiguration |
const QgsGeometryCheckContext * | mContext |
This class implements a geometry check.
Geometry checks run over a set of features and can detect errors like topological or other issues which are reported in the geometry validation panel in QGIS and help a user to create valid geometries.
Implementing a custom geometry check consists of the following parts
A new subclass of QgsGeometryCheck needs to be written and at least the following abstract methods need to be implemented:
A Geometry check factory manages meta information for checks. There will always be one single geometry check factory created per check type, but it's possible that multiple QgsGeometryCheck instances are created and used in parallel.
A new subclass of QgsGeometryCheckFactory needs to be written and at least the following abstract methods need to be implemented:
Finally the geometry check factory needs to be registered in QGIS, so the system is aware of the available geometry checks.
Definition at line 91 of file qgsgeometrycheck.h.
typedef QMap<QString, QMap<QgsFeatureId, QList<QgsGeometryCheck::Change> > > QgsGeometryCheck::Changes |
A collection of changes.
Grouped by layer id and feature id.
Definition at line 213 of file qgsgeometrycheck.h.
Description of the type of a change.
Enumerator | |
---|---|
ChangeAdded | Something has been added. |
ChangeRemoved | Something has been removed. |
ChangeChanged | Something has been updated. |
Definition at line 142 of file qgsgeometrycheck.h.
Description of a change to indicate at which level a change occurred.
Enumerator | |
---|---|
ChangeFeature | This change happens on feature level. |
ChangePart | This change happens on part level. |
ChangeRing | This change happens on ring level. |
ChangeNode | This change happens on node level. |
Definition at line 129 of file qgsgeometrycheck.h.
The type of a check.
Enumerator | |
---|---|
FeatureNodeCheck | The check controls individual nodes. |
FeatureCheck | The check controls geometries as a whole. |
LayerCheck | The check controls a whole layer (topology checks) |
Definition at line 154 of file qgsgeometrycheck.h.
Flags for geometry checks.
Enumerator | |
---|---|
AvailableInValidation | This geometry check should be available in layer validation on the vector layer peroperties. |
Definition at line 164 of file qgsgeometrycheck.h.
QgsGeometryCheck::QgsGeometryCheck | ( | const QgsGeometryCheckContext * | context, |
const QVariantMap & | configuration | ||
) |
Create a new geometry check.
Definition at line 29 of file qgsgeometrycheck.cpp.
|
virtualdefault |
|
protected |
Returns all layers and feature ids.
Definition at line 82 of file qgsgeometrycheck.cpp.
|
virtual |
Returns a list of available resolution methods.
Reimplemented in QgsGeometryGapCheck.
Definition at line 59 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns the check type.
Implemented in QgsGeometryTypeCheck, QgsGeometrySelfIntersectionCheck, QgsGeometrySelfContactCheck, QgsGeometrySegmentLengthCheck, QgsGeometryPointInPolygonCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryOverlapCheck, QgsGeometryMultipartCheck, QgsGeometryMissingVertexCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryLineIntersectionCheck, QgsGeometryIsValidCheck, QgsGeometryHoleCheck, QgsGeometryGapCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryDuplicateCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDangleCheck, QgsGeometryContainedCheck, QgsGeometryAreaCheck, and QgsGeometryAngleCheck.
|
pure virtual |
The main worker method.
Check all features available from featurePools and write errors found to errors. Other status messages can be written to messages. Progress should be reported to feedback. Only features and layers listed in ids should be checked.
Implemented in QgsSingleGeometryCheck, QgsGeometrySegmentLengthCheck, QgsGeometryPointInPolygonCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryOverlapCheck, QgsGeometryMissingVertexCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryLineIntersectionCheck, QgsGeometryHoleCheck, QgsGeometryGapCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryDuplicateCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDangleCheck, QgsGeometryContainedCheck, QgsGeometryAreaCheck, and QgsGeometryAngleCheck.
|
pure virtual |
A list of geometry types for which this check can be performed.
Implemented in QgsGeometryTypeCheck, QgsGeometrySelfIntersectionCheck, QgsGeometrySelfContactCheck, QgsGeometrySegmentLengthCheck, QgsGeometryPointInPolygonCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryOverlapCheck, QgsGeometryMultipartCheck, QgsGeometryMissingVertexCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryLineIntersectionCheck, QgsGeometryIsValidCheck, QgsGeometryHoleCheck, QgsGeometryGapCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryDuplicateCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDangleCheck, QgsGeometryContainedCheck, QgsGeometryAreaCheck, and QgsGeometryAngleCheck.
|
inline |
Returns the configuration value with the name, saved in the QGIS settings for this geometry check.
If no configuration could be found, defaultValue is returned.
Definition at line 235 of file qgsgeometrycheck.h.
|
inline |
|
protected |
Deletes a part of a feature geometry.
Definition at line 115 of file qgsgeometrycheck.cpp.
|
protected |
Deletes a ring in a feature geometry.
Definition at line 142 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns a human readable description for this check.
Implemented in QgsGeometryTypeCheck, QgsGeometrySliverPolygonCheck, QgsGeometrySelfIntersectionCheck, QgsGeometrySelfContactCheck, QgsGeometrySegmentLengthCheck, QgsGeometryPointInPolygonCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryOverlapCheck, QgsGeometryMultipartCheck, QgsGeometryMissingVertexCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryLineIntersectionCheck, QgsGeometryIsValidCheck, QgsGeometryHoleCheck, QgsGeometryGapCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryDuplicateCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDangleCheck, QgsGeometryContainedCheck, QgsGeometryAreaCheck, and QgsGeometryAngleCheck.
|
virtual |
Fixes the error error with the specified method.
Is executed on the main thread.
Reimplemented in QgsGeometryTypeCheck, QgsGeometrySelfIntersectionCheck, QgsGeometrySegmentLengthCheck, QgsGeometryPointInPolygonCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryOverlapCheck, QgsGeometryMultipartCheck, QgsGeometryMissingVertexCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryLineIntersectionCheck, QgsGeometryHoleCheck, QgsGeometryGapCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryDuplicateCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDangleCheck, QgsGeometryContainedCheck, QgsGeometryAreaCheck, QgsGeometryAngleCheck, and QgsGeometrySelfContactCheck.
Definition at line 50 of file qgsgeometrycheck.cpp.
|
virtual |
Flags for this geometry check.
Reimplemented in QgsGeometrySelfIntersectionCheck, QgsGeometryOverlapCheck, QgsGeometryMissingVertexCheck, and QgsGeometryGapCheck.
Definition at line 45 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns an id for this check.
Implemented in QgsGeometryTypeCheck, QgsGeometrySliverPolygonCheck, QgsGeometrySelfIntersectionCheck, QgsGeometrySelfContactCheck, QgsGeometrySegmentLengthCheck, QgsGeometryPointInPolygonCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryOverlapCheck, QgsGeometryMultipartCheck, QgsGeometryMissingVertexCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryLineIntersectionCheck, QgsGeometryIsValidCheck, QgsGeometryHoleCheck, QgsGeometryGapCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryDuplicateCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDangleCheck, QgsGeometryContainedCheck, QgsGeometryAreaCheck, and QgsGeometryAngleCheck.
|
virtual |
Returns if this geometry check is compatible with layer.
By default it checks for the geometry type in compatibleGeometryTypes().
Definition at line 40 of file qgsgeometrycheck.cpp.
|
virtual |
Will be run in the main thread before collectErrors is called (which may be run from a background thread).
Reimplemented in QgsGeometryGapCheck.
Definition at line 34 of file qgsgeometrycheck.cpp.
|
protected |
Replaces a part in a feature geometry.
Definition at line 92 of file qgsgeometrycheck.cpp.
|
virtual |
Returns a list of descriptions for available resolutions for errors.
The index will be passed as method
to
Reimplemented in QgsGeometryTypeCheck, QgsGeometrySelfIntersectionCheck, QgsGeometrySelfContactCheck, QgsGeometrySegmentLengthCheck, QgsGeometryPointInPolygonCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryOverlapCheck, QgsGeometryMultipartCheck, QgsGeometryMissingVertexCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryLineIntersectionCheck, QgsGeometryIsValidCheck, QgsGeometryHoleCheck, QgsGeometryGapCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryDuplicateCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDangleCheck, QgsGeometryContainedCheck, QgsGeometryAreaCheck, and QgsGeometryAngleCheck.
Definition at line 77 of file qgsgeometrycheck.cpp.
|
protected |
Determines the scale factor of a layer to the map coordinate reference system.
Definition at line 171 of file qgsgeometrycheck.cpp.
|
protected |
Definition at line 359 of file qgsgeometrycheck.h.
|
protected |
Definition at line 358 of file qgsgeometrycheck.h.