36 QVector< QgsCurvePolygon * > polygonList;
41 polygonList.append( curvePoly );
45 polygonList.reserve( multiGeom->numGeometries() );
46 for (
int i = 0; i < multiGeom->numGeometries(); ++i )
48 polygonList.append( qgsgeometry_cast< QgsCurvePolygon * >( multiGeom->geometryN( i ) ) );
53 return QgsGeometry::OperationResult::InvalidInputGeometryType;
57 if ( !ring->isClosed() )
59 return QgsGeometry::OperationResult::AddRingNotClosed;
61 else if ( !ring->isRing() )
63 return QgsGeometry::OperationResult::AddRingNotValid;
67 ringGeom->prepareGeometry();
70 QVector< QgsCurvePolygon * >::const_iterator polyIter = polygonList.constBegin();
71 for ( ; polyIter != polygonList.constEnd(); ++polyIter )
73 if ( ringGeom->within( *polyIter ) )
76 int nInnerRings = ( *polyIter )->numInteriorRings();
77 for (
int i = 0; i < nInnerRings; ++i )
79 if ( !ringGeom->disjoint( ( *polyIter )->interiorRing( i ) ) )
81 return QgsGeometry::OperationResult::AddRingCrossesExistingRings;
91 ( *polyIter )->addInteriorRing( ring.release() );
92 return QgsGeometry::OperationResult::Success;
95 return QgsGeometry::OperationResult::AddRingNotInExistingFeature;
102 return QgsGeometry::OperationResult::InvalidBaseGeometry;
107 return QgsGeometry::OperationResult::InvalidInputGeometryType;
112 if ( !geomCollection )
114 return QgsGeometry::OperationResult::AddPartNotMultiGeometry;
125 std::unique_ptr<QgsCurvePolygon> poly;
128 poly = qgis::make_unique< QgsPolygon >();
132 poly = qgis::make_unique< QgsCurvePolygon >();
137 poly->setExteriorRing( curve );
138 added = geomCollection->
addGeometry( poly.release() );
143 added = geomCollection->
addGeometry( part.release() );
148 std::unique_ptr<QgsGeometryCollection> parts( static_cast<QgsGeometryCollection *>( part.release() ) );
152 for ( i = 0; i < parts->numGeometries() && geomCollection->
addGeometry( parts->geometryN( i )->clone() ); i++ )
155 added = i == parts->numGeometries();
160 return QgsGeometry::OperationResult::InvalidInputGeometryType;
165 return QgsGeometry::OperationResult::InvalidInputGeometryType;
170 added = geomCollection->
addGeometry( part.release() );
177 if ( !geom || partNum < 0 )
193 else if ( partNum > 0 )
225 const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
226 const QHash<
QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures )
242 if ( avoidIntersectionsLayers.isEmpty() )
245 QVector< QgsGeometry > nearGeometries;
251 QHash<QgsVectorLayer *, QSet<qint64> >::const_iterator ignoreIt = ignoreFeatures.constFind( currentLayer );
252 if ( ignoreIt != ignoreFeatures.constEnd() )
253 ignoreIds = ignoreIt.value();
261 if ( ignoreIds.contains( f.
id() ) )
271 if ( nearGeometries.isEmpty() )
276 std::unique_ptr< QgsAbstractGeometry > combinedGeometries( geomEngine->combine( nearGeometries ) );
277 if ( !combinedGeometries )
282 std::unique_ptr< QgsAbstractGeometry > diffGeom( geomEngine->difference( combinedGeometries.get() ) );
Wrapper for iterator of features from vector data provider or vector layer.
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
Use exact geometry intersection (slower) instead of bounding boxes.
QSet< QgsFeatureId > QgsFeatureIds
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Curve polygon geometry type.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual QgsRectangle boundingBox() const =0
Returns the minimal bounding box for the geometry.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
OperationResult
Success or failure of a geometry operation.
bool removeInteriorRing(int ringIndex)
Removes an interior ring from the polygon.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Type
The WKB type describes the number of dimensions a geometry has.
static bool deleteRing(QgsAbstractGeometry *geom, int ringNum, int partNum=0)
Deletes a ring from a geometry.
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
static std::unique_ptr< QgsAbstractGeometry > avoidIntersections(const QgsAbstractGeometry &geom, const QList< QgsVectorLayer *> &avoidIntersectionsLayers, const QHash< QgsVectorLayer *, QSet< QgsFeatureId > > &ignoreFeatures=(QHash< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Alters a geometry so that it avoids intersections with features from all open vector layers...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
Abstract base class for curved geometry type.
Abstract base class for all geometries.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
int numGeometries() const
Returns the number of geometries within the collection.
virtual bool isClosed() const
Returns true if the curve is closed.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine.
static QgsGeometry::OperationResult addPart(QgsAbstractGeometry *geometry, std::unique_ptr< QgsAbstractGeometry > part)
Add a part to multi type geometry.
The input geometry (ring, part, split line, etc.) has not the correct geometry type.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
static bool hasM(Type type)
Tests whether a WKB type contains m values.
static bool deletePart(QgsAbstractGeometry *geom, int partNum)
Deletes a part from a geometry.
QList< int > QgsAttributeList
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.
static Type flatType(Type type)
Returns the flat type for a WKB type.
virtual int numPoints() const =0
Returns the number of points in the curve.
static QgsGeometry::OperationResult addRing(QgsAbstractGeometry *geometry, std::unique_ptr< QgsCurve > ring)
Add an interior ring to a geometry.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.