@@ -4864,7 +4864,7 @@ int QgsGeometry::splitPolygonGeometry( GEOSGeometry* splitLine, QList<QgsGeometr
4864
4864
// ratio intersect geometry / geometry. This should be close to 1
4865
4865
// if the polygon belongs to the input geometry
4866
4866
4867
- for ( int i = 0 ; i < GEOSGetNumGeometries ( polygons ); i++ )
4867
+ for ( int i = 0 ; i < getNumberOfGeometries ( polygons ); i++ )
4868
4868
{
4869
4869
const GEOSGeometry *polygon = GEOSGetGeometryN ( polygons, i );
4870
4870
intersectGeometry = GEOSIntersection ( mGeos , polygon );
@@ -4883,7 +4883,7 @@ int QgsGeometry::splitPolygonGeometry( GEOSGeometry* splitLine, QList<QgsGeometr
4883
4883
}
4884
4884
4885
4885
bool splitDone = true ;
4886
- int nGeometriesThis = GEOSGetNumGeometries ( mGeos ); // original number of geometries
4886
+ int nGeometriesThis = getNumberOfGeometries ( mGeos ); // original number of geometries
4887
4887
if ( testedGeometries.size () == nGeometriesThis )
4888
4888
{
4889
4889
splitDone = false ;
@@ -5003,6 +5003,23 @@ GEOSGeometry *QgsGeometry::nodeGeometries( const GEOSGeometry *splitLine, GEOSGe
5003
5003
return unionGeometry;
5004
5004
}
5005
5005
5006
+ int QgsGeometry::getNumberOfGeometries (GEOSGeometry* g) const
5007
+ {
5008
+ if (!g)
5009
+ {
5010
+ return 0 ;
5011
+ }
5012
+ int geometryType = GEOSGeomTypeId (g);
5013
+ if (geometryType == GEOS_POINT || geometryType == GEOS_LINESTRING || geometryType == GEOS_LINEARRING
5014
+ || geometryType == GEOS_POLYGON)
5015
+ {
5016
+ return 1 ;
5017
+ }
5018
+
5019
+ // calling GEOSGetNumGeometries is save for multi types and collections also in geos2
5020
+ return GEOSGetNumGeometries (g);
5021
+ }
5022
+
5006
5023
int QgsGeometry::mergeGeometriesMultiTypeSplit ( QVector<GEOSGeometry*>& splitResult )
5007
5024
{
5008
5025
if ( !mGeos || mDirtyGeos )
0 commit comments