more api updates in fTools (still incomplete)

This commit is contained in:
Alexander Bruy 2013-05-31 14:57:34 +04:00
parent 979a11ec0b
commit d3d51820e3
17 changed files with 93 additions and 95 deletions

View File

@ -28,6 +28,8 @@
#
#---------------------------------------------------------------------
import re
from PyQt4.QtCore import *
from PyQt4.QtGui import *
@ -50,14 +52,14 @@ class Dialog(QDialog, Ui_Dialog):
self.setWindowTitle(self.tr("Define current projection"))
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
QObject.connect(self.btnProjection, SIGNAL("clicked()"), self.outProjFile)
#QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
#QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
#self.inShape.addItems(layers)
#self.cmbLayer.addItems(layers)
self.inShape.addItems(layers)
self.cmbLayer.addItems(layers)
self.crs = None
@ -114,11 +116,14 @@ class Dialog(QDialog, Ui_Dialog):
provider = vLayer.dataProvider()
self.progressBar.setValue(35)
inPath = provider.dataSourceUri()
inPath = inPath.remove( QRegExp( "\|.*" ) )
p = re.compile("\|.*")
inPath = p.sub("", inPath)
print "PATH", inPath
self.progressBar.setValue(40)
if inPath.endsWith(".shp"):
inPath = inPath.left(inPath.length() - 4)
if inPath.endswith(".shp"):
inPath = inPath[:-4]
self.progressBar.setValue(55)
print "PATH2", inPath
if not srsDefine.isValid():
QMessageBox.information(self, self.tr("Define current projection"), self.tr("Output spatial reference system is not valid"))
else:
@ -142,20 +147,22 @@ class Dialog(QDialog, Ui_Dialog):
self.progressBar.setValue(95)
vLayer.setCrs(srsDefine)
self.progressBar.setValue(100)
QMessageBox.information(self, self.tr("Define current projection"), self.tr("Defined Projection For:\n%1.shp").arg( inPath ) )
print "PATH3", inPath
QMessageBox.information(self, self.tr("Define current projection"),
self.tr("Defined Projection For:\n%s.shp") % (inPath) )
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )
def outProjFile(self):
format = "<h2>%1</h2>%2 <br/> %3"
header = "Define layer CRS:"
sentence1 = self.tr( "Please select the projection system that defines the current layer." )
sentence2 = self.tr( "Layer CRS information will be updated to the selected CRS." )
projSelector = QgsGenericProjectionSelector(self)
projSelector.setMessage( format.arg( header ).arg( sentence1 ).arg( sentence2 ))
projSelector.setMessage( "<h2>%s</h2>%s <br/> %s" % (header, sentence1, sentence2) )
if projSelector.exec_():
self.crs = QgsCoordinateReferenceSystem( projSelector.selectedCrsId(), QgsCoordinateReferenceSystem.InternalCrsId )
if projSelector.selectedAuthId().isEmpty():
print "AUTHID", projSelector.selectedAuthId()
if len(projSelector.selectedAuthId()) == 0:
QMessageBox.information(self, self.tr("Export to new projection"), self.tr("No Valid CRS selected"))
return
else:

View File

@ -55,7 +55,7 @@ class Dialog(QtGui.QDialog, Ui_Dialog):
def update(self, inputLayer):
changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
selFeatures = changedLayer.selectedFeatureCount()
self.selected.setText( self.tr("Selected features: %1").arg(selFeatures))
self.selected.setText( self.tr("Selected features: %s") % (selFeatures))
def accept(self):
self.buttonOk.setEnabled(False)
@ -75,7 +75,7 @@ class Dialog(QtGui.QDialog, Ui_Dialog):
if outFile.exists():
if not QgsVectorFileWriter.deleteShapeFile(outFileName):
QtGui.QMessageBox.warning(self, self.tr("Delete error"),
self.tr("Can't delete file %1").arg(outFileName))
self.tr("Can't delete file %s") % (outFileName))
self.buttonOk.setEnabled(True)
return None
@ -109,7 +109,7 @@ class Dialog(QtGui.QDialog, Ui_Dialog):
msg = ""
for aStrm in outLayer.commitErrors():
msg = msg + "\n" + aStrm
QtGui.QMessageBox.warning(self, self.tr("Eliminate"), self.tr("Commit error:\n %1").arg(msg))
QtGui.QMessageBox.warning(self, self.tr("Eliminate"), self.tr("Commit error:\n%s") % (msg))
outLayer.rollBack()
return False
@ -203,7 +203,7 @@ class Dialog(QtGui.QDialog, Ui_Dialog):
fidsToDeselect.append(fid2Eliminate)
else:
QtGui.QMessageBox.warning(self, self.tr("Eliminate"),
self.tr("Could not replace geometry of feature with id %1").arg( mergeWithFid ))
self.tr("Could not replace geometry of feature with id %s") % (mergeWithFid))
return None
start = start + add
@ -219,16 +219,16 @@ class Dialog(QtGui.QDialog, Ui_Dialog):
# copy all features that could not be eliminated to outLayer
if outLayer.addFeatures(inLayer.selectedFeatures()):
# inform user
fidList = QtCore.QString()
fidList = ""
for fid in inLayer.selectedFeaturesIds():
if not fidList.isEmpty():
fidList.append(", ")
if not fidList == "":
fidList += ", "
fidList.append(str(fid))
fidList += str(fid)
QtGui.QMessageBox.information(self, self.tr("Eliminate"),
self.tr("Could not eliminate features with these ids:\n%1").arg(fidList))
self.tr("Could not eliminate features with these ids:\n%s") %s (fidList))
else:
QtGui.QMessageBox.warning(self, self.tr("Eliminate"), self.tr("Could not add features"))
@ -241,6 +241,6 @@ class Dialog(QtGui.QDialog, Ui_Dialog):
ftools_utils.addShapeToCanvas(outFileName)
else:
QtGui.QMessageBox.information(self, self.tr("Eliminate"),
self.tr("Created output shapefile:\n%1").arg(outFileName))
self.tr("Created output shapefile:\n%s") %s (outFileName))
self.iface.mapCanvas().refresh()

