27#include "moc_qgsgeometrycheck.cpp"
37 Q_UNUSED( configuration )
52 Q_UNUSED( featurePools )
64 Q_UNUSED( featurePools )
67 Q_UNUSED( mergeAttributeIndices )
73 QList<QgsGeometryCheckResolutionMethod> fixes;
81 for (
const QString &method : methods )
96 QMap<QString, QgsFeatureIds> featureIds;
99 featureIds.insert( pool->layerId(), pool->allFeatureIds() );
111 geomCollection->removeGeometry( partIdx );
112 geomCollection->addGeometry( newPartGeom );
166 static_cast<QgsCurvePolygon *
>( partGeom )->removeInteriorRing( ringIdx - 1 );
194 const int uniqueIdFieldIndex =
mContext->uniqueIdFieldIndex;
195 if ( uniqueIdFieldIndex == -1 )
200 auto uniqueIdIt = uniqueIds.find( layerFeature.
layerId() );
201 if ( uniqueIdIt == uniqueIds.end() )
203 uniqueIdIt = uniqueIds.insert( layerFeature.
layerId(), QSet<QVariant>() );
205 const QVariant uniqueIdValue = layerFeature.
feature().
attribute( uniqueIdFieldIndex );
206 if ( uniqueIdIt.value().contains( uniqueIdValue ) )
210 uniqueIdIt.value().insert( uniqueIdValue );
Abstract base class for all geometries.
Curve polygon geometry type.
A feature pool is based on a vector layer and caches features.
virtual void updateFeature(QgsFeature &feature)=0
Updates a feature in this pool.
virtual void deleteFeature(QgsFeatureId fid)=0
Removes a feature from this pool.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Base configuration for geometry checks.
This represents an error reported by a geometry check.
Implements a resolution for problems detected in geometry checks.
QMap< QString, QMap< QgsFeatureId, QList< QgsGeometryCheck::Change > > > Changes
A collection of changes.
void deleteFeatureGeometryPart(const QMap< QString, QgsFeaturePool * > &featurePools, const QString &layerId, QgsFeature &feature, int partIdx, Changes &changes) const
Deletes a part of a feature geometry.
virtual QList< QgsGeometryCheckResolutionMethod > availableResolutionMethods() const
Returns a list of available resolution methods.
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.
virtual Q_DECL_DEPRECATED QStringList resolutionMethods() const
Returns a list of descriptions for available resolutions for errors.
const QgsGeometryCheckContext * mContext
@ ChangeRing
This change happens on ring level.
@ ChangeFeature
This change happens on feature level.
@ ChangePart
This change happens on part level.
QMap< QString, QgsFeatureIds > allLayerFeatureIds(const QMap< QString, QgsFeaturePool * > &featurePools) const
Returns all layers and feature ids.
Result checkUniqueId(const QgsGeometryCheckerUtils::LayerFeature layerFeature, QMap< QString, QSet< QVariant > > &uniqueIds) const
Checks that there are no duplicated unique IDs.
Result
Result of the geometry checker operation.
@ DuplicatedUniqueId
Found duplicated unique ID value.
@ Success
Operation completed successfully.
QVariantMap mConfiguration
@ ChangeChanged
Something has been updated.
@ ChangeAdded
Something has been added.
@ ChangeRemoved
Something has been removed.
double scaleFactor(const QPointer< QgsVectorLayer > &layer) const
Determines the scale factor of a layer to the map coordinate reference system.
virtual QgsGeometryCheck::Flags flags() const
Flags for this geometry 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 QList< Qgis::GeometryType > compatibleGeometryTypes() const =0
A list of geometry types for which this check can be performed.
QgsGeometryCheck(const QgsGeometryCheckContext *context, const QVariantMap &configuration)
Create a new geometry check.
const QgsGeometryCheckContext * context() const
Returns the context.
virtual bool isCompatible(QgsVectorLayer *layer) const
Returns if this geometry check is compatible with layer.
virtual Result collectErrors(const QMap< QString, QgsFeaturePool * > &featurePools, QList< QgsGeometryCheckError * > &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids=QgsGeometryCheck::LayerFeatureIds()) const
The main worker method.
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 t...
A layer feature combination to uniquely identify and access a feature in a set of layers.
QString layerId() const
The layer id.
QgsFeature feature() const
Returns the feature.
static QgsAbstractGeometry * getGeomPart(QgsAbstractGeometry *geom, int partIdx)
A geometry is the spatial representation of a feature.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
QgsCoordinateReferenceSystem crs
Represents a vector layer which manages a vector based dataset.
QgsRectangle extent() const final
Returns the extent of the layer.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
Descripts a change to fix a geometry.
A list of layers and feature ids for each of these layers.
Utility class for identifying a unique vertex within a geometry.