Skip to content

Commit a75563f

Browse files
committed
more SIP updates for fTools
1 parent d3d5182 commit a75563f

19 files changed

+132
-136
lines changed

python/plugins/fTools/tools/doGeometry.py

+40-40
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def outFile( self ):
8989
(self.shapefileName, self.encoding) = ftools_utils.saveDialog( self )
9090
if self.shapefileName is None or self.encoding is None:
9191
return
92-
self.outShape.setText( QString( self.shapefileName ) )
92+
self.outShape.setText( self.shapefileName )
9393

9494
def manageGui( self ):
9595
self.lblField.setVisible( False )
@@ -365,12 +365,12 @@ def single_to_multi( self ):
365365
if not index == -1:
366366
unique = ftools_utils.getUniqueValues( vprovider, int( index ) )
367367
else:
368-
unique = [ QVariant( QString() ) ]
368+
unique = [ "" ]
369369
nFeat = vprovider.featureCount() * len( unique )
370370
nElement = 0
371371
self.emit( SIGNAL( "runStatus( PyQt_PyObject )" ), 0 )
372372
self.emit( SIGNAL( "runRange( PyQt_PyObject )" ), ( 0, nFeat ) )
373-
merge_all = self.myField == QString( "--- " + self.tr( "Merge all" ) + " ---" )
373+
merge_all = self.myField == "--- " + self.tr( "Merge all" ) + " ---"
374374
if not len( unique ) == self.vlayer.featureCount() or merge_all:
375375
for i in unique:
376376
multi_feature= []
@@ -381,8 +381,8 @@ def single_to_multi( self ):
381381
if not merge_all:
382382
idVar = atMap[ index ]
383383
else:
384-
idVar = QVariant( QString() )
385-
if idVar.toString().trimmed() == i.toString().trimmed() or merge_all:
384+
idVar = ""
385+
if idVar.strip() == i.strip() or merge_all:
386386
if first:
387387
atts = atMap
388388
first = False
@@ -530,7 +530,7 @@ def export_geometry_info( self ):
530530
# 2 - ellipsoidal
531531
if self.myCalcType == 2:
532532
settings = QSettings()
533-
ellips = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString()
533+
ellips = settings.value( "/qgis/measure/ellipsoid", "WGS84" )
534534
crs = self.vlayer.crs().srsid()
535535
elif self.myCalcType == 1:
536536
mapCRS = self.parent.iface.mapCanvas().mapRenderer().destinationCrs()
@@ -568,7 +568,7 @@ def export_geometry_info( self ):
568568
atMap = inFeat.attributes()
569569
maxIndex = index1 if index1>index2 else index2
570570
if maxIndex>len(atMap):
571-
atMap += [ QVariant() ] * ( index2+1 - len(atMap) )
571+
atMap += [ "" ] * ( index2+1 - len(atMap) )
572572
atMap[ index1 ] = attr1
573573
if index1!=index2:
574574
atMap[ index2 ] = attr2
@@ -577,9 +577,9 @@ def export_geometry_info( self ):
577577
else:
578578
changeMap = {}
579579
changeMap[ inFeat.id() ] = {}
580-
changeMap[ inFeat.id() ][ index1 ] = QVariant( attr1 )
580+
changeMap[ inFeat.id() ][ index1 ] = attr1
581581
if index1!=index2:
582-
changeMap[ inFeat.id() ][ index2 ] = QVariant( attr2 )
582+
changeMap[ inFeat.id() ][ index2 ] = attr2
583583
vprovider.changeAttributeValues( changeMap )
584584

