diff --git a/python/plugins/fTools/doAbout.py b/python/plugins/fTools/doAbout.py index 3b50c5a23cc..1746655845d 100755 --- a/python/plugins/fTools/doAbout.py +++ b/python/plugins/fTools/doAbout.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # licensed under the terms of GNU GPL 2 # # This program is free software; you can redistribute it and/or modify @@ -53,6 +54,11 @@ This program is free software; you can redistribute it and/or modify it under th This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +fTools DEVELOPERS: +Carson J. Q. Farmer +Alexander Bruy +**If you have contributed code to fTools and I haven't mentioned your name here, please contact me and I will add your name. + ACKNOWLEDGEMENTS: The following individuals (whether they know it or not) have contributed ideas, help, testing, code, and guidence towards this project, and I thank them. Hawthorn Beyer diff --git a/python/plugins/fTools/tools/doGeometry.py b/python/plugins/fTools/tools/doGeometry.py index aa0b19ddc81..3e0acd4ffa2 100755 --- a/python/plugins/fTools/tools/doGeometry.py +++ b/python/plugins/fTools/tools/doGeometry.py @@ -421,52 +421,22 @@ class geometryThread( QThread ): writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields, QGis.WKBPoint, vprovider.crs() ) inFeat = QgsFeature() - outfeat = QgsFeature() + outFeat = QgsFeature() nFeat = vprovider.featureCount() nElement = 0 self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 ) self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) ) while vprovider.nextFeature( inFeat ): - geom = inFeat.geometry() - area = 0.00 - bounding = inFeat.geometry().boundingBox() - xmin = bounding.xMinimum() - ymin = bounding.yMinimum() - if geom.type() == 2: - cx = 0 - cy = 0 - factor = 0 - if geom.isMultipart(): - polygons = geom.asMultiPolygon() - for polygon in polygons: - for line in polygon: - for i in range(0,len(line)-1): - j = (i + 1) % len(line) - factor=((line[i].x()-xmin)*(line[j].y()-ymin)-(line[j].x()-xmin)*(line[i].y()-ymin)) - cx+=((line[i].x()-xmin)+(line[j].x()-xmin))*factor - cy+=((line[i].y()-ymin)+(line[j].y()-ymin))*factor - area+=factor - else: - polygon = geom.asPolygon() - for line in polygon: - for i in range(0,len(line)-1): - j = (i + 1) % len(line) - factor=((line[i].x()-xmin)*(line[j].y()-ymin)-(line[j].x()-xmin)*(line[i].y()-ymin)) - cx+=((line[i].x()-xmin)+(line[j].x()-xmin))*factor - cy+=((line[i].y()-ymin)+(line[j].y()-ymin))*factor - area+=factor - - if area==0: - continue - - cx/=area*3.00 - cy/=area*3.00 - outfeat.setGeometry( QgsGeometry.fromPoint( QgsPoint( cx+xmin, cy+ymin ) ) ) - atMap = inFeat.attributeMap() - outfeat.setAttributeMap( atMap ) - writer.addFeature( outfeat ) nElement += 1 self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement ) + inGeom = inFeat.geometry() + atMap = inFeat.attributeMap() + outGeom = QgsGeometry(inGeom.centroid()) + if outGeom is None: + return "math_error" + outFeat.setAttributeMap( atMap ) + outFeat.setGeometry( outGeom ) + writer.addFeature( outFeat ) del writer return True