Skip to content

Commit 76b13ff

Browse files
committed
[processing][gdal] More descriptive name for separate parameter
in buildvrt algorithm Fixes #19212
1 parent 4fb9091 commit 76b13ff

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

python/plugins/processing/algs/gdal/buildvrt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def defaultFileExtension(self):
8383
options=self.RESOLUTION_OPTIONS,
8484
defaultValue=0))
8585
self.addParameter(QgsProcessingParameterBoolean(self.SEPARATE,
86-
QCoreApplication.translate("ParameterVrtDestination", 'Layer stack'),
86+
QCoreApplication.translate("ParameterVrtDestination", 'Place each input file into a separate band'),
8787
defaultValue=True))
8888
self.addParameter(QgsProcessingParameterBoolean(self.PROJ_DIFFERENCE,
8989
QCoreApplication.translate("ParameterVrtDestination", 'Allow projection difference'),

python/plugins/processing/tests/GdalAlgorithmsTest.py

+51
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from processing.algs.gdal.GridInverseDistanceNearestNeighbor import GridInverseDistanceNearestNeighbor
4242
from processing.algs.gdal.GridLinear import GridLinear
4343
from processing.algs.gdal.GridNearestNeighbor import GridNearestNeighbor
44+
from processing.algs.gdal.buildvrt import buildvrt
4445
from processing.algs.gdal.hillshade import hillshade
4546
from processing.algs.gdal.ogr2ogr import ogr2ogr
4647
from processing.algs.gdal.proximity import proximity
@@ -638,6 +639,56 @@ def testGdalCalc(self):
638639
'OUTPUT': output}, context, feedback),
639640
['gdal_calc', '--calc "{}" --format JPEG --type Float32 -A {} --A_band 1 --outfile {}'.format(formula, source, output)])
640641

642+
def testBuildVrt(self):
643+
context = QgsProcessingContext()
644+
feedback = QgsProcessingFeedback()
645+
source = os.path.join(testDataPath, 'dem.tif')
646+
alg = buildvrt()
647+
alg.initAlgorithm()
648+
649+
commands = alg.getConsoleCommands({'LAYERS': [source],
650+
'OUTPUT': 'd:/temp/test.vrt'}, context, feedback)
651+
self.assertEqual(len(commands), 2)
652+
self.assertEqual(commands[0], 'gdalbuildvrt')
653+
self.assertIn('-resolution average', commands[1])
654+
self.assertIn('-separate', commands[1])
655+
self.assertNotIn('-allow_projection_difference', commands[1])
656+
self.assertIn('-input_file_list', commands[1])
657+
self.assertIn('d:/temp/test.vrt', commands[1])
658+
659+
commands = alg.getConsoleCommands({'LAYERS': [source],
660+
'RESOLUTION': 2,
661+
'OUTPUT': 'd:/temp/test.vrt'}, context, feedback)
662+
self.assertEqual(len(commands), 2)
663+
self.assertEqual(commands[0], 'gdalbuildvrt')
664+
self.assertIn('-resolution lowest', commands[1])
665+
self.assertIn('-separate', commands[1])
666+
self.assertNotIn('-allow_projection_difference', commands[1])
667+
self.assertIn('-input_file_list', commands[1])
668+
self.assertIn('d:/temp/test.vrt', commands[1])
669+
670+
commands = alg.getConsoleCommands({'LAYERS': [source],
671+
'SEPARATE': False,
672+
'OUTPUT': 'd:/temp/test.vrt'}, context, feedback)
673+
self.assertEqual(len(commands), 2)
674+
self.assertEqual(commands[0], 'gdalbuildvrt')
675+
self.assertIn('-resolution average', commands[1])
676+
self.assertNotIn('-allow_projection_difference', commands[1])
677+
self.assertNotIn('-separate', commands[1])
678+
self.assertIn('-input_file_list', commands[1])
679+
self.assertIn('d:/temp/test.vrt', commands[1])
680+
681+
commands = alg.getConsoleCommands({'LAYERS': [source],
682+
'PROJ_DIFFERENCE': True,
683+
'OUTPUT': 'd:/temp/test.vrt'}, context, feedback)
684+
self.assertEqual(len(commands), 2)
685+
self.assertEqual(commands[0], 'gdalbuildvrt')
686+
self.assertIn('-resolution average', commands[1])
687+
self.assertIn('-allow_projection_difference', commands[1])
688+
self.assertIn('-separate', commands[1])
689+
self.assertIn('-input_file_list', commands[1])
690+
self.assertIn('d:/temp/test.vrt', commands[1])
691+
641692
def testGdalTindex(self):
642693
context = QgsProcessingContext()
643694
feedback = QgsProcessingFeedback()

0 commit comments

Comments
 (0)