Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] add multithreading option to warp (fix #15340)
  • Loading branch information
alexbruy committed Apr 29, 2017
1 parent 4377f20 commit 3450a9f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion python/plugins/processing/algs/gdal/warp.py
Expand Up @@ -36,7 +36,8 @@
ParameterSelection,
ParameterCrs,
ParameterNumber,
ParameterString)
ParameterString,
ParameterBoolean)
from processing.core.outputs import OutputRaster
from processing.algs.gdal.GdalUtils import GdalUtils

Expand All @@ -56,6 +57,7 @@ class warp(GdalAlgorithm):
EXT_CRS = 'EXT_CRS'
RTYPE = 'RTYPE'
OPTIONS = 'OPTIONS'
MULTITHREADING = 'MULTITHREADING'

METHOD_OPTIONS = ['near', 'bilinear', 'cubic', 'cubicspline', 'lanczos']
TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']
Expand Down Expand Up @@ -105,6 +107,10 @@ def defineCharacteristics(self):
self.tr('Additional creation options'),
optional=True,
metadata={'widget_wrapper': 'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'}))
self.addParameter(ParameterBoolean(self.MULTITHREADING,
self.tr('Use multithreaded warping implementation'),
False
))
self.addParameter(ParameterSelection(self.RTYPE,
self.tr('Output raster type'),
self.TYPE, 5))
Expand All @@ -118,6 +124,7 @@ def getConsoleCommands(self):
rastext_crs = self.getParameterValue(self.EXT_CRS)
opts = self.getParameterValue(self.OPTIONS)
noData = self.getParameterValue(self.NO_DATA)
multithreading = self.getParameterValue(self.MULTITHREADING)

if noData is not None:
noData = str(noData)
Expand Down Expand Up @@ -165,6 +172,9 @@ def getConsoleCommands(self):
arguments.append('-co')
arguments.append(opts)

if multithreading:
arguments.append('-multi')

if GdalUtils.version() in [2010000, 2010100]:
arguments.append("--config GDALWARP_IGNORE_BAD_CUTLINE YES")

Expand Down

0 comments on commit 3450a9f

Please sign in to comment.