Skip to content

Commit d416555

Browse files
ccrookm-kuhn
authored andcommitted
Som fTools fixes for SIP API updates
1 parent e27fe3b commit d416555

File tree

7 files changed

+16
-36
lines changed

7 files changed

+16
-36
lines changed

python/plugins/fTools/tools/doMeanCoords.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,8 @@ def accept(self):
8585
else:
8686
inName = self.inShape.currentText()
8787
outPath = self.outShape.text()
88+
outName = ftools_utils.getShapefileName(outPath)
8889

89-
if outPath.contains("\\"):
90-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
91-
else:
92-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
93-
if outName.endsWith(".shp"):
94-
outName = outName.left(outName.length() - 4)
9590
self.compute(inName, outPath, self.weightField.currentText(), self.sizeValue.value(), self.uniqueField.currentText())
9691
self.progressBar.setValue(100)
9792
self.outShape.clear()

python/plugins/fTools/tools/doPointDistance.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,7 @@ def accept(self):
128128
else: matType = "Summary"
129129
if self.chkNearest.isChecked(): nearest = self.spnNearest.value()
130130
else: nearest = 0
131-
if outPath.contains("\\"):
132-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
133-
else:
134-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
135-
if outName.endsWith(".csv"):
136-
outName = outName.left(outName.length() - 4)
131+
outName = ftools_utils.getShapefileName(outPath)
137132
self.outFile.clear()
138133
self.compute(point1, point2, field1, field2, outPath, matType, nearest, self.progressBar)
139134
self.progressBar.setValue(100)

python/plugins/fTools/tools/doRandPoints.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,7 @@ def accept(self):
9191
self.progressBar.setValue(1)
9292
outPath = self.outShape.text()
9393
self.progressBar.setValue(2.5)
94-
if outPath.contains("\\"):
95-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
96-
else:
97-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
98-
if outName.endsWith(".shp"):
99-
outName = outName.left(outName.length() - 4)
94+
outName = ftools_utils.getShapefileName( outPath )
10095
self.progressBar.setValue(5)
10196
mLayer = ftools_utils.getMapLayerByName(unicode(inName))
10297
if mLayer.type() == mLayer.VectorLayer:

python/plugins/fTools/tools/doRegPoints.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,7 @@ def accept(self):
6969
inName = self.inShape.currentText()
7070
outPath = self.outShape.text()
7171
self.outShape.clear()
72-
if outPath.contains("\\"):
73-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
74-
else:
75-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
76-
if outName.endsWith(".shp"):
77-
outName = outName.left(outName.length() - 4)
72+
outName = ftools_utils.getShapefileName( outPath )
7873
if self.rdoSpacing.isChecked(): value = self.spnSpacing.value()
7974
else: value = self.spnNumber.value()
8075
if self.chkRandom.isChecked(): offset = True

python/plugins/fTools/tools/doSpatialJoin.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,7 @@ def accept(self):
9595
sumList = ["all"]
9696
if self.rdoKeep.isChecked(): keep = True
9797
else: keep = False
98-
if outPath.contains("\\"):
99-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
100-
else:
101-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
102-
if outName.endsWith(".shp"):
103-
outName = outName.left(outName.length() - 4)
98+
outName = ftools_utils.getShapefileName( outPath )
10499
res = self.compute(inName, joinName, outPath, summary, sumList, keep, self.progressBar)
105100
self.outShape.clear()
106101
if res:

python/plugins/fTools/tools/doSumLines.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,7 @@ def accept(self):
7070
inLns = self.inPoint.currentText()
7171
inField = self.lnField.text()
7272
outPath = self.outShape.text()
73-
if outPath.contains("\\"):
74-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
75-
else:
76-
outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
77-
if outName.endsWith(".shp"):
78-
outName = outName.left(outName.length() - 4)
73+
outName = ftools_utils.getShapefileName( outPath )
7974
self.compute(inPoly, inLns, inField, outPath, self.progressBar)
8075
self.outShape.clear()
8176
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)

python/plugins/fTools/tools/ftools_utils.py

+10
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,13 @@ def getShapesByGeometryType( baseDir, inShapes, geomType ):
382382
return None
383383

384384
return outShapes
385+
386+
def getShapefileName( outPath ):
387+
import os.path
388+
outName=os.path.basename(outPath)
389+
if outName.endswith('.shp'):
390+
outName=outName[:-4]
391+
if outName.endswith('.csv'):
392+
outName=outName[:-4]
393+
return outName
394+

0 commit comments

Comments
 (0)