File tree 1 file changed +6
-6
lines changed
python/plugins/fTools/tools
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -598,22 +598,22 @@ def polygon_centroids(self):
598
598
writer = QgsVectorFileWriter (self .myName , self .myEncoding , vprovider .fields (),
599
599
QGis .WKBPoint , vprovider .crs ())
600
600
inFeat = QgsFeature ()
601
- outFeat = QgsFeature ()
602
601
nFeat = vprovider .featureCount ()
603
602
nElement = 0
604
603
self .emit (SIGNAL ("runStatus( PyQt_PyObject )" ), 0 )
605
604
self .emit (SIGNAL ("runRange( PyQt_PyObject )" ), (0 , nFeat ))
606
605
fit = vprovider .getFeatures ()
607
606
while fit .nextFeature (inFeat ):
607
+ outFeat = QgsFeature ()
608
608
nElement += 1
609
609
self .emit (SIGNAL ("runStatus( PyQt_PyObject )" ), nElement )
610
- inGeom = inFeat .geometry ()
610
+ if inFeat .constGeometry ():
611
+ inGeom = inFeat .geometry ()
612
+ outGeom = inGeom .centroid ()
613
+ outFeat .setGeometry (QgsGeometry (outGeom ))
614
+
611
615
atMap = inFeat .attributes ()
612
- outGeom = inGeom .centroid ()
613
- if outGeom is None :
614
- return "math_error"
615
616
outFeat .setAttributes (atMap )
616
- outFeat .setGeometry (QgsGeometry (outGeom ))
617
617
writer .addFeature (outFeat )
618
618
del writer
619
619
return True
You can’t perform that action at this time.
0 commit comments