QGIS API Documentation 3.41.0-Master (cea29feecf2)
|
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. | |
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... | |
typedef QFlags< Flag > | Flags |
Public Member Functions | |
QgsGeometryCheck (const QgsGeometryCheckContext *context, const QVariantMap &configuration) | |
Create a new geometry check. | |
virtual | ~QgsGeometryCheck ()=default |
virtual QList< QgsGeometryCheckResolutionMethod > | availableResolutionMethods () const |
Returns a list of available resolution methods. | |
virtual CheckType | checkType () const =0 |
Returns the check type. | |
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. | |
virtual QList< Qgis::GeometryType > | compatibleGeometryTypes () const =0 |
A list of geometry types for which this check can be performed. | |
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. | |
const QgsGeometryCheckContext * | context () const |
Returns the context. | |
virtual QString | description () const =0 |
Returns a human readable description for this check. | |
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. | |
virtual QgsGeometryCheck::Flags | flags () const |
Flags for this geometry check. | |
virtual QString | id () const =0 |
Returns an id for this check. | |
virtual bool | isCompatible (QgsVectorLayer *layer) const |
Returns if this geometry check is compatible with layer. | |
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). | |
virtual Q_DECL_DEPRECATED QStringList | resolutionMethods () const |
Returns a list of descriptions for available resolutions for errors. | |
Protected Member Functions | |
QMap< QString, QgsFeatureIds > | allLayerFeatureIds (const QMap< QString, QgsFeaturePool * > &featurePools) const |
Returns all layers and feature ids. | |
void | deleteFeatureGeometryPart (const QMap< QString, QgsFeaturePool * > &featurePools, const QString &layerId, QgsFeature &feature, int partIdx, Changes &changes) const |
Deletes a part of a feature geometry. | |
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. | |
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. | |
double | scaleFactor (const QPointer< QgsVectorLayer > &layer) const |
Determines the scale factor of a layer to the map coordinate reference system. | |
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 219 of file qgsgeometrycheck.h.
typedef QFlags< Flag > QgsGeometryCheck::Flags |
Definition at line 167 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 141 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 128 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 153 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 163 of file qgsgeometrycheck.h.
QgsGeometryCheck::QgsGeometryCheck | ( | const QgsGeometryCheckContext * | context, |
const QVariantMap & | configuration | ||
) |
Create a new geometry check.
Definition at line 28 of file qgsgeometrycheck.cpp.
|
virtualdefault |
|
protected |
Returns all layers and feature ids.
Definition at line 81 of file qgsgeometrycheck.cpp.
|
virtual |
Returns a list of available resolution methods.
Reimplemented in QgsGeometryGapCheck.
Definition at line 58 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns the check type.
Implemented in QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryContainedCheck, QgsGeometryDangleCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryGapCheck, QgsGeometryHoleCheck, QgsGeometryIsValidCheck, QgsGeometryLineIntersectionCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryMissingVertexCheck, QgsGeometryMultipartCheck, QgsGeometryOverlapCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometrySegmentLengthCheck, QgsGeometrySelfContactCheck, QgsGeometrySelfIntersectionCheck, and QgsGeometryTypeCheck.
|
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 QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryContainedCheck, QgsGeometryDangleCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryGapCheck, QgsGeometryHoleCheck, QgsGeometryLineIntersectionCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryMissingVertexCheck, QgsGeometryOverlapCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometrySegmentLengthCheck, and QgsSingleGeometryCheck.
|
pure virtual |
A list of geometry types for which this check can be performed.
Implemented in QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryContainedCheck, QgsGeometryDangleCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryGapCheck, QgsGeometryHoleCheck, QgsGeometryIsValidCheck, QgsGeometryLineIntersectionCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryMissingVertexCheck, QgsGeometryMultipartCheck, QgsGeometryOverlapCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometrySegmentLengthCheck, QgsGeometrySelfContactCheck, QgsGeometrySelfIntersectionCheck, and QgsGeometryTypeCheck.
|
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 241 of file qgsgeometrycheck.h.
|
inline |
|
protected |
Deletes a part of a feature geometry.
Definition at line 112 of file qgsgeometrycheck.cpp.
|
protected |
Deletes a ring in a feature geometry.
Definition at line 139 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns a human readable description for this check.
Implemented in QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryContainedCheck, QgsGeometryDangleCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryGapCheck, QgsGeometryHoleCheck, QgsGeometryIsValidCheck, QgsGeometryLineIntersectionCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryMissingVertexCheck, QgsGeometryMultipartCheck, QgsGeometryOverlapCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometrySegmentLengthCheck, QgsGeometrySelfContactCheck, QgsGeometrySelfIntersectionCheck, QgsGeometrySliverPolygonCheck, and QgsGeometryTypeCheck.
|
virtual |
Fixes the error error with the specified method.
Is executed on the main thread.
Reimplemented in QgsGeometrySelfContactCheck, QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryContainedCheck, QgsGeometryDangleCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryGapCheck, QgsGeometryHoleCheck, QgsGeometryLineIntersectionCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryMissingVertexCheck, QgsGeometryMultipartCheck, QgsGeometryOverlapCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometrySegmentLengthCheck, QgsGeometrySelfIntersectionCheck, and QgsGeometryTypeCheck.
Definition at line 49 of file qgsgeometrycheck.cpp.
|
virtual |
Flags for this geometry check.
Reimplemented in QgsGeometryGapCheck, QgsGeometryMissingVertexCheck, QgsGeometryOverlapCheck, and QgsGeometrySelfIntersectionCheck.
Definition at line 44 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns an id for this check.
Implemented in QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryContainedCheck, QgsGeometryDangleCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryGapCheck, QgsGeometryHoleCheck, QgsGeometryIsValidCheck, QgsGeometryLineIntersectionCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryMissingVertexCheck, QgsGeometryMultipartCheck, QgsGeometryOverlapCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometrySegmentLengthCheck, QgsGeometrySelfContactCheck, QgsGeometrySelfIntersectionCheck, QgsGeometrySliverPolygonCheck, and QgsGeometryTypeCheck.
|
virtual |
Returns if this geometry check is compatible with layer.
By default it checks for the geometry type in compatibleGeometryTypes().
Definition at line 39 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 33 of file qgsgeometrycheck.cpp.
|
protected |
Replaces a part in a feature geometry.
Definition at line 91 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 QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryContainedCheck, QgsGeometryDangleCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryGapCheck, QgsGeometryHoleCheck, QgsGeometryIsValidCheck, QgsGeometryLineIntersectionCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometryMissingVertexCheck, QgsGeometryMultipartCheck, QgsGeometryOverlapCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometrySegmentLengthCheck, QgsGeometrySelfContactCheck, QgsGeometrySelfIntersectionCheck, and QgsGeometryTypeCheck.
Definition at line 76 of file qgsgeometrycheck.cpp.
|
protected |
Determines the scale factor of a layer to the map coordinate reference system.
Definition at line 166 of file qgsgeometrycheck.cpp.
|
protected |
Definition at line 364 of file qgsgeometrycheck.h.
|
protected |
Definition at line 363 of file qgsgeometrycheck.h.