Skip to content
Permalink
Browse files
Prefer parameterAsBoolean over parameterAsBool
  • Loading branch information
m-kuhn committed Apr 16, 2019
1 parent 4771f80 commit b90a01847f177324147553363722542a577aa307
Show file tree
Hide file tree
Showing 74 changed files with 149 additions and 149 deletions.
@@ -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.