View File

@ -241,8 +241,7 @@ class GeoprocessingDialog( QDialog, Ui_Dialog ):
out_text = ""
if results[3] is not None:
QMessageBox.warning( self, self.tr( "Geoprocessing" ),
self.tr( "No output created. File creation error:\n%1" )
.arg( results[3] ) )
self.tr( "No output created. File creation error:\n%s" ) % ( results[3] ) )
return
if (not results[2] is None and not results[2]) or not results[1] or not results [0]:
out_text = self.tr( "\nWarnings:" )
@ -259,10 +258,10 @@ class GeoprocessingDialog( QDialog, Ui_Dialog ):
out_text = out_text + self.tr( "\nFeature geometry error: One or more output features ignored due to invalid geometry.")
if not results[0]:
out_text = out_text + self.tr( "\nGEOS geoprocessing error: One or more input features have invalid geometry.")
addToTOC = QMessageBox.question( self, self.tr("Geoprocessing"), self.tr( "Created output shapefile:\n%1\n%2%3" ).arg( unicode( self.shapefileName ) ).arg( out_text ).arg( end_text ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton )
addToTOC = QMessageBox.question( self, self.tr("Geoprocessing"), self.tr( "Created output shapefile:\n%s\n%s%s" ) % ( unicode( self.shapefileName ), out_text, end_text ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton )
if addToTOC == QMessageBox.Yes:
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( self.shapefileName ) ))
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
self.populateLayers()
def runStatusFromThread( self, status ):
@ -378,7 +377,7 @@ class geoprocessingThread( QThread ):
for inFeat in selectionA:
atMap = inFeat.attributes()
if useField:
value = atMap[ self.myParam ].toDouble()[ 0 ]
value = atMap[ self.myParam ]
else:
value = self.myParam
inGeom = QgsGeometry( inFeat.geometry() )
@ -408,7 +407,7 @@ class geoprocessingThread( QThread ):
while fit.nextFeature( inFeat ):
atMap = inFeat.attributes()
if useField:
value = atMap[ self.myParam ].toDouble()[ 0 ]
value = atMap[ self.myParam ]
else:
value = self.myParam
inGeom = QgsGeometry( inFeat.geometry() )
@ -439,7 +438,7 @@ class geoprocessingThread( QThread ):
while fit.nextFeature( inFeat ):
atMap = inFeat.attributes()
if useField:
value = atMap[ self.myParam ].toDouble()[ 0 ]
value = atMap[ self.myParam ]
else:
value = self.myParam
inGeom = QgsGeometry( inFeat.geometry() )
@ -644,7 +643,7 @@ class geoprocessingThread( QThread ):
nElement += 1
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
atMap = inFeat.attributes()
tempItem = unicode(atMap[self.myParam].toString().trimmed())
tempItem = unicode(atMap[self.myParam]).strip()
if not (tempItem in outFeats):
outFeats[tempItem] = QgsGeometry(inFeat.geometry())
@ -699,7 +698,7 @@ class geoprocessingThread( QThread ):
nElement += 1
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
atMap = inFeat.attributes()
tempItem = unicode(atMap[self.myParam].toString().trimmed())
tempItem = unicode(atMap[self.myParam]).strip()
if not (tempItem in outFeats):
outFeats[tempItem] = QgsGeometry(inFeat.geometry())
@ -894,7 +893,7 @@ class geoprocessingThread( QThread ):
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
longNames = ftools_utils.checkFieldNameLength( fields )
if not longNames.isEmpty():
message = QString( 'Following field names are longer than 10 characters:\n%1' ).arg( longNames.join( '\n' ) )
message = QString( 'Following field names are longer than 10 characters:\n%s' ) % ( '\n'.join(longNames) )
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,
@ -1079,7 +1078,7 @@ class geoprocessingThread( QThread ):
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
longNames = ftools_utils.checkFieldNameLength( fields )
if not longNames.isEmpty():
message = QString( 'Following field names are longer than 10 characters:\n%1' ).arg( longNames.join( '\n' ) )
message = QString( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,
@ -1265,7 +1264,7 @@ class geoprocessingThread( QThread ):
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
longNames = ftools_utils.checkFieldNameLength( fields )
if not longNames.isEmpty():
message = QString( 'Following field names are longer than 10 characters:\n%1' ).arg( longNames.join( '\n' ) )
message = QString( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,

View File

@ -95,10 +95,10 @@ class Dialog(QDialog, Ui_Dialog):
self.outShape.clear()
self.compute(line1, line2, field1, field2, outPath, self.progressBar)
self.progressBar.setValue(100)
addToTOC = QMessageBox.question(self, self.tr("Generate Centroids"), 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 Centroids"), 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:
if not ftools_utils.addShapeToCanvas( unicode( outPath ) ):
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( outPath ) ))
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
self.populateLayers()
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

View File

@ -95,7 +95,7 @@ class Dialog(QDialog, Ui_Dialog):
self.compute(inName, outPath, self.weightField.currentText(), self.sizeValue.value(), self.uniqueField.currentText())
self.progressBar.setValue(100)
self.outShape.clear()
addToTOC = QMessageBox.question(self, self.tr("Coordinate statistics"), 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("Coordinate statistics"), 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:
vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayers([vlayer])
@ -155,7 +155,7 @@ class Dialog(QDialog, Ui_Dialog):
nElement += 1
self.progressBar.setValue(nElement)
if single:
check = j.toString().trimmed()
check = j.strip()
else:
check = feat.attributes()[uniqueIndex].toString().trimmed()
if check == j.toString().trimmed():
@ -164,7 +164,7 @@ class Dialog(QDialog, Ui_Dialog):
if weightIndex == -1:
weight = 1.00
else:
weight = float(feat.attributes()[weightIndex].toDouble()[0])
weight = float(feat.attributes()[weightIndex]
geom = QgsGeometry(feat.geometry())
geom = ftools_utils.extractPoints(geom)
for i in geom:

View File

@ -48,7 +48,7 @@ class Dialog( QDialog, Ui_Dialog ):
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 )
@ -109,7 +109,7 @@ class Dialog( QDialog, Ui_Dialog ):
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 )
@ -148,7 +148,7 @@ class Dialog( QDialog, Ui_Dialog ):
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:
@ -197,8 +197,7 @@ class Dialog( QDialog, Ui_Dialog ):
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()

View File

@ -193,14 +193,14 @@ class Dialog(QDialog, Ui_Dialog):
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:
@ -223,13 +223,13 @@ class Dialog(QDialog, Ui_Dialog):
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:

View File

@ -114,7 +114,7 @@ class Dialog(QDialog, Ui_Dialog):
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() )

