34
34
QgsProcessingParameterEnum ,
35
35
QgsProcessingParameterNumber ,
36
36
QgsProcessingParameterExtent ,
37
+ QgsProcessingParameterDefinition ,
37
38
QgsProcessingParameterRasterDestination ,
38
39
QgsWkbTypes ,
39
40
QgsProcessingParameterFeatureSink ,
@@ -53,6 +54,8 @@ class TinInterpolation(QgisAlgorithm):
53
54
INTERPOLATION_DATA = 'INTERPOLATION_DATA'
54
55
METHOD = 'METHOD'
55
56
PIXEL_SIZE = 'PIXEL_SIZE'
57
+ COLUMNS = 'COLUMNS'
58
+ ROWS = 'ROWS'
56
59
EXTENT = 'EXTENT'
57
60
OUTPUT = 'OUTPUT'
58
61
TRIANGULATION = 'TRIANGULATION'
@@ -91,6 +94,20 @@ def initAlgorithm(self, config=None):
91
94
default = 0.1 )
92
95
self .addParameter (pixel_size_param )
93
96
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
+
94
111
self .addParameter (QgsProcessingParameterRasterDestination (self .OUTPUT ,
95
112
self .tr ('Interpolated' )))
96
113
@@ -114,6 +131,13 @@ def processAlgorithm(self, parameters, context, feedback):
114
131
pixel_size = self .parameterAsDouble (parameters , self .PIXEL_SIZE , context )
115
132
output = self .parameterAsOutputLayer (parameters , self .OUTPUT , context )
116
133
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
+
117
141
if interpolationData is None :
118
142
raise QgsProcessingException (
119
143
self .tr ('You need to specify at least one input layer.' ))
@@ -154,9 +178,6 @@ def processAlgorithm(self, parameters, context, feedback):
154
178
if triangulation_sink is not None :
155
179
interpolator .setTriangulationSink (triangulation_sink )
156
180
157
- rows = max (round (bbox .height () / pixel_size ) + 1 , 1 )
158
- columns = max (round (bbox .width () / pixel_size ) + 1 , 1 )
159
-
160
181
writer = QgsGridFileWriter (interpolator ,
161
182
output ,
162
183
bbox ,
0 commit comments