Skip to content

Commit

Permalink
[processing] Make centroid algorithm null geometry safe
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Feb 4, 2016
1 parent b956886 commit ce0d610
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python/plugins/processing/algs/qgis/Centroids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ce0d610

Please sign in to comment.