Skip to content

Commit

Permalink
[processing] don't apply -te and -te_srs if not requested (fix #16519)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed May 10, 2017
1 parent 883e4f3 commit abc74b4
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions python/plugins/processing/algs/gdal/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ class warp(GdalAlgorithm):
METHOD = 'METHOD'
TR = 'TR'
NO_DATA = 'NO_DATA'
RAST_EXT = 'RAST_EXT'
EXT_CRS = 'EXT_CRS'
USE_RASTER_EXTENT = 'USE_RASTER_EXTENT'
RASTER_EXTENT = 'RASTER_EXTENT'
EXTENT_CRS = 'EXTENT_CRS'
RTYPE = 'RTYPE'
OPTIONS = 'OPTIONS'
MULTITHREADING = 'MULTITHREADING'
Expand Down Expand Up @@ -95,14 +96,16 @@ def defineCharacteristics(self):
self.addParameter(ParameterSelection(self.METHOD,
self.tr('Resampling method'),
self.METHOD_OPTIONS))
self.addParameter(ParameterExtent(self.RAST_EXT,
self.addParameter(ParameterBoolean(self.USE_RASTER_EXTENT,
self.tr('Set georeferenced extents of output file'),
False
))
self.addParameter(ParameterExtent(self.RASTER_EXTENT,
self.tr('Raster extent'),
optional=True))

self.addParameter(ParameterCrs(self.EXT_CRS,
self.addParameter(ParameterCrs(self.EXTENT_CRS,
self.tr('CRS of the raster extent, leave blank for using Destination SRS'),
optional=True))

self.addParameter(ParameterString(self.OPTIONS,
self.tr('Additional creation options'),
optional=True,
Expand All @@ -120,8 +123,9 @@ def defineCharacteristics(self):
def getConsoleCommands(self):
srccrs = self.getParameterValue(self.SOURCE_SRS)
dstcrs = self.getParameterValue(self.DEST_SRS)
rastext = self.getParameterValue(self.RAST_EXT)
rastext_crs = self.getParameterValue(self.EXT_CRS)
useRasterExtent = self.getParameterValue(self.USE_RASTER_EXTENT)
rasterExtent = self.getParameterValue(self.RASTER_EXTENT)
extentCrs = self.getParameterValue(self.EXTENT_CRS)
opts = self.getParameterValue(self.OPTIONS)
noData = self.getParameterValue(self.NO_DATA)
multithreading = self.getParameterValue(self.MULTITHREADING)
Expand Down Expand Up @@ -155,18 +159,18 @@ def getConsoleCommands(self):
arguments.append(str(self.getParameterValue(self.TR)))
arguments.append(str(self.getParameterValue(self.TR)))

if rastext:
regionCoords = rastext.split(',')
if useRasterExtent:
regionCoords = rasterExtent.split(',')
if len(regionCoords) >= 4:
arguments.append('-te')
arguments.append(regionCoords[0])
arguments.append(regionCoords[2])
arguments.append(regionCoords[1])
arguments.append(regionCoords[3])

if rastext_crs:
if extentCrs:
arguments.append('-te_srs')
arguments.append(rastext_crs)
arguments.append(extentCrs)

if opts:
arguments.append('-co')
Expand Down

0 comments on commit abc74b4

Please sign in to comment.