Skip to content

Commit

Permalink
Make Extent and Extent CRS GDAL parameters optional
Browse files Browse the repository at this point in the history
Specify what the default is when extent CRS is not specified.
Allow using "auto" to have extent automatically set to min covering extent.

Fixes #15685
  • Loading branch information
strk committed Oct 20, 2016
1 parent ea0ad5d commit 06976a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions python/plugins/processing/algs/gdal/warp.py
Expand Up @@ -92,7 +92,8 @@ def defineCharacteristics(self):

if GdalUtils.version() >= 2000000:
self.addParameter(ParameterCrs(self.EXT_CRS,
self.tr('CRS of the raster extent'), ''))
self.tr('CRS of the raster extent, leave blank for using Destination SRS'),
optional=True))

params = []
params.append(ParameterSelection(self.RTYPE,
Expand Down Expand Up @@ -136,7 +137,7 @@ def getConsoleCommands(self):
compress = self.COMPRESSTYPE[self.getParameterValue(self.COMPRESS)]
bigtiff = self.BIGTIFFTYPE[self.getParameterValue(self.BIGTIFF)]
tfw = str(self.getParameterValue(self.TFW))
rastext = str(self.getParameterValue(self.RAST_EXT))
rastext = self.getParameterValue(self.RAST_EXT)
rastext_crs = self.getParameterValue(self.EXT_CRS)

arguments = []
Expand Down Expand Up @@ -174,11 +175,9 @@ def getConsoleCommands(self):
rastext.append(regionCoords[3])
except IndexError:
rastext = []
if rastext:
arguments.extend(rastext)

if GdalUtils.version() >= 2000000:
if rastext and rastext_crs is not None:
if rastext and rastext_crs:
arguments.append('-te_srs')
arguments.append(rastext_crs)

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/core/parameters.py
Expand Up @@ -348,7 +348,7 @@ def __init__(self, name='', description='', default=None, optional=True):
# The value is a string in the form "xmin, xmax, ymin, ymax"

def setValue(self, value):
if value is None:
if not value:
if not self.optional:
return False
self.value = None
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/gui/ExtentSelectionPanel.py
Expand Up @@ -59,7 +59,7 @@ def __init__(self, dialog, param):
if self.param.optional:
if hasattr(self.leText, 'setPlaceholderText'):
self.leText.setPlaceholderText(
self.tr('[Leave blank to use min covering extent]'))
self.tr('[Use "auto" to use min covering extent]'))

self.btnSelect.clicked.connect(self.selectExtent)

Expand Down Expand Up @@ -104,7 +104,7 @@ def selectExtent(self):
popupmenu.exec_(QCursor.pos())

def useMinCoveringExtent(self):
self.leText.setText('')
self.leText.setText('auto')

def useLayerExtent(self):
CANVAS_KEY = 'Use canvas extent'
Expand Down Expand Up @@ -153,7 +153,7 @@ def setValueFromRect(self, r):
self.dialog.activateWindow()

def getValue(self):
if str(self.leText.text()).strip() != '':
if str(self.leText.text()).strip() == '':
return str(self.leText.text())
else:
return None
Expand Down

0 comments on commit 06976a2

Please sign in to comment.