Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
now supports fields containing non-ascii chars. Fixes #2496. Patch fr…
…om alexbruy

git-svn-id: http://svn.osgeo.org/qgis/trunk@13478 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer committed May 13, 2010
1 parent b168560 commit b2dc354
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/plugins/fTools/tools/doPointDistance.py
Expand Up @@ -85,6 +85,7 @@ def __init__(self, iface):
QObject.connect(self.btnFile, SIGNAL("clicked()"), self.saveFile)
QObject.connect(self.inPoint1, SIGNAL("currentIndexChanged(QString)"), self.update1)
QObject.connect(self.inPoint2, SIGNAL("currentIndexChanged(QString)"), self.update2)
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.setWindowTitle(self.tr("Distance matrix"))
self.progressBar.setValue(0)
Expand Down Expand Up @@ -112,6 +113,7 @@ def update2(self, inputLayer):
self.inField2.addItem(unicode(changedField[i].name()))

def accept(self):
self.buttonOk.setEnabled( False )
if self.inPoint1.currentText() == "":
QMessageBox.information(self, self.tr("Create Point Distance Matrix"), self.tr("Please specify input point layer"))
elif self.outFile.text() == "":
Expand Down Expand Up @@ -144,6 +146,7 @@ def accept(self):
self.progressBar.setValue(100)
addToTOC = QMessageBox.information(self, "Create Point Distance Matrix", self.tr("Created output matrix:\n") + outPath)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

def saveFile(self):
self.outFile.clear()
Expand Down Expand Up @@ -239,14 +242,14 @@ def linearMatrix(self, writer, provider1, provider2, index1, index2, nearest, di
outGeom = outFeat.geometry()
dist = distArea.measureLine(inGeom.asPoint(), outGeom.asPoint())
if dist > 0:
if matType == "Linear": writer.writerow([unicode(inID), unicode(outID), float(dist)])
if matType == "Linear": writer.writerow([unicode(inID), unicode(outID), str(dist)])
else: distList.append(float(dist))
if matType == "Summary":
mean = sum(distList) / len(distList)
for i in distList:
vari = vari + ((i - mean)*(i - mean))
vari = sqrt(vari / len(distList))
writer.writerow([unicode(inID), float(mean), float(vari), float(min(distList)), float(max(distList))])
writer.writerow([unicode(inID), str(mean), str(vari), str(min(distList)), str(max(distList))])
start = start + add
progressBar.setValue(start)
del writer

0 comments on commit b2dc354

Please sign in to comment.