Skip to content

Commit 32cd9b5

Browse files
alexbruyjef-n
authored andcommitted
also add MultiPolygon support in Densify geometry
1 parent 99f88b3 commit 32cd9b5

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

python/plugins/fTools/tools/doSimplify.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,19 @@ def densify( polyline, pointsNumber ):
196196
def densifyGeometry( geometry, pointsNumber, isPolygon ):
197197
output = []
198198
if isPolygon:
199-
rings = geometry.asPolygon()
200-
for ring in rings:
201-
ring = densify( ring, pointsNumber )
202-
output.append( ring )
203-
return QgsGeometry.fromPolygon( output )
199+
if geometry.isMultipart():
200+
polygons = geometry.asMultiPolygon()
201+
for poly in polygons:
202+
p = []
203+
for ring in poly:
204+
p.append( densify( ring, pointsNumber ) )
205+
output.append( p )
206+
return QgsGeometry.fromMultiPolygon( output )
207+
else:
208+
rings = geometry.asPolygon()
209+
for ring in rings:
210+
output.append( densify( ring, pointsNumber ) )
211+
return QgsGeometry.fromPolygon( output )
204212
else:
205213
if geometry.isMultipart():
206214
lines = geometry.asMultiPolyline()

0 commit comments

Comments
 (0)