QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
41 QgsFeaturePool *featurePool = featurePools.value( featureIds.firstKey() );
52 const QgsGeometry geometry = layerFeature.geometry();
55 if (
QgsCurvePolygon *polygon = qgsgeometry_cast<QgsCurvePolygon *>( geom ) )
57 processPolygon( polygon, featurePool, errors, layerFeature, feedback );
61 const int numGeometries = collection->numGeometries();
62 for (
int i = 0; i < numGeometries; ++i )
64 if (
QgsCurvePolygon *polygon = qgsgeometry_cast<QgsCurvePolygon *>( collection->geometryN( i ) ) )
66 processPolygon( polygon, featurePool, errors, layerFeature, feedback );
75 Q_UNUSED( featurePools )
78 QMetaEnum metaEnum = QMetaEnum::fromType<QgsGeometryMissingVertexCheck::ResolutionMethod>();
79 if ( !metaEnum.isValid() || !metaEnum.valueToKey( method ) )
86 switch ( methodValue )
118 static QStringList methods = QStringList()
120 << tr(
"Add missing vertex" );
126 return factoryDescription();
132 std::unique_ptr<QgsMultiPolygon> boundaries = std::make_unique<QgsMultiPolygon>();
138 for (
int i = 0; i < numRings; ++i )
145 geomEngine->prepareGeometry();
152 if ( fid == currentFeature.
id() )
155 if ( featurePool->
getFeature( fid, compareFeature ) )
162 while ( vertexIterator.
hasNext() )
165 if ( geomEngine->intersects( &pt ) )
172 bool alreadyReported =
false;
176 if ( error->featureId() == currentFeature.
id() && error->location() ==
QgsPointXY( pt ) )
178 alreadyReported =
true;
182 if ( !alreadyReported )
184 std::unique_ptr<QgsGeometryMissingVertexCheckError> error = std::make_unique<QgsGeometryMissingVertexCheckError>(
this, layerFeature,
QgsPointXY( pt ) );
185 error->setAffectedAreaBBox( contextBoundingBox( polygon, vertexId, pt ) );
186 QMap<QString, QgsFeatureIds> involvedFeatures;
187 involvedFeatures[layerFeature.
layerId()].insert( layerFeature.
feature().
id() );
188 involvedFeatures[featurePool->
layerId()].insert( fid );
189 error->setInvolvedFeatures( involvedFeatures );
191 errors.append( error.release() );
211 double length = std::abs( ptAt.
distance( ptBefore ) ) + std::abs( ptAt.
distance( ptAfter ) );
213 QgsRectangle rect( point.
x() - length / 2, point.
y() - length / 2, point.
x() + length / 2, point.
y() + length / 2 );
224 return factoryCompatibleGeometryTypes();
229 return factoryFlags();
234 return factoryCheckType();
238 QList<QgsWkbTypes::GeometryType> QgsGeometryMissingVertexCheck::factoryCompatibleGeometryTypes()
245 return factoryCompatibleGeometryTypes().contains( layer->geometryType() );
248 QString QgsGeometryMissingVertexCheck::factoryDescription()
250 return tr(
"Missing Vertex" );
253 QString QgsGeometryMissingVertexCheck::factoryId()
255 return QStringLiteral(
"QgsGeometryMissingVertexCheck" );
258 QgsGeometryCheck::Flags QgsGeometryMissingVertexCheck::factoryFlags()
276 return mAffectedAreaBBox;
286 return mInvolvedFeatures;
Q_DECL_DEPRECATED QStringList resolutionMethods() const override
Returns a list of descriptions for available resolutions for errors.
void setFixFailed(const QString &reason)
Set the error status to failed and specify the reason for failure.
void setProgress(double progress)
Sets the current progress for the feedback object.
double distance(double x, double y) const SIP_HOLDGIL
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
Point geometry type, with support for z-dimension and m-values.
@ StatusFixed
The error is fixed.
ValueType
Describes the type of an error value.
const QgsCurve * exteriorRing() const SIP_HOLDGIL
Returns the curve polygon's exterior ring.
QgsFeatureId featureId() const
The id of the feature on which this error has been detected.
Curve polygon geometry type.
QMap< QString, QMap< QgsFeatureId, QList< QgsGeometryCheck::Change > > > Changes
A collection of changes.
void fixError(const QMap< QString, QgsFeaturePool * > &featurePools, QgsGeometryCheckError *error, int method, const QMap< QString, int > &mergeAttributeIndices, Changes &changes) const override
Fixes the error error with the specified method.
QMap< QString, QgsFeatureIds > allLayerFeatureIds(const QMap< QString, QgsFeaturePool * > &featurePools) const
Returns all layers and feature ids.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
@ LayerCheck
The check controls a whole layer (topology checks)
QString layerId() const
The layer id.
void setAffectedAreaBBox(const QgsRectangle &affectedAreaBBox)
Set the bounding box of the affected area.
QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const override
A list of geometry types for which this check can be performed.
QgsFeature feature() const
Returns the feature.
bool getFeature(QgsFeatureId id, QgsFeature &feature)
Retrieves the feature with the specified id into feature.
A rectangle specified with double values.
QgsRectangle affectedAreaBBox() const override
The bounding box of the affected area of the error.
QMap< QString, QgsFeatureIds > toMap() const
bool insertVertex(double x, double y, int beforeVertex)
Insert a new vertex before the given vertex index, ring and item (first number is index 0) If the req...
void adjacentVertices(QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex) const override
Returns the vertices adjacent to a specified vertex within a geometry.
This class implements a geometry check.
int numInteriorRings() const SIP_HOLDGIL
Returns the number of interior rings contained with the curve polygon.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
virtual void updateFeature(QgsFeature &feature)=0
Updates a feature in this pool.
void setFixed(int method)
Set the status to fixed and specify the method that has been used to fix the error.
void setInvolvedFeatures(const QMap< QString, QgsFeatureIds > &involvedFeatures)
The two involved features, that share a common boundary but not all common vertices on this boundary.
QgsGeometryMissingVertexCheckError(const QgsGeometryCheck *check, const QgsGeometryCheckerUtils::LayerFeature &layerFeature, const QgsPointXY &errorLocation, QgsVertexId vidx=QgsVertexId(), const QVariant &value=QVariant(), ValueType valueType=ValueOther)
Create a new missing vertex check error.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
const QgsPointXY & location() const
The location of the error in map units.
QMap< QString, QgsFeatureIds > involvedFeatures() const override
Returns a list of involved features.
Base configuration for geometry checks.
A layer feature combination to uniquely identify and access a feature in a set of layers.
Status status() const
The status of the error.
A list of layers and feature ids for each of these layers.
double closestSegmentWithContext(const QgsPointXY &point, QgsPointXY &minDistPoint, int &nextVertexIndex, int *leftOrRightOfSegment=nullptr, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Searches for the closest segment of geometry to the given point.
const QgsCurve * interiorRing(int i) const SIP_HOLDGIL
Retrieves an interior ring from the curve polygon.
QgsPoint next()
Returns next vertex of the geometry (undefined behavior if hasNext() returns false before calling nex...
QgsGeometryMissingVertexCheck(const QgsGeometryCheckContext *context, const QVariantMap &geometryCheckConfiguration)
Creates a new missing vertex geometry check with context and the provided geometryCheckConfiguration.
QgsGeometryCheck::CheckType checkType() const override
Returns the check type.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QSet< QgsFeatureId > QgsFeatureIds
static QgsPoint closestVertex(const QgsAbstractGeometry &geom, const QgsPoint &pt, QgsVertexId &id)
Returns the closest vertex to a geometry for a specified point.
Abstract base class for all geometries.
const QgsGeometryCheckContext * mContext
A class to represent a 2D point.
@ AvailableInValidation
This geometry check should be available in layer validation on the vector layer peroperties.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
QgsGeometryCheck::Flags flags() const override
Flags for this geometry check.
QString id() const override
Returns an id for this check.
A geometry is the spatial representation of a feature.
Represents a vector layer which manages a vector based data sets.
Contains a set of layers and feature ids in those layers to pass to a geometry check.
CheckType
The type of a check.
Utility class for identifying a unique vertex within a geometry.
const double tolerance
The tolerance to allow for in geometry checks.
QgsVertexIterator vertices() const
Returns a read-only, Java-style iterator for traversal of vertices of all the geometry,...
QIcon icon() const override
Returns an icon that should be shown for this kind of error.
Java-style iterator for traversal of vertices of a geometry.
static std::unique_ptr< QgsGeometryEngine > createGeomEngine(const QgsAbstractGeometry *geometry, double tolerance)
bool hasNext() const
Find out whether there are more vertices.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
double progress() const SIP_HOLDGIL
Returns the current progress reported by the feedback object.
@ AddMissingVertex
Add the missing vertex.
void collectErrors(const QMap< QString, QgsFeaturePool * > &featurePools, QList< QgsGeometryCheckError * > &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids=LayerFeatureIds()) const override
The main worker method.
QString layerId() const
The layer id of the layer.
const QString & layerId() const
The id of the layer on which this error has been detected.
ResolutionMethod
The available resolutions for missing vertex check.
This represents an error reported by a geometry check.
QgsFeatureIds getIntersects(const QgsRectangle &rect) const
Gets all feature ids in the bounding box rect.
QString description() const override
Returns a human readable description for this check.
A feature pool is based on a vector layer and caches features.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QgsPoint vertexAt(QgsVertexId id) const override
Returns the point corresponding to a specified vertex id.