Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Fix multipart to singlepart handling of null geometry
(cherry-picked from 0455b66)
  • Loading branch information
nyalldawson committed Aug 10, 2016
1 parent 7790cc8 commit 22a9406
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions python/plugins/processing/algs/qgis/MultipartToSingleparts.py
Expand Up @@ -63,20 +63,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))
Expand Down

0 comments on commit 22a9406

Please sign in to comment.