36 qDeleteAll( mParameters );
37 qDeleteAll( mOutputs );
42 std::unique_ptr< QgsProcessingAlgorithm > creation(
createInstance() );
46 creation->initAlgorithm( configuration );
47 return creation.release();
53 return QStringLiteral(
"%1:%2" ).arg( mProvider->
id(),
name() );
102 if ( !def->checkValueIsAcceptable( parameters.value( def->name() ), &context ) )
115 *message = QObject::tr(
"Incorrect parameter value for %1" ).arg( def->name() );
142 if ( definition->isDestination() )
188 bool foundCrs =
false;
197 if ( foundCrs && layer->
crs().
isValid() && crs != layer->
crs() )
201 else if ( !foundCrs && layer->
crs().
isValid() )
213 if ( foundCrs && source->sourceCrs().isValid() && crs != source->sourceCrs() )
217 else if ( !foundCrs && source->sourceCrs().isValid() )
220 crs = source->sourceCrs();
232 if ( foundCrs && layer->
crs().
isValid() && crs != layer->
crs() )
236 else if ( !foundCrs && layer->
crs().
isValid() )
246 if ( foundCrs && extentCrs.
isValid() && crs != extentCrs )
250 else if ( !foundCrs && extentCrs.
isValid() )
259 if ( foundCrs && pointCrs.
isValid() && crs != pointCrs )
263 else if ( !foundCrs && pointCrs.
isValid() )
275 QString s = QStringLiteral(
"processing.run(\"%1\"," ).arg(
id() );
283 if ( !parameters.contains( def->name() ) )
286 parts << QStringLiteral(
"'%1':%2" ).arg( def->name(), def->valueAsPythonString( parameters.value( def->name() ), context ) );
289 s += QStringLiteral(
" {%1})" ).arg( parts.join(
',' ) );
300 if ( existingDef && existingDef->
name() == definition->
name() )
302 QgsMessageLog::logMessage( QObject::tr(
"Duplicate parameter %1 registered for alg %2" ).arg( definition->
name(),
id() ), QObject::tr(
"Processing" ) );
314 mParameters << definition;
318 return createAutoOutputForParameter( definition );
329 mParameters.removeAll( def );
346 mOutputs << definition;
357 return QVariantMap();
365 if ( def->name() ==
name )
372 if ( def->name().compare( name, Qt::CaseInsensitive ) == 0 )
394 if ( def->isDestination() )
404 if ( def->name().compare( name, Qt::CaseInsensitive ) == 0 )
414 if ( def->type() == QStringLiteral(
"outputHtml" ) )
422 std::unique_ptr< QgsProcessingAlgorithm > alg(
create( configuration ) );
426 bool res = alg->prepare( parameters, context, feedback );
428 return QVariantMap();
433 runRes = alg->runPrepared( parameters, context, feedback );
439 return QVariantMap();
445 QVariantMap ppRes = alg->postProcess( context, feedback );
446 if ( !ppRes.isEmpty() )
454 Q_ASSERT_X( QThread::currentThread() == context.
temporaryLayerStore()->thread(),
"QgsProcessingAlgorithm::prepare",
"prepare() must be called from the same thread as context was created in" );
455 Q_ASSERT_X( !mHasPrepared,
"QgsProcessingAlgorithm::prepare",
"prepare() has already been called for the algorithm instance" );
471 Q_ASSERT_X( mHasPrepared,
"QgsProcessingAlgorithm::runPrepared", QStringLiteral(
"prepare() was not called for the algorithm instance %1" ).arg(
name() ).toLatin1() );
472 Q_ASSERT_X( !mHasExecuted,
"QgsProcessingAlgorithm::runPrepared",
"runPrepared() was already called for this algorithm instance" );
478 if ( context.
thread() == QThread::currentThread() )
483 runContext = &context;
494 mLocalContext->copyThreadSafeSettings( context );
496 runContext = mLocalContext.get();
501 QVariantMap runResults =
processAlgorithm( parameters, *runContext, feedback );
509 mLocalContext->pushToThread( context.
thread() );
518 mLocalContext->pushToThread( context.
thread() );
527 Q_ASSERT_X( QThread::currentThread() == context.
temporaryLayerStore()->thread(),
"QgsProcessingAlgorithm::postProcess",
"postProcess() must be called from the same thread the context was created in" );
528 Q_ASSERT_X( mHasExecuted,
"QgsProcessingAlgorithm::postProcess", QStringLiteral(
"algorithm instance %1 was not executed" ).arg(
name() ).toLatin1() );
529 Q_ASSERT_X( !mHasPostProcessed,
"QgsProcessingAlgorithm::postProcess",
"postProcess() was already called for this algorithm instance" );
538 mLocalContext.reset();
541 mHasPostProcessed =
true;
550 return QVariantMap();
696 if ( !parameters.contains( name ) )
697 return QObject::tr(
"Could not load source layer for %1: no value specified for parameter" ).arg( name );
700 QVariant var = parameters.value( name );
719 if ( !var.toString().isEmpty() )
720 return QObject::tr(
"Could not load source layer for %1: %2 not found" ).arg( name, var.toString() );
722 return QObject::tr(
"Could not load source layer for %1: invalid value" ).arg( name );
728 if ( !parameters.contains( name ) )
729 return QObject::tr(
"Could not load source layer for %1: no value specified for parameter" ).arg( name );
732 QVariant var = parameters.value( name );
741 if ( !var.toString().isEmpty() )
742 return QObject::tr(
"Could not load source layer for %1: %2 not found" ).arg( name, var.toString() );
744 return QObject::tr(
"Could not load source layer for %1: invalid value" ).arg( name );
750 if ( !parameters.contains( name ) )
751 return QObject::tr(
"Could not create destination layer for %1: no value specified for parameter" ).arg( name );
754 QVariant var = parameters.value( name );
768 if ( !var.toString().isEmpty() )
769 return QObject::tr(
"Could not create destination layer for %1: %2" ).arg( name, var.toString() );
771 return QObject::tr(
"Could not create destination layer for %1: invalid value" ).arg( name );
818 initParameters( config );
864 return mSource->sourceCrs();
871 prepareSource( parameters, context );
873 std::unique_ptr< QgsFeatureSink > sink(
parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest,
874 outputFields( mSource->fields() ),
875 outputWkbType( mSource->wkbType() ),
888 long count = mSource->featureCount();
893 double step = count > 0 ? 100.0 / count : 1;
903 const QgsFeatureList transformed = processFeature( f, context, feedback );
904 for (
QgsFeature transformedFeature : transformed )
917 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
933 if ( !inputLayerTypes().empty() &&
958 mSource.reset(
parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
QgsProperty sink
Sink/layer definition.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
virtual QgsFields outputFields(const QgsFields &inputFields) const
Maps the input source fields (inputFields) to corresponding output fields generated by the algorithm...
QList< const QgsProcessingParameterDefinition *> QgsProcessingParameterDefinitions
List of processing parameters.
void setProvider(QgsProcessingProvider *provider)
Associates this algorithm with its provider.
virtual bool prepareAlgorithm(const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)
Prepares the algorithm to run using the specified parameters.
QString parameterAsFile(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a file/folder name.
QgsProcessingFeatureSource * parameterAsSource(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a feature source.
virtual QString helpUrl() const
Returns a url pointing to the algorithm's help page.
static QgsExpressionContextScope * processingAlgorithmScope(const QgsProcessingAlgorithm *algorithm, const QVariantMap ¶meters, QgsProcessingContext &context)
Creates a new scope which contains variables and functions relating to a processing algorithm...
Wrapper for iterator of features from vector data provider or vector layer.
double parameterAsDouble(const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static double value.
QVariantMap processAlgorithm(const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) override SIP_THROW(QgsProcessingException)
Runs the algorithm using the specified parameters.
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
QList< QgsMapLayer * > parameterAsLayerList(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a list of map layers.
A rectangle specified with double values.
Base class for all map layer types.
QgsCoordinateReferenceSystem parameterAsPointCrs(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value. ...
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
QgsRasterLayer * parameterAsRasterLayer(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a raster layer.
QString id() const
Returns the unique ID for the algorithm, which is a combination of the algorithm provider's ID and th...
virtual QIcon icon() const
Returns an icon for the algorithm.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
virtual Q_DECL_DEPRECATED QString helpString() const
Returns a localised help string for the algorithm.
Base class for providing feedback from a processing algorithm.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm...
int countVisibleParameters() const
Returns the number of visible (non-hidden) parameters defined by this algorithm.
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...
QVariantMap postProcess(QgsProcessingContext &context, QgsProcessingFeedback *feedback)
Should be called in the main thread following the completion of runPrepared().
QgsPointXY parameterAsPoint(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const
Evaluates the parameter with matching name to a point.
virtual QgsExpressionContext createExpressionContext(const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeatureSource *source=nullptr) const
Creates an expression context relating to the algorithm.
Algorithm can be canceled.
static QString typeName()
Returns the type name for the parameter class.
bool hasHtmlOutputs() const
Returns true if this algorithm generates HTML outputs.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
QList< QgsFeature > QgsFeatureList
QVariantList parameterAsMatrix(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a matrix/table of values.
virtual QString name() const =0
Returns the algorithm name, used for identifying the algorithm.
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
QString name() const
Returns the name of the output.
A class to represent a 2D point.
QgsCoordinateReferenceSystem sourceCrs() const
Returns the source's coordinate reference system.
QList< int > parameterAsEnums(const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to list of enum values.
static QString typeName()
Returns the type name for the parameter class.
void setProgress(double progress)
Sets the current progress for the feedback object.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
An interface for objects which accept features via addFeature(s) methods.
QgsMeshLayer * parameterAsMeshLayer(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a mesh layer.
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
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.
virtual Flags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users...
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
QgsFeatureSink * parameterAsSink(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier, const QgsFields &fields, QgsWkbTypes::Type geometryType=QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem(), QgsFeatureSink::SinkFlags sinkFlags=nullptr) const
Evaluates the parameter with matching name to a feature sink.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource, modifying results according to the settings in a QgsProcessingContext.
Container of fields for a vector layer.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
A geometry is the spatial representation of a feature.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
static QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a map layer.
QgsMapLayer * parameterAsLayer(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a map layer.
Abstract base class for processing providers.
Algorithm requires that all input layers have matching coordinate reference systems.
QThread * thread()
Returns the thread in which the context lives.
virtual bool supportsNonFileBasedOutput() const
Returns true if the provider supports non-file based outputs (such as memory layers or direct databas...
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 parame...
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
QStringList parameterAsFields(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a list of fields.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
const QgsCoordinateReferenceSystem & crs
virtual QList< int > inputLayerTypes() const
Returns the valid input layer types for the source layer for this algorithm.
virtual QString shortHelpString() const
Returns a localised short helper string for the algorithm.
Algorithm supports batch mode.
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
Base class for all parameter definitions which represent file or layer destinations, e.g.
Abstract base class for processing algorithms.
QgsCoordinateReferenceSystem parameterAsCrs(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a coordinate reference system.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
A feature sink output for processing algorithms.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
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...
QgsProject * project() const
Returns the project in which the algorithm is being executed.
QVariantMap runPrepared(const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)
Runs the algorithm, which has been prepared by an earlier call to prepare().
static QString typeName()
Returns the type name for the parameter class.
virtual bool supportInPlaceEdit(const QgsMapLayer *layer) const
Checks whether this algorithm supports in-place editing on the given layer Default implementation ret...
static QgsGeometry parameterAsExtentGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry cove...
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
QgsProcessingParameterDefinitions destinationParameterDefinitions() const
Returns a list of destination parameters definitions utilized by the algorithm.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
virtual QVariantMap preprocessParameters(const QVariantMap ¶meters)
Pre-processes a set of parameters, allowing the algorithm to clean their values.
void removeParameter(const QString &name)
Removes the parameter with matching name from the algorithm, and deletes any existing definition...
Type
The WKB type describes the number of dimensions a geometry has.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value. ...
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
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 typeName()
Returns the type name for the parameter class.
QgsMapLayerStore * temporaryLayerStore()
Returns a reference to the layer store used for storing temporary layers during algorithm execution...
static QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags=nullptr)
Evaluates the parameter with matching definition to a feature sink.
QgsProperty source
Source definition.
Type propertyType() const
Returns the property type.
bool prepare(const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
Prepares the algorithm for execution.
QgsCoordinateReferenceSystem parameterAsExtentCrs(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
virtual QWidget * createCustomParametersWidget(QWidget *parent=nullptr) const
If an algorithm subclass implements a custom parameters widget, a copy of this widget should be const...
virtual QString id() const =0
Returns the unique provider id, used for identifying the provider.
int scopeCount() const
Returns the number of scopes contained in the context.
static QString typeName()
Returns the type name for the parameter class.
bool parameterAsBool(const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static boolean value.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual QVariantMap postProcessAlgorithm(QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)
Allows the algorithm to perform any required cleanup tasks.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
void takeResultsFrom(QgsProcessingContext &context)
Takes the results from another context and merges them with the results currently stored in this cont...
virtual QgsWkbTypes::Type outputWkbType(QgsWkbTypes::Type inputWkbType) const
Maps the input WKB geometry type (inputWkbType) to the corresponding output WKB type generated by the...
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
virtual QgsFeatureRequest request() const
Returns the feature request used for fetching features to process from the source layer...
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
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...
Custom exception class for processing related exceptions.
QgsVectorLayer * parameterAsVectorLayer(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a vector layer.
QString parameterAsString(const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static string value.
Single scope for storing variables and functions for use within a QgsExpressionContext.
int parameterAsInt(const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static integer value.
A store for object properties.
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 i...
virtual QgsProcessingAlgorithm * createInstance() const =0
Creates a new instance of the algorithm class.
QString parameterAsExpression(const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to an expression.
QgsExpressionContext & expressionContext()
Returns the expression context.
const QgsProcessingParameterDefinition * parameterDefinition(const QString &name) const
Returns a matching parameter by name.
QgsGeometry parameterAsExtentGeometry(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching name to a rectangular extent, and returns a geometry covering t...
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
QString name() const
Returns the name of the parameter.
Algorithm supports in-place editing.
QgsExpressionContextScope * createExpressionContextScope() const
Returns an expression context scope suitable for this source.
Encapsulates settings relating to a feature source input to a processing algorithm.
const QgsProcessingOutputDefinition * outputDefinition(const QString &name) const
Returns a matching output by name.
void prepareSource(const QVariantMap ¶meters, QgsProcessingContext &context)
Read the source from parameters and context and set it.
virtual bool isDestination() const
Returns true if this parameter represents a file or layer destination, e.g.
Base class for the definition of processing outputs.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
virtual QgsFeatureSink::SinkFlags sinkFlags() const
Returns the feature sink flags to be used for the output.
virtual QVariantMap processAlgorithm(const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)=0
Runs the algorithm using the specified parameters.
static QgsMeshLayer * parameterAsMeshLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition and value to a mesh layer.
bool isCanceled() const
Tells whether the operation has been canceled already.
bool addOutput(QgsProcessingOutputDefinition *outputDefinition)
Adds an output definition to the algorithm.
virtual bool canExecute(QString *errorMessage=nullptr) const
Returns true if the algorithm can execute.
QString parameterAsOutputLayer(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a output layer destination.
An input feature source (such as vector layers) parameter for processing algorithms.
virtual ~QgsProcessingAlgorithm()
This class represents a coordinate reference system (CRS).
virtual QString shortDescription() const
Returns an optional translated short description of the algorithm.
Base class for the definition of processing parameters.
virtual QgsProcessingFeatureSource::Flag sourceFlags() const
Returns the processing feature source flags to be used in the algorithm.
QVariant staticValue() const
Returns the current static value for the property.
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
void initAlgorithm(const QVariantMap &configuration=QVariantMap()) override
Initializes the algorithm using the specified configuration.
SourceType
Data source types enum.
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
const QgsCoordinateReferenceSystem & outputCrs
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
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.
bool supportInPlaceEdit(const QgsMapLayer *layer) const override
Checks whether this algorithm supports in-place editing on the given layer Default implementation for...
virtual void initParameters(const QVariantMap &configuration=QVariantMap())
Initializes any extra parameters added by the algorithm subclass.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
void setSupportsNonFileBasedOutput(bool supportsNonFileBasedOutput)
Sets whether the destination parameter supports non filed-based outputs, such as memory layers or dir...
static QString typeName()
Returns the type name for the parameter class.
void appendScopes(const QList< QgsExpressionContextScope *> &scopes)
Appends a list of scopes to the end of the context.
bool nextFeature(QgsFeature &f)
QString parameterAsCompatibleSourceLayerPath(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching name to a source vector layer file path of compatible format...
static QString parameterAsCompatibleSourceLayerPath(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path of compatible for...
Parameter is hidden and should not be shown to users.
bool addParameter(QgsProcessingParameterDefinition *parameterDefinition, bool createOutput=true)
Adds a parameter definition to the algorithm.
QList< double > parameterAsRange(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a range of values.
Represents a vector layer which manages a vector based data sets.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
Invalid (not set) property.
Contains information about the context in which a processing algorithm is executed.
QgsProcessingAlgorithm::Flags flags() const override
Returns the flags indicating how and when the algorithm operates and should be exposed to users...
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
virtual QgsProcessingOutputDefinition * toOutputDefinition() const =0
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Any vector layer with geometry.
QgsCoordinateReferenceSystem crs
virtual QgsCoordinateReferenceSystem outputCrs(const QgsCoordinateReferenceSystem &inputCrs) const
Maps the input source coordinate reference system (inputCrs) to a corresponding output CRS generated ...
virtual QgsProcessing::SourceType outputLayerType() const
Returns the layer type for layers generated by this algorithm, if this is possible to determine in ad...
QVariantMap run(const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback, bool *ok=nullptr, const QVariantMap &configuration=QVariantMap()) const
Executes the algorithm using the specified parameters.
virtual QString svgIconPath() const
Returns a path to an SVG version of the algorithm's icon.
QString parameterAsFileOutput(const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a file based output destination.
QgsProcessingAlgorithm * create(const QVariantMap &configuration=QVariantMap()) const SIP_THROW(QgsProcessingException)
Creates a copy of the algorithm, ready for execution.
int parameterAsEnum(const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a enum value.
static QString parameterAsFileOutput(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file based output destination.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
static QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.