9 changes: 4 additions & 5 deletions python/plugins/fTools/tools/doMergeShapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__( self, iface ):

def inputDir( self ):
settings = QSettings()
lastDir = settings.value( "/fTools/lastShapeDir", "." ).toString()
lastDir = settings.value( "/fTools/lastShapeDir", "." )
inDir = QFileDialog.getExistingDirectory( self,
self.tr( "Select directory with shapefiles to merge" ),
lastDir )
Expand Down Expand Up @@ -109,7 +109,7 @@ def changeMode( self ):
def updateOutFile( self ):
self.outFileName = self.leOutShape.text()
settings = QSettings()
self.outEncoding = settings.value( "/UI/encoding" ).toString()
self.outEncoding = settings.value( "/UI/encoding" )

def reject( self ):
QDialog.reject( self )
Expand Down Expand Up @@ -148,7 +148,7 @@ def accept( self ):
outFile = QFile( self.outFileName )
if outFile.exists():
if not QgsVectorFileWriter.deleteShapeFile( self.outFileName ):
QMessageBox.warning( self, self.tr( "Delete error" ), self.tr( "Can't delete file %1" ).arg( self.outFileName ) )
QMessageBox.warning( self, self.tr( "Delete error" ), self.tr( "Can't delete file %s" ) % ( self.outFileName ) )
return

if self.inEncoding == None:
Expand Down Expand Up @@ -197,8 +197,7 @@ def processingFinished( self ):
if self.chkAddToCanvas.isChecked():
if not ftools_utils.addShapeToCanvas( unicode( self.outFileName ) ):
QMessageBox.warning( self, self.tr( "Merging" ),
self.tr( "Error loading output shapefile:\n%1" )
.arg( unicode( self.outFileName ) ) )
self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.outFileName ) ) )

self.restoreGui()

