Skip to content
Permalink
Browse files

Prefer parameterAsBoolean over parameterAsBool

  • Loading branch information
m-kuhn committed Apr 16, 2019
1 parent 4771f80 commit b90a01847f177324147553363722542a577aa307
Showing with 149 additions and 149 deletions.
  1. +2 −2 python/plugins/processing/algs/gdal/Buffer.py
  2. +5 −5 python/plugins/processing/algs/gdal/ClipRasterByMask.py
  3. +1 −1 python/plugins/processing/algs/gdal/ColorRelief.py
  4. +5 −5 python/plugins/processing/algs/gdal/Dissolve.py
  5. +9 −9 python/plugins/processing/algs/gdal/OgrToPostGis.py
  6. +2 −2 python/plugins/processing/algs/gdal/OneSideBuffer.py
  7. +4 −4 python/plugins/processing/algs/gdal/aspect.py
  8. +3 −3 python/plugins/processing/algs/gdal/buildvrt.py
  9. +2 −2 python/plugins/processing/algs/gdal/contour.py
  10. +3 −3 python/plugins/processing/algs/gdal/extractprojection.py
  11. +1 −1 python/plugins/processing/algs/gdal/fillnodata.py
  12. +3 −3 python/plugins/processing/algs/gdal/gdal2tiles.py
  13. +1 −1 python/plugins/processing/algs/gdal/gdal2xyz.py
  14. +1 −1 python/plugins/processing/algs/gdal/gdaladdo.py
  15. +4 −4 python/plugins/processing/algs/gdal/gdalinfo.py
  16. +2 −2 python/plugins/processing/algs/gdal/gdaltindex.py
  17. +4 −4 python/plugins/processing/algs/gdal/hillshade.py
  18. +2 −2 python/plugins/processing/algs/gdal/merge.py
  19. +1 −1 python/plugins/processing/algs/gdal/nearblack.py
  20. +9 −9 python/plugins/processing/algs/gdal/ogr2ogrtopostgislist.py
  21. +2 −2 python/plugins/processing/algs/gdal/ogrinfo.py
  22. +1 −1 python/plugins/processing/algs/gdal/pct2rgb.py
  23. +1 −1 python/plugins/processing/algs/gdal/polygonize.py
  24. +2 −2 python/plugins/processing/algs/gdal/rasterize.py
  25. +2 −2 python/plugins/processing/algs/gdal/retile.py
  26. +1 −1 python/plugins/processing/algs/gdal/roughness.py
  27. +2 −2 python/plugins/processing/algs/gdal/sieve.py
  28. +3 −3 python/plugins/processing/algs/gdal/slope.py
  29. +1 −1 python/plugins/processing/algs/gdal/tpi.py
  30. +1 −1 python/plugins/processing/algs/gdal/translate.py
  31. +1 −1 python/plugins/processing/algs/gdal/tri.py
  32. +1 −1 python/plugins/processing/algs/gdal/warp.py
  33. +5 −5 python/plugins/processing/algs/grass7/Grass7Algorithm.py
  34. +4 −4 python/plugins/processing/algs/grass7/ext/i_albedo.py
  35. +2 −2 python/plugins/processing/algs/grass7/ext/i_evapo_mh.py
  36. +1 −1 python/plugins/processing/algs/grass7/ext/r_drain.py
  37. +1 −1 python/plugins/processing/algs/grass7/ext/v_voronoi.py
  38. +1 −1 python/plugins/processing/algs/otb/OtbAlgorithm.py
  39. +1 −1 python/plugins/processing/algs/qgis/CheckValidity.py
  40. +2 −2 python/plugins/processing/algs/qgis/ConcaveHull.py
  41. +1 −1 python/plugins/processing/algs/qgis/Datasources2Vrt.py
  42. +2 −2 python/plugins/processing/algs/qgis/FieldsCalculator.py
  43. +2 −2 python/plugins/processing/algs/qgis/GeometryByExpression.py
  44. +1 −1 python/plugins/processing/algs/qgis/HypsometricCurves.py
  45. +5 −5 python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
  46. +5 −5 python/plugins/processing/algs/qgis/ImportIntoSpatialite.py
  47. +1 −1 python/plugins/processing/algs/qgis/PointsDisplacement.py
  48. +1 −1 python/plugins/processing/algs/qgis/Polygonize.py
  49. +1 −1 python/plugins/processing/algs/qgis/Rasterize.py
  50. +2 −2 python/plugins/processing/algs/qgis/RegularPoints.py
  51. +1 −1 python/plugins/processing/algs/qgis/Relief.py
  52. +1 −1 python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py
  53. +1 −1 python/plugins/processing/algs/qgis/ServiceAreaFromPoint.py
  54. +1 −1 python/plugins/processing/algs/qgis/SpatialJoin.py
  55. +1 −1 python/plugins/processing/algs/qgis/SpatialJoinSummary.py
  56. +1 −1 python/plugins/processing/algs/qgis/VariableDistanceBuffer.py
  57. +1 −1 python/plugins/processing/algs/saga/SagaAlgorithm.py
  58. +2 −2 src/analysis/processing/qgsalgorithmaddincrementalfield.cpp
  59. +1 −1 src/analysis/processing/qgsalgorithmbuffer.cpp
  60. +2 −2 src/analysis/processing/qgsalgorithmcategorizeusingstyle.cpp
  61. +1 −1 src/analysis/processing/qgsalgorithmcentroid.cpp
  62. +1 −1 src/analysis/processing/qgsalgorithmdbscanclustering.cpp
  63. +2 −2 src/analysis/processing/qgsalgorithmdropmzvalues.cpp
  64. +1 −1 src/analysis/processing/qgsalgorithmextractbyextent.cpp
  65. +1 −1 src/analysis/processing/qgsalgorithmimportphotos.cpp
  66. +1 −1 src/analysis/processing/qgsalgorithmjoinbyattribute.cpp
  67. +1 −1 src/analysis/processing/qgsalgorithmjoinbynearest.cpp
  68. +2 −2 src/analysis/processing/qgsalgorithmjoinwithlines.cpp
  69. +2 −2 src/analysis/processing/qgsalgorithmorderbyexpression.cpp
  70. +1 −1 src/analysis/processing/qgsalgorithmpackage.cpp
  71. +1 −1 src/analysis/processing/qgsalgorithmpointonsurface.cpp
  72. +1 −1 src/analysis/processing/qgsalgorithmrasterlogicalop.cpp
  73. +1 −1 src/analysis/processing/qgsalgorithmreclassifybylayer.cpp
  74. +1 −1 src/analysis/processing/qgsalgorithmremoveduplicatevertices.cpp
