3434 QgsProcessingParameterEnum ,
3535 QgsProcessingParameterNumber ,
3636 QgsProcessingParameterExtent ,
37+ QgsProcessingParameterDefinition ,
3738 QgsProcessingParameterRasterDestination ,
3839 QgsWkbTypes ,
3940 QgsProcessingParameterFeatureSink ,
@@ -53,6 +54,8 @@ class TinInterpolation(QgisAlgorithm):
5354 INTERPOLATION_DATA = 'INTERPOLATION_DATA'
5455 METHOD = 'METHOD'
5556 PIXEL_SIZE = 'PIXEL_SIZE'
57+ COLUMNS = 'COLUMNS'
58+ ROWS = 'ROWS'
5659 EXTENT = 'EXTENT'
5760 OUTPUT = 'OUTPUT'
5861 TRIANGULATION = 'TRIANGULATION'
@@ -91,6 +94,20 @@ def initAlgorithm(self, config=None):
9194 default = 0.1 )
9295 self .addParameter (pixel_size_param )
9396
97+ cols_param = QgsProcessingParameterNumber (self .COLUMNS ,
98+ self .tr ('Number of columns' ),
99+ optional = True ,
100+ minValue = 0 , maxValue = 10000000 )
101+ cols_param .setFlags (cols_param .flags () | QgsProcessingParameterDefinition .FlagHidden )
102+ self .addParameter (cols_param )
103+
104+ rows_param = QgsProcessingParameterNumber (self .ROWS ,
105+ self .tr ('Number of rows' ),
106+ optional = True ,
107+ minValue = 0 , maxValue = 10000000 )
108+ rows_param .setFlags (rows_param .flags () | QgsProcessingParameterDefinition .FlagHidden )
109+ self .addParameter (rows_param )
110+
94111 self .addParameter (QgsProcessingParameterRasterDestination (self .OUTPUT ,
95112 self .tr ('Interpolated' )))
96113
@@ -114,6 +131,13 @@ def processAlgorithm(self, parameters, context, feedback):
114131 pixel_size = self .parameterAsDouble (parameters , self .PIXEL_SIZE , context )
115132 output = self .parameterAsOutputLayer (parameters , self .OUTPUT , context )
116133
134+ columns = self .parameterAsInt (parameters , self .COLUMNS , context )
135+ rows = self .parameterAsInt (parameters , self .ROWS , context )
136+ if columns == 0 :
137+ columns = max (round (bbox .width () / pixel_size ) + 1 , 1 )
138+ if rows == 0 :
139+ rows = max (round (bbox .height () / pixel_size ) + 1 , 1 )
140+
117141 if interpolationData is None :
118142 raise QgsProcessingException (
119143 self .tr ('You need to specify at least one input layer.' ))
@@ -154,9 +178,6 @@ def processAlgorithm(self, parameters, context, feedback):
154178 if triangulation_sink is not None :
155179 interpolator .setTriangulationSink (triangulation_sink )
156180
157- rows = max (round (bbox .height () / pixel_size ) + 1 , 1 )
158- columns = max (round (bbox .width () / pixel_size ) + 1 , 1 )
159-
160181 writer = QgsGridFileWriter (interpolator ,
161182 output ,
162183 bbox ,
0 commit comments