Skip to content
Permalink
Browse files

[processing][gdal] More descriptive name for separate parameter

in buildvrt algorithm

Fixes #19212
  • Loading branch information
nyalldawson committed Jun 17, 2018
1 parent 4fb9091 commit 76b13ff4c430f995134be153df3ec5a7a0dbfd09
@@ -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'),
@@ -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
@@ -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()

0 comments on commit 76b13ff

Please sign in to comment.
You can’t perform that action at this time.