[processing] Fix GDAL "Fill NoData" algorithm

The gdal_fillnodata.py -nomask option is no longer supported since GDAL 3.4.0
This commit is contained in:
Andrea Giudiceandrea 2024-02-07 07:06:47 +01:00 committed by Nyall Dawson
parent 9131a308e2
commit 5a721c47c0

View File

@ -68,9 +68,15 @@ class fillnodata(GdalAlgorithm):
type=QgsProcessingParameterNumber.Type.Integer,
minValue=0,
defaultValue=0))
self.addParameter(QgsProcessingParameterBoolean(self.NO_MASK,
self.tr('Do not use the default validity mask for the input band'),
defaultValue=False))
nomask_param = QgsProcessingParameterBoolean(self.NO_MASK,
self.tr('Do not use the default validity mask for the input band'),
defaultValue=False,
optional=True)
# The -nomask option is no longer supported since GDAL 3.4.0 https://github.com/OSGeo/gdal/pull/4201
if GdalUtils.version() >= 3040000:
nomask_param.setFlags(nomask_param.flags() | QgsProcessingParameterDefinition.FlagHidden)
self.addParameter(nomask_param)
self.addParameter(QgsProcessingParameterRasterLayer(self.MASK_LAYER,
self.tr('Validity mask'),
optional=True))
@ -136,7 +142,11 @@ class fillnodata(GdalAlgorithm):
arguments.append(str(self.parameterAsInt(parameters, self.BAND, context)))
if self.parameterAsBoolean(parameters, self.NO_MASK, context):
arguments.append('-nomask')
if GdalUtils.version() >= 3040000:
# The -nomask option is no longer supported since GDAL 3.4.0 https://github.com/OSGeo/gdal/pull/4201
feedback.pushInfo(self.tr('The -nomask option is no longer supported since GDAL 3.4.0'))
else:
arguments.append('-nomask')
mask = self.parameterAsRasterLayer(parameters, self.MASK_LAYER, context)
if mask: