40 if ( change.vidx.vertex == mIntersection.
segment1 ||
41 change.vidx.vertex == mIntersection.
segment1 + 1 ||
42 change.vidx.vertex == mIntersection.
segment2 ||
43 change.vidx.vertex == mIntersection.
segment2 + 1 )
47 else if ( change.vidx.vertex >= 0 )
49 if ( change.vidx.vertex < mIntersection.
segment1 )
53 if ( change.vidx.vertex < mIntersection.
segment2 )
67 mIntersection.
point = err->mIntersection.
point;
95 bool ringIsClosed =
false;
115 if ( method == NoChange )
119 else if ( method == ToMultiObject || method == ToSingleObjects )
123 bool ring1EndsWithS =
false;
124 bool ring2EndsWithS =
false;
125 for (
int i = 0; i < nVerts; ++i )
127 if ( i <= inter.segment1 || i >= inter.
segment2 + 1 )
130 ring1EndsWithS =
false;
134 ring2EndsWithS =
true;
140 ring2EndsWithS =
true;
144 ring1EndsWithS =
false;
151 ring2EndsWithS =
true;
153 if ( ringIsClosed || ring1EndsWithS )
154 ring1.append( ring1.front() );
155 if ( ringIsClosed || ring2EndsWithS )
156 ring2.append( ring2.front() );
158 if ( ring1.size() < 3 + ( ringIsClosed || ring1EndsWithS ) || ring2.size() < 3 + ( ringIsClosed || ring2EndsWithS ) )
160 error->
setFixFailed( tr(
"Resulting geometry is degenerate" ) );
170 if ( dynamic_cast<QgsCurvePolygon *>( part ) )
179 changes[error->
layerId()][feature.
id()].append(
Change( ChangeRing, ChangeRemoved, vidx ) );
199 if ( !geomEnginePoly1->contains( poly->
interiorRing( i ) ) )
201 if ( geomEnginePoly2->contains( poly->
interiorRing( i ) ) )
211 if ( method == ToMultiObject )
214 if ( dynamic_cast<QgsGeometryCollection *>( geom ) )
230 changes[error->
layerId()][feature.
id()].append(
Change( ChangeFeature, ChangeChanged ) );
242 changes[error->
layerId()][newFeature.
id()].append(
Change( ChangeFeature, ChangeAdded ) );
246 else if ( dynamic_cast<QgsCurve *>( part ) )
248 if ( method == ToMultiObject )
250 if ( dynamic_cast<QgsGeometryCollection *>( geom ) )
269 changes[error->
layerId()][feature.
id()].append(
Change( ChangeFeature, ChangeChanged ) );
274 if ( dynamic_cast<QgsGeometryCollection *>( geom ) )
294 changes[error->
layerId()][newFeature.
id()].append(
Change( ChangeFeature, ChangeAdded ) );
312 static QStringList methods = QStringList()
313 << tr(
"Split feature into a multi-object feature" )
314 << tr(
"Split feature into multiple single-object features" )
315 << tr(
"No action" );
321 QList<QgsSingleGeometryCheckError *> errors;
323 for (
int iPart = 0, nParts = geom->
partCount(); iPart < nParts; ++iPart )
325 for (
int iRing = 0, nRings = geom->
ringCount( iPart ); iRing < nRings; ++iRing )
337 QList<QgsWkbTypes::GeometryType> QgsGeometrySelfIntersectionCheck::factoryCompatibleGeometryTypes()
342 bool QgsGeometrySelfIntersectionCheck::factoryIsCompatible(
QgsVectorLayer *layer )
344 return factoryCompatibleGeometryTypes().contains( layer->
geometryType() );
347 QString QgsGeometrySelfIntersectionCheck::factoryDescription()
349 return tr(
"Self intersection" );
352 QgsGeometryCheck::Flags QgsGeometrySelfIntersectionCheck::factoryFlags()
357 QString QgsGeometrySelfIntersectionCheck::factoryId()
359 return QStringLiteral(
"QgsGeometrySelfIntersectionCheck" );
virtual void setExteriorRing(QgsCurve *ring)
Sets the exterior ring of the polygon.
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
void setPoints(const QgsPointSequence &points)
Resets the line string to match the specified list of points.
static bool segmentIntersection(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint, bool &isIntersection, double tolerance=1e-8, bool acceptImproperIntersection=false)
Compute the intersection between two segments.
static QVector< SelfIntersection > selfIntersections(const QgsAbstractGeometry *geom, int part, int ring, double tolerance)
Find self intersections in a polyline.
void update(const QgsSingleGeometryCheckError *other) override
Update this error with the information from other.
static QgsAbstractGeometry * getGeomPart(QgsAbstractGeometry *geom, int partIdx)
bool isValid() const
Returns true if the vertex id is valid.
Something has been added.
virtual void addInteriorRing(QgsCurve *ring)
Adds an interior ring to the geometry (takes ownership)
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
virtual bool isEqual(const QgsSingleGeometryCheckError *other) const
Check if this error is equal to other.
Multi line string geometry collection.
Curve polygon geometry type.
CheckType
The type of a check.
static int polyLineSize(const QgsAbstractGeometry *geom, int iPart, int iRing, bool *isClosed=nullptr)
Returns the number of points in a polyline, accounting for duplicate start and end point if the polyl...
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
QgsGeometrySelfIntersectionCheckError(const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, QgsVertexId vertexId, const QgsGeometryUtils::SelfIntersection &intersection)
bool isEqual(const QgsSingleGeometryCheckError *other) const override
Check if this error is equal to other.
void setObsolete()
Set the error status to obsolete.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool handleChanges(const QList< QgsGeometryCheck::Change > &changes) override
Apply a list of changes.
bool removeInteriorRing(int ringIndex)
Removes an interior ring from the polygon.
virtual void updateFeature(QgsFeature &feature)=0
Updates a feature in this pool.
void setFixFailed(const QString &reason)
Set the error status to failed and specify the reason for failure.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
virtual bool handleChanges(const QList< QgsGeometryCheck::Change > &changes)
Apply a list of changes.
QList< QgsSingleGeometryCheckError * > processGeometry(const QgsGeometry &geometry) const override
Check the geometry for errors.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
QgsSingleGeometryCheckError * singleError() const
The underlying single error.
Utility class for identifying a unique vertex within a geometry.
int ringCount(int part=0) const override
Returns the number of rings of which this geometry is built.
bool getFeature(QgsFeatureId id, QgsFeature &feature)
Retrieves the feature with the specified id into feature.
Multi curve geometry collection.
QStringList resolutionMethods() const override
Returns a list of descriptions for available resolutions for errors.
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr)
Adds a single feature to the sink.
virtual int ringCount(int part=0) const =0
Returns the number of rings of which this geometry is built.
Abstract base class for all geometries.
const QString & layerId() const
The id of the layer on which this error has been detected.
Wraps a QgsSingleGeometryError into a standard QgsGeometryCheckError.
Point geometry type, with support for z-dimension and m-values.
An error from a QgsSingleGeometryCheck.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QVector< QgsPoint > QgsPointSequence
int partCount() const override
Returns count of parts contained in the geometry.
QMap< QString, QMap< QgsFeatureId, QList< QgsGeometryCheck::Change > > > Changes
A collection of changes.
Multi polygon geometry collection.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
A feature pool is based on a vector layer and caches features.
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.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
Line string geometry type, with support for z-dimension and m-values.
Descripts a change to fix a geometry.
void setFixed(int method)
Set the status to fixed and specify the method that has been used to fix the error.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
QgsFeatureId featureId() const
The id of the feature on which this error has been detected.
QgsCurvePolygon * clone() const override
Clones the geometry by performing a deep copy.
This represents an error reported by a geometry check.
static std::unique_ptr< QgsGeometryEngine > createGeomEngine(const QgsAbstractGeometry *geometry, double tolerance)
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
Represents a vector layer which manages a vector based data sets.
virtual void update(const QgsSingleGeometryCheckError *other)
Update this error with the information from other.
const QgsVertexId & vidx() const
The id of the affected vertex.
const QgsGeometryUtils::SelfIntersection & intersection() const
virtual int partCount() const =0
Returns count of parts contained in the geometry.
The check controls individual nodes.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.