Skip to content

Commit

Permalink
[needs-docs] Harmonize display of GDAL build vrt options
Browse files Browse the repository at this point in the history
  • Loading branch information
DelazJ authored and nyalldawson committed May 22, 2019
1 parent 7cba36b commit 48f837a
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions python/plugins/processing/algs/gdal/buildvrt.py
Expand Up @@ -60,9 +60,6 @@ class buildvrt(GdalAlgorithm):
RESAMPLING = 'RESAMPLING'
SRC_NODATA = 'SRC_NODATA'

RESOLUTION_OPTIONS = ['average', 'highest', 'lowest']
RESAMPLING_OPTIONS = ['nearest', 'bilinear', 'cubic', 'cubicspline', 'lanczos', 'average', 'mode']

def __init__(self):
super().__init__()

Expand All @@ -83,12 +80,24 @@ def type(self):
def defaultFileExtension(self):
return 'vrt'

self.RESAMPLING_OPTIONS = ((self.tr('Nearest neighbour'), 'nearest'),
(self.tr('Bilinear'), 'bilinear'),
(self.tr('Cubic convolution'), 'cubic'),
(self.tr('B-Spline convolution'), 'cubicspline'),
(self.tr('Lanczos windowed sinc'), 'lanczos'),
(self.tr('Average'), 'average'),
(self.tr('Mode'), 'mode'))

self.RESOLUTION_OPTIONS = ((self.tr('Average'), 'average'),
(self.tr('Highest'), 'highest'),
(self.tr('Lowest'), 'lowest'))

self.addParameter(QgsProcessingParameterMultipleLayers(self.INPUT,
self.tr('Input layers'),
QgsProcessing.TypeRaster))
self.addParameter(QgsProcessingParameterEnum(self.RESOLUTION,
self.tr('Resolution'),
options=self.RESOLUTION_OPTIONS,
options=[i[0] for i in self.RESOLUTION_OPTIONS],
defaultValue=0))
self.addParameter(QgsProcessingParameterBoolean(self.SEPARATE,
self.tr('Place each input file into a separate band'),
Expand All @@ -111,7 +120,7 @@ def defaultFileExtension(self):

resampling = QgsProcessingParameterEnum(self.RESAMPLING,
self.tr('Resampling algorithm'),
options=self.RESAMPLING_OPTIONS,
options=[i[0] for i in self.RESAMPLING_OPTIONS],
defaultValue=0)
resampling.setFlags(resampling.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
self.addParameter(resampling)
Expand Down Expand Up @@ -146,7 +155,7 @@ def commandName(self):
def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
arguments.append('-resolution')
arguments.append(self.RESOLUTION_OPTIONS[self.parameterAsEnum(parameters, self.RESOLUTION, context)])
arguments.append(self.RESOLUTION_OPTIONS[self.parameterAsEnum(parameters, self.RESOLUTION, context)][1])
if self.parameterAsBool(parameters, buildvrt.SEPARATE, context):
arguments.append('-separate')
if self.parameterAsBool(parameters, buildvrt.PROJ_DIFFERENCE, context):
Expand All @@ -158,7 +167,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-a_srs')
arguments.append(GdalUtils.gdal_crs_string(crs))
arguments.append('-r')
arguments.append(self.RESAMPLING_OPTIONS[self.parameterAsEnum(parameters, self.RESAMPLING, context)])
arguments.append(self.RESAMPLING_OPTIONS[self.parameterAsEnum(parameters, self.RESAMPLING, context)][1])

if self.SRC_NODATA in parameters and parameters[self.SRC_NODATA] not in (None, ''):
nodata = self.parameterAsString(parameters, self.SRC_NODATA, context)
Expand Down

0 comments on commit 48f837a

Please sign in to comment.