Skip to content
Permalink
Browse files

[processing] add a few more parameter tests to gdal's warp & translat…

…e algs
  • Loading branch information
nirvn committed Jul 16, 2018
1 parent e9b6da1 commit 53df974131e6edf8d2fb9dabd63cf3bd8cc0148d
Showing with 52 additions and 0 deletions.
  1. +52 −0 python/plugins/processing/tests/GdalAlgorithmsTest.py
@@ -313,6 +313,15 @@ def testGdalTranslate(self):
'-ot Float32 -of JPEG ' +
source + ' ' +
'd:/temp/check.jpg'])
# with None NODATA value
self.assertEqual(
translate_alg.getConsoleCommands({'INPUT': source,
'NODATA': None,
'OUTPUT': 'd:/temp/check.jpg'}, context, feedback),
['gdal_translate',
'-ot Float32 -of JPEG ' +
source + ' ' +
'd:/temp/check.jpg'])
# with NODATA value
self.assertEqual(
translate_alg.getConsoleCommands({'INPUT': source,
@@ -1285,6 +1294,16 @@ def testWarp(self):
'-s_srs EPSG:3111 -t_srs EPSG:4326 -r near -ot Float32 -of JPEG ' +
source + ' ' +
'd:/temp/check.jpg'])
# with None NODATA value
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'NODATA': None,
'SOURCE_CRS': 'EPSG:3111',
'OUTPUT': 'd:/temp/check.jpg'}, context, feedback),
['gdalwarp',
'-s_srs EPSG:3111 -t_srs EPSG:4326 -r near -ot Float32 -of JPEG ' +
source + ' ' +
'd:/temp/check.jpg'])
# with NODATA value
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
@@ -1341,6 +1360,39 @@ def testWarp(self):
source + ' ' +
'd:/temp/check.jpg'])

# with target resolution with None value
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'SOURCE_CRS': 'EPSG:3111',
'TARGET_RESOLUTION': None,
'OUTPUT': 'd:/temp/check.jpg'}, context, feedback),
['gdalwarp',
'-s_srs EPSG:3111 -t_srs EPSG:4326 -r near -ot Float32 -of JPEG ' +
source + ' ' +
'd:/temp/check.jpg'])

# test target resolution with a valid value
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'SOURCE_CRS': 'EPSG:3111',
'TARGET_RESOLUTION': 10.0,
'OUTPUT': 'd:/temp/check.jpg'}, context, feedback),
['gdalwarp',
'-s_srs EPSG:3111 -t_srs EPSG:4326 -tr 10.0 10.0 -r near -ot Float32 -of JPEG ' +
source + ' ' +
'd:/temp/check.jpg'])

# test target resolution with a value of zero, to be ignored
self.assertEqual(
alg.getConsoleCommands({'INPUT': source,
'SOURCE_CRS': 'EPSG:3111',
'TARGET_RESOLUTION': 0.0,
'OUTPUT': 'd:/temp/check.jpg'}, context, feedback),
['gdalwarp',
'-s_srs EPSG:3111 -t_srs EPSG:4326 -r near -ot Float32 -of JPEG ' +
source + ' ' +
'd:/temp/check.jpg'])

def testFillnodata(self):
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()

0 comments on commit 53df974

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