Skip to content
Permalink
Browse files

Fix Polygon Centroids tool hangs on null geometry (fix #15045)

  • Loading branch information
nyalldawson committed Jun 17, 2016
1 parent c6457a6 commit b380a1d56524d70083e4ab7a8013acaaebbd23f1
Showing with 6 additions and 6 deletions.
  1. +6 −6 python/plugins/fTools/tools/doGeometry.py
@@ -598,22 +598,22 @@ def polygon_centroids(self):
writer = QgsVectorFileWriter(self.myName, self.myEncoding, vprovider.fields(),
QGis.WKBPoint, vprovider.crs())
inFeat = QgsFeature()
outFeat = QgsFeature()
nFeat = vprovider.featureCount()
nElement = 0
self.emit(SIGNAL("runStatus( PyQt_PyObject )"), 0)
self.emit(SIGNAL("runRange( PyQt_PyObject )"), (0, nFeat))
fit = vprovider.getFeatures()
while fit.nextFeature(inFeat):
outFeat = QgsFeature()
nElement += 1
self.emit(SIGNAL("runStatus( PyQt_PyObject )"), nElement)
inGeom = inFeat.geometry()
if inFeat.constGeometry():
inGeom = inFeat.geometry()
outGeom = inGeom.centroid()
outFeat.setGeometry(QgsGeometry(outGeom))

atMap = inFeat.attributes()
outGeom = inGeom.centroid()
if outGeom is None:
return "math_error"
outFeat.setAttributes(atMap)
outFeat.setGeometry(QgsGeometry(outGeom))
writer.addFeature(outFeat)
del writer
return True

0 comments on commit b380a1d

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