/
qgsprocessingalgorithm.sip
592 lines (484 loc) · 22.4 KB
/
qgsprocessingalgorithm.sip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/processing/qgsprocessingalgorithm.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsProcessingAlgorithm
{
%Docstring
Abstract base class for processing algorithms.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgsprocessingalgorithm.h"
%End
public:
enum Flag
{
FlagHideFromToolbox,
FlagHideFromModeler,
FlagSupportsBatch,
FlagCanCancel,
FlagRequiresMatchingCrs,
FlagDeprecated,
};
typedef QFlags<QgsProcessingAlgorithm::Flag> Flags;
QgsProcessingAlgorithm();
%Docstring
Constructor for QgsProcessingAlgorithm.
%End
virtual ~QgsProcessingAlgorithm();
virtual QgsProcessingAlgorithm *create() const = 0 /Factory/;
%Docstring
Creates a copy of the algorithm, ready for execution.
:rtype: QgsProcessingAlgorithm
%End
virtual QString name() const = 0;
%Docstring
Returns the algorithm name, used for identifying the algorithm. This string
should be fixed for the algorithm, and must not be localised. The name should
be unique within each provider. Names should contain lowercase alphanumeric characters
only and no spaces or other formatting characters.
.. seealso:: displayName()
.. seealso:: group()
.. seealso:: tags()
:rtype: str
%End
QString id() const;
%Docstring
Returns the unique ID for the algorithm, which is a combination of the algorithm
provider's ID and the algorithms unique name (e.g. "qgis:mergelayers" ).
.. seealso:: name()
.. seealso:: provider()
:rtype: str
%End
virtual QString displayName() const = 0;
%Docstring
Returns the translated algorithm name, which should be used for any user-visible display
of the algorithm name.
.. seealso:: name()
:rtype: str
%End
virtual QStringList tags() const;
%Docstring
Returns a list of tags which relate to the algorithm, and are used to assist users in searching
for suitable algorithms. These tags should be localised.
:rtype: list of str
%End
virtual QString shortHelpString() const;
%Docstring
Returns a localised short helper string for the algorithm. This string should provide a basic description
about what the algorithm does and the parameters and outputs associated with it.
.. seealso:: helpString()
.. seealso:: helpUrl()
:rtype: str
%End
virtual QString helpString() const;
%Docstring
Returns a localised help string for the algorithm. Algorithm subclasses should implement either
helpString() or helpUrl().
.. seealso:: helpUrl()
.. seealso:: shortHelpString()
:rtype: str
%End
virtual QString helpUrl() const;
%Docstring
Returns a url pointing to the algorithm's help page.
.. seealso:: helpString()
.. seealso:: shortHelpString()
:rtype: str
%End
virtual QIcon icon() const;
%Docstring
Returns an icon for the algorithm.
.. seealso:: svgIconPath()
:rtype: QIcon
%End
virtual QString svgIconPath() const;
%Docstring
Returns a path to an SVG version of the algorithm's icon.
.. seealso:: icon()
:rtype: str
%End
virtual QString group() const;
%Docstring
Returns the name of the group this algorithm belongs to. This string
should be localised.
.. seealso:: tags()
:rtype: str
%End
virtual Flags flags() const;
%Docstring
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
Default flags are FlagSupportsBatch and FlagCanCancel.
:rtype: Flags
%End
virtual bool canExecute( QString *errorMessage /Out/ = 0 ) const;
%Docstring
Returns true if the algorithm can execute. Algorithm subclasses can return false
here to indicate that they are not able to execute, e.g. as a result of unmet
external dependencies. If specified, the ``errorMessage`` argument will be filled
with a localised error message describing why the algorithm cannot execute.
:rtype: bool
%End
virtual bool checkParameterValues( const QVariantMap ¶meters,
QgsProcessingContext &context, QString *message /Out/ = 0 ) const;
%Docstring
Checks the supplied ``parameter`` values to verify that they satisfy the requirements
of this algorithm in the supplied ``context``. The ``message`` parameter will be
filled with explanatory text if validation fails.
Overridden implementations should also check this base class implementation.
:return: true if parameters are acceptable for the algorithm.
:rtype: bool
%End
QgsProcessingProvider *provider() const;
%Docstring
Returns the provider to which this algorithm belongs.
:rtype: QgsProcessingProvider
%End
QgsProcessingParameterDefinitions parameterDefinitions() const;
%Docstring
Returns an ordered list of parameter definitions utilized by the algorithm.
.. seealso:: addParameter()
.. seealso:: parameterDefinition()
.. seealso:: destinationParameterDefinitions()
:rtype: QgsProcessingParameterDefinitions
%End
const QgsProcessingParameterDefinition *parameterDefinition( const QString &name ) const;
%Docstring
Returns a matching parameter by ``name``. Matching is done in a case-insensitive
manner.
.. seealso:: parameterDefinitions()
:rtype: QgsProcessingParameterDefinition
%End
int countVisibleParameters() const;
%Docstring
Returns the number of visible (non-hidden) parameters defined by this
algorithm.
:rtype: int
%End
QgsProcessingParameterDefinitions destinationParameterDefinitions() const;
%Docstring
Returns a list of destination parameters definitions utilized by the algorithm.
.. seealso:: QgsProcessingParameterDefinition.isDestination()
.. seealso:: parameterDefinitions()
:rtype: QgsProcessingParameterDefinitions
%End
QgsProcessingOutputDefinitions outputDefinitions() const;
%Docstring
Returns an ordered list of output definitions utilized by the algorithm.
.. seealso:: addOutput()
.. seealso:: outputDefinition()
:rtype: QgsProcessingOutputDefinitions
%End
const QgsProcessingOutputDefinition *outputDefinition( const QString &name ) const;
%Docstring
Returns a matching output by ``name``. Matching is done in a case-insensitive
manner.
.. seealso:: outputDefinitions()
:rtype: QgsProcessingOutputDefinition
%End
bool hasHtmlOutputs() const;
%Docstring
Returns true if this algorithm generates HTML outputs.
:rtype: bool
%End
QVariantMap run( const QVariantMap ¶meters,
QgsProcessingContext &context, QgsProcessingFeedback *feedback, bool *ok /Out/ = 0 ) const;
%Docstring
Executes the algorithm using the specified ``parameters``. This method internally
creates a copy of the algorithm before running it, so it is safe to call
on algorithms directly retrieved from QgsProcessingRegistry and QgsProcessingProvider.
The ``context`` argument specifies the context in which the algorithm is being run.
Algorithm progress should be reported using the supplied ``feedback`` object.
If specified, ``ok`` will be set to true if algorithm was successfully run.
:return: A map of algorithm outputs. These may be output layer references, or calculated
values such as statistical calculations.
.. note::
this method can only be called from the main thread. Use prepare(), runPrepared() and postProcess()
if you need to run algorithms from a background thread, or use the QgsProcessingAlgRunnerTask class.
:rtype: QVariantMap
%End
bool prepare( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback );
%Docstring
Prepares the algorithm for execution. This must be run in the main thread, and allows the algorithm
to pre-evaluate input parameters in a thread-safe manner. This must be called before
calling runPrepared() (which is safe to do in any thread).
.. seealso:: runPrepared()
.. seealso:: postProcess()
.. note::
This method modifies the algorithm instance, so it is not safe to call
on algorithms directly retrieved from QgsProcessingRegistry and QgsProcessingProvider. Instead, a copy
of the algorithm should be created with clone() and prepare()/runPrepared() called on the copy.
:rtype: bool
%End
bool runPrepared( QgsProcessingContext &context, QgsProcessingFeedback *feedback );
%Docstring
Runs the algorithm, which has been prepared by an earlier call to prepare().
This method is safe to call from any thread. Returns true if the algorithm was successfully executed.
After runPrepared() has finished, the postProcess() method should be called from the main thread
to allow the algorithm to perform any required cleanup tasks and return its final result.
.. seealso:: prepare()
.. seealso:: postProcess()
.. note::
This method modifies the algorithm instance, so it is not safe to call
on algorithms directly retrieved from QgsProcessingRegistry and QgsProcessingProvider. Instead, a copy
of the algorithm should be created with clone() and prepare()/runPrepared() called on the copy.
:rtype: bool
%End
QVariantMap postProcess( QgsProcessingContext &context, QgsProcessingFeedback *feedback );
%Docstring
Should be called in the main thread following the completion of runPrepared(). This method
allows the algorithm to perform any required cleanup tasks. The returned variant map
includes the results evaluated by the algorithm.
.. note::
This method modifies the algorithm instance, so it is not safe to call
on algorithms directly retrieved from QgsProcessingRegistry and QgsProcessingProvider. Instead, a copy
of the algorithm should be created with clone() and prepare()/runPrepared() called on the copy.
:rtype: QVariantMap
%End
virtual QWidget *createCustomParametersWidget( QWidget *parent = 0 ) const /Factory/;
%Docstring
If an algorithm subclass implements a custom parameters widget, a copy of this widget
should be constructed and returned by this method.
The base class implementation returns None, which indicates that an autogenerated
parameters widget should be used.
:rtype: QWidget
%End
QgsExpressionContext createExpressionContext( const QVariantMap ¶meters,
QgsProcessingContext &context ) const;
%Docstring
Creates an expression context relating to the algorithm. This can be called by algorithms
to create a new expression context ready for evaluating expressions within the algorithm.
:rtype: QgsExpressionContext
%End
virtual bool validateInputCrs( const QVariantMap ¶meters,
QgsProcessingContext &context ) const;
%Docstring
Checks whether the coordinate reference systems for the specified set of ``parameters``
are valid for the algorithm. For instance, the base implementation performs
checks to ensure that all input CRS are equal
Returns true if ``parameters`` have passed the CRS check.
:rtype: bool
%End
virtual QString asPythonCommand( const QVariantMap ¶meters, QgsProcessingContext &context ) const;
%Docstring
Returns a Python command string which can be executed to run the algorithm
using the specified ``parameters``.
Algorithms which cannot be run from a Python command should return an empty
string.
:rtype: str
%End
void setProvider( QgsProcessingProvider *provider );
%Docstring
Associates this algorithm with its provider. No transfer of ownership is involved.
%End
protected:
bool addParameter( QgsProcessingParameterDefinition *parameterDefinition /Transfer/ );
%Docstring
Adds a parameter ``definition`` to the algorithm. Ownership of the definition is transferred to the algorithm.
Returns true if parameter could be successfully added, or false if the parameter could not be added (e.g.
as a result of a duplicate name).
.. seealso:: addOutput()
:rtype: bool
%End
void removeParameter( const QString &name );
%Docstring
Removes the parameter with matching ``name`` from the algorithm, and deletes any existing
definition.
%End
bool addOutput( QgsProcessingOutputDefinition *outputDefinition /Transfer/ );
%Docstring
Adds an output ``definition`` to the algorithm. Ownership of the definition is transferred to the algorithm.
Returns true if the output could be successfully added, or false if the output could not be added (e.g.
as a result of a duplicate name).
.. seealso:: addParameter()
:rtype: bool
%End
virtual bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) /VirtualErrorHandler=processing_exception_handler/;
%Docstring
Prepares the algorithm to run using the specified ``parameters``. Algorithms should implement
their logic for evaluating parameter values here. The evaluated parameter results should
be stored in member variables ready for a call to processAlgorithm().
The ``context`` argument specifies the context in which the algorithm is being run.
Algorithm preparation progress should be reported using the supplied ``feedback`` object. Additionally,
well-behaved algorithms should periodically check ``feedback`` to determine whether the
algorithm should be canceled and exited early.
:return: true if preparation was successful.
.. seealso:: processAlgorithm()
.. seealso:: postProcessAlgorithm()
:rtype: bool
%End
virtual bool processAlgorithm( QgsProcessingContext &context, QgsProcessingFeedback *feedback ) = 0 /VirtualErrorHandler=processing_exception_handler/;
%Docstring
Runs the algorithm using the specified ``parameters``. Algorithms should implement
their custom processing logic here.
The ``context`` argument specifies the context in which the algorithm is being run.
Algorithm progress should be reported using the supplied ``feedback`` object. Additionally,
well-behaved algorithms should periodically check ``feedback`` to determine whether the
algorithm should be canceled and exited early.
:return: A map of algorithm outputs. These may be output layer references, or calculated
values such as statistical calculations.
.. seealso:: prepareAlgorithm()
.. seealso:: postProcessAlgorithm()
:rtype: bool
%End
virtual QVariantMap postProcessAlgorithm( QgsProcessingContext &context, QgsProcessingFeedback *feedback ) = 0 /VirtualErrorHandler=processing_exception_handler/;
%Docstring
Allows the algorithm to perform any required cleanup tasks. The returned variant map
includes the results evaluated by the algorithm. These may be output layer references, or calculated
values such as statistical calculations.
The ``context`` argument specifies the context in which the algorithm was run.
Postprocess progress should be reported using the supplied ``feedback`` object. Additionally,
well-behaved algorithms should periodically check ``feedback`` to determine whether the
post processing should be canceled and exited early.
:return: A map of algorithm outputs. These may be output layer references, or calculated
values such as statistical calculations.
.. seealso:: prepareAlgorithm()
.. seealso:: processAlgorithm()
:rtype: QVariantMap
%End
QString parameterAsString( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a static string value.
:rtype: str
%End
QString parameterAsExpression( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to an expression.
:rtype: str
%End
double parameterAsDouble( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a static double value.
:rtype: float
%End
int parameterAsInt( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a static integer value.
:rtype: int
%End
int parameterAsEnum( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a enum value.
:rtype: int
%End
QList<int> parameterAsEnums( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to list of enum values.
:rtype: list of int
%End
bool parameterAsBool( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a static boolean value.
:rtype: bool
%End
QgsFeatureSink *parameterAsSink( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier /Out/,
const QgsFields &fields, QgsWkbTypes::Type geometryType = QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() ) const /Factory/;
%Docstring
Evaluates the parameter with matching ``name`` to a feature sink.
Sinks will either be taken from ``context``'s active project, or created from external
providers and stored temporarily in the ``context``.
The ``fields``, ``geometryType`` and ``crs`` parameters dictate the properties
of the resulting feature sink.
The ``destinationIdentifier`` argument will be set to a string which can be used to retrieve the layer corresponding
to the sink, e.g. via calling QgsProcessingUtils.mapLayerFromString().
This function creates a new object and the caller takes responsibility for deleting the returned object.
:rtype: QgsFeatureSink
%End
QgsProcessingFeatureSource *parameterAsSource( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const /Factory/;
%Docstring
Evaluates the parameter with matching ``definition`` to a feature source.
Sources will either be taken from ``context``'s active project, or loaded from external
sources and stored temporarily in the ``context``.
This function creates a new object and the caller takes responsibility for deleting the returned object.
:rtype: QgsProcessingFeatureSource
%End
QgsMapLayer *parameterAsLayer( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a map layer.
Layers will either be taken from ``context``'s active project, or loaded from external
sources and stored temporarily in the ``context``. In either case, callers do not
need to handle deletion of the returned layer.
:rtype: QgsMapLayer
%End
QgsRasterLayer *parameterAsRasterLayer( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a raster layer.
Layers will either be taken from ``context``'s active project, or loaded from external
sources and stored temporarily in the ``context``. In either case, callers do not
need to handle deletion of the returned layer.
:rtype: QgsRasterLayer
%End
QString parameterAsRasterOutputLayer( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a raster output layer destination.
:rtype: str
%End
QString parameterAsFileOutput( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a file based output destination.
:rtype: str
%End
QgsVectorLayer *parameterAsVectorLayer( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a vector layer.
Layers will either be taken from ``context``'s active project, or loaded from external
sources and stored temporarily in the ``context``. In either case, callers do not
need to handle deletion of the returned layer.
:rtype: QgsVectorLayer
%End
QgsCoordinateReferenceSystem parameterAsCrs( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a coordinate reference system.
:rtype: QgsCoordinateReferenceSystem
%End
QgsRectangle parameterAsExtent( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a rectangular extent.
:rtype: QgsRectangle
%End
QgsPointXY parameterAsPoint( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a point.
:rtype: QgsPointXY
%End
QString parameterAsFile( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a file/folder name.
:rtype: str
%End
QVariantList parameterAsMatrix( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a matrix/table of values.
Tables are collapsed to a 1 dimensional list.
:rtype: QVariantList
%End
QList< QgsMapLayer *> parameterAsLayerList( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a list of map layers.
:rtype: list of QgsMapLayer
%End
QList<double> parameterAsRange( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a range of values.
:rtype: list of float
%End
QStringList parameterAsFields( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a list of fields.
:rtype: list of str
%End
private:
QgsProcessingAlgorithm( const QgsProcessingAlgorithm &other );
};
QFlags<QgsProcessingAlgorithm::Flag> operator|(QgsProcessingAlgorithm::Flag f1, QFlags<QgsProcessingAlgorithm::Flag> f2);
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/processing/qgsprocessingalgorithm.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/