585585
if self.writeShape:
@@ -663,7 +663,7 @@ def delaunay_triangulation( self ):
663663
point = QgsPoint( geom.asPoint() )
664664
polygon.append( point )
665665
if step <= 3:
666-
attrs.append(QVariant( ids[ index ] ) )
666+
attrs.append(ids[ index ] )
667667
step += 1
668668
feat.setAttributes(attrs)
669669
geometry = QgsGeometry().fromPolygon( [ polygon ] )
@@ -853,16 +853,16 @@ def layer_extent( self ):
853853
geometry = QgsGeometry().fromPolygon( [ rect ] )
854854
feat = QgsFeature()
855855
feat.setGeometry( geometry )
856-
feat.setAttributes( [ QVariant( minx ),
857-
QVariant( miny ),
858-
QVariant( maxx ),
859-
QVariant( maxy ),
860-
QVariant( cntx ),
861-
QVariant( cnty ),
862-
QVariant( area ),
863-
QVariant( perim ),
864-
QVariant( height ),
865-
QVariant( width ) ] )
856+
feat.setAttributes( [ minx,
857+
miny,
858+
maxx,
859+
maxy,
860+
cntx,
861+
cnty,
862+
area,
863+
perim,
864+
height,
865+
width ] )
866866
writer.addFeature( feat )
867867
self.emit( SIGNAL( "runRange( PyQt_PyObject )" ), ( 0, 100 ) )
868868
self.emit( SIGNAL( "runStatus( PyQt_PyObject )" ), 0 )
@@ -916,16 +916,16 @@ def feature_extent( self, ):
916916
geometry = QgsGeometry().fromPolygon( [ rect ] )
917917

918918
outFeat.setGeometry( geometry )
919-
outFeat.setAttributes( [ QVariant( minx ),
920-
QVariant( miny ),
921-
QVariant( maxx ),
922-
QVariant( maxy ),
923-
QVariant( cntx ),
924-
QVariant( cnty ),
925-
QVariant( area ),
926-
QVariant( perim ),
927-
QVariant( height ),
928-
QVariant( width ) ] )
919+
outFeat.setAttributes( [ minx,
920+
miny,
921+
maxx,
922+
maxy,
923+
cntx,
924+
cnty,
925+
area,
926+
perim,
927+
height,
928+
width ] )
929929
writer.addFeature( outFeat )
930930
else:
931931
self.emit( SIGNAL( "runRange( PyQt_PyObject )" ), ( 0, vprovider.featureCount() ) )
@@ -953,16 +953,16 @@ def feature_extent( self, ):
953953
geometry = QgsGeometry().fromPolygon( [ rect ] )
954954

955955
outFeat.setGeometry( geometry )
956-
outFeat.setAttributes( [ QVariant( minx ),
957-
QVariant( miny ),
958-
QVariant( maxx ),
959-
QVariant( maxy ),
960-
QVariant( cntx ),
961-
QVariant( cnty ),
962-
QVariant( area ),
963-
QVariant( perim ),
964-
QVariant( height ),
965-
QVariant( width ) ] )
956+
outFeat.setAttributes( [ minx,
957+
miny,
958+
maxx,
959+
maxy,
960+
cntx,
961+
cnty,
962+
area,
963+
perim,
964+
height,
965+
width ] )
966966
writer.addFeature( outFeat )
967967

968968
del writer

python/plugins/fTools/tools/doGeoprocessing.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def outFile( self ):
124124
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
125125
if self.shapefileName is None or self.encoding is None:
126126
return
127-
self.outShape.setText( QString( self.shapefileName ) )
127+
self.outShape.setText( self.shapefileName )
128128

