Merge pull request #2389 from NaturalGIS/gdal_advanced

Processing gdal translate and warp advanced parameters as such
This commit is contained in:
volaya 2015-10-24 15:38:07 +02:00
commit 1dd8e79baf
2 changed files with 34 additions and 18 deletions

View File

@ -87,27 +87,34 @@ class translate(GdalAlgorithm):
self.addParameter(ParameterBoolean(self.SDS, self.addParameter(ParameterBoolean(self.SDS,
self.tr('Copy all subdatasets of this file to individual output files'), self.tr('Copy all subdatasets of this file to individual output files'),
False)) False))
self.addParameter(ParameterSelection(self.RTYPE,
params = []
params.append(ParameterSelection(self.RTYPE,
self.tr('Output raster type'), self.TYPE, 5)) self.tr('Output raster type'), self.TYPE, 5))
self.addParameter(ParameterSelection(self.COMPRESS, params.append(ParameterSelection(self.COMPRESS,
self.tr('GeoTIFF options. Compression type:'), self.COMPRESSTYPE, 4)) self.tr('GeoTIFF options. Compression type:'), self.COMPRESSTYPE, 4))
self.addParameter(ParameterNumber(self.JPEGCOMPRESSION, params.append(ParameterNumber(self.JPEGCOMPRESSION,
self.tr('Set the JPEG compression level'), self.tr('Set the JPEG compression level'),
1, 100, 75)) 1, 100, 75))
self.addParameter(ParameterNumber(self.ZLEVEL, params.append(ParameterNumber(self.ZLEVEL,
self.tr('Set the DEFLATE compression level'), self.tr('Set the DEFLATE compression level'),
1, 9, 6)) 1, 9, 6))
self.addParameter(ParameterNumber(self.PREDICTOR, params.append(ParameterNumber(self.PREDICTOR,
self.tr('Set the predictor for LZW or DEFLATE compression'), self.tr('Set the predictor for LZW or DEFLATE compression'),
1, 3, 1)) 1, 3, 1))
self.addParameter(ParameterBoolean(self.TILED, params.append(ParameterBoolean(self.TILED,
self.tr('Create tiled output (only used for the GTiff format)'), False)) self.tr('Create tiled output (only used for the GTiff format)'), False))
self.addParameter(ParameterSelection(self.BIGTIFF, params.append(ParameterSelection(self.BIGTIFF,
self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0)) self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0))
self.addParameter(ParameterBoolean(self.TFW, params.append(ParameterBoolean(self.TFW,
self.tr('Force the generation of an associated ESRI world file (.tfw))'), False)) self.tr('Force the generation of an associated ESRI world file (.tfw))'), False))
self.addParameter(ParameterString(self.EXTRA, params.append(ParameterString(self.EXTRA,
self.tr('Additional creation parameters'), '', optional=True)) self.tr('Additional creation parameters'), '', optional=True))
for param in params:
param.isAdvanced = True
self.addParameter(param)
self.addOutput(OutputRaster(self.OUTPUT, self.tr('Converted'))) self.addOutput(OutputRaster(self.OUTPUT, self.tr('Converted')))
def getConsoleCommands(self): def getConsoleCommands(self):
@ -175,6 +182,7 @@ class translate(GdalAlgorithm):
arguments.append("-co TFW=YES") arguments.append("-co TFW=YES")
if len(bigtiff) > 0: if len(bigtiff) > 0:
arguments.append("-co BIGTIFF=" + bigtiff) arguments.append("-co BIGTIFF=" + bigtiff)
arguments.append(self.getParameterValue(self.INPUT)) arguments.append(self.getParameterValue(self.INPUT))
arguments.append(out) arguments.append(out)

View File

@ -75,27 +75,34 @@ class warp(GdalAlgorithm):
0.0, None, 0.0)) 0.0, None, 0.0))
self.addParameter(ParameterSelection(self.METHOD, self.addParameter(ParameterSelection(self.METHOD,
self.tr('Resampling method'), self.METHOD_OPTIONS)) self.tr('Resampling method'), self.METHOD_OPTIONS))
self.addParameter(ParameterSelection(self.RTYPE,
params = []
params.append(ParameterSelection(self.RTYPE,
self.tr('Output raster type'), self.TYPE, 5)) self.tr('Output raster type'), self.TYPE, 5))
self.addParameter(ParameterSelection(self.COMPRESS, params.append(ParameterSelection(self.COMPRESS,
self.tr('GeoTIFF options. Compression type:'), self.COMPRESSTYPE, 4)) self.tr('GeoTIFF options. Compression type:'), self.COMPRESSTYPE, 4))
self.addParameter(ParameterNumber(self.JPEGCOMPRESSION, params.append(ParameterNumber(self.JPEGCOMPRESSION,
self.tr('Set the JPEG compression level'), self.tr('Set the JPEG compression level'),
1, 100, 75)) 1, 100, 75))
self.addParameter(ParameterNumber(self.ZLEVEL, params.append(ParameterNumber(self.ZLEVEL,
self.tr('Set the DEFLATE compression level'), self.tr('Set the DEFLATE compression level'),
1, 9, 6)) 1, 9, 6))
self.addParameter(ParameterNumber(self.PREDICTOR, params.append(ParameterNumber(self.PREDICTOR,
self.tr('Set the predictor for LZW or DEFLATE compression'), self.tr('Set the predictor for LZW or DEFLATE compression'),
1, 3, 1)) 1, 3, 1))
self.addParameter(ParameterBoolean(self.TILED, params.append(ParameterBoolean(self.TILED,
self.tr('Create tiled output (only used for the GTiff format)'), False)) self.tr('Create tiled output (only used for the GTiff format)'), False))
self.addParameter(ParameterSelection(self.BIGTIFF, params.append(ParameterSelection(self.BIGTIFF,
self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0)) self.tr('Control whether the created file is a BigTIFF or a classic TIFF'), self.BIGTIFFTYPE, 0))
self.addParameter(ParameterBoolean(self.TFW, params.append(ParameterBoolean(self.TFW,
self.tr('Force the generation of an associated ESRI world file (.tfw))'), False)) self.tr('Force the generation of an associated ESRI world file (.tfw))'), False))
self.addParameter(ParameterString(self.EXTRA, params.append(ParameterString(self.EXTRA,
self.tr('Additional creation parameters'), '', optional=True)) self.tr('Additional creation parameters'), '', optional=True))
for param in params:
param.isAdvanced = True
self.addParameter(param)
self.addOutput(OutputRaster(self.OUTPUT, self.tr('Reprojected'))) self.addOutput(OutputRaster(self.OUTPUT, self.tr('Reprojected')))
def getConsoleCommands(self): def getConsoleCommands(self):
@ -149,6 +156,7 @@ class warp(GdalAlgorithm):
arguments.append("-co TFW=YES") arguments.append("-co TFW=YES")
if len(bigtiff) > 0: if len(bigtiff) > 0:
arguments.append("-co BIGTIFF=" + bigtiff) arguments.append("-co BIGTIFF=" + bigtiff)
arguments.append(self.getParameterValue(self.INPUT)) arguments.append(self.getParameterValue(self.INPUT))
arguments.append(out) arguments.append(out)