QGIS API Documentation
3.6.0-Noosa (5873452)
|
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 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 |
Fix 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 QStringList | resolutionMethods () const =0 |
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 list of geometry types to which this check applies
A list of names for (automated) resolution methods that can be used to fix errors of this type
A description for the geometry check.
A unique id for this check.
One of QgsGeometryCheck.LayerCheck, QgsGeometryCheck.FeatureCheck,QgsGeometryCheck.FeatureNodeCheck
collectErrors(featurePools, errors, messages, feedback, ids)
This method will be called to validate geometries. All geometries which should be validated are passed into this method with the parameter ids and should be retrieved from the available featurePools to make use of caching. New errors should be appended to the error list and other message strings to messages. The method needs to return a tuple (errors, messages).
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:
createGeometryCheck(context, configuration)
Needs to return a new subclassed QgsGeometryCheck object that has been written in the previous step.
A unique id for this geometry check.
A description for this geometry check that can be presented to the user for more explanation.
QgsGeometryCheckFactory::isCompatible(layer)
Returns a boolean that determines if this check is available for a given layer. This often checks for the geometry type of the layer.
Returns additional flags for a geometry check. If unsure return QgsGeometryCheck.AvailableInValidation.
Returns the type of this geometry check.
Finally the geometry check factory needs to be registered in QGIS, so the system is aware of the available geometry checks.
Definition at line 125 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 248 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 177 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 164 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 189 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 199 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 53 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns the check type.
Implemented in QgsGeometryOverlapCheck, QgsGeometryGapCheck, QgsGeometryDuplicateCheck, QgsGeometrySelfIntersectionCheck, QgsGeometryContainedCheck, QgsGeometryIsValidCheck, QgsGeometryMissingVertexCheck, QgsGeometryTypeCheck, QgsGeometryAngleCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometrySegmentLengthCheck, QgsGeometryAreaCheck, QgsGeometryLineIntersectionCheck, QgsGeometryMultipartCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryHoleCheck, QgsGeometrySelfContactCheck, and QgsGeometryDangleCheck.
|
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, QgsGeometryOverlapCheck, QgsGeometryGapCheck, QgsGeometryDuplicateCheck, QgsGeometryContainedCheck, QgsGeometryMissingVertexCheck, QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometrySegmentLengthCheck, QgsGeometryDangleCheck, QgsGeometryLineIntersectionCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateNodesCheck, and QgsGeometryHoleCheck.
|
pure virtual |
A list of geometry types for which this check can be performed.
Implemented in QgsGeometryOverlapCheck, QgsGeometryGapCheck, QgsGeometryDuplicateCheck, QgsGeometrySelfIntersectionCheck, QgsGeometryIsValidCheck, QgsGeometryContainedCheck, QgsGeometryMissingVertexCheck, QgsGeometryTypeCheck, QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometrySegmentLengthCheck, QgsGeometryDangleCheck, QgsGeometryLineIntersectionCheck, QgsGeometryMultipartCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryHoleCheck, and QgsGeometrySelfContactCheck.
|
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 263 of file qgsgeometrycheck.h.
|
inline |
|
protected |
Deletes a part of a feature geometry.
Definition at line 86 of file qgsgeometrycheck.cpp.
|
protected |
Deletes a ring in a feature geometry.
Definition at line 113 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns a human readable description for this check.
Implemented in QgsGeometryOverlapCheck, QgsGeometryGapCheck, QgsGeometryDuplicateCheck, QgsGeometryContainedCheck, QgsGeometrySelfIntersectionCheck, QgsGeometryIsValidCheck, QgsGeometryTypeCheck, QgsGeometryMissingVertexCheck, QgsGeometryAreaCheck, QgsGeometryAngleCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometrySegmentLengthCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryLineIntersectionCheck, QgsGeometryMultipartCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryHoleCheck, QgsGeometrySelfContactCheck, QgsGeometryDangleCheck, and QgsGeometrySliverPolygonCheck.
|
virtual |
Fix the error error with the specified method.
Reimplemented in QgsGeometryOverlapCheck, QgsGeometryGapCheck, QgsGeometryDuplicateCheck, QgsGeometrySelfIntersectionCheck, QgsGeometryContainedCheck, QgsGeometryTypeCheck, QgsGeometryMissingVertexCheck, QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometrySegmentLengthCheck, QgsGeometryLineIntersectionCheck, QgsGeometryMultipartCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryHoleCheck, QgsGeometrySelfContactCheck, and QgsGeometryDangleCheck.
Definition at line 44 of file qgsgeometrycheck.cpp.
|
virtual |
Flags for this geometry check.
Reimplemented in QgsGeometryOverlapCheck, QgsGeometryGapCheck, QgsGeometrySelfIntersectionCheck, and QgsGeometryMissingVertexCheck.
Definition at line 39 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns an id for this check.
Implemented in QgsGeometryOverlapCheck, QgsGeometryGapCheck, QgsGeometryDuplicateCheck, QgsGeometrySelfIntersectionCheck, QgsGeometryIsValidCheck, QgsGeometryContainedCheck, QgsGeometryTypeCheck, QgsGeometryMissingVertexCheck, QgsGeometryAngleCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometrySegmentLengthCheck, QgsGeometryAreaCheck, QgsGeometryLineIntersectionCheck, QgsGeometryMultipartCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryHoleCheck, QgsGeometrySelfContactCheck, QgsGeometryDangleCheck, and QgsGeometrySliverPolygonCheck.
|
virtual |
Returns if this geometry check is compatible with layer.
By default it checks for the geometry type in compatibleGeometryTypes().
Definition at line 34 of file qgsgeometrycheck.cpp.
|
protected |
Replaces a part in a feature geometry.
Definition at line 63 of file qgsgeometrycheck.cpp.
|
pure virtual |
Returns a list of descriptions for available resolutions for errors.
The index will be passed as method
to
Implemented in QgsGeometryOverlapCheck, QgsGeometryGapCheck, QgsGeometryDuplicateCheck, QgsGeometrySelfIntersectionCheck, QgsGeometryContainedCheck, QgsGeometryIsValidCheck, QgsGeometryTypeCheck, QgsGeometryMissingVertexCheck, QgsGeometryAngleCheck, QgsGeometryAreaCheck, QgsGeometryFollowBoundariesCheck, QgsGeometryDegeneratePolygonCheck, QgsGeometryLineLayerIntersectionCheck, QgsGeometrySegmentLengthCheck, QgsGeometryLineIntersectionCheck, QgsGeometryMultipartCheck, QgsGeometryPointCoveredByLineCheck, QgsGeometryPointInPolygonCheck, QgsGeometryDangleCheck, QgsGeometryDuplicateNodesCheck, QgsGeometryHoleCheck, and QgsGeometrySelfContactCheck.
|
protected |
Determines the scale factor of a layer to the map coordinate reference system.
Definition at line 142 of file qgsgeometrycheck.cpp.
|
protected |
Definition at line 376 of file qgsgeometrycheck.h.
|
protected |
Definition at line 375 of file qgsgeometrycheck.h.