36 QVector< QgsCurvePolygon * > polygonList;
37 QgsCurvePolygon *curvePoly = qgsgeometry_cast< QgsCurvePolygon * >( geom );
41 polygonList.append( curvePoly );
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;
121 QgsCurve *curve = qgsgeometry_cast<QgsCurve *>( part.get() );
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() );
144 added = geomCollection->
addGeometry( part.release() );
149 std::unique_ptr<QgsGeometryCollection> parts(
static_cast<QgsGeometryCollection *
>( part.release() ) );
153 for ( i = 0; i < parts->numGeometries() && geomCollection->
addGeometry( parts->geometryN( i )->clone() ); i++ )
156 added = i == parts->numGeometries();
161 return QgsGeometry::OperationResult::InvalidInputGeometryType;
166 return QgsGeometry::OperationResult::InvalidInputGeometryType;
171 added = geomCollection->
addGeometry( part.release() );
178 if ( !geom || partNum < 0 )
192 g =
c->geometryN( partNum );
194 else if ( partNum > 0 )
222 return c->removeGeometry( partNum );
226 const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
227 const QHash<
QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures )
243 if ( avoidIntersectionsLayers.isEmpty() )
246 QVector< QgsGeometry > nearGeometries;
252 QHash<QgsVectorLayer *, QSet<qint64> >::const_iterator ignoreIt = ignoreFeatures.constFind( currentLayer );
253 if ( ignoreIt != ignoreFeatures.constEnd() )
254 ignoreIds = ignoreIt.value();
262 if ( ignoreIds.contains( f.
id() ) )
272 if ( nearGeometries.isEmpty() )
277 std::unique_ptr< QgsAbstractGeometry > combinedGeometries( geomEngine->combine( nearGeometries ) );
278 if ( !combinedGeometries )
283 std::unique_ptr< QgsAbstractGeometry > diffGeom( geomEngine->difference( combinedGeometries.get() ) );