Skip to content

Commit

Permalink
fix typos and add tests for gdal algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 11, 2017
1 parent 9b74d9f commit fde5c89
Show file tree
Hide file tree
Showing 19 changed files with 404,461 additions and 227 deletions.
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/gdal/ClipRasterByMask.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-of')
arguments.append(QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1]))

if self.parameterAsBool(self.KEEP_RESOLUTION):
if self.parameterAsBool(parameters, self.KEEP_RESOLUTION, context):
arguments.append('-tr')
arguments.append(str(inLayer.rasterUnitsPerPixelX()))
arguments.append(str(-inLayer.rasterUnitsPerPixelY()))
Expand All @@ -145,10 +145,10 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-cwhere')
arguments.append(maskLayer.subsetString())

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

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

if nodata:
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/gdal/ColorRelief.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

__revision__ = '$Format:%H$'

import os
from qgis.core import (QgsRasterFileWriter,
QgsProcessingParameterDefinition,
QgsProcessingParameterRasterLayer,
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/gdal/GridInverseDistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-of')
arguments.append(QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1]))

options = self.parameterAsString(parameters, self.OPTIONS, context)
if options:
arguments.append('-co')
arguments.append(options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def initAlgorithm(self, config=None):
self.addParameter(dataType_param)

self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
self.tr('Interpolated (IDW)')))
self.tr('Interpolated (IDW with NN search)')))

def name(self):
return 'gridinversedistancenearestneighbor'
Expand Down Expand Up @@ -171,6 +171,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-of')
arguments.append(QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1]))

options = self.parameterAsString(parameters, self.OPTIONS, context)
if options:
arguments.append('-co')
arguments.append(options)
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/gdal/GridLinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def initAlgorithm(self, config=None):
self.addParameter(dataType_param)

self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
self.tr('Interpolated (IDW)')))
self.tr('Interpolated (Linear)')))

def name(self):
return 'gridlinear'
Expand Down Expand Up @@ -142,6 +142,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-of')
arguments.append(QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1]))

options = self.parameterAsString(parameters, self.OPTIONS, context)
if options:
arguments.append('-co')
arguments.append(options)
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/gdal/GridNearestNeighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-of')
arguments.append(QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1]))

options = self.parameterAsString(parameters, self.OPTIONS, context)
if options:
arguments.append('-co')
arguments.append(options)
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/gdal/fillnodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ def group(self):
def getConsoleCommands(self, parameters, context, feedback):
arguments = []
arguments.append('-md')
arguments.append(str(self.parameterAsInt(self.DISTANCE)))
arguments.append(str(self.parameterAsInt(parameters, self.DISTANCE, context)))

nIterations = self.parameterAsInt(self.ITERATIONS)
nIterations = self.parameterAsInt(parameters, self.ITERATIONS, context)
if nIterations:
arguments.append('-si')
arguments.append(str(nIterations))

arguments.append('-b')
arguments.append(str(self.parameterAsInt(self.BAND)))
arguments.append(str(self.parameterAsInt(parameters, self.BAND, context)))

if self.parameterAsBool(parameters, self.NO_MASK, context):
arguments.append('-nomask')
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/gdaltindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,6 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-f {}'.format(outFormat))

arguments.append(output)
arguments.extend(' '.join(layers))
arguments.append(' '.join(layers))

return ['gdaltindex', GdalUtils.escapeAndJoin(arguments)]
2 changes: 2 additions & 0 deletions python/plugins/processing/algs/gdal/nearblack.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def icon(self):

def getConsoleCommands(self, parameters, context, feedback):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)

arguments = []
arguments.append(inLayer.source())

out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/sieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def icon(self):
def getConsoleCommands(self, parameters, context, feedback):
arguments = []
arguments.append('-st')
arguments.append(str(self.parameterAsInt(self.THRESHOLD)))
arguments.append(str(self.parameterAsInt(parameters, self.THRESHOLD, context)))

if self.parameterAsBool(parameters, self.EIGHT_CONNECTEDNESS, context):
arguments.append('-8')
Expand Down
Loading

0 comments on commit fde5c89

Please sign in to comment.