Skip to content

Commit

Permalink
[processing] add a few more parameter tests to gdal's warp & translat…
Browse files Browse the repository at this point in the history
…e algs
  • Loading branch information
nirvn committed Jul 16, 2018
1 parent e9b6da1 commit 53df974
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 53df974

Please sign in to comment.