@@ -112,7 +112,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
geometry = self.parameterAsString(parameters, self.GEOMETRY, context)
distance = self.parameterAsDouble(parameters, self.DISTANCE, context)
fieldName = self.parameterAsString(parameters, self.FIELD, context)
dissolve = self.parameterAsBool(parameters, self.DISSOLVE, context)
dissolve = self.parameterAsBoolean(parameters, self.DISSOLVE, context)
options = self.parameterAsString(parameters, self.OPTIONS, context)
outFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
self.setOutputValue(self.OUTPUT, outFile)
@@ -147,7 +147,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

arguments.append(sql)

if self.parameterAsBool(parameters, self.EXPLODE_COLLECTIONS, context):
if self.parameterAsBoolean(parameters, self.EXPLODE_COLLECTIONS, context):
arguments.append('-explodecollections')

if options:
@@ -188,13 +188,13 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-of')
arguments.append(QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1]))

if self.parameterAsBool(parameters, self.KEEP_RESOLUTION, context):
if self.parameterAsBoolean(parameters, self.KEEP_RESOLUTION, context):
arguments.append('-tr')
arguments.append(str(inLayer.rasterUnitsPerPixelX()))
arguments.append(str(-inLayer.rasterUnitsPerPixelY()))
arguments.append('-tap')

if self.parameterAsBool(parameters, self.SET_RESOLUTION, context):
if self.parameterAsBoolean(parameters, self.SET_RESOLUTION, context):
arguments.append('-tr')
if self.X_RESOLUTION in parameters and parameters[self.X_RESOLUTION] is not None:
xres = self.parameterAsDouble(parameters, self.X_RESOLUTION, context)
@@ -211,16 +211,16 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-cutline')
arguments.append(maskLayer)

if self.parameterAsBool(parameters, self.CROP_TO_CUTLINE, context):
if self.parameterAsBoolean(parameters, self.CROP_TO_CUTLINE, context):
arguments.append('-crop_to_cutline')

if self.parameterAsBool(parameters, self.ALPHA_BAND, context):
if self.parameterAsBoolean(parameters, self.ALPHA_BAND, context):
arguments.append('-dstalpha')

if nodata is not None:
arguments.append('-dstnodata {}'.format(nodata))

if self.parameterAsBool(parameters, self.MULTITHREADING, context):
if self.parameterAsBoolean(parameters, self.MULTITHREADING, context):
arguments.append('-multi')

