Skip to content

Commit

Permalink
tests for rasterize_over_fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and nyalldawson committed Nov 5, 2019
1 parent d7960b7 commit 9af729e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsRasterTest.py
Expand Up @@ -68,6 +68,7 @@
from processing.algs.gdal.nearblack import nearblack
from processing.algs.gdal.slope import slope
from processing.algs.gdal.rasterize_over import rasterize_over
from processing.algs.gdal.rasterize_over_fixed_value import rasterize_over_fixed_value

testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')

Expand Down Expand Up @@ -1539,6 +1540,41 @@ def testRasterizeOver(self):
'-l polys2 -a id -i ' +
vector + ' ' + raster])

def testRasterizeOverFixed(self):
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()
raster = os.path.join(testDataPath, 'dem.tif')
vector = os.path.join(testDataPath, 'polys.gml')
alg = rasterize_over_fixed_value()
alg.initAlgorithm()

with tempfile.TemporaryDirectory() as outdir:
self.assertEqual(
alg.getConsoleCommands({'INPUT': vector,
'BURN': 100,
'INPUT_RASTER': raster}, context, feedback),
['gdal_rasterize',
'-l polys2 -burn 100.0 ' +
vector + ' ' + raster])

self.assertEqual(
alg.getConsoleCommands({'INPUT': vector,
'BURN': 100,
'ADD': True,
'INPUT_RASTER': raster}, context, feedback),
['gdal_rasterize',
'-l polys2 -burn 100.0 -add ' +
vector + ' ' + raster])

self.assertEqual(
alg.getConsoleCommands({'INPUT': vector,
'BURN': 100,
'EXTRA': '-i',
'INPUT_RASTER': raster}, context, feedback),
['gdal_rasterize',
'-l polys2 -burn 100.0 -i ' +
vector + ' ' + raster])

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

0 comments on commit 9af729e

Please sign in to comment.