Skip to content

Commit

Permalink
Fixes polygon centroids tool, updates version number and about dialog
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10422 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer committed Mar 26, 2009
1 parent 915df51 commit 857df4c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion python/plugins/fTools/__init__.py
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/fTools/doAbout.py
Expand Up @@ -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):
Expand Down
30 changes: 16 additions & 14 deletions python/plugins/fTools/tools/doGeometry.py
Expand Up @@ -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 )
Expand Down

0 comments on commit 857df4c

Please sign in to comment.