if options:
@@ -120,7 +120,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-b')
arguments.append(str(self.parameterAsInt(parameters, self.BAND, context)))

if self.parameterAsBool(parameters, self.COMPUTE_EDGES, context):
if self.parameterAsBoolean(parameters, self.COMPUTE_EDGES, context):
arguments.append('-compute_edges')

arguments.append(self.modes[self.parameterAsEnum(parameters, self.MATCH_MODE, context)][1])
@@ -149,14 +149,14 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-sql')

tokens = []
if self.parameterAsBool(parameters, self.COUNT_FEATURES, context):
if self.parameterAsBoolean(parameters, self.COUNT_FEATURES, context):
tokens.append("COUNT({}) AS count".format(geometry))

if self.parameterAsBool(parameters, self.COMPUTE_AREA, context):
if self.parameterAsBoolean(parameters, self.COMPUTE_AREA, context):
tokens.append("SUM(ST_Area({0})) AS area, ST_Perimeter(ST_Union({0})) AS perimeter".format(geometry))

statsField = self.parameterAsString(parameters, self.STATISTICS_ATTRIBUTE, context)
if statsField and self.parameterAsBool(parameters, self.COMPUTE_STATISTICS, context):
if statsField and self.parameterAsBoolean(parameters, self.COMPUTE_STATISTICS, context):
tokens.append("SUM({0}) AS sum, MIN({0}) AS min, MAX({0}) AS max, AVG({0}) AS avg".format(statsField))

params = ','.join(tokens)
@@ -167,15 +167,15 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if fieldName:
group_by = ' GROUP BY {}'.format(fieldName)

if self.parameterAsBool(parameters, self.KEEP_ATTRIBUTES, context):
if self.parameterAsBoolean(parameters, self.KEEP_ATTRIBUTES, context):
sql = "SELECT ST_Union({}) AS {}{}{} FROM '{}'{}".format(geometry, geometry, other_fields, params, layerName, group_by)
else:
sql = "SELECT ST_Union({}) AS {}{}{} FROM '{}'{}".format(geometry, geometry, ', ' + fieldName if fieldName else '',
params, layerName, group_by)

arguments.append(sql)

if self.parameterAsBool(parameters, self.EXPLODE_COLLECTIONS, context):
if self.parameterAsBoolean(parameters, self.EXPLODE_COLLECTIONS, context):
arguments.append('-explodecollections')

if options:
@@ -240,22 +240,22 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
simplify = self.parameterAsString(parameters, self.SIMPLIFY, context)
segmentize = self.parameterAsString(parameters, self.SEGMENTIZE, context)
spat = self.parameterAsExtent(parameters, self.SPAT, context)
clip = self.parameterAsBool(parameters, self.CLIP, context)
clip = self.parameterAsBoolean(parameters, self.CLIP, context)
include_fields = self.parameterAsFields(parameters, self.FIELDS, context)
fields_string = '-select "' + ','.join(include_fields) + '"'
where = self.parameterAsString(parameters, self.WHERE, context)
wherestring = '-where "' + where + '"'
gt = self.parameterAsString(parameters, self.GT, context)
overwrite = self.parameterAsBool(parameters, self.OVERWRITE, context)
append = self.parameterAsBool(parameters, self.APPEND, context)
addfields = self.parameterAsBool(parameters, self.ADDFIELDS, context)
launder = self.parameterAsBool(parameters, self.LAUNDER, context)
overwrite = self.parameterAsBoolean(parameters, self.OVERWRITE, context)
append = self.parameterAsBoolean(parameters, self.APPEND, context)
addfields = self.parameterAsBoolean(parameters, self.ADDFIELDS, context)
launder = self.parameterAsBoolean(parameters, self.LAUNDER, context)
launderstring = "-lco LAUNDER=NO"
index = self.parameterAsBool(parameters, self.INDEX, context)
index = self.parameterAsBoolean(parameters, self.INDEX, context)
indexstring = "-lco SPATIAL_INDEX=OFF"
skipfailures = self.parameterAsBool(parameters, self.SKIPFAILURES, context)
promotetomulti = self.parameterAsBool(parameters, self.PROMOTETOMULTI, context)
precision = self.parameterAsBool(parameters, self.PRECISION, context)
skipfailures = self.parameterAsBoolean(parameters, self.SKIPFAILURES, context)
promotetomulti = self.parameterAsBoolean(parameters, self.PROMOTETOMULTI, context)
precision = self.parameterAsBoolean(parameters, self.PRECISION, context)
options = self.parameterAsString(parameters, self.OPTIONS, context)

