Skip to content

Commit 4cf08c5

Browse files
author
Sandro Santilli
committedOct 29, 2014
Avoid unneeded geometry cloning in QgsGeometry::nodeGeometries
Affects splitGeometry and reshapeGeometry public functions
1 parent 8d7eb7d commit 4cf08c5

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed
 

‎src/core/qgsgeometry.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -5221,18 +5221,17 @@ GEOSGeometry *QgsGeometry::nodeGeometries( const GEOSGeometry *splitLine, const
52215221
if ( !splitLine || !geom )
52225222
return 0;
52235223

5224-
GEOSGeometry *geometryBoundary = 0;
52255224
if ( GEOSGeomTypeId_r( geosinit.ctxt, geom ) == GEOS_POLYGON || GEOSGeomTypeId_r( geosinit.ctxt, geom ) == GEOS_MULTIPOLYGON )
5226-
geometryBoundary = GEOSBoundary_r( geosinit.ctxt, geom );
5225+
{
5226+
GEOSGeometry *geometryBoundary = GEOSBoundary_r( geosinit.ctxt, geom );
5227+
GEOSGeometry *unionGeometry = GEOSUnion_r( geosinit.ctxt, splitLine, geometryBoundary );
5228+
GEOSGeom_destroy_r( geosinit.ctxt, geometryBoundary );
5229+
return unionGeometry;
5230+
}
52275231
else
5228-
geometryBoundary = GEOSGeom_clone_r( geosinit.ctxt, geom );
5229-
5230-
GEOSGeometry *splitLineClone = GEOSGeom_clone_r( geosinit.ctxt, splitLine );
5231-
GEOSGeometry *unionGeometry = GEOSUnion_r( geosinit.ctxt, splitLineClone, geometryBoundary );
5232-
GEOSGeom_destroy_r( geosinit.ctxt, splitLineClone );
5233-
5234-
GEOSGeom_destroy_r( geosinit.ctxt, geometryBoundary );
5235-
return unionGeometry;
5232+
{
5233+
return GEOSUnion_r( geosinit.ctxt, splitLine, geom );
5234+
}
52365235
}
52375236

52385237
int QgsGeometry::lineContainedInLine( const GEOSGeometry* line1, const GEOSGeometry* line2 )

0 commit comments

Comments
 (0)