|
30 | 30 | import importlib
|
31 | 31 | from qgis.core import (QgsProcessingUtils,
|
32 | 32 | QgsProcessingException,
|
33 |
| - QgsMessageLog) |
| 33 | + QgsMessageLog, |
| 34 | + QgsProcessingParameterRasterLayer, |
| 35 | + QgsProcessingParameterNumber) |
34 | 36 | from processing.core.ProcessingConfig import ProcessingConfig
|
35 | 37 | from processing.core.parameters import (getParameterFromString,
|
36 | 38 | ParameterExtent,
|
37 |
| - ParameterRaster, |
38 | 39 | ParameterVector,
|
39 | 40 | ParameterTable,
|
40 | 41 | ParameterMultipleInput,
|
41 | 42 | ParameterBoolean,
|
42 | 43 | ParameterFixedTable,
|
43 |
| - ParameterNumber, |
44 | 44 | ParameterSelection)
|
45 | 45 | from processing.core.outputs import (getOutputFromString,
|
46 | 46 | OutputVector,
|
@@ -145,13 +145,13 @@ def processAlgorithm(self, parameters, context, feedback):
|
145 | 145 | # 1: Export rasters to sgrd and vectors to shp
|
146 | 146 | # Tables must be in dbf format. We check that.
|
147 | 147 | for param in self.parameterDefinitions():
|
148 |
| - if isinstance(param, ParameterRaster): |
| 148 | + if isinstance(param, QgsProcessingParameterRasterLayer): |
149 | 149 | if param.name() not in parameters or parameters[param.name()] is None:
|
150 | 150 | continue
|
151 | 151 | if parameters[param.name()].endswith('sdat'):
|
152 | 152 | parameters[param.name()] = parameters[param.name()][:-4] + "sgrd"
|
153 | 153 | elif not parameters[param.name()].endswith('sgrd'):
|
154 |
| - exportCommand = self.exportRasterLayer(parameters[param.name()]) |
| 154 | + exportCommand = self.exportRasterLayer(parameters[param.name()], context) |
155 | 155 | if exportCommand is not None:
|
156 | 156 | commands.append(exportCommand)
|
157 | 157 | if isinstance(param, ParameterVector):
|
@@ -214,7 +214,7 @@ def processAlgorithm(self, parameters, context, feedback):
|
214 | 214 | for param in self.parameterDefinitions():
|
215 | 215 | if not param.name() in parameters or parameters[param.name()] is None:
|
216 | 216 | continue
|
217 |
| - if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable)): |
| 217 | + if isinstance(param, (QgsProcessingParameterRasterLayer, ParameterVector, ParameterTable)): |
218 | 218 | value = parameters[param.name()]
|
219 | 219 | if value in list(self.exportedLayers.keys()):
|
220 | 220 | command += ' -' + param.name() + ' "' \
|
@@ -249,7 +249,7 @@ def processAlgorithm(self, parameters, context, feedback):
|
249 | 249 | for i in range(4):
|
250 | 250 | command += ' -' + self.extentParamNames[i] + ' ' \
|
251 | 251 | + str(float(values[i]) + offset[i])
|
252 |
| - elif isinstance(param, (ParameterNumber, ParameterSelection)): |
| 252 | + elif isinstance(param, (QgsProcessingParameterNumber, ParameterSelection)): |
253 | 253 | command += ' -' + param.name() + ' ' + str(param.value)
|
254 | 254 | else:
|
255 | 255 | command += ' -' + param.name() + ' "' + str(param.value) + '"'
|
@@ -322,9 +322,8 @@ def getOutputCellsize(self, parameters):
|
322 | 322 | break
|
323 | 323 | return cellsize
|
324 | 324 |
|
325 |
| - def exportRasterLayer(self, source): |
| 325 | + def exportRasterLayer(self, source, context): |
326 | 326 | global sessionExportedLayers
|
327 |
| - context = dataobjects.createContext() |
328 | 327 | if source in sessionExportedLayers:
|
329 | 328 | exportedLayer = sessionExportedLayers[source]
|
330 | 329 | if os.path.exists(exportedLayer):
|
@@ -354,7 +353,7 @@ def checkParameterValues(self, parameters, context):
|
354 | 353 | extent = None
|
355 | 354 | for param in self.parameterDefinitions():
|
356 | 355 | files = []
|
357 |
| - if isinstance(param, ParameterRaster): |
| 356 | + if isinstance(param, QgsProcessingParameterRasterLayer): |
358 | 357 | files = [parameters[param.name()]]
|
359 | 358 | elif (isinstance(param, ParameterMultipleInput) and
|
360 | 359 | param.datatype == ParameterMultipleInput.TYPE_RASTER):
|
|
0 commit comments