Skip to content
Permalink
Browse files

[FEATURE][processing] Add custom OPTIONS to contour algorithm (#7834)

  • Loading branch information
gkimbell authored and nyalldawson committed Sep 11, 2018
1 parent 318946a commit cb0b335a95a5dbbf168114fbb6a25d97f1eb6118
@@ -55,6 +55,7 @@ class contour(GdalAlgorithm):
IGNORE_NODATA = 'IGNORE_NODATA'
NODATA = 'NODATA'
OFFSET = 'OFFSET'
OPTIONS = 'OPTIONS'
OUTPUT = 'OUTPUT'

def __init__(self):
@@ -104,6 +105,13 @@ def initAlgorithm(self, config=None):
nodata_param.setFlags(offset_param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
self.addParameter(offset_param)

options_param = QgsProcessingParameterString(self.OPTIONS,
self.tr('Additional creation options'),
defaultValue='',
optional=True)
options_param.setFlags(options_param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
self.addParameter(options_param)

self.addParameter(QgsProcessingParameterVectorDestination(
self.OUTPUT, self.tr('Contours'), QgsProcessing.TypeVectorLine))

@@ -163,6 +171,10 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if offset:
arguments.append('-off {}'.format(offset))

options = self.parameterAsString(parameters, self.OPTIONS, context)
if options:
arguments.append(options)

if outFormat:
arguments.append('-f {}'.format(outFormat))

@@ -589,6 +589,18 @@ def testContour(self):
'-b 1 -a elev -i 5.0 -snodata 0.0 -f "GPKG" ' +
source + ' ' +
'd:/temp/check.gpkg'])
# fixed level contours
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'BAND': 1,
'FIELD_NAME': 'elev',
'INTERVAL': 0,
'OPTIONS': '-fl 100 125 150 200',
'OUTPUT': 'd:/temp/check.shp'}, context, feedback),
['gdal_contour',
'-b 1 -a elev -i 0.0 -fl 100 125 150 200 -f "ESRI Shapefile" ' +
source + ' ' +
'd:/temp/check.shp'])

def testGdal2Tiles(self):
context = QgsProcessingContext()

0 comments on commit cb0b335

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