mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-29 00:06:58 -05:00
additional parameters for proximity algorithm
This commit is contained in:
parent
d66914aec6
commit
c313f1da50
@ -52,6 +52,7 @@ class proximity(GdalAlgorithm):
|
|||||||
UNITS = 'UNITS'
|
UNITS = 'UNITS'
|
||||||
NODATA = 'NODATA'
|
NODATA = 'NODATA'
|
||||||
OPTIONS = 'OPTIONS'
|
OPTIONS = 'OPTIONS'
|
||||||
|
EXTRA = 'EXTRA'
|
||||||
DATA_TYPE = 'DATA_TYPE'
|
DATA_TYPE = 'DATA_TYPE'
|
||||||
OUTPUT = 'OUTPUT'
|
OUTPUT = 'OUTPUT'
|
||||||
|
|
||||||
@ -108,11 +109,20 @@ class proximity(GdalAlgorithm):
|
|||||||
'class': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'}})
|
'class': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'}})
|
||||||
self.addParameter(options_param)
|
self.addParameter(options_param)
|
||||||
|
|
||||||
self.addParameter(QgsProcessingParameterEnum(self.DATA_TYPE,
|
extra_param = QgsProcessingParameterString(self.EXTRA,
|
||||||
|
self.tr('Additional command-line parameters'),
|
||||||
|
defaultValue=None,
|
||||||
|
optional=True)
|
||||||
|
extra_param.setFlags(extra_param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
|
||||||
|
self.addParameter(extra_param)
|
||||||
|
|
||||||
|
dataType_param = QgsProcessingParameterEnum(self.DATA_TYPE,
|
||||||
self.tr('Output data type'),
|
self.tr('Output data type'),
|
||||||
self.TYPES,
|
self.TYPES,
|
||||||
allowMultiple=False,
|
allowMultiple=False,
|
||||||
defaultValue=5))
|
defaultValue=5)
|
||||||
|
dataType_param.setFlags(dataType_param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
|
||||||
|
self.addParameter(dataType_param)
|
||||||
|
|
||||||
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
|
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
|
||||||
self.tr('Proximity map')))
|
self.tr('Proximity map')))
|
||||||
@ -180,6 +190,10 @@ class proximity(GdalAlgorithm):
|
|||||||
if options:
|
if options:
|
||||||
arguments.extend(GdalUtils.parseCreationOptions(options))
|
arguments.extend(GdalUtils.parseCreationOptions(options))
|
||||||
|
|
||||||
|
if self.EXTRA in parameters and parameters[self.EXTRA] not in (None, ''):
|
||||||
|
extra = self.parameterAsString(parameters, self.EXTRA, context)
|
||||||
|
arguments.append(extra)
|
||||||
|
|
||||||
arguments.append(inLayer.source())
|
arguments.append(inLayer.source())
|
||||||
arguments.append(out)
|
arguments.append(out)
|
||||||
|
|
||||||
|
|||||||
@ -2376,7 +2376,7 @@ class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
|||||||
alg.initAlgorithm()
|
alg.initAlgorithm()
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as outdir:
|
with tempfile.TemporaryDirectory() as outdir:
|
||||||
# with no NODATA value
|
# without NODATA value
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
alg.getConsoleCommands({'INPUT': source,
|
alg.getConsoleCommands({'INPUT': source,
|
||||||
'BAND': 1,
|
'BAND': 1,
|
||||||
@ -2405,6 +2405,16 @@ class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
|
|||||||
'-srcband 1 -distunits PIXEL -nodata 0.0 -ot Float32 -of JPEG ' +
|
'-srcband 1 -distunits PIXEL -nodata 0.0 -ot Float32 -of JPEG ' +
|
||||||
source + ' ' +
|
source + ' ' +
|
||||||
outdir + '/check.jpg'])
|
outdir + '/check.jpg'])
|
||||||
|
# additional parameters
|
||||||
|
self.assertEqual(
|
||||||
|
alg.getConsoleCommands({'INPUT': source,
|
||||||
|
'BAND': 1,
|
||||||
|
'EXTRA': '-dstband 2 -values 3,4,12',
|
||||||
|
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
|
||||||
|
['gdal_proximity.py',
|
||||||
|
'-srcband 1 -distunits PIXEL -ot Float32 -of JPEG -dstband 2 -values 3,4,12 ' +
|
||||||
|
source + ' ' +
|
||||||
|
outdir + '/check.jpg'])
|
||||||
|
|
||||||
def testRasterize(self):
|
def testRasterize(self):
|
||||||
context = QgsProcessingContext()
|
context = QgsProcessingContext()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user