129129
def manageGui( self ):
130130
if self.myFunction == 1: # Buffer
@@ -403,7 +403,7 @@ def buffering( self, useField ):
403403
# with dissolve
404404
if self.myMerge:
405405
first = True
406-
fit = vproviderA.getFeatures()
406+
fit = vproviderA.getFeatures()
407407
while fit.nextFeature( inFeat ):
408408
atMap = inFeat.attributes()
409409
if useField:
@@ -434,7 +434,7 @@ def buffering( self, useField ):
434434
FEATURE_EXCEPT = False
435435
# without dissolve
436436
else:
437-
fit = vproviderA.getFeatures()
437+
fit = vproviderA.getFeatures()
438438
while fit.nextFeature( inFeat ):
439439
atMap = inFeat.attributes()
440440
if useField:
@@ -491,7 +491,7 @@ def convex_hull(self, useField ):
491491
for inFeat in selectionA:
492492
atMap = inFeat.attributes()
493493
idVar = atMap[ self.myParam ]
494-
if idVar.toString().trimmed() == i.toString().trimmed():
494+
if idVar.strip() == i.strip():
495495
if first:
496496
outID = idVar
497497
first = False
@@ -506,9 +506,9 @@ def convex_hull(self, useField ):
506506
outGeom = tmpGeom.convexHull()
507507
outFeat.setGeometry( outGeom )
508508
(area, perim) = self.simpleMeasure( outGeom )
509-
outFeat.setAttribute( 0, QVariant( outID ) )
510-
outFeat.setAttribute( 1, QVariant( area ) )
511-
outFeat.setAttribute( 2, QVariant( perim ) )
509+
outFeat.setAttribute( 0, outID )
510+
outFeat.setAttribute( 1, area )
511+
outFeat.setAttribute( 2, perim )
512512
writer.addFeature( outFeat )
513513
except:
514514
GEOS_EXCEPT = False
@@ -547,7 +547,7 @@ def convex_hull(self, useField ):
547547
while fitA.nextFeature( inFeat ):
548548
atMap = inFeat.attributes()
549549
idVar = atMap[ self.myParam ]
550-
if idVar.toString().trimmed() == i.toString().trimmed():
550+
if idVar.strip() == i.strip():
551551
if first:
552552
outID = idVar
553553
first = False
@@ -562,9 +562,9 @@ def convex_hull(self, useField ):
562562
outGeom = tmpGeom.convexHull()
563563
outFeat.setGeometry( outGeom )
564564
(area, perim) = self.simpleMeasure( outGeom )
565-
outFeat.setAttribute( 0, QVariant( outID ) )
566-
outFeat.setAttribute( 1, QVariant( area ) )
567-
outFeat.setAttribute( 2, QVariant( perim ) )
565+
outFeat.setAttribute( 0, outID )
566+
outFeat.setAttribute( 1, area )
567+
outFeat.setAttribute( 2, perim )
568568
writer.addFeature( outFeat )
569569
except:
570570
GEOS_EXCEPT = False
@@ -573,7 +573,7 @@ def convex_hull(self, useField ):
573573
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
574574
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
575575
hull = []
576-
fitA = vproviderA.getFeatures()
576+
fitA = vproviderA.getFeatures()
577577
while fitA.nextFeature( inFeat ):
578578
inGeom = QgsGeometry( inFeat.geometry() )
579579
points = ftools_utils.extractPoints( inGeom )
@@ -816,7 +816,7 @@ def difference( self ):
816816
# we have selection in overlay layer
817817
if self.mySelectionB:
818818
selectionB = self.vlayerB.selectedFeaturesIds()
819-
fitA = vproviderA.getFeatures()
819+
fitA = vproviderA.getFeatures()
820820
while fitA.nextFeature( inFeatA ):
821821
nElement += 1
822822
add = True
@@ -893,7 +893,7 @@ def intersect( self ):
893893
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
894894
longNames = ftools_utils.checkFieldNameLength( fields )
895895
if not longNames.isEmpty():
896-
message = QString( 'Following field names are longer than 10 characters:\n%s' ) % ( '\n'.join(longNames) )
896+
message = self.tr('Following field names are longer than 10 characters:\n%s') % ( '\n'.join(longNames) )
897897
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
898898