Expand Down
12 changes: 6 additions & 6 deletions python/plugins/fTools/tools/doPointDistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def compute(self, line1, line2, field1, field2, outPath, matType, nearest, progr
provider2 = layer2.dataProvider()
sindex = QgsSpatialIndex()
inFeat = QgsFeature()
fit2 = provider2.getFeatures()
fit2 = provider2.getFeatures()
while fit2.nextFeature(inFeat):
sindex.insertFeature(inFeat)
if nearest < 1: nearest = layer2.featureCount()
Expand Down Expand Up @@ -190,17 +190,17 @@ def regularMatrix(self, writer, provider1, provider2, index1, index2, nearest, d
first = True
start = 15.00
add = 85.00 / provider1.featureCount()
fit1 = provider1.getFeatures()
fit1 = provider1.getFeatures()
while fit1.nextFeature(inFeat):
inGeom = inFeat.geometry()
inID = inFeat.attributes()[index1].toString()
inID = inFeat.attributes()[index1]
if first:
featList = sindex.nearestNeighbor(inGeom.asPoint(), nearest)
first = False
data = ["ID"]
for i in featList:
provider2.getFeatures( QgsFeatureRequest().setFilterFid( int(i) ).setSubsetOfAttributes([index2]) ).nextFeature( outFeat )
data.append(unicode(outFeat.attributes()[index2].toString()))
data.append(unicode(outFeat.attributes()[index2]))
writer.writerow(data)
data = [unicode(inID)]
for j in featList:
Expand All @@ -223,13 +223,13 @@ def linearMatrix(self, writer, provider1, provider2, index1, index2, nearest, di
fit1 = provider1.getFeatures()
while fit1.nextFeature(inFeat):
inGeom = inFeat.geometry()
inID = inFeat.attributes()[index1].toString()
inID = inFeat.attributes()[index1]
featList = sindex.nearestNeighbor(inGeom.asPoint(), nearest)
distList = []
vari = 0.00
for i in featList:
provider2.getFeatures( QgsFeatureRequest().setFilterFid( int(i) ).setSubsetOfAttributes([index2]) ).nextFeature( outFeat )
outID = outFeat.attributes()[index2].toString()
outID = outFeat.attributes()[index2]
outGeom = outFeat.geometry()
dist = distArea.measureLine(inGeom.asPoint(), outGeom.asPoint())
if dist > 0:
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doPointsInPolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def processFinished(self):
self.stopProcessing()

addToTOC = QMessageBox.question(self, self.tr("Count Points in Polygon"),
self.tr("Created output shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg(self.outShape.text()),
self.tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (self.outShape.text()),
QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
if addToTOC == QMessageBox.Yes:
fileInfo = QFileInfo( self.outShape.text() )
Expand Down Expand Up @@ -188,7 +188,7 @@ def run(self):
pntFeat = QgsFeature()
outFeat = QgsFeature()
inGeom = QgsGeometry()
polyFit = polyProvider.getFeatures()
polyFit = polyProvider.getFeatures()
while polyFit.nextFeature(polyFeat):
inGeom = polyFeat.geometry()
atMap = polyFeat.attributes()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doRandPoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def accept(self):
self.progressBar.setValue(100)
self.outShape.clear()
addToTOC = QMessageBox.question(self, self.tr("Random Points"),
self.tr("Created output point shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg(outPath), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
self.tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (outPath), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
Expand Down Expand Up @@ -255,7 +255,7 @@ def loopThruPolygons(self, inLayer, numRand, design):
value = int(round(numRand * sDistArea.measure(sGeom)))
elif design == self.tr("field"):
sAtMap = sFeat.attributes()
value = sAtMap[index].toInt()[0]
value = sAtMap[index]
else:
value = numRand
sExt = sGeom.boundingBox()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/fTools/tools/doRegPoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def accept(self):
print crs.isValid()
if not crs.isValid(): crs = None
self.regularize(boundBox, outPath, offset, value, self.rdoSpacing.isChecked(), self.spnInset.value(), crs)
addToTOC = QMessageBox.question(self, self.tr("Generate Regular Points"), self.tr("Created output point shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg( outPath ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
addToTOC = QMessageBox.question(self, self.tr("Generate Regular Points"), self.tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % ( outPath ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
Expand Down
17 changes: 7 additions & 10 deletions python/plugins/fTools/tools/doSimplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def accept( self ):
if outFile.exists():
if not QgsVectorFileWriter.deleteShapeFile( outFileName ):
QMessageBox.warning( self, self.tr( "Delete error" ),
self.tr( "Can't delete file %1" ).arg( outFileName ) )
self.tr( "Can't delete file %s" ) % ( outFileName ) )
return

self.workThread = GeomThread( self.myFunction, vLayer, self.chkUseSelection.isChecked(),
Expand Down Expand Up @@ -137,17 +137,14 @@ def processFinished( self, pointsCount ):

if self.myFunction == 1:
QMessageBox.information( self, self.tr( "Simplify results" ),
self.tr( "There were %1 vertices in original dataset which\nwere reduced to %2 vertices after simplification" )
.arg( pointsCount[ 0 ] )
.arg( pointsCount[ 1 ] ) )
self.tr( "There were %d vertices in original dataset which\nwere reduced to %d vertices after simplification" ) % ( pointsCount[ 0 ], pointsCount[ 1 ] ) )

self.restoreGui()

if self.chkAddToCanvas.isEnabled() and self.chkAddToCanvas.isChecked():
if not ftools_utils.addShapeToCanvas( unicode( self.shapeFileName ) ):
QMessageBox.warning( self, self.tr( "Error" ),
self.tr( "Error loading output shapefile:\n%1" )
.arg( unicode( self.shapeFileName ) ) )
self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapeFileName ) ) )
self.populateLayers()

QMessageBox.information( self, self.tr( "Finished" ), self.tr( "Processing completed." ) )
Expand Down Expand Up @@ -304,7 +301,7 @@ def runSimplify( self ):
else:
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
f = QgsFeature()
fit = vProvider.getFeatures()
fit = vProvider.getFeatures()
while fit.nextFeature( f ):
featGeometry = QgsGeometry( f.geometry() )
attrMap = f.attributes()
Expand Down Expand Up @@ -354,7 +351,7 @@ def runSimplify( self ):
vProvider = self.inputLayer.dataProvider()
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
f = QgsFeature()
fit = vProvider.getFeatures()
fit = vProvider.getFeatures()
while fit.nextFeature( f ):
featureId = f.id()
featGeometry = QgsGeometry( f.geometry() )
Expand Down Expand Up @@ -431,7 +428,7 @@ def runDensify( self ):
else:
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
f = QgsFeature()
fit = vProvider.getFeatures()
fit = vProvider.getFeatures()
while fit.nextFeature( f ):
featGeometry = QgsGeometry( f.geometry() )
attrMap = f.attributes()
Expand Down Expand Up @@ -477,7 +474,7 @@ def runDensify( self ):
vProvider = self.inputLayer.dataProvider()
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
f = QgsFeature()
fit = vProvider.getFeatures()
fit = vProvider.getFeatures()
while fit.nextFeature( f ):
featureId = f.id()
featGeometry = QgsGeometry( f.geometry() )
Expand Down
14 changes: 6 additions & 8 deletions python/plugins/fTools/tools/doSpatialJoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ def accept(self):
self.outShape.clear()
if res:
addToTOC = QMessageBox.question(self, self.tr("Spatial Join"),
self.tr("Created output shapefile:\n%1\n\nWould you like to add the new layer to the TOC?")
.arg(unicode(outPath)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
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)
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
Expand All @@ -123,12 +122,12 @@ def outFile(self):
def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar):
layer1 = ftools_utils.getVectorLayerByName(inName)
provider1 = layer1.dataProvider()
fieldList1 = ftools_utils.getFieldList(layer1).toList()
fieldList1 = ftools_utils.getFieldList(layer1)

layer2 = ftools_utils.getVectorLayerByName(joinName)
provider2 = layer2.dataProvider()

fieldList2 = ftools_utils.getFieldList(layer2).toList()
fieldList2 = ftools_utils.getFieldList(layer2)
fieldList = []
if provider1.crs() != provider2.crs():
QMessageBox.warning(self, self.tr("CRS warning!"), self.tr("Warning: Input layers have non-matching CRS.\nThis may cause unexpected results."))
Expand Down Expand Up @@ -157,8 +156,7 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
longNames = ftools_utils.checkFieldNameLength( fieldList1.values() )
if not longNames.isEmpty():
QMessageBox.warning( self, self.tr( 'Incorrect field names' ),
self.tr( 'No output will be created.\nFollowing field names are longer than 10 characters:\n%1' )
.arg( longNames.join( '\n' ) ) )
self.tr( 'No output will be created.\nFollowing field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) ) )
return False

sRs = provider1.crs()
Expand All @@ -167,7 +165,7 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
QMessageBox.warning( self, self.tr( 'Error deleting shapefile' ),
self.tr( "Can't delete existing shapefile\n%1" ).arg( self.shapefileName ) )
self.tr( "Can't delete existing shapefile\n%s" ) % ( self.shapefileName ) )
return False
fields = QgsFields()
for f in fieldList1.values():
Expand Down Expand Up @@ -222,7 +220,7 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
break
else:
for j in numFields.keys():
numFields[j].append(atMap2[j].toDouble()[0])
numFields[j].append(atMap2[j])
if summary and not none:
atMap = atMap1
for j in numFields.keys():
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/fTools/tools/doSumLines.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def accept(self):
outName = outName.left(outName.length() - 4)
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%1\n\nWould you like to add the new layer to the TOC?").arg(unicode(outPath)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
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)
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/fTools/tools/doValidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self, iface):
self.marker = MarkerErrorGeometry(self.iface.mapCanvas())

settings = QSettings()
self.restoreGeometry( settings.value("/fTools/ValidateDialog/geometry").toByteArray() )
self.restoreGeometry( settings.value("/fTools/ValidateDialog/geometry") )

QObject.connect( self.browseShpError, SIGNAL( "clicked()" ), self.outFile )
QObject.connect( self.ckBoxShpError, SIGNAL( "stateChanged( int )" ), self.updateGui )
Expand Down Expand Up @@ -181,8 +181,8 @@ def zoomToError(self, curr, prev):
self.marker.reset()

ft = QgsFeature()
(fid,ok) = self.tblUnique.item(row, 0).text().toInt()
if not ok or not self.vlayer.getFeatures( QgsFeatureRequest().setFilterFid( fid ) ).nextFeature( ft ):
fid = int(self.tblUnique.item(row, 0).text())
if not self.vlayer.getFeatures( QgsFeatureRequest().setFilterFid( fid ) ).nextFeature( ft ):
return

rect = mc.mapRenderer().layerExtentToOutputExtent( self.vlayer, ft.geometry().boundingBox() )
Expand Down Expand Up @@ -230,12 +230,12 @@ def runFinishedFromThread( self, success ):
if success == "writeShape":
extra = ""
addToTOC = QMessageBox.question( self, self.tr("Geometry"),
self.tr( "Created output shapefile:\n%1\n%2\n\nWould you like to add the new layer to the TOC?" ).arg( unicode( self.shapefileName ) ).arg( extra ),
self.tr( "Created output shapefile:\n%s\n%s\n\nWould you like to add the new layer to the TOC?" ) % ( unicode( self.shapefileName ), extra ),
QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton )
if addToTOC == QMessageBox.Yes:
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
QMessageBox.warning( self, self.tr( "Geometry"),
self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( self.shapefileName ) ) )
self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ) )
else:
self.tblUnique.setColumnCount( 2 )
count = 0
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/fTools/tools/doVectorGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def accept(self):
QApplication.setOverrideCursor(Qt.WaitCursor)
self.compute( boundBox, xSpace, ySpace, polygon )
QApplication.restoreOverrideCursor()
addToTOC = QMessageBox.question(self, self.tr("Generate Vector Grid"), self.tr("Created output shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg(unicode(self.shapefileName)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
addToTOC = QMessageBox.question(self, self.tr("Generate Vector Grid"), self.tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (unicode(self.shapefileName)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
if addToTOC == QMessageBox.Yes:
ftools_utils.addShapeToCanvas( self.shapefileName )
self.populateLayers()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/fTools/tools/doVectorSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def processFinished(self, errors):
QErrorMessage( self ).showMessage( msg )

QMessageBox.information(self, self.tr("Vector Split"),
self.tr("Created output shapefiles in folder:\n%1").arg(outPath))
self.tr("Created output shapefiles in folder:\n%s") % (outPath))

class SplitThread(QThread):
def __init__(self, layer, splitField, encoding, outDir):
Expand Down
10 changes: 4 additions & 6 deletions python/plugins/fTools/tools/doVisual.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ def __init__( self, parentThread, parentObject, function, vlayer, myField, mySel
self.vlayer = vlayer
self.myField = myField
self.mySelection = mySelection
# self.total = 0
# self.currentCount = 0

def run( self ):
self.running = True
Expand Down Expand Up @@ -274,7 +272,7 @@ def basic_statistics( self, vlayer, myField ):
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
for f in selection:
atMap = f.attributes()
lenVal = float( len( atMap[ index ].toString() ) )
lenVal = float( len( atMap[ index ] ) )
if first:
minVal = lenVal
maxVal = lenVal
Expand All @@ -298,7 +296,7 @@ def basic_statistics( self, vlayer, myField ):
fit = vprovider.getFeatures()
while fit.nextFeature( feat ):
atMap = feat.attributes()
lenVal = float( len( atMap[ index ].toString() ) )
lenVal = float( len( atMap[ index ] ) )
if first:
minVal = lenVal
maxVal = lenVal
Expand Down Expand Up @@ -343,7 +341,7 @@ def basic_statistics( self, vlayer, myField ):
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
for f in selection:
atMap = f.attributes()
value = float( atMap[ index ].toDouble()[ 0 ] )
value = float( atMap[ index ] )
if first:
minVal = value
maxVal = value
Expand All @@ -364,7 +362,7 @@ def basic_statistics( self, vlayer, myField ):
fit = vprovider.getFeatures()
while fit.nextFeature( feat ):
atMap = feat.attributes()
value = float( atMap[ index ].toDouble()[ 0 ] )
value = float( atMap[ index ] )
if first:
minVal = value
maxVal = value
Expand Down