arguments = []
@@ -123,7 +123,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
distance = self.parameterAsDouble(parameters, self.DISTANCE, context)
side = self.parameterAsEnum(parameters, self.BUFFER_SIDE, context)
fieldName = self.parameterAsString(parameters, self.FIELD, context)
dissolve = self.parameterAsBool(parameters, self.DISSOLVE, context)
dissolve = self.parameterAsBoolean(parameters, self.DISSOLVE, context)
options = self.parameterAsString(parameters, self.OPTIONS, context)
outFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
self.setOutputValue(self.OUTPUT, outFile)
@@ -158,7 +158,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

arguments.append(sql)

if self.parameterAsBool(parameters, self.EXPLODE_COLLECTIONS, context):
if self.parameterAsBoolean(parameters, self.EXPLODE_COLLECTIONS, context):
arguments.append('-explodecollections')

if options:
@@ -118,16 +118,16 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-b')
arguments.append(str(self.parameterAsInt(parameters, self.BAND, context)))

if self.parameterAsBool(parameters, self.TRIG_ANGLE, context):
if self.parameterAsBoolean(parameters, self.TRIG_ANGLE, context):
arguments.append('-trigonometric')

if self.parameterAsBool(parameters, self.ZERO_FLAT, context):
if self.parameterAsBoolean(parameters, self.ZERO_FLAT, context):
arguments.append('-zero_for_flat')

if self.parameterAsBool(parameters, self.COMPUTE_EDGES, context):
if self.parameterAsBoolean(parameters, self.COMPUTE_EDGES, context):
arguments.append('-compute_edges')

if self.parameterAsBool(parameters, self.ZEVENBERGEN, context):
if self.parameterAsBoolean(parameters, self.ZEVENBERGEN, context):
arguments.append('-alg')
arguments.append('ZevenbergenThorne')

@@ -147,11 +147,11 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
arguments.append('-resolution')
arguments.append(self.RESOLUTION_OPTIONS[self.parameterAsEnum(parameters, self.RESOLUTION, context)])
if self.parameterAsBool(parameters, buildvrt.SEPARATE, context):
if self.parameterAsBoolean(parameters, buildvrt.SEPARATE, context):
arguments.append('-separate')
if self.parameterAsBool(parameters, buildvrt.PROJ_DIFFERENCE, context):
if self.parameterAsBoolean(parameters, buildvrt.PROJ_DIFFERENCE, context):
arguments.append('-allow_projection_difference')
if self.parameterAsBool(parameters, buildvrt.ADD_ALPHA, context):
if self.parameterAsBoolean(parameters, buildvrt.ADD_ALPHA, context):
arguments.append('-addalpha')
crs = self.parameterAsCrs(parameters, self.ASSIGN_CRS, context)
if crs.isValid():
@@ -161,10 +161,10 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-i')
arguments.append(str(self.parameterAsDouble(parameters, self.INTERVAL, context)))

if self.parameterAsBool(parameters, self.CREATE_3D, context):
if self.parameterAsBoolean(parameters, self.CREATE_3D, context):
arguments.append('-3d')

if self.parameterAsBool(parameters, self.IGNORE_NODATA, context):
if self.parameterAsBoolean(parameters, self.IGNORE_NODATA, context):
arguments.append('-inodata')

