1/************************************************************************
2 * This file has been generated automatically from                      *
3 *                                                                      *
4 * src/core/processing/qgsprocessingalgorithm.h                         *
5 *                                                                      *
6 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
7 ************************************************************************/
8
9
10
11
12
13%ModuleHeaderCode
14#include <qgsprocessingmodelalgorithm.h>
15%End
16
17class QgsProcessingAlgorithm
18{
19%Docstring
20Abstract base class for processing algorithms.
21
22.. versionadded:: 3.0
23%End
24
25%TypeHeaderCode
26#include "qgsprocessingalgorithm.h"
27%End
28%ConvertToSubClassCode
29    if ( dynamic_cast< QgsProcessingModelAlgorithm * >( sipCpp ) != NULL )
30      sipType = sipType_QgsProcessingModelAlgorithm;
31    else if ( dynamic_cast< QgsProcessingFeatureBasedAlgorithm * >( sipCpp ) != NULL )
32      sipType = sipType_QgsProcessingFeatureBasedAlgorithm;
33    else
34      sipType = sipType_QgsProcessingAlgorithm;
35%End
36  public:
37
38    enum Flag
39    {
40      FlagHideFromToolbox,
41      FlagHideFromModeler,
42      FlagSupportsBatch,
43      FlagCanCancel,
44      FlagRequiresMatchingCrs,
45      FlagNoThreading,
46      FlagDisplayNameIsLiteral,
47      FlagSupportsInPlaceEdits,
48      FlagKnownIssues,
49      FlagCustomException,
50      FlagPruneModelBranchesBasedOnAlgorithmResults,
51      FlagSkipGenericModelLogging,
52      FlagNotAvailableInStandaloneTool,
53      FlagRequiresProject,
54      FlagDeprecated,
55    };
56    typedef QFlags<QgsProcessingAlgorithm::Flag> Flags;
57
58
59    QgsProcessingAlgorithm();
60%Docstring
61Constructor for QgsProcessingAlgorithm.
62
63:py:func:`~QgsProcessingAlgorithm.initAlgorithm` should be called after creating an algorithm to ensure it can correctly configure
64its :py:func:`~QgsProcessingAlgorithm.parameterDefinitions` and :py:func:`~QgsProcessingAlgorithm.outputDefinitions`. Alternatively, calling :py:func:`~QgsProcessingAlgorithm.create` will return
65a pre-initialized copy of the algorithm.
66%End
67
68    virtual ~QgsProcessingAlgorithm();
69
70
71
72    QgsProcessingAlgorithm *create( const QVariantMap &configuration = QVariantMap() ) const throw( QgsProcessingException ) /TransferBack/;
73%Docstring
74Creates a copy of the algorithm, ready for execution.
75
76This method returns a new, preinitialized copy of the algorithm, ready for
77executing.
78
79The ``configuration`` argument allows passing of a map of configuration settings
80to the algorithm, allowing it to dynamically adjust its initialized parameters
81and outputs according to this configuration. This is generally used only for
82algorithms in a model, allowing them to adjust their behavior at run time
83according to some user configuration.
84
85Raises a QgsProcessingException if a new algorithm instance could not be created,
86e.g. if there is an issue with the subclass' :py:func:`~QgsProcessingAlgorithm.createInstance` method.
87
88.. seealso:: :py:func:`initAlgorithm`
89%End
90
91    virtual QString name() const = 0;
92%Docstring
93Returns the algorithm name, used for identifying the algorithm. This string
94should be fixed for the algorithm, and must not be localised. The name should
95be unique within each provider. Names should contain lowercase alphanumeric characters
96only and no spaces or other formatting characters.
97
98.. seealso:: :py:func:`displayName`
99
100.. seealso:: :py:func:`group`
101
102.. seealso:: :py:func:`tags`
103%End
104
105    QString id() const;
106%Docstring
107Returns the unique ID for the algorithm, which is a combination of the algorithm
108provider's ID and the algorithms unique name (e.g. "qgis:mergelayers" ).
109
110.. seealso:: :py:func:`name`
111
112.. seealso:: :py:func:`provider`
113%End
114
115    virtual QString displayName() const = 0;
116%Docstring
117Returns the translated algorithm name, which should be used for any user-visible display
118of the algorithm name.
119
120Algorithm display names should be short, e.g. ideally no more than 3 or 4 words.
121The name should use sentence case (e.g. "Raster layer statistics", not "Raster Layer Statistics").
122
123.. seealso:: :py:func:`name`
124
125.. seealso:: :py:func:`shortDescription`
126%End
127
128    virtual QString shortDescription() const;
129%Docstring
130Returns an optional translated short description of the algorithm. This should be
131at most a single sentence, e.g. "Converts 2D features to 3D by sampling a DEM raster."
132
133.. versionadded:: 3.2
134%End
135
136    virtual QStringList tags() const;
137%Docstring
138Returns a list of tags which relate to the algorithm, and are used to assist users in searching
139for suitable algorithms. These tags should be localised.
140%End
141
142    virtual QString shortHelpString() const;
143%Docstring
144Returns a localised short helper string for the algorithm. This string should provide a basic description
145about what the algorithm does and the parameters and outputs associated with it.
146
147.. seealso:: :py:func:`helpString`
148
149.. seealso:: :py:func:`helpUrl`
150%End
151
152 virtual QString helpString() const /Deprecated/;
153%Docstring
154Returns a localised help string for the algorithm. Algorithm subclasses should implement either
155:py:func:`~QgsProcessingAlgorithm.helpString` or :py:func:`~QgsProcessingAlgorithm.helpUrl`.
156
157.. seealso:: :py:func:`helpUrl`
158
159.. seealso:: :py:func:`shortHelpString`
160
161.. deprecated::
162   Unused, will be removed in QGIS 4.0
163%End
164
165    virtual QString helpUrl() const;
166%Docstring
167Returns a url pointing to the algorithm's help page.
168
169.. seealso:: :py:func:`helpString`
170
171.. seealso:: :py:func:`shortHelpString`
172%End
173
174    virtual QIcon icon() const;
175%Docstring
176Returns an icon for the algorithm.
177
178.. seealso:: :py:func:`svgIconPath`
179%End
180
181    virtual QString svgIconPath() const;
182%Docstring
183Returns a path to an SVG version of the algorithm's icon.
184
185.. seealso:: :py:func:`icon`
186%End
187
188    virtual QString group() const;
189%Docstring
190Returns the name of the group this algorithm belongs to. This string
191should be localised.
192
193.. seealso:: :py:func:`groupId`
194
195.. seealso:: :py:func:`tags`
196%End
197
198    virtual QString groupId() const;
199%Docstring
200Returns the unique ID of the group this algorithm belongs to. This string
201should be fixed for the algorithm, and must not be localised. The group id
202should be unique within each provider. Group id should contain lowercase
203alphanumeric characters only and no spaces or other formatting characters.
204
205.. seealso:: :py:func:`group`
206%End
207
208    virtual Flags flags() const;
209%Docstring
210Returns the flags indicating how and when the algorithm operates and should be exposed to users.
211Default flags are FlagSupportsBatch and FlagCanCancel.
212%End
213
214    virtual bool canExecute( QString *errorMessage /Out/ = 0 ) const;
215%Docstring
216Returns ``True`` if the algorithm can execute. Algorithm subclasses can return ``False``
217here to indicate that they are not able to execute, e.g. as a result of unmet
218external dependencies. If specified, the ``errorMessage`` argument will be filled
219with a localised error message describing why the algorithm cannot execute.
220%End
221
222    virtual bool checkParameterValues( const QVariantMap &parameters,
223                                       QgsProcessingContext &context, QString *message /Out/ = 0 ) const;
224%Docstring
225Checks the supplied ``parameter`` values to verify that they satisfy the requirements
226of this algorithm in the supplied ``context``. The ``message`` parameter will be
227filled with explanatory text if validation fails.
228Overridden implementations should also check this base class implementation.
229
230:return: ``True`` if parameters are acceptable for the algorithm.
231%End
232
233    virtual QVariantMap preprocessParameters( const QVariantMap &parameters );
234%Docstring
235Pre-processes a set of ``parameters``, allowing the algorithm to clean their
236values.
237
238This method is automatically called after users enter parameters, e.g. via the algorithm
239dialog. This method should NOT be called manually by algorithms.
240%End
241
242    QgsProcessingProvider *provider() const;
243%Docstring
244Returns the provider to which this algorithm belongs.
245%End
246
247    QgsProcessingParameterDefinitions parameterDefinitions() const;
248%Docstring
249Returns an ordered list of parameter definitions utilized by the algorithm.
250
251.. seealso:: :py:func:`addParameter`
252
253.. seealso:: :py:func:`parameterDefinition`
254
255.. seealso:: :py:func:`destinationParameterDefinitions`
256%End
257
258    const QgsProcessingParameterDefinition *parameterDefinition( const QString &name ) const;
259%Docstring
260Returns a matching parameter by ``name``. Matching is done in a case-insensitive
261manner, but exact case matches will be preferred.
262
263.. seealso:: :py:func:`parameterDefinitions`
264%End
265
266    int countVisibleParameters() const;
267%Docstring
268Returns the number of visible (non-hidden) parameters defined by this
269algorithm.
270%End
271
272    QgsProcessingParameterDefinitions destinationParameterDefinitions() const;
273%Docstring
274Returns a list of destination parameters definitions utilized by the algorithm.
275
276.. seealso:: :py:func:`QgsProcessingParameterDefinition.isDestination`
277
278.. seealso:: :py:func:`parameterDefinitions`
279%End
280
281    QgsProcessingOutputDefinitions outputDefinitions() const;
282%Docstring
283Returns an ordered list of output definitions utilized by the algorithm.
284
285.. seealso:: :py:func:`addOutput`
286
287.. seealso:: :py:func:`outputDefinition`
288%End
289
290    const QgsProcessingOutputDefinition *outputDefinition( const QString &name ) const;
291%Docstring
292Returns a matching output by ``name``. Matching is done in a case-insensitive
293manner.
294
295.. seealso:: :py:func:`outputDefinitions`
296%End
297
298    bool hasHtmlOutputs() const;
299%Docstring
300Returns ``True`` if this algorithm generates HTML outputs.
301%End
302
303    enum PropertyAvailability
304    {
305      NotAvailable,
306      Available,
307    };
308
309    struct VectorProperties
310    {
311      QgsFields fields;
312
313      QgsWkbTypes::Type wkbType;
314
315      QgsCoordinateReferenceSystem crs;
316
317      QgsProcessingAlgorithm::PropertyAvailability availability;
318    };
319
320    virtual QgsProcessingAlgorithm::VectorProperties sinkProperties( const QString &sink,
321        const QVariantMap &parameters,
322        QgsProcessingContext &context,
323        const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties ) const;
324%Docstring
325Returns the vector properties which will be used for the ``sink`` with matching name.
326
327The ``parameters`` argument specifies the values of all parameters which would be used to generate
328the sink. These can be used alongside the provided ``context`` in order to pre-evaluate inputs
329when required in order to determine the sink's properties.
330
331The ``sourceProperties`` map will contain the vector properties of the various sources used
332as inputs to the algorithm. These will only be available in certain circumstances (e.g. when the
333algorithm is used within a model), so implementations will need to be adaptable to circumstances
334when either ``sourceParameters`` is empty or ``parameters`` is empty, and use whatever information
335is passed in order to make a best guess determination of the output properties.
336
337.. versionadded:: 3.14
338%End
339
340    QVariantMap run( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback, bool *ok /Out/ = 0, const QVariantMap &configuration = QVariantMap(),
341                     bool catchExceptions = true ) const throw( QgsProcessingException );
342%Docstring
343Executes the algorithm using the specified ``parameters``. This method internally
344creates a copy of the algorithm before running it, so it is safe to call
345on algorithms directly retrieved from QgsProcessingRegistry and :py:class:`QgsProcessingProvider`.
346
347The ``context`` argument specifies the context in which the algorithm is being run.
348
349Algorithm progress should be reported using the supplied ``feedback`` object.
350
351If specified, ``ok`` will be set to ``True`` if algorithm was successfully run.
352
353If ``catchExceptions`` is set to ``False``, then QgsProcessingExceptions raised during
354the algorithm run will not be automatically caught and will be raised instead.
355
356:return: A map of algorithm outputs. These may be output layer references, or calculated
357         values such as statistical calculations.
358
359.. note::
360
361   this method can only be called from the main thread. Use :py:func:`~QgsProcessingAlgorithm.prepare`, :py:func:`~QgsProcessingAlgorithm.runPrepared` and :py:func:`~QgsProcessingAlgorithm.postProcess`
362   if you need to run algorithms from a background thread, or use the QgsProcessingAlgRunnerTask class.
363%End
364
365    bool prepare( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback );
366%Docstring
367Prepares the algorithm for execution. This must be run in the main thread, and allows the algorithm
368to pre-evaluate input parameters in a thread-safe manner. This must be called before
369calling :py:func:`~QgsProcessingAlgorithm.runPrepared` (which is safe to do in any thread).
370
371.. seealso:: :py:func:`runPrepared`
372
373.. seealso:: :py:func:`postProcess`
374
375.. note::
376
377   This method modifies the algorithm instance, so it is not safe to call
378   on algorithms directly retrieved from QgsProcessingRegistry and :py:class:`QgsProcessingProvider`. Instead, a copy
379   of the algorithm should be created with :py:func:`~QgsProcessingAlgorithm.clone` and :py:func:`~QgsProcessingAlgorithm.prepare`/:py:func:`~QgsProcessingAlgorithm.runPrepared` called on the copy.
380%End
381
382    QVariantMap runPrepared( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException );
383%Docstring
384Runs the algorithm, which has been prepared by an earlier call to :py:func:`~QgsProcessingAlgorithm.prepare`.
385This method is safe to call from any thread. Returns ``True`` if the algorithm was successfully executed.
386After :py:func:`~QgsProcessingAlgorithm.runPrepared` has finished, the :py:func:`~QgsProcessingAlgorithm.postProcess` method should be called from the main thread
387to allow the algorithm to perform any required cleanup tasks and return its final result.
388
389.. seealso:: :py:func:`prepare`
390
391.. seealso:: :py:func:`postProcess`
392
393.. note::
394
395   This method modifies the algorithm instance, so it is not safe to call
396   on algorithms directly retrieved from QgsProcessingRegistry and :py:class:`QgsProcessingProvider`. Instead, a copy
397   of the algorithm should be created with :py:func:`~QgsProcessingAlgorithm.clone` and :py:func:`~QgsProcessingAlgorithm.prepare`/:py:func:`~QgsProcessingAlgorithm.runPrepared` called on the copy.
398%End
399
400    QVariantMap postProcess( QgsProcessingContext &context, QgsProcessingFeedback *feedback );
401%Docstring
402Should be called in the main thread following the completion of :py:func:`~QgsProcessingAlgorithm.runPrepared`. This method
403allows the algorithm to perform any required cleanup tasks. The returned variant map
404includes the results evaluated by the algorithm.
405
406.. note::
407
408   This method modifies the algorithm instance, so it is not safe to call
409   on algorithms directly retrieved from QgsProcessingRegistry and :py:class:`QgsProcessingProvider`. Instead, a copy
410   of the algorithm should be created with :py:func:`~QgsProcessingAlgorithm.clone` and :py:func:`~QgsProcessingAlgorithm.prepare`/:py:func:`~QgsProcessingAlgorithm.runPrepared` called on the copy.
411%End
412
413    virtual QWidget *createCustomParametersWidget( QWidget *parent = 0 ) const /Factory/;
414%Docstring
415If an algorithm subclass implements a custom parameters widget, a copy of this widget
416should be constructed and returned by this method.
417The base class implementation returns ``None``, which indicates that an autogenerated
418parameters widget should be used.
419%End
420
421    virtual QgsExpressionContext createExpressionContext( const QVariantMap &parameters,
422        QgsProcessingContext &context, QgsProcessingFeatureSource *source = 0 ) const;
423%Docstring
424Creates an expression context relating to the algorithm. This can be called by algorithms
425to create a new expression context ready for evaluating expressions within the algorithm.
426Optionally, a ``source`` can be specified which will be used to populate the context if it
427implements the QgsExpressionContextGenerator interface.
428%End
429
430    virtual bool validateInputCrs( const QVariantMap &parameters,
431                                   QgsProcessingContext &context ) const;
432%Docstring
433Checks whether the coordinate reference systems for the specified set of ``parameters``
434are valid for the algorithm. For instance, the base implementation performs
435checks to ensure that all input CRS are equal
436Returns ``True`` if ``parameters`` have passed the CRS check.
437%End
438
439    virtual QString asPythonCommand( const QVariantMap &parameters, QgsProcessingContext &context ) const;
440%Docstring
441Returns a Python command string which can be executed to run the algorithm
442using the specified ``parameters``.
443
444Algorithms which cannot be run from a Python command should return an empty
445string.
446%End
447
448    void setProvider( QgsProcessingProvider *provider );
449%Docstring
450Associates this algorithm with its provider. No transfer of ownership is involved.
451%End
452
453  protected:
454
455    virtual QgsProcessingAlgorithm *createInstance() const = 0 /Factory,VirtualErrorHandler=processing_exception_handler/;
456%Docstring
457Creates a new instance of the algorithm class.
458
459This method should return a 'pristine' instance of the algorithm class.
460%End
461
462    virtual void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) = 0;
463%Docstring
464Initializes the algorithm using the specified ``configuration``.
465
466This should be called directly after creating algorithms and before retrieving
467any :py:func:`~QgsProcessingAlgorithm.parameterDefinitions` or :py:func:`~QgsProcessingAlgorithm.outputDefinitions`.
468
469Subclasses should use their implementations to add all required input parameter and output
470definitions (which can be dynamically adjusted according to ``configuration``).
471
472Dynamic configuration can be used by algorithms which alter their behavior
473when used inside processing models. For instance, a "feature router" type
474algorithm which sends input features to one of any number of outputs sinks
475based on some preconfigured filter parameters can use the init method to
476create these outputs based on the specified ``configuration``.
477
478.. seealso:: :py:func:`addParameter`
479
480.. seealso:: :py:func:`addOutput`
481%End
482
483    bool addParameter( QgsProcessingParameterDefinition *parameterDefinition /Transfer/, bool createOutput = true );
484%Docstring
485Adds a parameter ``definition`` to the algorithm. Ownership of the definition is transferred to the algorithm.
486Returns ``True`` if parameter could be successfully added, or ``False`` if the parameter could not be added (e.g.
487as a result of a duplicate name).
488
489This should usually be called from a subclass' :py:func:`~QgsProcessingAlgorithm.initAlgorithm` implementation.
490
491If the ``createOutput`` argument is ``True``, then a corresponding output definition will also be created
492(and added to the algorithm) where appropriate. E.g. when adding a :py:class:`QgsProcessingParameterVectorDestination`
493and ``createOutput`` is ``True``, then a QgsProcessingOutputVectorLayer output will be created and
494added to the algorithm. There is no need to call :py:func:`~QgsProcessingAlgorithm.addOutput` to manually add a corresponding output
495for this vector. If ``createOutput`` is ``False`` then this automatic output creation will not
496occur.
497
498.. seealso:: :py:func:`initAlgorithm`
499
500.. seealso:: :py:func:`addOutput`
501%End
502
503    void removeParameter( const QString &name );
504%Docstring
505Removes the parameter with matching ``name`` from the algorithm, and deletes any existing
506definition.
507%End
508
509    bool addOutput( QgsProcessingOutputDefinition *outputDefinition /Transfer/ );
510%Docstring
511Adds an output ``definition`` to the algorithm. Ownership of the definition is transferred to the algorithm.
512Returns ``True`` if the output could be successfully added, or ``False`` if the output could not be added (e.g.
513as a result of a duplicate name).
514
515This should usually be called from a subclass' :py:func:`~QgsProcessingAlgorithm.initAlgorithm` implementation.
516
517Note that in some cases output creation can be automatically performed when calling :py:func:`~QgsProcessingAlgorithm.addParameter`.
518See the notes in :py:func:`~QgsProcessingAlgorithm.addParameter` for a description of when this occurs.
519
520.. seealso:: :py:func:`addParameter`
521
522.. seealso:: :py:func:`initAlgorithm`
523%End
524
525    virtual bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException ) /VirtualErrorHandler=processing_exception_handler/;
526%Docstring
527Prepares the algorithm to run using the specified ``parameters``. Algorithms should implement
528their logic for evaluating parameter values here. The evaluated parameter results should
529be stored in member variables ready for a call to :py:func:`~QgsProcessingAlgorithm.processAlgorithm`.
530
531The ``context`` argument specifies the context in which the algorithm is being run.
532
533prepareAlgorithm should be used to handle any thread-sensitive preparation which is required
534by the algorithm. It will always be called from the same thread that ``context`` has thread
535affinity with. While this will generally be the main thread, it is not guaranteed. For instance,
536algorithms which are run as a step in a larger model or as a subcomponent of a script-based algorithm
537will call prepareAlgorithm from the same thread as that model/script it being executed in.
538
539Note that the processAlgorithm step uses a temporary context with affinity for the thread in
540which the algorithm is executed, making it safe for processAlgorithm implementations to load
541sources and sinks without issue. Implementing prepareAlgorithm is only required if special
542thread safe handling is required by the algorithm.
543
544Algorithm preparation progress should be reported using the supplied ``feedback`` object. Additionally,
545well-behaved algorithms should periodically check ``feedback`` to determine whether the
546algorithm should be canceled and exited early.
547
548If the preparation was successful algorithms must return ``True``. If a ``False`` value is returned
549this indicates that the preparation could not be completed, and the algorithm execution
550will be canceled.
551
552:return: ``True`` if preparation was successful.
553
554.. seealso:: :py:func:`processAlgorithm`
555
556.. seealso:: :py:func:`postProcessAlgorithm`
557%End
558
559    virtual QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException ) = 0 /VirtualErrorHandler=processing_exception_handler/;
560%Docstring
561Runs the algorithm using the specified ``parameters``. Algorithms should implement
562their custom processing logic here.
563
564The ``context`` argument gives a temporary context with thread affinity matching the thread
565in which the algorithm is being run. This is a cut-back copy of the context passed to
566the :py:func:`~QgsProcessingAlgorithm.prepareAlgorithm` and :py:func:`~QgsProcessingAlgorithm.postProcessAlgorithm` steps, but it is generally safe
567for most algorithms to utilize this context for loading layers and creating sinks.
568Any loaded layers or sinks created within this temporary context will be transferred
569back to the main execution context upon successful completion of the :py:func:`~QgsProcessingAlgorithm.processAlgorithm`
570step.
571
572Algorithm progress should be reported using the supplied ``feedback`` object. Additionally,
573well-behaved algorithms should periodically check ``feedback`` to determine whether the
574algorithm should be canceled and exited early.
575
576This method will not be called if the :py:func:`~QgsProcessingAlgorithm.prepareAlgorithm` step failed (returned ``False``).
577
578Implementations of processAlgorithm can throw the QgsProcessingException exception
579to indicate that a fatal error occurred within the execution.
580
581:return: A map of algorithm outputs. These may be output layer references, or calculated
582         values such as statistical calculations. Unless the algorithm subclass overrides
583         the :py:func:`~QgsProcessingAlgorithm.postProcessAlgorithm` step this returned map will be used as the output for the
584         algorithm.
585
586.. seealso:: :py:func:`prepareAlgorithm`
587
588.. seealso:: :py:func:`postProcessAlgorithm`
589%End
590
591    virtual QVariantMap postProcessAlgorithm( QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException ) /VirtualErrorHandler=processing_exception_handler/;
592%Docstring
593Allows the algorithm to perform any required cleanup tasks. The returned variant map
594includes the results evaluated by the algorithm. These may be output layer references, or calculated
595values such as statistical calculations.
596
597The ``context`` argument specifies the context in which the algorithm was run.
598
599Postprocess progress should be reported using the supplied ``feedback`` object. Additionally,
600well-behaved algorithms should periodically check ``feedback`` to determine whether the
601post processing should be canceled and exited early.
602
603postProcessAlgorithm should be used to handle any thread-sensitive cleanup which is required
604by the algorithm. It will always be called from the same thread that ``context`` has thread
605affinity with. While this will generally be the main thread, it is not guaranteed. For instance,
606algorithms which are run as a step in a larger model or as a subcomponent of a script-based algorithm
607will call postProcessAlgorithm from the same thread as that model/script it being executed in.
608
609postProcessAlgorithm will not be called if the :py:func:`~QgsProcessingAlgorithm.prepareAlgorithm` step failed (returned ``False``),
610or if an exception was raised by the :py:func:`~QgsProcessingAlgorithm.processAlgorithm` step.
611
612:return: A map of algorithm outputs. These may be output layer references, or calculated
613         values such as statistical calculations. Implementations which return a non-empty
614         map will override any results returned by :py:func:`~QgsProcessingAlgorithm.processAlgorithm`.
615
616.. seealso:: :py:func:`prepareAlgorithm`
617
618.. seealso:: :py:func:`processAlgorithm`
619%End
620
621    QString parameterAsString( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const;
622%Docstring
623Evaluates the parameter with matching ``name`` to a static string value.
624%End
625
626    QString parameterAsExpression( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const;
627%Docstring
628Evaluates the parameter with matching ``name`` to an expression.
629%End
630
631    double parameterAsDouble( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const;
632%Docstring
633Evaluates the parameter with matching ``name`` to a static double value.
634%End
635
636    int parameterAsInt( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const;
637%Docstring
638Evaluates the parameter with matching ``name`` to a static integer value.
639%End
640
641    QList<int> parameterAsInts( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const;
642%Docstring
643Evaluates the parameter with matching ``name`` to a list of integer values.
644
645.. versionadded:: 3.4
646%End
647
648    int parameterAsEnum( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const;
649%Docstring
650Evaluates the parameter with matching ``name`` to a enum value.
651%End
652
653    QList<int> parameterAsEnums( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const;
654%Docstring
655Evaluates the parameter with matching ``name`` to list of enum values.
656%End
657
658    bool parameterAsBool( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const;
659%Docstring
660Evaluates the parameter with matching ``name`` to a static boolean value.
661%End
662
663    bool parameterAsBoolean( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const;
664%Docstring
665Evaluates the parameter with matching ``name`` to a static boolean value.
666
667.. versionadded:: 3.8
668%End
669
670    QgsFeatureSink *parameterAsSink( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier /Out/,
671                                     const QgsFields &fields, QgsWkbTypes::Type geometryType = QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem(), QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags(), const QVariantMap &createOptions = QVariantMap(), const QStringList &datasourceOptions = QStringList(), const QStringList &layerOptions = QStringList() ) const throw( QgsProcessingException ) /Factory/;
672%Docstring
673Evaluates the parameter with matching ``name`` to a feature sink.
674
675Sinks will either be taken from ``context``'s active project, or created from external
676providers and stored temporarily in the ``context``.
677
678The ``fields``, ``geometryType`` and ``crs`` parameters dictate the properties
679of the resulting feature sink.
680
681The ``destinationIdentifier`` argument will be set to a string which can be used to retrieve the layer corresponding
682to the sink, e.g. via calling :py:func:`QgsProcessingUtils.mapLayerFromString()`.
683
684The ``createOptions`` argument is used to pass on creation options such as layer name.
685
686The ``datasourceOptions`` and ``layerOptions`` arguments is used to pass on GDAL-specific format driver options.
687
688This function creates a new object and the caller takes responsibility for deleting the returned object.
689
690:raises :: py:class:`QgsProcessingException`
691%End
692
693    QgsProcessingFeatureSource *parameterAsSource( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const /Factory/;
694%Docstring
695Evaluates the parameter with matching ``name`` to a feature source.
696
697Sources will either be taken from ``context``'s active project, or loaded from external
698sources and stored temporarily in the ``context``.
699
700This function creates a new object and the caller takes responsibility for deleting the returned object.
701%End
702
703    QString parameterAsCompatibleSourceLayerPath( const QVariantMap &parameters, const QString &name,
704        QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat = QString( "shp" ), QgsProcessingFeedback *feedback = 0 );
705%Docstring
706Evaluates the parameter with matching ``name`` to a source vector layer file path of compatible format.
707
708If the parameter is evaluated to an existing layer, and that layer is not of the format listed in the
709``compatibleFormats`` argument, then the layer will first be exported to a compatible format
710in a temporary location. The function will then return the path to that temporary file.
711
712``compatibleFormats`` should consist entirely of lowercase file extensions, e.g. 'shp'.
713
714The ``preferredFormat`` argument is used to specify to desired file extension to use when a temporary
715layer export is required.
716
717When an algorithm is capable of handling multi-layer input files (such as Geopackage), it is preferable
718to use :py:func:`~QgsProcessingAlgorithm.parameterAsCompatibleSourceLayerPathAndLayerName` which may avoid conversion in more situations.
719%End
720
721    QString parameterAsCompatibleSourceLayerPathAndLayerName( const QVariantMap &parameters, const QString &name,
722        QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat = QString( "shp" ), QgsProcessingFeedback *feedback = 0, QString *layerName /Out/ = 0 );
723%Docstring
724Evaluates the parameter with matching ``name`` to a source vector layer file path and layer name of compatible format.
725
726If the parameter is evaluated to an existing layer, and that layer is not of the format listed in the
727``compatibleFormats`` argument, then the layer will first be exported to a compatible format
728in a temporary location. The function will then return the path to that temporary file.
729
730``compatibleFormats`` should consist entirely of lowercase file extensions, e.g. 'shp'.
731
732The ``preferredFormat`` argument is used to specify to desired file extension to use when a temporary
733layer export is required. This defaults to shapefiles, because shapefiles are the future (don't believe the geopackage hype!).
734
735This method should be preferred over :py:func:`~QgsProcessingAlgorithm.parameterAsCompatibleSourceLayerPath` when an algorithm is able
736to correctly handle files with multiple layers. Unlike :py:func:`~QgsProcessingAlgorithm.parameterAsCompatibleSourceLayerPath`, it will not force
737a conversion in this case and will return the target layer name in the ``layerName`` argument.
738
739:param parameters: input parameter value map
740:param name: name of target parameter
741:param context: processing context
742:param compatibleFormats: a list of lowercase file extensions compatible with the algorithm
743:param preferredFormat: preferred format extension to use if conversion if required
744:param feedback: feedback object
745
746:return: - path to source layer, or nearly converted compatible layer
747         - layerName: will be set to the target layer name for multi-layer sources (e.g. Geopackage)
748
749
750.. seealso:: :py:func:`parameterAsCompatibleSourceLayerPath`
751
752.. versionadded:: 3.10
753%End
754
755    QgsMapLayer *parameterAsLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
756%Docstring
757Evaluates the parameter with matching ``name`` to a map layer.
758
759Layers will either be taken from ``context``'s active project, or loaded from external
760sources and stored temporarily in the ``context``. In either case, callers do not
761need to handle deletion of the returned layer.
762%End
763
764    QgsRasterLayer *parameterAsRasterLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
765%Docstring
766Evaluates the parameter with matching ``name`` to a raster layer.
767
768Layers will either be taken from ``context``'s active project, or loaded from external
769sources and stored temporarily in the ``context``. In either case, callers do not
770need to handle deletion of the returned layer.
771%End
772
773    QgsMeshLayer *parameterAsMeshLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
774%Docstring
775Evaluates the parameter with matching ``name`` to a mesh layer.
776
777Layers will either be taken from ``context``'s active project, or loaded from external
778sources and stored temporarily in the ``context``. In either case, callers do not
779need to handle deletion of the returned layer.
780
781.. versionadded:: 3.6
782%End
783
784
785    QString parameterAsOutputLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
786%Docstring
787Evaluates the parameter with matching ``name`` to a output layer destination.
788%End
789
790    QString parameterAsFileOutput( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
791%Docstring
792Evaluates the parameter with matching ``name`` to a file based output destination.
793%End
794
795    QgsVectorLayer *parameterAsVectorLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
796%Docstring
797Evaluates the parameter with matching ``name`` to a vector layer.
798
799Layers will either be taken from ``context``'s active project, or loaded from external
800sources and stored temporarily in the ``context``. In either case, callers do not
801need to handle deletion of the returned layer.
802%End
803
804    QgsCoordinateReferenceSystem parameterAsCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
805%Docstring
806Evaluates the parameter with matching ``name`` to a coordinate reference system.
807%End
808
809    QgsRectangle parameterAsExtent( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context,
810                                    const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() ) const;
811%Docstring
812Evaluates the parameter with matching ``name`` to a rectangular extent.
813
814If ``crs`` is set, and the original coordinate reference system of the parameter can be determined, then the extent will be automatically
815reprojected so that it is in the specified ``crs``. In this case the extent of the reproject rectangle will be returned.
816
817.. seealso:: :py:func:`parameterAsExtentGeometry`
818%End
819
820    QgsGeometry parameterAsExtentGeometry( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context,
821                                           const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
822%Docstring
823Evaluates the parameter with matching ``name`` to a rectangular extent, and returns a geometry covering this extent.
824
825If ``crs`` is set, and the original coordinate reference system of the parameter can be determined, then the extent will be automatically
826reprojected so that it is in the specified ``crs``. Unlike :py:func:`~QgsProcessingAlgorithm.parameterAsExtent`, the reprojected rectangle returned by this function
827will no longer be a rectangle itself (i.e. this method returns the geometry of the actual reprojected rectangle, while :py:func:`~QgsProcessingAlgorithm.parameterAsExtent` returns
828just the extent of the reprojected rectangle).
829
830.. seealso:: :py:func:`parameterAsExtent`
831%End
832
833    QgsCoordinateReferenceSystem parameterAsExtentCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
834%Docstring
835Returns the coordinate reference system associated with an extent parameter value.
836
837.. seealso:: :py:func:`parameterAsExtent`
838%End
839
840    QgsPointXY parameterAsPoint( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context,
841                                 const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() ) const;
842%Docstring
843Evaluates the parameter with matching ``name`` to a point.
844
845If ``crs`` is set then the point will be automatically
846reprojected so that it is in the specified ``crs``.
847
848.. seealso:: :py:func:`parameterAsPointCrs`
849%End
850
851    QgsCoordinateReferenceSystem parameterAsPointCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
852%Docstring
853Returns the coordinate reference system associated with an point parameter value.
854
855.. seealso:: :py:func:`parameterAsPoint`
856%End
857
858    QgsGeometry parameterAsGeometry( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context,
859                                     const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() ) const;
860%Docstring
861Evaluates the parameter with matching ``name`` to a geometry.
862
863If ``crs`` is set then the geometry will be automatically
864reprojected so that it is in the specified ``crs``.
865
866.. seealso:: :py:func:`parameterAsGeometryCrs`
867%End
868
869    QgsCoordinateReferenceSystem parameterAsGeometryCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
870%Docstring
871Returns the coordinate reference system associated with a geometry parameter value.
872
873.. seealso:: :py:func:`parameterAsGeometry`
874%End
875
876
877
878    QString parameterAsFile( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
879%Docstring
880Evaluates the parameter with matching ``name`` to a file/folder name.
881%End
882
883    QVariantList parameterAsMatrix( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
884%Docstring
885Evaluates the parameter with matching ``name`` to a matrix/table of values.
886Tables are collapsed to a 1 dimensional list.
887%End
888
889    QList< QgsMapLayer *> parameterAsLayerList( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
890%Docstring
891Evaluates the parameter with matching ``name`` to a list of map layers.
892%End
893
894    QStringList parameterAsFileList( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
895%Docstring
896Evaluates the parameter with matching ``name`` to a list of files (for QgsProcessingParameterMultipleLayers in QgsProcessing:TypeFile mode).
897
898.. versionadded:: 3.10
899%End
900
901    QList<double> parameterAsRange( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
902%Docstring
903Evaluates the parameter with matching ``name`` to a range of values.
904%End
905
906    QStringList parameterAsFields( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
907%Docstring
908Evaluates the parameter with matching ``name`` to a list of fields.
909%End
910
911    QgsPrintLayout *parameterAsLayout( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
912%Docstring
913Evaluates the parameter with matching ``name`` to a print layout.
914
915.. warning::
916
917   This method is not safe to run in a background thread, so it must either be used within a prepareAlgorithm
918   implementation (which runs in the main thread), or the algorithm must return the FlagNoThreading flag.
919
920.. versionadded:: 3.8
921%End
922
923    QgsLayoutItem *parameterAsLayoutItem( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QgsPrintLayout *layout );
924%Docstring
925Evaluates the parameter with matching ``name`` to a print layout item, taken from the specified ``layout``.
926
927.. warning::
928
929   This method is not safe to run in a background thread, so it must either be used within a prepareAlgorithm
930   implementation (which runs in the main thread), or the algorithm must return the FlagNoThreading flag.
931
932.. versionadded:: 3.8
933%End
934
935    QColor parameterAsColor( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
936%Docstring
937Evaluates the parameter with matching ``name`` to a color, or returns an invalid color if the parameter was not set.
938
939.. versionadded:: 3.10
940%End
941
942    QString parameterAsConnectionName( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
943%Docstring
944Evaluates the parameter with matching ``name`` to a connection name string.
945
946.. versionadded:: 3.14
947%End
948
949    QString parameterAsSchema( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
950%Docstring
951Evaluates the parameter with matching ``name`` to a database schema name string.
952
953.. versionadded:: 3.14
954%End
955
956    QString parameterAsDatabaseTableName( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
957%Docstring
958Evaluates the parameter with matching ``name`` to a database table name string.
959
960.. versionadded:: 3.14
961%End
962
963    QDateTime parameterAsDateTime( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
964%Docstring
965Evaluates the parameter with matching ``name`` to a DateTime, or returns an invalid date time if the parameter was not set.
966
967.. versionadded:: 3.14
968%End
969
970
971    static QString invalidSourceError( const QVariantMap &parameters, const QString &name );
972%Docstring
973Returns a user-friendly string to use as an error when a source parameter could
974not be loaded.
975
976The ``parameters`` argument should give the algorithms parameter map, and the ``name``
977should correspond to the invalid source parameter name.
978
979.. seealso:: :py:func:`invalidRasterError`
980
981.. seealso:: :py:func:`invalidSinkError`
982
983.. versionadded:: 3.2
984%End
985
986    static QString invalidRasterError( const QVariantMap &parameters, const QString &name );
987%Docstring
988Returns a user-friendly string to use as an error when a raster layer input could
989not be loaded.
990
991The ``parameters`` argument should give the algorithms parameter map, and the ``name``
992should correspond to the invalid source parameter name.
993
994.. seealso:: :py:func:`invalidSourceError`
995
996.. seealso:: :py:func:`invalidSinkError`
997
998.. versionadded:: 3.2
999%End
1000
1001    static QString invalidSinkError( const QVariantMap &parameters, const QString &name );
1002%Docstring
1003Returns a user-friendly string to use as an error when a sink parameter could
1004not be created.
1005
1006The ``parameters`` argument should give the algorithms parameter map, and the ``name``
1007should correspond to the invalid source parameter name.
1008
1009.. seealso:: :py:func:`invalidSourceError`
1010
1011.. seealso:: :py:func:`invalidRasterError`
1012
1013.. versionadded:: 3.2
1014%End
1015
1016    virtual bool supportInPlaceEdit( const QgsMapLayer *layer ) const;
1017%Docstring
1018Checks whether this algorithm supports in-place editing on the given ``layer``
1019Default implementation returns ``False``.
1020
1021:return: ``True`` if the algorithm supports in-place editing
1022
1023.. versionadded:: 3.4
1024%End
1025
1026  private:
1027    QgsProcessingAlgorithm( const QgsProcessingAlgorithm &other );
1028};
1029QFlags<QgsProcessingAlgorithm::Flag> operator|(QgsProcessingAlgorithm::Flag f1, QFlags<QgsProcessingAlgorithm::Flag> f2);
1030
1031
1032
1033
1034
1035class QgsProcessingFeatureBasedAlgorithm : QgsProcessingAlgorithm
1036{
1037%Docstring
1038An abstract QgsProcessingAlgorithm base class for processing algorithms which operate "feature-by-feature".
1039
1040Feature based algorithms are algorithms which operate on individual features in isolation. These
1041are algorithms where one feature is output for each input feature, and the output feature result
1042for each input feature is not dependent on any other features present in the source.
1043
1044For instance, algorithms like "centroids" and "buffers" are feature based algorithms since the centroid
1045or buffer of a feature is calculated for each feature in isolation. An algorithm like "dissolve"
1046is NOT suitable for a feature based algorithm as the dissolved output depends on multiple input features
1047and these features cannot be processed in isolation.
1048
1049Using QgsProcessingFeatureBasedAlgorithm as the base class for feature based algorithms allows
1050shortcutting much of the common algorithm code for handling iterating over sources and pushing
1051features to output sinks. It also allows the algorithm execution to be optimised in future
1052(for instance allowing automatic multi-thread processing of the algorithm, or use of the
1053algorithm in "chains", avoiding the need for temporary outputs in multi-step models).
1054
1055.. versionadded:: 3.0
1056%End
1057
1058%TypeHeaderCode
1059#include "qgsprocessingalgorithm.h"
1060%End
1061  public:
1062
1063    QgsProcessingFeatureBasedAlgorithm();
1064%Docstring
1065Constructor for QgsProcessingFeatureBasedAlgorithm.
1066%End
1067
1068    virtual QgsProcessingAlgorithm::Flags flags() const;
1069
1070
1071    virtual QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException ) = 0 /VirtualErrorHandler=processing_exception_handler/;
1072%Docstring
1073Processes an individual input ``feature`` from the source. Algorithms should implement their
1074logic in this method for performing the algorithm's operation (e.g. replacing the feature's
1075geometry with the centroid of the original feature geometry for a 'centroid' type
1076algorithm).
1077
1078Implementations should return a list containing the modified feature. Returning an empty an list
1079will indicate that this feature should be 'skipped', and will not be added to the algorithm's output.
1080Subclasses can use this approach to filter the incoming features as desired.
1081
1082Additionally, multiple features can be returned for a single input feature. Each returned feature
1083will be added to the algorithm's output. This allows for "explode" type algorithms where a single
1084input feature results in multiple output features.
1085
1086The provided ``feedback`` object can be used to push messages to the log and for giving feedback
1087to users. Note that handling of progress reports and algorithm cancellation is handled by
1088the base class and subclasses do not need to reimplement this logic.
1089
1090Algorithms can throw a QgsProcessingException if a fatal error occurred which should
1091prevent the algorithm execution from continuing. This can be annoying for users though as it
1092can break valid model execution - so use with extreme caution, and consider using
1093``feedback`` to instead report non-fatal processing failures for features instead.
1094%End
1095
1096  protected:
1097
1098    virtual void initAlgorithm( const QVariantMap &configuration = QVariantMap() );
1099
1100
1101    virtual QString inputParameterName() const;
1102%Docstring
1103Returns the name of the parameter corresponding to the input layer.
1104
1105By default this is the standard "INPUT" parameter name.
1106
1107.. versionadded:: 3.12
1108%End
1109
1110    virtual QString inputParameterDescription() const;
1111%Docstring
1112Returns the translated description of the parameter corresponding to the input layer.
1113
1114By default this is a translated "Input layer" string.
1115
1116.. versionadded:: 3.12
1117%End
1118
1119    virtual QString outputName() const = 0;
1120%Docstring
1121Returns the translated, user visible name for any layers created by this algorithm.
1122This name will be used as the default name when loading the resultant layer into a
1123QGIS project.
1124%End
1125
1126    virtual QList<int> inputLayerTypes() const;
1127%Docstring
1128Returns the valid input layer types for the source layer for this algorithm.
1129By default vector layers with any geometry types (excluding non-spatial, geometryless layers)
1130are accepted.
1131%End
1132
1133    virtual QgsProcessing::SourceType outputLayerType() const;
1134%Docstring
1135Returns the layer type for layers generated by this algorithm, if
1136this is possible to determine in advance.
1137%End
1138
1139    virtual QgsProcessingFeatureSource::Flag sourceFlags() const;
1140%Docstring
1141Returns the processing feature source flags to be used in the algorithm.
1142%End
1143
1144    virtual QgsFeatureSink::SinkFlags sinkFlags() const;
1145%Docstring
1146Returns the feature sink flags to be used for the output.
1147
1148.. versionadded:: 3.4.1
1149%End
1150
1151    virtual QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type inputWkbType ) const;
1152%Docstring
1153Maps the input WKB geometry type (``inputWkbType``) to the corresponding
1154output WKB type generated by the algorithm. The default behavior is that the algorithm maintains
1155the same WKB type.
1156This is called once by the base class when creating the output sink for the algorithm (i.e. it is
1157not called once per feature processed).
1158%End
1159
1160    virtual QgsFields outputFields( const QgsFields &inputFields ) const;
1161%Docstring
1162Maps the input source fields (``inputFields``) to corresponding
1163output fields generated by the algorithm. The default behavior is that the algorithm maintains
1164the same fields as are input.
1165Algorithms which add, remove or modify existing fields should override this method and
1166implement logic here to indicate which fields are output by the algorithm.
1167
1168This is called once by the base class when creating the output sink for the algorithm (i.e. it is
1169not called once per feature processed).
1170%End
1171
1172    virtual QgsCoordinateReferenceSystem outputCrs( const QgsCoordinateReferenceSystem &inputCrs ) const;
1173%Docstring
1174Maps the input source coordinate reference system (``inputCrs``) to a corresponding
1175output CRS generated by the algorithm. The default behavior is that the algorithm maintains
1176the same CRS as the input source.
1177
1178This is called once by the base class when creating the output sink for the algorithm (i.e. it is
1179not called once per feature processed).
1180%End
1181
1182    virtual void initParameters( const QVariantMap &configuration = QVariantMap() );
1183%Docstring
1184Initializes any extra parameters added by the algorithm subclass. There is no need
1185to declare the input source or output sink, as these are automatically created by
1186QgsProcessingFeatureBasedAlgorithm.
1187%End
1188
1189    QgsCoordinateReferenceSystem sourceCrs() const;
1190%Docstring
1191Returns the source's coordinate reference system. This will only return a valid CRS when
1192called from a subclasses' :py:func:`~QgsProcessingFeatureBasedAlgorithm.processFeature` implementation.
1193%End
1194
1195
1196    virtual QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException );
1197
1198
1199    virtual QgsFeatureRequest request() const;
1200%Docstring
1201Returns the feature request used for fetching features to process from the
1202source layer. The default implementation requests all attributes and geometry.
1203%End
1204
1205    virtual bool supportInPlaceEdit( const QgsMapLayer *layer ) const;
1206
1207%Docstring
1208Checks whether this algorithm supports in-place editing on the given ``layer``
1209Default implementation for feature based algorithms run some basic compatibility
1210checks based on the geometry type of the layer.
1211
1212:return: ``True`` if the algorithm supports in-place editing
1213
1214.. versionadded:: 3.4
1215%End
1216
1217    void prepareSource( const QVariantMap &parameters, QgsProcessingContext &context );
1218%Docstring
1219Read the source from ``parameters`` and ``context`` and set it
1220
1221.. versionadded:: 3.4
1222%End
1223
1224     virtual QgsProcessingAlgorithm::VectorProperties sinkProperties( const QString &sink,
1225        const QVariantMap &parameters,
1226        QgsProcessingContext &context,
1227        const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties ) const;
1228
1229};
1230
1231
1232
1233
1234/************************************************************************
1235 * This file has been generated automatically from                      *
1236 *                                                                      *
1237 * src/core/processing/qgsprocessingalgorithm.h                         *
1238 *                                                                      *
1239 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
1240 ************************************************************************/
1241