Skip to content
Permalink
Browse files

Make Extent and Extent CRS GDAL parameters optional

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 19, 2016
1 parent 1f5fb80 commit dc2df62b88cdc01b0fc8839779da44fb87ccd213
@@ -91,7 +91,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,
@@ -135,7 +136,7 @@ def getConsoleCommands(self):
compress = self.COMPRESSTYPE[self.getParameterValue(self.COMPRESS)]
bigtiff = self.BIGTIFFTYPE[self.getParameterValue(self.BIGTIFF)]
tfw = unicode(self.getParameterValue(self.TFW))
rastext = unicode(self.getParameterValue(self.RAST_EXT))
rastext = self.getParameterValue(self.RAST_EXT)
rastext_crs = self.getParameterValue(self.EXT_CRS)

arguments = []
@@ -163,21 +164,17 @@ def getConsoleCommands(self):
extra = self.getParameterValue(self.EXTRA)
if extra is not None:
extra = unicode(extra)
regionCoords = rastext.split(',')
try:
rastext = []
rastext.append('-te')
rastext.append(regionCoords[0])
rastext.append(regionCoords[2])
rastext.append(regionCoords[1])
rastext.append(regionCoords[3])
except IndexError:
rastext = []
if rastext:
arguments.extend(rastext)
regionCoords = rastext.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 GdalUtils.version() >= 2000000:
if rastext and rastext_crs is not None:
if rastext and rastext_crs:
arguments.append('-te_srs')
arguments.append(rastext_crs)

@@ -198,7 +198,7 @@ def __init__(self, name='', description='', default=None, optional=False):
# The value is a string in the form "xmin, xmax, ymin, ymax"

def setValue(self, text):
if text is None:
if not text:
if not self.optional:
return False
self.value = None
@@ -58,7 +58,7 @@ def __init__(self, dialog, alg, default=None):
if self.canUseAutoExtent():
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)

@@ -112,7 +112,7 @@ def selectExtent(self):
popupmenu.exec_(QCursor.pos())

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

def getMinCoveringExtent(self):
first = True
@@ -205,10 +205,10 @@ def setValueFromRect(self, r):
self.dialog.activateWindow()

def getValue(self):
if unicode(self.leText.text()).strip() != '':
return unicode(self.leText.text())
else:
if unicode(self.leText.text()).strip() == 'auto':
return self.getMinCoveringExtent()
else:
return unicode(self.leText.text())

def setExtentFromString(self, s):
self.leText.setText(s)

0 comments on commit dc2df62

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