[processing] pass layer name to the gdalwarp to avoid issues with

multi-layer datasources (fix #30292)
This commit is contained in:
Alexander Bruy 2019-07-15 15:56:07 +03:00
parent 5f0447b397
commit 109d1fb7a8
2 changed files with 8 additions and 6 deletions

View File

@ -217,6 +217,8 @@ class ClipRasterByMask(GdalAlgorithm):
arguments.append('-cutline')
arguments.append(maskLayer)
arguments.append('-cl')
arguments.append(maskLayerName)
if self.parameterAsBoolean(parameters, self.CROP_TO_CUTLINE, context):
arguments.append('-crop_to_cutline')

View File

@ -343,7 +343,7 @@ class TestGdalRasterAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline ' + source + ' ' +
mask + ' -cl polys2 -crop_to_cutline ' + source + ' ' +
outdir + '/check.jpg'])
# with NODATA value
self.assertEqual(
@ -353,7 +353,7 @@ class TestGdalRasterAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline -dstnodata 9999.0 ' + source + ' ' +
mask + ' -cl polys2 -crop_to_cutline -dstnodata 9999.0 ' + source + ' ' +
outdir + '/check.jpg'])
# with "0" NODATA value
self.assertEqual(
@ -363,7 +363,7 @@ class TestGdalRasterAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline -dstnodata 0.0 ' + source + ' ' +
mask + ' -cl polys2 -crop_to_cutline -dstnodata 0.0 ' + source + ' ' +
outdir + '/check.jpg'])
# with "0" NODATA value and custom data type
self.assertEqual(
@ -374,7 +374,7 @@ class TestGdalRasterAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-ot Float32 -of JPEG -cutline ' +
mask + ' -crop_to_cutline -dstnodata 0.0 ' + source + ' ' +
mask + ' -cl polys2 -crop_to_cutline -dstnodata 0.0 ' + source + ' ' +
outdir + '/check.jpg'])
# with creation options
self.assertEqual(
@ -384,7 +384,7 @@ class TestGdalRasterAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 ' +
mask + ' -cl polys2 -crop_to_cutline -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 ' +
source + ' ' +
outdir + '/check.jpg'])
# with multothreading and additional parameters
@ -396,7 +396,7 @@ class TestGdalRasterAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
'OUTPUT': outdir + '/check.jpg'}, context, feedback),
['gdalwarp',
'-of JPEG -cutline ' +
mask + ' -crop_to_cutline -multi -nosrcalpha -wm 2048 -nomd ' +
mask + ' -cl polys2 -crop_to_cutline -multi -nosrcalpha -wm 2048 -nomd ' +
source + ' ' +
outdir + '/check.jpg'])