Skip to content

Commit

Permalink
[processing] fixed simplify geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Oct 27, 2016
1 parent 530bf51 commit bf6607f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions python/plugins/processing/algs/qgis/SimplifyGeometries.py
Expand Up @@ -75,15 +75,16 @@ def processAlgorithm(self, progress):
features = vector.features(layer)
total = 100.0 / len(features)
for current, f in enumerate(features):
featGeometry = QgsGeometry(f.geometry())
attrs = f.attributes()
pointsBefore += self.geomVertexCount(featGeometry)
newGeometry = featGeometry.simplify(tolerance)
pointsAfter += self.geomVertexCount(newGeometry)
feature = QgsFeature()
feature.setGeometry(newGeometry)
feature.setAttributes(attrs)
writer.addFeature(feature)
featGeometry = f.geometry()
if featGeometry is not None:
attrs = f.attributes()
pointsBefore += self.geomVertexCount(featGeometry)
newGeometry = featGeometry.simplify(tolerance)
pointsAfter += self.geomVertexCount(newGeometry)
feature = QgsFeature()
feature.setGeometry(newGeometry)
feature.setAttributes(attrs)
writer.addFeature(feature)
progress.setPercentage(int(current * total))

del writer
Expand Down Expand Up @@ -114,4 +115,4 @@ def geomVertexCount(self, geometry):

return len(points)
else:
return None
return 0

0 comments on commit bf6607f

Please sign in to comment.