Skip to content
Permalink
Browse files

Fixes polygon centroids tool, updates version number and about dialog

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10422 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer
cfarmer committed Mar 26, 2009
1 parent 915df51 commit 857df4c0fbf3c983682452f69a90d5910109cd00
Showing with 18 additions and 16 deletions.
  1. +1 −1 python/plugins/fTools/__init__.py
  2. +1 −1 python/plugins/fTools/doAbout.py
  3. +16 −14 python/plugins/fTools/tools/doGeometry.py
@@ -21,7 +21,7 @@ def description():
return "Tools for vector data analysis and management"

def version():
return "0.5.7"
return "0.5.8"

def qgisMinimumVersion():
return "1"
@@ -32,7 +32,7 @@ def __init__(self, iface):
QObject.connect(self.btnWeb, SIGNAL("clicked()"), self.openWeb)
QObject.connect(self.btnHelp, SIGNAL("clicked()"), self.openHelp)
self.fToolsLogo.setPixmap(QPixmap(":/icons/default/ftools_logo.png"))
self.label_3.setText("fTools 0.5.6")
self.label_3.setText("fTools 0.5.8")
self.textEdit.setText(self.getText())

def getText(self):
@@ -447,29 +447,31 @@ def polygon_centroids( self ):
for h in k:
for i in range(0, len(h) - 1):
j = (i + 1) % len(h)
factor = ((h[i].x()) * (h[j].y()) - (h[j].x()) * (h[i].y()))
cx = cx + ((h[i].x()) + (h[j].x())) * factor
cy = cy + ((h[i].y()) + (h[j].y())) * factor
factor = ((h[i].x()-xmin) * (h[j].y()-ymin) - (h[j].x()-xmin) * (h[i].y()-ymin))
cx = cx + ((h[i].x()-xmin) + (h[j].x()-xmin)) * factor
cy = cy + ((h[i].y()-ymin) + (h[j].y()-ymin)) * factor
else:
multi_geom = geom.asPolygon()
for k in multi_geom:
for i in range(0, len(k) - 1):
j = (i + 1) % len(k)
factor = (k[i].x()) * (k[j].y()) - (k[j].x()) * (k[i].y())
cx = cx + ((k[i].x()) + (k[j].x())) * factor
cy = cy + ((k[i].y()) + (k[j].y())) * factor
factor = (k[i].x()-xmin) * (k[j].y()-ymin) - (k[j].x()-xmin) * (k[i].y()-ymin)
cx = cx + ((k[i].x()-xmin) + (k[j].x()-xmin)) * factor
cy = cy + ((k[i].y()-ymin) + (k[j].y()-ymin)) * factor
A = A * 6
factor = 1/A
cx = cx * factor
cy = cy * factor
if cx < xmin:
cx = cx * -1
if cy < ymin:
cy = cy * -1
if cx > xmax:
cx = cx * -1
if cy > ymax:
cy = cy * -1
# if cx < xmin:
# cx = cx * -1
# if cy < ymin:
# cy = cy * -1
# if cx > xmax:
# cx = cx * -1
# if cy > ymax:
# cy = cy * -1
cx = cx + xmin
cy = cy + ymin
outfeat.setGeometry( QgsGeometry.fromPoint( QgsPoint( cx, cy ) ) )
atMap = inFeat.attributeMap()
outfeat.setAttributeMap( atMap )

0 comments on commit 857df4c

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