Skip to content
Permalink
Browse files

[processing] Make centroid algorithm null geometry safe

  • Loading branch information
m-kuhn committed Feb 4, 2016
1 parent b956886 commit ce0d6102c3d3b224a29cb9adce6dbd238ed0c951
Showing with 7 additions and 4 deletions.
  1. +7 −4 python/plugins/processing/algs/qgis/Centroids.py
@@ -67,10 +67,13 @@ def processAlgorithm(self, progress):
inGeom = inFeat.geometry()
attrs = inFeat.attributes()

outGeom = QgsGeometry(inGeom.centroid())
if outGeom is None:
raise GeoAlgorithmExecutionException(
self.tr('Error calculating centroid'))
if not inGeom:
outGeom = QgsGeometry()
else:
outGeom = QgsGeometry(inGeom.centroid())
if outGeom is None:
raise GeoAlgorithmExecutionException(
self.tr('Error calculating centroid'))

outFeat.setGeometry(outGeom)
outFeat.setAttributes(attrs)

0 comments on commit ce0d610

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