QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
|
An abstract QgsProcessingAlgorithm base class for processing algorithms which operate "feature-by-feature". More...
#include <qgsprocessingalgorithm.h>
Public Member Functions | |
QgsProcessingFeatureBasedAlgorithm ()=default | |
Constructor for QgsProcessingFeatureBasedAlgorithm. | |
QgsProcessingAlgorithm::Flags | flags () const override |
Returns the flags indicating how and when the algorithm operates and should be exposed to users. | |
virtual QgsFeatureList | processFeature (const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback)=0 |
Processes an individual input feature from the source. | |
Public Member Functions inherited from QgsProcessingAlgorithm | |
QgsProcessingAlgorithm ()=default | |
Constructor for QgsProcessingAlgorithm. | |
QgsProcessingAlgorithm (const QgsProcessingAlgorithm &other)=delete | |
Algorithms cannot be copied - create() should be used instead. | |
virtual | ~QgsProcessingAlgorithm () |
virtual QVariantMap | asMap (const QVariantMap ¶meters, QgsProcessingContext &context) const |
Returns a JSON serializable variant map containing the specified parameters and context settings. | |
virtual QString | asPythonCommand (const QVariantMap ¶meters, QgsProcessingContext &context) const |
Returns a Python command string which can be executed to run the algorithm using the specified parameters. | |
virtual QString | asQgisProcessCommand (const QVariantMap ¶meters, QgsProcessingContext &context, bool &ok) const |
Returns a command string which will execute the algorithm using the specified parameters via the command line qgis_process tool. | |
virtual bool | canExecute (QString *errorMessage=nullptr) const |
Returns true if the algorithm can execute. | |
virtual bool | checkParameterValues (const QVariantMap ¶meters, QgsProcessingContext &context, QString *message=nullptr) const |
Checks the supplied parameter values to verify that they satisfy the requirements of this algorithm in the supplied context. | |
int | countVisibleParameters () const |
Returns the number of visible (non-hidden) parameters defined by this algorithm. | |
QgsProcessingAlgorithm * | create (const QVariantMap &configuration=QVariantMap()) const |
Creates a copy of the algorithm, ready for execution. | |
virtual QWidget * | createCustomParametersWidget (QWidget *parent=nullptr) const |
If an algorithm subclass implements a custom parameters widget, a copy of this widget should be constructed and returned by this method. | |
virtual QgsExpressionContext | createExpressionContext (const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeatureSource *source=nullptr) const |
Creates an expression context relating to the algorithm. | |
QgsProcessingParameterDefinitions | destinationParameterDefinitions () const |
Returns a list of destination parameters definitions utilized by the algorithm. | |
virtual QString | displayName () const =0 |
Returns the translated algorithm name, which should be used for any user-visible display of the algorithm name. | |
virtual QString | group () const |
Returns the name of the group this algorithm belongs to. | |
virtual QString | groupId () const |
Returns the unique ID of the group this algorithm belongs to. | |
bool | hasHtmlOutputs () const |
Returns true if this algorithm generates HTML outputs. | |
virtual Q_DECL_DEPRECATED QString | helpString () const |
Returns a localised help string for the algorithm. | |
virtual QString | helpUrl () const |
Returns a url pointing to the algorithm's help page. | |
virtual QIcon | icon () const |
Returns an icon for the algorithm. | |
QString | id () const |
Returns the unique ID for the algorithm, which is a combination of the algorithm provider's ID and the algorithms unique name (e.g. | |
virtual QString | name () const =0 |
Returns the algorithm name, used for identifying the algorithm. | |
QgsProcessingAlgorithm & | operator= (const QgsProcessingAlgorithm &other)=delete |
Algorithms cannot be copied- create() should be used instead. | |
const QgsProcessingOutputDefinition * | outputDefinition (const QString &name) const |
Returns a matching output by name. | |
QgsProcessingOutputDefinitions | outputDefinitions () const |
Returns an ordered list of output definitions utilized by the algorithm. | |
const QgsProcessingParameterDefinition * | parameterDefinition (const QString &name) const |
Returns a matching parameter by name. | |
QgsProcessingParameterDefinitions | parameterDefinitions () const |
Returns an ordered list of parameter definitions utilized by the algorithm. | |
QVariantMap | postProcess (QgsProcessingContext &context, QgsProcessingFeedback *feedback) |
Should be called in the main thread following the completion of runPrepared(). | |
bool | prepare (const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) |
Prepares the algorithm for execution. | |
virtual QVariantMap | preprocessParameters (const QVariantMap ¶meters) |
Pre-processes a set of parameters, allowing the algorithm to clean their values. | |
QgsProcessingProvider * | provider () const |
Returns the provider to which this algorithm belongs. | |
QVariantMap | run (const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback, bool *ok=nullptr, const QVariantMap &configuration=QVariantMap(), bool catchExceptions=true) const |
Executes the algorithm using the specified parameters. | |
QVariantMap | runPrepared (const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) |
Runs the algorithm, which has been prepared by an earlier call to prepare(). | |
void | setProvider (QgsProcessingProvider *provider) |
Associates this algorithm with its provider. | |
virtual QString | shortDescription () const |
Returns an optional translated short description of the algorithm. | |
virtual QString | shortHelpString () const |
Returns a localised short helper string for the algorithm. | |
virtual QString | svgIconPath () const |
Returns a path to an SVG version of the algorithm's icon. | |
virtual QStringList | tags () const |
Returns a list of tags which relate to the algorithm, and are used to assist users in searching for suitable algorithms. | |
virtual bool | validateInputCrs (const QVariantMap ¶meters, QgsProcessingContext &context) const |
Checks whether the coordinate reference systems for the specified set of parameters are valid for the algorithm. | |
Protected Member Functions | |
void | initAlgorithm (const QVariantMap &configuration=QVariantMap()) override |
Initializes the algorithm using the specified configuration. | |
virtual void | initParameters (const QVariantMap &configuration=QVariantMap()) |
Initializes any extra parameters added by the algorithm subclass. | |
virtual QList< int > | inputLayerTypes () const |
Returns the valid input layer types for the source layer for this algorithm. | |
virtual QString | inputParameterDescription () const |
Returns the translated description of the parameter corresponding to the input layer. | |
virtual QString | inputParameterName () const |
Returns the name of the parameter corresponding to the input layer. | |
virtual QgsCoordinateReferenceSystem | outputCrs (const QgsCoordinateReferenceSystem &inputCrs) const |
Maps the input source coordinate reference system (inputCrs) to a corresponding output CRS generated by the algorithm. | |
virtual QgsFields | outputFields (const QgsFields &inputFields) const |
Maps the input source fields (inputFields) to corresponding output fields generated by the algorithm. | |
virtual QgsProcessing::SourceType | outputLayerType () const |
Returns the layer type for layers generated by this algorithm, if this is possible to determine in advance. | |
virtual QString | outputName () const =0 |
Returns the translated, user visible name for any layers created by this algorithm. | |
virtual Qgis::WkbType | outputWkbType (Qgis::WkbType inputWkbType) const |
Maps the input WKB geometry type (inputWkbType) to the corresponding output WKB type generated by the algorithm. | |
void | prepareSource (const QVariantMap ¶meters, QgsProcessingContext &context) |
Read the source from parameters and context and set it. | |
QVariantMap | processAlgorithm (const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) override |
Runs the algorithm using the specified parameters. | |
virtual QgsFeatureRequest | request () const |
Returns the feature request used for fetching features to process from the source layer. | |
virtual QgsFeatureSink::SinkFlags | sinkFlags () const |
Returns the feature sink flags to be used for the output. | |
QgsProcessingAlgorithm::VectorProperties | sinkProperties (const QString &sink, const QVariantMap ¶meters, QgsProcessingContext &context, const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties) const override |
Returns the vector properties which will be used for the sink with matching name. | |
QgsCoordinateReferenceSystem | sourceCrs () const |
Returns the source's coordinate reference system. | |
virtual QgsProcessingFeatureSource::Flag | sourceFlags () const |
Returns the processing feature source flags to be used in the algorithm. | |
bool | supportInPlaceEdit (const QgsMapLayer *layer) const override |
Checks whether this algorithm supports in-place editing on the given layer Default implementation for feature based algorithms run some basic compatibility checks based on the geometry type of the layer. | |
Protected Member Functions inherited from QgsProcessingAlgorithm | |
bool | addOutput (QgsProcessingOutputDefinition *outputDefinition) |
Adds an output definition to the algorithm. | |
bool | addParameter (QgsProcessingParameterDefinition *parameterDefinition, bool createOutput=true) |
Adds a parameter definition to the algorithm. | |
virtual QgsProcessingAlgorithm * | createInstance () const =0 |
Creates a new instance of the algorithm class. | |
QgsAnnotationLayer * | parameterAsAnnotationLayer (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to an annotation layer. | |
bool | parameterAsBool (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a static boolean value. | |
bool | parameterAsBoolean (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a static boolean value. | |
QColor | parameterAsColor (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a color, or returns an invalid color if the parameter was not set. | |
QString | parameterAsCompatibleSourceLayerPath (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr) const |
Evaluates the parameter with matching name to a source vector layer file path of compatible format. | |
QString | parameterAsCompatibleSourceLayerPathAndLayerName (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr, QString *layerName=nullptr) const |
Evaluates the parameter with matching name to a source vector layer file path and layer name of compatible format. | |
QString | parameterAsConnectionName (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a connection name string. | |
QgsCoordinateReferenceSystem | parameterAsCrs (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a coordinate reference system. | |
QString | parameterAsDatabaseTableName (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a database table name string. | |
QDateTime | parameterAsDateTime (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a DateTime, or returns an invalid date time if the parameter was not set. | |
double | parameterAsDouble (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a static double value. | |
int | parameterAsEnum (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a enum value. | |
QList< int > | parameterAsEnums (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to list of enum values. | |
QString | parameterAsEnumString (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a static enum string. | |
QStringList | parameterAsEnumStrings (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to list of static enum strings. | |
QString | parameterAsExpression (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to an expression. | |
QgsRectangle | parameterAsExtent (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const |
Evaluates the parameter with matching name to a rectangular extent. | |
QgsCoordinateReferenceSystem | parameterAsExtentCrs (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Returns the coordinate reference system associated with an extent parameter value. | |
QgsGeometry | parameterAsExtentGeometry (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const |
Evaluates the parameter with matching name to a rectangular extent, and returns a geometry covering this extent. | |
Q_DECL_DEPRECATED QStringList | parameterAsFields (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a list of fields. | |
QString | parameterAsFile (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a file/folder name. | |
QStringList | parameterAsFileList (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a list of files (for QgsProcessingParameterMultipleLayers in QgsProcessing:TypeFile mode). | |
QString | parameterAsFileOutput (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a file based output destination. | |
QgsGeometry | parameterAsGeometry (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const |
Evaluates the parameter with matching name to a geometry. | |
QgsCoordinateReferenceSystem | parameterAsGeometryCrs (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Returns the coordinate reference system associated with a geometry parameter value. | |
int | parameterAsInt (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a static integer value. | |
QList< int > | parameterAsInts (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a list of integer values. | |
QgsMapLayer * | parameterAsLayer (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a map layer. | |
QList< QgsMapLayer * > | parameterAsLayerList (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags()) const |
Evaluates the parameter with matching name to a list of map layers. | |
QgsPrintLayout * | parameterAsLayout (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) |
Evaluates the parameter with matching name to a print layout. | |
QgsLayoutItem * | parameterAsLayoutItem (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, QgsPrintLayout *layout) |
Evaluates the parameter with matching name to a print layout item, taken from the specified layout. | |
QVariantList | parameterAsMatrix (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a matrix/table of values. | |
QgsMeshLayer * | parameterAsMeshLayer (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a mesh layer. | |
QString | parameterAsOutputLayer (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a output layer destination. | |
QgsPointXY | parameterAsPoint (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const |
Evaluates the parameter with matching name to a point. | |
QgsPointCloudLayer * | parameterAsPointCloudLayer (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags()) const |
Evaluates the parameter with matching name to a point cloud layer. | |
QgsCoordinateReferenceSystem | parameterAsPointCrs (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Returns the coordinate reference system associated with an point parameter value. | |
QList< double > | parameterAsRange (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a range of values. | |
QgsRasterLayer * | parameterAsRasterLayer (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a raster layer. | |
QString | parameterAsSchema (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a database schema name string. | |
QgsFeatureSink * | parameterAsSink (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier, const QgsFields &fields, Qgis::WkbType geometryType=Qgis::WkbType::NoGeometry, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList()) const |
Evaluates the parameter with matching name to a feature sink. | |
QgsProcessingFeatureSource * | parameterAsSource (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a feature source. | |
QString | parameterAsString (const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a static string value. | |
QStringList | parameterAsStrings (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a list of strings (e.g. | |
QgsVectorLayer * | parameterAsVectorLayer (const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const |
Evaluates the parameter with matching name to a vector layer. | |
virtual QVariantMap | postProcessAlgorithm (QgsProcessingContext &context, QgsProcessingFeedback *feedback) |
Allows the algorithm to perform any required cleanup tasks. | |
virtual bool | prepareAlgorithm (const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) |
Prepares the algorithm to run using the specified parameters. | |
void | removeParameter (const QString &name) |
Removes the parameter with matching name from the algorithm, and deletes any existing definition. | |
Additional Inherited Members | |
Public Types inherited from QgsProcessingAlgorithm | |
enum | Flag { FlagHideFromToolbox = 1 << 1 , FlagHideFromModeler = 1 << 2 , FlagSupportsBatch = 1 << 3 , FlagCanCancel = 1 << 4 , FlagRequiresMatchingCrs = 1 << 5 , FlagNoThreading = 1 << 6 , FlagDisplayNameIsLiteral = 1 << 7 , FlagSupportsInPlaceEdits = 1 << 8 , FlagKnownIssues = 1 << 9 , FlagCustomException = 1 << 10 , FlagPruneModelBranchesBasedOnAlgorithmResults = 1 << 11 , FlagSkipGenericModelLogging = 1 << 12 , FlagNotAvailableInStandaloneTool = 1 << 13 , FlagRequiresProject = 1 << 14 , FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler } |
Flags indicating how and when an algorithm operates and should be exposed to users. More... | |
enum | PropertyAvailability { NotAvailable , Available } |
Property availability, used for QgsProcessingAlgorithm::VectorProperties in order to determine if properties are available or not. More... | |
Static Protected Member Functions inherited from QgsProcessingAlgorithm | |
static QString | invalidPointCloudError (const QVariantMap ¶meters, const QString &name) |
Returns a user-friendly string to use as an error when a point cloud layer input could not be loaded. | |
static QString | invalidRasterError (const QVariantMap ¶meters, const QString &name) |
Returns a user-friendly string to use as an error when a raster layer input could not be loaded. | |
static QString | invalidSinkError (const QVariantMap ¶meters, const QString &name) |
Returns a user-friendly string to use as an error when a sink parameter could not be created. | |
static QString | invalidSourceError (const QVariantMap ¶meters, const QString &name) |
Returns a user-friendly string to use as an error when a source parameter could not be loaded. | |
static QString | writeFeatureError (QgsFeatureSink *sink, const QVariantMap ¶meters, const QString &name) |
Returns a user-friendly string to use as an error when a feature cannot be written into a sink. | |
An abstract QgsProcessingAlgorithm base class for processing algorithms which operate "feature-by-feature".
Feature based algorithms are algorithms which operate on individual features in isolation. These are algorithms where one feature is output for each input feature, and the output feature result for each input feature is not dependent on any other features present in the source.
For instance, algorithms like "centroids" and "buffers" are feature based algorithms since the centroid or buffer of a feature is calculated for each feature in isolation. An algorithm like "dissolve" is NOT suitable for a feature based algorithm as the dissolved output depends on multiple input features and these features cannot be processed in isolation.
Using QgsProcessingFeatureBasedAlgorithm as the base class for feature based algorithms allows shortcutting much of the common algorithm code for handling iterating over sources and pushing features to output sinks. It also allows the algorithm execution to be optimised in future (for instance allowing automatic multi-thread processing of the algorithm, or use of the algorithm in "chains", avoiding the need for temporary outputs in multi-step models).
Definition at line 1172 of file qgsprocessingalgorithm.h.
|
default |
Constructor for QgsProcessingFeatureBasedAlgorithm.
|
overridevirtual |
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
Default flags are FlagSupportsBatch and FlagCanCancel.
Reimplemented from QgsProcessingAlgorithm.
Definition at line 1042 of file qgsprocessingalgorithm.cpp.
|
overrideprotectedvirtual |
Initializes the algorithm using the specified configuration.
This should be called directly after creating algorithms and before retrieving any parameterDefinitions() or outputDefinitions().
Subclasses should use their implementations to add all required input parameter and output definitions (which can be dynamically adjusted according to configuration).
Dynamic configuration can be used by algorithms which alter their behavior when used inside processing models. For instance, a "feature router" type algorithm which sends input features to one of any number of outputs sinks based on some preconfigured filter parameters can use the init method to create these outputs based on the specified configuration.
Implements QgsProcessingAlgorithm.
Definition at line 1049 of file qgsprocessingalgorithm.cpp.
|
protectedvirtual |
Initializes any extra parameters added by the algorithm subclass.
There is no need to declare the input source or output sink, as these are automatically created by QgsProcessingFeatureBasedAlgorithm.
Reimplemented in QgsBatchGeocodeAlgorithm.
Definition at line 1101 of file qgsprocessingalgorithm.cpp.
|
protectedvirtual |
Returns the valid input layer types for the source layer for this algorithm.
By default vector layers with any geometry types (excluding non-spatial, geometryless layers) are accepted.
Reimplemented in QgsBatchGeocodeAlgorithm.
Definition at line 1066 of file qgsprocessingalgorithm.cpp.
|
protectedvirtual |
Returns the translated description of the parameter corresponding to the input layer.
By default this is a translated "Input layer" string.
Definition at line 1061 of file qgsprocessingalgorithm.cpp.
|
protectedvirtual |
Returns the name of the parameter corresponding to the input layer.
By default this is the standard "INPUT" parameter name.
Definition at line 1056 of file qgsprocessingalgorithm.cpp.
|
protectedvirtual |
Maps the input source coordinate reference system (inputCrs) to a corresponding output CRS generated by the algorithm.
The default behavior is that the algorithm maintains the same CRS as the input source.
This is called once by the base class when creating the output sink for the algorithm (i.e. it is not called once per feature processed).
Reimplemented in QgsBatchGeocodeAlgorithm.
Definition at line 1096 of file qgsprocessingalgorithm.cpp.
|
protectedvirtual |
Maps the input source fields (inputFields) to corresponding output fields generated by the algorithm.
The default behavior is that the algorithm maintains the same fields as are input. Algorithms which add, remove or modify existing fields should override this method and implement logic here to indicate which fields are output by the algorithm.
This is called once by the base class when creating the output sink for the algorithm (i.e. it is not called once per feature processed).
Reimplemented in QgsBatchGeocodeAlgorithm.
Definition at line 1091 of file qgsprocessingalgorithm.cpp.
|
protectedvirtual |
Returns the layer type for layers generated by this algorithm, if this is possible to determine in advance.
Definition at line 1071 of file qgsprocessingalgorithm.cpp.
|
protectedpure virtual |
Returns the translated, user visible name for any layers created by this algorithm.
This name will be used as the default name when loading the resultant layer into a QGIS project.
Implemented in QgsBatchGeocodeAlgorithm.
|
protectedvirtual |
Maps the input WKB geometry type (inputWkbType) to the corresponding output WKB type generated by the algorithm.
The default behavior is that the algorithm maintains the same WKB type. This is called once by the base class when creating the output sink for the algorithm (i.e. it is not called once per feature processed).
Reimplemented in QgsBatchGeocodeAlgorithm.
Definition at line 1086 of file qgsprocessingalgorithm.cpp.
|
protected |
Read the source from parameters and context and set it.
Definition at line 1199 of file qgsprocessingalgorithm.cpp.
|
overrideprotectedvirtual |
Runs the algorithm using the specified parameters.
Algorithms should implement their custom processing logic here.
The context argument gives a temporary context with thread affinity matching the thread in which the algorithm is being run. This is a cut-back copy of the context passed to the prepareAlgorithm() and postProcessAlgorithm() steps, but it is generally safe for most algorithms to utilize this context for loading layers and creating sinks. Any loaded layers or sinks created within this temporary context will be transferred back to the main execution context upon successful completion of the processAlgorithm() step.
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.
This method will not be called if the prepareAlgorithm() step failed (returned false
).
Implementations of processAlgorithm can throw the QgsProcessingException exception to indicate that a fatal error occurred within the execution.
Implements QgsProcessingAlgorithm.
Definition at line 1113 of file qgsprocessingalgorithm.cpp.
|
pure virtual |
Processes an individual input feature from the source.
Algorithms should implement their logic in this method for performing the algorithm's operation (e.g. replacing the feature's geometry with the centroid of the original feature geometry for a 'centroid' type algorithm).
Implementations should return a list containing the modified feature. Returning an empty an list will indicate that this feature should be 'skipped', and will not be added to the algorithm's output. Subclasses can use this approach to filter the incoming features as desired.
Additionally, multiple features can be returned for a single input feature. Each returned feature will be added to the algorithm's output. This allows for "explode" type algorithms where a single input feature results in multiple output features.
The provided feedback object can be used to push messages to the log and for giving feedback to users. Note that handling of progress reports and algorithm cancellation is handled by the base class and subclasses do not need to reimplement this logic.
Algorithms can throw a QgsProcessingException if a fatal error occurred which should prevent the algorithm execution from continuing. This can be annoying for users though as it can break valid model execution - so use with extreme caution, and consider using feedback to instead report non-fatal processing failures for features instead.
Implemented in QgsBatchGeocodeAlgorithm.
|
protectedvirtual |
Returns the feature request used for fetching features to process from the source layer.
The default implementation requests all attributes and geometry.
Definition at line 1165 of file qgsprocessingalgorithm.cpp.
|
protectedvirtual |
Returns the feature sink flags to be used for the output.
Definition at line 1081 of file qgsprocessingalgorithm.cpp.
|
overrideprotectedvirtual |
Returns the vector properties which will be used for the sink with matching name.
The parameters argument specifies the values of all parameters which would be used to generate the sink. These can be used alongside the provided context in order to pre-evaluate inputs when required in order to determine the sink's properties.
The sourceProperties map will contain the vector properties of the various sources used as inputs to the algorithm. These will only be available in certain circumstances (e.g. when the algorithm is used within a model), so implementations will need to be adaptable to circumstances when either sourceParameters is empty or parameters is empty, and use whatever information is passed in order to make a best guess determination of the output properties.
Reimplemented from QgsProcessingAlgorithm.
Definition at line 1210 of file qgsprocessingalgorithm.cpp.
|
protected |
Returns the source's coordinate reference system.
This will only return a valid CRS when called from a subclasses' processFeature() implementation.
Definition at line 1105 of file qgsprocessingalgorithm.cpp.
|
protectedvirtual |
Returns the processing feature source flags to be used in the algorithm.
Definition at line 1076 of file qgsprocessingalgorithm.cpp.
|
overrideprotectedvirtual |
Checks whether this algorithm supports in-place editing on the given layer Default implementation for feature based algorithms run some basic compatibility checks based on the geometry type of the layer.
true
if the algorithm supports in-place editing Reimplemented from QgsProcessingAlgorithm.
Definition at line 1170 of file qgsprocessingalgorithm.cpp.