QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
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;
107 bool intersection =
false;
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" ) );
199 if ( !geomEnginePoly1->contains( poly->
interiorRing( i ) ) )
201 if ( geomEnginePoly2->contains( poly->
interiorRing( i ) ) )
246 else if (
dynamic_cast<QgsCurve *
>( part ) )
312 static const 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()
354 return QgsGeometryCheck::Flags();
357 QString QgsGeometrySelfIntersectionCheck::factoryId()
359 return QStringLiteral(
"QgsGeometrySelfIntersectionCheck" );
Abstract base class for curved geometry type.
void setFixFailed(const QString &reason)
Set the error status to failed and specify the reason for failure.
Descripts a change to fix a geometry.
void update(const QgsSingleGeometryCheckError *other) override
Update this error with the information from other.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
static QgsAbstractGeometry * getGeomPart(QgsAbstractGeometry *geom, int partIdx)
@ ChangeAdded
Something has been added.
@ ChangeFeature
This change happens on feature level.
Point geometry type, with support for z-dimension and m-values.
virtual void setExteriorRing(QgsCurve *ring)
Sets the exterior ring of the polygon.
void setObsolete()
Set the error status to obsolete.
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.
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())
Adds a single feature to the sink.
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...
QgsCurvePolygon * clone() const override
Clones the geometry by performing a deep copy.
Multi line string geometry collection.
virtual void update(const QgsSingleGeometryCheckError *other)
Update this error with the information from other.
@ FeatureNodeCheck
The check controls individual nodes.
QList< QgsSingleGeometryCheckError * > processGeometry(const QgsGeometry &geometry) const override
Check the geometry for errors.
@ ChangeChanged
Something has been updated.
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.
virtual int partCount() const =0
Returns count of parts contained in the geometry.
Line string geometry type, with support for z-dimension and m-values.
An error from a QgsSingleGeometryCheck.
bool getFeature(QgsFeatureId id, QgsFeature &feature)
Retrieves the feature with the specified id into feature.
A self intersection check error.
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
@ ChangeRemoved
Something has been removed.
int numInteriorRings() const SIP_HOLDGIL
Returns the number of interior rings contained with the curve polygon.
bool isEqual(const QgsSingleGeometryCheckError *other) const override
Check if this error is equal to other.
bool removeInteriorRing(int ringIndex)
Removes an interior ring from the polygon.
int partCount() const override
Returns count of parts contained in the geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Multi curve geometry collection.
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.
virtual void addInteriorRing(QgsCurve *ring)
Adds an interior ring to the geometry (takes ownership)
void setPoints(size_t size, const double *x, const double *y, const double *z=nullptr, const double *m=nullptr)
Resets the line string to match the specified point data.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
Q_DECL_DEPRECATED QStringList resolutionMethods() const override
Returns a list of descriptions for available resolutions for errors.
Multi polygon geometry collection.
bool handleChanges(const QList< QgsGeometryCheck::Change > &changes) override
Apply a list of changes.
int ringCount(int part=0) const override SIP_HOLDGIL
Returns the number of rings of which this geometry is built.
const QgsCurve * interiorRing(int i) const SIP_HOLDGIL
Retrieves an interior ring from the curve polygon.
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) SIP_HOLDGIL
Compute the intersection between two segments.
const QgsVertexId & vidx() const
The id of the affected vertex.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Wraps a QgsSingleGeometryError into a standard QgsGeometryCheckError. The single error can be obtaine...
Abstract base class for all geometries.
const QgsGeometryCheckContext * mContext
const QgsGeometryUtils::SelfIntersection & intersection() const
virtual bool isEqual(const QgsSingleGeometryCheckError *other) const
Check if this error is equal to other.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
bool isValid() const SIP_HOLDGIL
Returns true if the vertex id is valid.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
@ ChangePart
This change happens on part level.
QVector< QgsPoint > QgsPointSequence
A geometry is the spatial representation of a feature.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
@ ChangeRing
This change happens on ring level.
Represents a vector layer which manages a vector based data sets.
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.
static std::unique_ptr< QgsGeometryEngine > createGeomEngine(const QgsAbstractGeometry *geometry, double tolerance)
static QVector< SelfIntersection > selfIntersections(const QgsAbstractGeometry *geom, int part, int ring, double tolerance)
Find self intersections in a polyline.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
const QString & layerId() const
The id of the layer on which this error has been detected.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
This represents an error reported by a geometry check.
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
virtual int ringCount(int part=0) const =0
Returns the number of rings of which this geometry is built.
A feature pool is based on a vector layer and caches features.
QgsSingleGeometryCheckError * singleError() const
The underlying single error.
virtual bool handleChanges(const QList< QgsGeometryCheck::Change > &changes)
Apply a list of changes.