Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Som fTools fixes for SIP API updates
  • Loading branch information
ccrook authored and m-kuhn committed Jun 15, 2013
1 parent e27fe3b commit d416555
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 36 deletions.
7 changes: 1 addition & 6 deletions python/plugins/fTools/tools/doMeanCoords.py
Expand Up @@ -85,13 +85,8 @@ def accept(self):
else:
inName = self.inShape.currentText()
outPath = self.outShape.text()
outName = ftools_utils.getShapefileName(outPath)

if outPath.contains("\\"):
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
else:
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
if outName.endsWith(".shp"):
outName = outName.left(outName.length() - 4)
self.compute(inName, outPath, self.weightField.currentText(), self.sizeValue.value(), self.uniqueField.currentText())
self.progressBar.setValue(100)
self.outShape.clear()
Expand Down
7 changes: 1 addition & 6 deletions python/plugins/fTools/tools/doPointDistance.py
Expand Up @@ -128,12 +128,7 @@ def accept(self):
else: matType = "Summary"
if self.chkNearest.isChecked(): nearest = self.spnNearest.value()
else: nearest = 0
if outPath.contains("\\"):
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
else:
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
if outName.endsWith(".csv"):
outName = outName.left(outName.length() - 4)
outName = ftools_utils.getShapefileName(outPath)
self.outFile.clear()
self.compute(point1, point2, field1, field2, outPath, matType, nearest, self.progressBar)
self.progressBar.setValue(100)
Expand Down
7 changes: 1 addition & 6 deletions python/plugins/fTools/tools/doRandPoints.py
Expand Up @@ -91,12 +91,7 @@ def accept(self):
self.progressBar.setValue(1)
outPath = self.outShape.text()
self.progressBar.setValue(2.5)
if outPath.contains("\\"):
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
else:
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
if outName.endsWith(".shp"):
outName = outName.left(outName.length() - 4)
outName = ftools_utils.getShapefileName( outPath )
self.progressBar.setValue(5)
mLayer = ftools_utils.getMapLayerByName(unicode(inName))
if mLayer.type() == mLayer.VectorLayer:
Expand Down
7 changes: 1 addition & 6 deletions python/plugins/fTools/tools/doRegPoints.py
Expand Up @@ -69,12 +69,7 @@ def accept(self):
inName = self.inShape.currentText()
outPath = self.outShape.text()
self.outShape.clear()
if outPath.contains("\\"):
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
else:
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
if outName.endsWith(".shp"):
outName = outName.left(outName.length() - 4)
outName = ftools_utils.getShapefileName( outPath )
if self.rdoSpacing.isChecked(): value = self.spnSpacing.value()
else: value = self.spnNumber.value()
if self.chkRandom.isChecked(): offset = True
Expand Down
7 changes: 1 addition & 6 deletions python/plugins/fTools/tools/doSpatialJoin.py
Expand Up @@ -95,12 +95,7 @@ def accept(self):
sumList = ["all"]
if self.rdoKeep.isChecked(): keep = True
else: keep = False
if outPath.contains("\\"):
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
else:
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
if outName.endsWith(".shp"):
outName = outName.left(outName.length() - 4)
outName = ftools_utils.getShapefileName( outPath )
res = self.compute(inName, joinName, outPath, summary, sumList, keep, self.progressBar)
self.outShape.clear()
if res:
Expand Down
7 changes: 1 addition & 6 deletions python/plugins/fTools/tools/doSumLines.py
Expand Up @@ -70,12 +70,7 @@ def accept(self):
inLns = self.inPoint.currentText()
inField = self.lnField.text()
outPath = self.outShape.text()
if outPath.contains("\\"):
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
else:
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
if outName.endsWith(".shp"):
outName = outName.left(outName.length() - 4)
outName = ftools_utils.getShapefileName( outPath )
self.compute(inPoly, inLns, inField, outPath, self.progressBar)
self.outShape.clear()
addToTOC = QMessageBox.question(self, self.tr("Sum line lengths"), self.tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (unicode(outPath)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
Expand Down
10 changes: 10 additions & 0 deletions python/plugins/fTools/tools/ftools_utils.py
Expand Up @@ -382,3 +382,13 @@ def getShapesByGeometryType( baseDir, inShapes, geomType ):
return None

return outShapes

def getShapefileName( outPath ):
import os.path
outName=os.path.basename(outPath)
if outName.endswith('.shp'):
outName=outName[:-4]
if outName.endswith('.csv'):
outName=outName[:-4]
return outName

0 comments on commit d416555

Please sign in to comment.