if nodata is not None:
@@ -88,9 +88,9 @@ def getConsoleCommands(self, parameters, context, feedback,
return [self.commandName()]

def processAlgorithm(self, parameters, context, feedback):
createPrj = self.parameterAsBool(parameters,
self.PRJ_FILE_CREATE,
context)
createPrj = self.parameterAsBoolean(parameters,
self.PRJ_FILE_CREATE,
context)
raster = self.parameterAsRasterLayer(parameters, self.INPUT,
context)
if not raster.dataProvider().name() == 'gdal':
@@ -111,7 +111,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-b')
arguments.append(str(self.parameterAsInt(parameters, self.BAND, context)))

if self.parameterAsBool(parameters, self.NO_MASK, context):
if self.parameterAsBoolean(parameters, self.NO_MASK, context):
arguments.append('-nomask')

mask = self.parameterAsRasterLayer(parameters, self.MASK_LAYER, context)
@@ -213,13 +213,13 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-b')
arguments.append(key)

if self.parameterAsBool(parameters, self.RESUME, context):
if self.parameterAsBoolean(parameters, self.RESUME, context):
arguments.append('-e')

if self.parameterAsBool(parameters, self.KML, context):
if self.parameterAsBoolean(parameters, self.KML, context):
arguments.append('-k')

if self.parameterAsBool(parameters, self.NO_KML, context):
if self.parameterAsBoolean(parameters, self.NO_KML, context):
arguments.append('-n')

inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -84,7 +84,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-band')
arguments.append(str(self.parameterAsInt(parameters, self.BAND, context)))

if self.parameterAsBool(parameters, self.CSV, context):
if self.parameterAsBoolean(parameters, self.CSV, context):
arguments.append('-csv')

raster = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -134,7 +134,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
elif ovrFormat == 2:
arguments.extend('--config USE_RRD YES'.split(' '))

if self.parameterAsBool(parameters, self.CLEAN, context):
if self.parameterAsBoolean(parameters, self.CLEAN, context):
arguments.append('-clean')

arguments.extend(self.parameterAsString(parameters, self.LEVELS, context).split(' '))
@@ -90,13 +90,13 @@ def commandName(self):

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
if self.parameterAsBool(parameters, self.MIN_MAX, context):
if self.parameterAsBoolean(parameters, self.MIN_MAX, context):
arguments.append('-mm')
if self.parameterAsBool(parameters, self.STATS, context):
if self.parameterAsBoolean(parameters, self.STATS, context):
arguments.append('-stats')
if self.parameterAsBool(parameters, self.NO_GCP, context):
if self.parameterAsBoolean(parameters, self.NO_GCP, context):
arguments.append('-nogcp')
if self.parameterAsBool(parameters, self.NO_METADATA, context):
if self.parameterAsBoolean(parameters, self.NO_METADATA, context):
arguments.append('-nomd')
raster = self.parameterAsRasterLayer(parameters, self.INPUT, context)
if raster is None:
@@ -135,10 +135,10 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-tileindex')
arguments.append(self.parameterAsString(parameters, self.PATH_FIELD_NAME, context))

if self.parameterAsBool(parameters, self.ABSOLUTE_PATH, context):
if self.parameterAsBoolean(parameters, self.ABSOLUTE_PATH, context):
arguments.append('-write_absolute_path')

if self.parameterAsBool(parameters, self.PROJ_DIFFERENCE, context):
if self.parameterAsBoolean(parameters, self.PROJ_DIFFERENCE, context):
arguments.append('-skip_different_projection')

if crs_field:
@@ -150,7 +150,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-s')
arguments.append(str(self.parameterAsDouble(parameters, self.SCALE, context)))

multidirectional = self.parameterAsBool(parameters, self.MULTIDIRECTIONAL, context)
multidirectional = self.parameterAsBoolean(parameters, self.MULTIDIRECTIONAL, context)
# azimuth and multidirectional are mutually exclusive
if not multidirectional:
arguments.append('-az')
@@ -159,14 +159,14 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-alt')
arguments.append(str(self.parameterAsDouble(parameters, self.ALTITUDE, context)))

if self.parameterAsBool(parameters, self.COMPUTE_EDGES, context):
if self.parameterAsBoolean(parameters, self.COMPUTE_EDGES, context):
arguments.append('-compute_edges')

if self.parameterAsBool(parameters, self.ZEVENBERGEN, context):
if self.parameterAsBoolean(parameters, self.ZEVENBERGEN, context):
arguments.append('-alg')
arguments.append('ZevenbergenThorne')

if self.parameterAsBool(parameters, self.COMBINED, context):
if self.parameterAsBoolean(parameters, self.COMBINED, context):
arguments.append('-combined')

if multidirectional:
@@ -131,10 +131,10 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
self.setOutputValue(self.OUTPUT, out)

arguments = []
if self.parameterAsBool(parameters, self.PCT, context):
if self.parameterAsBoolean(parameters, self.PCT, context):
arguments.append('-pct')

if self.parameterAsBool(parameters, self.SEPARATE, context):
if self.parameterAsBoolean(parameters, self.SEPARATE, context):
arguments.append('-separate')

if self.NODATA_INPUT in parameters and parameters[self.NODATA_INPUT] is not None:
@@ -114,7 +114,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-near')
arguments.append(str(self.parameterAsInt(parameters, self.NEAR, context)))

if self.parameterAsBool(parameters, self.WHITE, context):
if self.parameterAsBoolean(parameters, self.WHITE, context):
arguments.append('-white')

options = self.parameterAsString(parameters, self.OPTIONS, context)

0 comments on commit b90a018

Please sign in to comment.
You can’t perform that action at this time.