mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
restore columns and rows parameters for the extremely rare case if
someone have used native interpolation algs in scripts/models
This commit is contained in:
parent
09dbb8917d
commit
e86ca50cc6
@ -33,6 +33,7 @@ from qgis.core import (QgsRectangle,
|
|||||||
QgsProcessingUtils,
|
QgsProcessingUtils,
|
||||||
QgsProcessingParameterNumber,
|
QgsProcessingParameterNumber,
|
||||||
QgsProcessingParameterExtent,
|
QgsProcessingParameterExtent,
|
||||||
|
QgsProcessingParameterDefinition,
|
||||||
QgsProcessingParameterRasterDestination,
|
QgsProcessingParameterRasterDestination,
|
||||||
QgsProcessingException)
|
QgsProcessingException)
|
||||||
from qgis.analysis import (QgsInterpolator,
|
from qgis.analysis import (QgsInterpolator,
|
||||||
@ -50,6 +51,8 @@ class IdwInterpolation(QgisAlgorithm):
|
|||||||
INTERPOLATION_DATA = 'INTERPOLATION_DATA'
|
INTERPOLATION_DATA = 'INTERPOLATION_DATA'
|
||||||
DISTANCE_COEFFICIENT = 'DISTANCE_COEFFICIENT'
|
DISTANCE_COEFFICIENT = 'DISTANCE_COEFFICIENT'
|
||||||
PIXEL_SIZE = 'PIXEL_SIZE'
|
PIXEL_SIZE = 'PIXEL_SIZE'
|
||||||
|
COLUMNS = 'COLUMNS'
|
||||||
|
ROWS = 'ROWS'
|
||||||
EXTENT = 'EXTENT'
|
EXTENT = 'EXTENT'
|
||||||
OUTPUT = 'OUTPUT'
|
OUTPUT = 'OUTPUT'
|
||||||
|
|
||||||
@ -83,6 +86,20 @@ class IdwInterpolation(QgisAlgorithm):
|
|||||||
default=0.1)
|
default=0.1)
|
||||||
self.addParameter(pixel_size_param)
|
self.addParameter(pixel_size_param)
|
||||||
|
|
||||||
|
cols_param = QgsProcessingParameterNumber(self.COLUMNS,
|
||||||
|
self.tr('Number of columns'),
|
||||||
|
optional=True,
|
||||||
|
minValue=0, maxValue=10000000)
|
||||||
|
cols_param.setFlags(cols_param.flags() | QgsProcessingParameterDefinition.FlagHidden)
|
||||||
|
self.addParameter(cols_param)
|
||||||
|
|
||||||
|
rows_param = QgsProcessingParameterNumber(self.ROWS,
|
||||||
|
self.tr('Number of rows'),
|
||||||
|
optional=True,
|
||||||
|
minValue=0, maxValue=10000000)
|
||||||
|
rows_param.setFlags(rows_param.flags() | QgsProcessingParameterDefinition.FlagHidden)
|
||||||
|
self.addParameter(rows_param)
|
||||||
|
|
||||||
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
|
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
|
||||||
self.tr('Interpolated')))
|
self.tr('Interpolated')))
|
||||||
|
|
||||||
@ -99,6 +116,13 @@ class IdwInterpolation(QgisAlgorithm):
|
|||||||
pixel_size = self.parameterAsDouble(parameters, self.PIXEL_SIZE, context)
|
pixel_size = self.parameterAsDouble(parameters, self.PIXEL_SIZE, context)
|
||||||
output = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
|
output = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
|
||||||
|
|
||||||
|
columns = self.parameterAsInt(parameters, self.COLUMNS, context)
|
||||||
|
rows = self.parameterAsInt(parameters, self.ROWS, context)
|
||||||
|
if columns == 0:
|
||||||
|
columns = max(round(bbox.width() / pixel_size) + 1, 1)
|
||||||
|
if rows == 0:
|
||||||
|
rows = max(round(bbox.height() / pixel_size) + 1, 1)
|
||||||
|
|
||||||
if interpolationData is None:
|
if interpolationData is None:
|
||||||
raise QgsProcessingException(
|
raise QgsProcessingException(
|
||||||
self.tr('You need to specify at least one input layer.'))
|
self.tr('You need to specify at least one input layer.'))
|
||||||
@ -127,9 +151,6 @@ class IdwInterpolation(QgisAlgorithm):
|
|||||||
interpolator = QgsIDWInterpolator(layerData)
|
interpolator = QgsIDWInterpolator(layerData)
|
||||||
interpolator.setDistanceCoefficient(coefficient)
|
interpolator.setDistanceCoefficient(coefficient)
|
||||||
|
|
||||||
rows = max(round(bbox.height() / pixel_size) + 1, 1)
|
|
||||||
columns = max(round(bbox.width() / pixel_size) + 1, 1)
|
|
||||||
|
|
||||||
writer = QgsGridFileWriter(interpolator,
|
writer = QgsGridFileWriter(interpolator,
|
||||||
output,
|
output,
|
||||||
bbox,
|
bbox,
|
||||||
|
@ -34,6 +34,7 @@ from qgis.core import (QgsProcessingUtils,
|
|||||||
QgsProcessingParameterEnum,
|
QgsProcessingParameterEnum,
|
||||||
QgsProcessingParameterNumber,
|
QgsProcessingParameterNumber,
|
||||||
QgsProcessingParameterExtent,
|
QgsProcessingParameterExtent,
|
||||||
|
QgsProcessingParameterDefinition,
|
||||||
QgsProcessingParameterRasterDestination,
|
QgsProcessingParameterRasterDestination,
|
||||||
QgsWkbTypes,
|
QgsWkbTypes,
|
||||||
QgsProcessingParameterFeatureSink,
|
QgsProcessingParameterFeatureSink,
|
||||||
@ -53,6 +54,8 @@ class TinInterpolation(QgisAlgorithm):
|
|||||||
INTERPOLATION_DATA = 'INTERPOLATION_DATA'
|
INTERPOLATION_DATA = 'INTERPOLATION_DATA'
|
||||||
METHOD = 'METHOD'
|
METHOD = 'METHOD'
|
||||||
PIXEL_SIZE = 'PIXEL_SIZE'
|
PIXEL_SIZE = 'PIXEL_SIZE'
|
||||||
|
COLUMNS = 'COLUMNS'
|
||||||
|
ROWS = 'ROWS'
|
||||||
EXTENT = 'EXTENT'
|
EXTENT = 'EXTENT'
|
||||||
OUTPUT = 'OUTPUT'
|
OUTPUT = 'OUTPUT'
|
||||||
TRIANGULATION = 'TRIANGULATION'
|
TRIANGULATION = 'TRIANGULATION'
|
||||||
@ -91,6 +94,20 @@ class TinInterpolation(QgisAlgorithm):
|
|||||||
default=0.1)
|
default=0.1)
|
||||||
self.addParameter(pixel_size_param)
|
self.addParameter(pixel_size_param)
|
||||||
|
|
||||||
|
cols_param = QgsProcessingParameterNumber(self.COLUMNS,
|
||||||
|
self.tr('Number of columns'),
|
||||||
|
optional=True,
|
||||||
|
minValue=0, maxValue=10000000)
|
||||||
|
cols_param.setFlags(cols_param.flags() | QgsProcessingParameterDefinition.FlagHidden)
|
||||||
|
self.addParameter(cols_param)
|
||||||
|
|
||||||
|
rows_param = QgsProcessingParameterNumber(self.ROWS,
|
||||||
|
self.tr('Number of rows'),
|
||||||
|
optional=True,
|
||||||
|
minValue=0, maxValue=10000000)
|
||||||
|
rows_param.setFlags(rows_param.flags() | QgsProcessingParameterDefinition.FlagHidden)
|
||||||
|
self.addParameter(rows_param)
|
||||||
|
|
||||||
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
|
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
|
||||||
self.tr('Interpolated')))
|
self.tr('Interpolated')))
|
||||||
|
|
||||||
@ -114,6 +131,13 @@ class TinInterpolation(QgisAlgorithm):
|
|||||||
pixel_size = self.parameterAsDouble(parameters, self.PIXEL_SIZE, context)
|
pixel_size = self.parameterAsDouble(parameters, self.PIXEL_SIZE, context)
|
||||||
output = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
|
output = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
|
||||||
|
|
||||||
|
columns = self.parameterAsInt(parameters, self.COLUMNS, context)
|
||||||
|
rows = self.parameterAsInt(parameters, self.ROWS, context)
|
||||||
|
if columns == 0:
|
||||||
|
columns = max(round(bbox.width() / pixel_size) + 1, 1)
|
||||||
|
if rows == 0:
|
||||||
|
rows = max(round(bbox.height() / pixel_size) + 1, 1)
|
||||||
|
|
||||||
if interpolationData is None:
|
if interpolationData is None:
|
||||||
raise QgsProcessingException(
|
raise QgsProcessingException(
|
||||||
self.tr('You need to specify at least one input layer.'))
|
self.tr('You need to specify at least one input layer.'))
|
||||||
@ -154,9 +178,6 @@ class TinInterpolation(QgisAlgorithm):
|
|||||||
if triangulation_sink is not None:
|
if triangulation_sink is not None:
|
||||||
interpolator.setTriangulationSink(triangulation_sink)
|
interpolator.setTriangulationSink(triangulation_sink)
|
||||||
|
|
||||||
rows = max(round(bbox.height() / pixel_size) + 1, 1)
|
|
||||||
columns = max(round(bbox.width() / pixel_size) + 1, 1)
|
|
||||||
|
|
||||||
writer = QgsGridFileWriter(interpolator,
|
writer = QgsGridFileWriter(interpolator,
|
||||||
output,
|
output,
|
||||||
bbox,
|
bbox,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user