Skip to content

Commit

Permalink
Merge pull request #7408 from luipir/fix_gdalfillnodata_issue19409
Browse files Browse the repository at this point in the history
[processing] Fix wrongly set mask in gdal:fillnodata Fixes #19409
  • Loading branch information
luipir authored Jul 13, 2018
2 parents be99819 + f7a1ef1 commit e2a740b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/fillnodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if self.parameterAsBool(parameters, self.NO_MASK, context):
arguments.append('-nomask')

mask = self.parameterAsRasterLayer(parameters, self.INPUT, context)
mask = self.parameterAsRasterLayer(parameters, self.MASK_LAYER, context)
if mask:
arguments.append('-mask {}'.format(mask.source()))

Expand Down
54 changes: 54 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from processing.algs.gdal.retile import retile
from processing.algs.gdal.translate import translate
from processing.algs.gdal.warp import warp
from processing.algs.gdal.fillnodata import fillnodata

from qgis.core import (QgsProcessingContext,
QgsProcessingFeedback,
Expand Down Expand Up @@ -1340,6 +1341,59 @@ def testWarp(self):
source + ' ' +
'd:/temp/check.jpg'])

def testFillnodata(self):
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()
source = os.path.join(testDataPath, 'dem.tif')
mask = os.path.join(testDataPath, 'raster.tif')
outsource = 'd:/temp/check.tif'
alg = fillnodata()
alg.initAlgorithm()

# with mask value
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'BAND': 1,
'DISTANCE': 10,
'ITERATIONS': 0,
'MASK_LAYER': mask,
'NO_MASK': False,
'OUTPUT': outsource}, context, feedback),
['gdal_fillnodata.py',
'-md 10 -b 1 -mask ' +
mask +
' -of GTiff ' +
source + ' ' +
outsource])

# without mask value
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'BAND': 1,
'DISTANCE': 10,
'ITERATIONS': 0,
'NO_MASK': False,
'OUTPUT': outsource}, context, feedback),
['gdal_fillnodata.py',
'-md 10 -b 1 ' +
'-of GTiff ' +
source + ' ' +
outsource])

# nomask true
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'BAND': 1,
'DISTANCE': 10,
'ITERATIONS': 0,
'NO_MASK': True,
'OUTPUT': outsource}, context, feedback),
['gdal_fillnodata.py',
'-md 10 -b 1 -nomask ' +
'-of GTiff ' +
source + ' ' +
outsource])


class TestGdalOgrToPostGis(unittest.TestCase):

Expand Down

0 comments on commit e2a740b

Please sign in to comment.