Skip to content
Permalink
Browse files

[processing] Fix multipart to singlepart handling of null geometry

(cherry-picked from 0455b66)
  • Loading branch information
nyalldawson committed Aug 9, 2016
1 parent e508ba2 commit 069ed71d2a2bbb5442f61029775d4380bdca6035
Showing with 10 additions and 8 deletions.
  1. +10 −8 python/plugins/processing/algs/qgis/MultipartToSingleparts.py
@@ -58,20 +58,22 @@ def processAlgorithm(self, progress):
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
layer.pendingFields().toList(), geomType, layer.crs())

outFeat = QgsFeature()
inGeom = QgsGeometry()

features = vector.features(layer)
total = 100.0 / len(features)
for current, f in enumerate(features):
inGeom = f.geometry()
outFeat = QgsFeature()
attrs = f.attributes()

geometries = self.extractAsSingle(inGeom)
outFeat.setAttributes(attrs)

for g in geometries:
outFeat.setGeometry(g)
if f.constGeometry():
inGeom = QgsGeometry(f.constGeometry())
geometries = self.extractAsSingle(inGeom)

for g in geometries:
outFeat.setGeometry(g)
writer.addFeature(outFeat)
else:
#input feature with null geometry
writer.addFeature(outFeat)

progress.setPercentage(int(current * total))

0 comments on commit 069ed71

Please sign in to comment.
You can’t perform that action at this time.