View File

@ -125,7 +125,7 @@ class Dialog(QDialog, Ui_Dialog):
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])
@ -255,7 +255,7 @@ class Dialog(QDialog, Ui_Dialog):
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()

View File

@ -89,7 +89,7 @@ class Dialog(QDialog, Ui_Dialog):
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])

View File

@ -98,7 +98,7 @@ class Dialog( QDialog, Ui_Dialog ):
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(),
@ -137,17 +137,14 @@ class Dialog( QDialog, Ui_Dialog ):
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." ) )

View File

@ -105,8 +105,7 @@ class Dialog(QDialog, Ui_Dialog):
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])
@ -123,12 +122,12 @@ class Dialog(QDialog, Ui_Dialog):
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."))
@ -157,8 +156,7 @@ class Dialog(QDialog, Ui_Dialog):
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()
@ -167,7 +165,7 @@ class Dialog(QDialog, Ui_Dialog):
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():
@ -222,7 +220,7 @@ class Dialog(QDialog, Ui_Dialog):
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():

View File

@ -78,7 +78,7 @@ class Dialog(QDialog, Ui_Dialog):
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])

View File

@ -95,7 +95,7 @@ class ValidateDialog( QDialog, Ui_Dialog ):
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 )
@ -181,8 +181,8 @@ class ValidateDialog( QDialog, Ui_Dialog ):
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() )
@ -230,12 +230,12 @@ class ValidateDialog( QDialog, Ui_Dialog ):
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

View File

@ -146,7 +146,7 @@ class Dialog(QDialog, Ui_Dialog):
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()

View File

@ -128,7 +128,7 @@ class Dialog(QDialog, Ui_Dialog):
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):

View File

@ -216,8 +216,6 @@ class visualThread( QThread ):
self.vlayer = vlayer
self.myField = myField
self.mySelection = mySelection
# self.total = 0
# self.currentCount = 0
def run( self ):
self.running = True
@ -274,7 +272,7 @@ class visualThread( QThread ):
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
@ -298,7 +296,7 @@ class visualThread( QThread ):
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
@ -343,7 +341,7 @@ class visualThread( QThread ):
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
@ -364,7 +362,7 @@ class visualThread( QThread ):
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