Skip to content

Commit

Permalink
[processing][gdal] More descriptive name for separate parameter
Browse files Browse the repository at this point in the history
in buildvrt algorithm

Fixes #19212
  • Loading branch information
nyalldawson committed Jun 18, 2018
1 parent 4fb9091 commit 76b13ff
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/buildvrt.py
Expand Up @@ -83,7 +83,7 @@ def defaultFileExtension(self):
options=self.RESOLUTION_OPTIONS,
defaultValue=0))
self.addParameter(QgsProcessingParameterBoolean(self.SEPARATE,
QCoreApplication.translate("ParameterVrtDestination", 'Layer stack'),
QCoreApplication.translate("ParameterVrtDestination", 'Place each input file into a separate band'),
defaultValue=True))
self.addParameter(QgsProcessingParameterBoolean(self.PROJ_DIFFERENCE,
QCoreApplication.translate("ParameterVrtDestination", 'Allow projection difference'),
Expand Down
51 changes: 51 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsTest.py
Expand Up @@ -41,6 +41,7 @@
from processing.algs.gdal.GridInverseDistanceNearestNeighbor import GridInverseDistanceNearestNeighbor
from processing.algs.gdal.GridLinear import GridLinear
from processing.algs.gdal.GridNearestNeighbor import GridNearestNeighbor
from processing.algs.gdal.buildvrt import buildvrt
from processing.algs.gdal.hillshade import hillshade
from processing.algs.gdal.ogr2ogr import ogr2ogr
from processing.algs.gdal.proximity import proximity
Expand Down Expand Up @@ -638,6 +639,56 @@ def testGdalCalc(self):
'OUTPUT': output}, context, feedback),
['gdal_calc', '--calc "{}" --format JPEG --type Float32 -A {} --A_band 1 --outfile {}'.format(formula, source, output)])

def testBuildVrt(self):
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()
source = os.path.join(testDataPath, 'dem.tif')
alg = buildvrt()
alg.initAlgorithm()

commands = alg.getConsoleCommands({'LAYERS': [source],
'OUTPUT': 'd:/temp/test.vrt'}, context, feedback)
self.assertEqual(len(commands), 2)
self.assertEqual(commands[0], 'gdalbuildvrt')
self.assertIn('-resolution average', commands[1])
self.assertIn('-separate', commands[1])
self.assertNotIn('-allow_projection_difference', commands[1])
self.assertIn('-input_file_list', commands[1])
self.assertIn('d:/temp/test.vrt', commands[1])

commands = alg.getConsoleCommands({'LAYERS': [source],
'RESOLUTION': 2,
'OUTPUT': 'd:/temp/test.vrt'}, context, feedback)
self.assertEqual(len(commands), 2)
self.assertEqual(commands[0], 'gdalbuildvrt')
self.assertIn('-resolution lowest', commands[1])
self.assertIn('-separate', commands[1])
self.assertNotIn('-allow_projection_difference', commands[1])
self.assertIn('-input_file_list', commands[1])
self.assertIn('d:/temp/test.vrt', commands[1])

commands = alg.getConsoleCommands({'LAYERS': [source],
'SEPARATE': False,
'OUTPUT': 'd:/temp/test.vrt'}, context, feedback)
self.assertEqual(len(commands), 2)
self.assertEqual(commands[0], 'gdalbuildvrt')
self.assertIn('-resolution average', commands[1])
self.assertNotIn('-allow_projection_difference', commands[1])
self.assertNotIn('-separate', commands[1])
self.assertIn('-input_file_list', commands[1])
self.assertIn('d:/temp/test.vrt', commands[1])

commands = alg.getConsoleCommands({'LAYERS': [source],
'PROJ_DIFFERENCE': True,
'OUTPUT': 'd:/temp/test.vrt'}, context, feedback)
self.assertEqual(len(commands), 2)
self.assertEqual(commands[0], 'gdalbuildvrt')
self.assertIn('-resolution average', commands[1])
self.assertIn('-allow_projection_difference', commands[1])
self.assertIn('-separate', commands[1])
self.assertIn('-input_file_list', commands[1])
self.assertIn('d:/temp/test.vrt', commands[1])

def testGdalTindex(self):
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()
Expand Down

0 comments on commit 76b13ff

Please sign in to comment.