From e9ff0723353dbe71cfba75797b05aa20668b97fe Mon Sep 17 00:00:00 2001 From: slarosa Date: Sat, 12 May 2012 20:01:39 +0200 Subject: [PATCH] Add Multigeometries support in Simplify tool for geomVertexCount function --- python/plugins/fTools/tools/doSimplify.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/python/plugins/fTools/tools/doSimplify.py b/python/plugins/fTools/tools/doSimplify.py index 62824197d592..7351940b7957 100644 --- a/python/plugins/fTools/tools/doSimplify.py +++ b/python/plugins/fTools/tools/doSimplify.py @@ -162,10 +162,18 @@ def restoreGui( self ): def geomVertexCount( geometry ): geomType = geometry.type() if geomType == 1: # line - points = geometry.asPolyline() + if geometry.isMultipart(): + pointsList = geometry.asMultiPolyline() + points=sum(pointsList, []) + else: + points = geometry.asPolyline() return len( points ) elif geomType == 2: # polygon - polylines = geometry.asPolygon() + if geometry.isMultipart(): + polylinesList = geometry.asMultiPolygon() + polylines=sum(polylinesList, []) + else: + polylines = geometry.asPolygon() points = [] for l in polylines: points.extend( l )