899899
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,
@@ -992,7 +992,7 @@ def intersect( self ):
992992
# we have selection in overlay layer
993993
if self.mySelectionB:
994994
selectionB = self.vlayerB.selectedFeaturesIds()
995-
fitA = vproviderA.getFeatures()
995+
fitA = vproviderA.getFeatures()
996996
while fitA.nextFeature( inFeatA ):
997997
nElement += 1
998998
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
@@ -1078,7 +1078,7 @@ def union( self ):
10781078
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
10791079
longNames = ftools_utils.checkFieldNameLength( fields )
10801080
if not longNames.isEmpty():
1081-
message = QString( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
1081+
message = self.tr( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
10821082
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
10831083

10841084
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,
@@ -1264,7 +1264,7 @@ def symetrical_difference( self ):
12641264
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
12651265
longNames = ftools_utils.checkFieldNameLength( fields )
12661266
if not longNames.isEmpty():
1267-
message = QString( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
1267+
message = self.tr( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
12681268
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
12691269

12701270
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,

python/plugins/fTools/tools/doIntersectLines.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def outFile(self):
108108
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
109109
if self.shapefileName is None or self.encoding is None:
110110
return
111-
self.outShape.setText( QString( self.shapefileName ) )
111+
self.outShape.setText( self.shapefileName )
112112

113113
def compute(self, line1, line2, field1, field2, outPath, progressBar):
114114

@@ -144,7 +144,7 @@ def compute(self, line1, line2, field1, field2, outPath, progressBar):
144144

145145
index = ftools_utils.createIndex( provider2 )
146146

147-
fit1 = vprovider.getFeatures( QgsFeatureRequest().setSubsetOfAttributes([index1]) )
147+
fit1 = vprovider.getFeatures( QgsFeatureRequest().setSubsetOfAttributes([index1]) )
148148
while fit1.nextFeature(inFeat):
149149
inGeom = inFeat.geometry()
150150
v1 = inFeat.attributes()[index1]

python/plugins/fTools/tools/doMeanCoords.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def outFile(self):
108108
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
109109
if self.shapefileName is None or self.encoding is None:
110110
return
111-
self.outShape.setText( QString( self.shapefileName ) )
111+
self.outShape.setText( self.shapefileName )
112112

113113
def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
114114
vlayer = ftools_utils.getVectorLayerByName(inName)
@@ -125,7 +125,7 @@ def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
125125
uniqueValues = ftools_utils.getUniqueValues(provider, int( uniqueIndex ) )
126126
single = False
127127
else:
128-
uniqueValues = [QVariant(1)]
128+
uniqueValues = [1]
129129
single = True
130130
if self.function == 2:
131131
fieldList = QgsFields()
@@ -157,14 +157,14 @@ def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
157157
if single:
158158
check = j.strip()
159159
else:
160-
check = feat.attributes()[uniqueIndex].toString().trimmed()
161-
if check == j.toString().trimmed():
160+
check = feat.attributes()[uniqueIndex].strip()
161+
if check == j.strip():
162162
cx = 0.00
163163
cy = 0.00
164164
if weightIndex == -1:
165165
weight = 1.00
166166
else:
167-
weight = float(feat.attributes()[weightIndex]
167+
weight = float(feat.attributes()[weightIndex])
168168
geom = QgsGeometry(feat.geometry())
169169
geom = ftools_utils.extractPoints(geom)
170170
for i in geom:
@@ -198,13 +198,13 @@ def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
198198
sd += (i-md)*(i-md)
199199
sd = sqrt(sd/item)
200200
outfeat.setGeometry(QgsGeometry.fromPoint(meanPoint).buffer(sd * times, 10))
201-
outfeat.setAttribute(0, QVariant(sd))
202-
outfeat.setAttribute(1, QVariant(j))
201+
outfeat.setAttribute(0, sd)
202+
outfeat.setAttribute(1, j)
203203
else:
204204
outfeat.setGeometry(QgsGeometry.fromPoint(meanPoint))
205-
outfeat.setAttribute(0, QVariant(cx))
206-
outfeat.setAttribute(1, QVariant(cy))
207-
outfeat.setAttribute(2, QVariant(j))
205+
outfeat.setAttribute(0, cx)
206+
outfeat.setAttribute(1, cy)
207+
outfeat.setAttribute(2, j)
208208
writer.addFeature(outfeat)
209209
if single:
210210
break

python/plugins/fTools/tools/doMergeShapes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def inputDir( self ):
5858

5959
workDir = QDir( inDir )
6060
workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
61-
nameFilter = QStringList() << "*.shp" << "*.SHP"
61+
nameFilter = [ "*.shp", "*.SHP" ]
6262
workDir.setNameFilters( nameFilter )
6363
self.inputFiles = workDir.entryList()
6464
if self.inputFiles.count() == 0:
@@ -84,7 +84,7 @@ def inputFile( self ):
8484
self.inputFiles = None
8585
return
8686

87-
self.inputFiles = QStringList()
87+
self.inputFiles = []
8888
for f in files:
8989
fileName = QFileInfo( f ).fileName()
9090
self.inputFiles.append( fileName )
@@ -118,7 +118,7 @@ def accept( self ):
118118
if self.inputFiles is None:
119119
workDir = QDir( self.leInputDir.text() )
120120
workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
121-
nameFilter = QStringList() << "*.shp" << "*.SHP"
121+
nameFilter = [ "*.shp" << "*.SHP" ]
122122
workDir.setNameFilters( nameFilter )
123123
self.inputFiles = workDir.entryList()
124124
if self.inputFiles.count() == 0:
@@ -306,7 +306,7 @@ def run( self ):
306306
inGeom = QgsGeometry()
307307
fit = vprovider.getFeatures()
308308
while fit.nextFeature( inFeat ):
309-
mergedAttrs = [QVariant()] * len(mergedFields)
309+
mergedAttrs = [""] * len(mergedFields)
310310

311311
# fill available attributes with values
312312
fieldIndex = 0

0 commit comments

Comments
 (0)