QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
31 qDeleteAll( mAlgorithms );
46 return QgsProcessingProvider::Flags();
71 qDeleteAll( mAlgorithms );
82 return mAlgorithms.values();
87 return mAlgorithms.value(
name );
125 if ( outputPath.isEmpty() )
133 error = tr(
"Missing parameter value %1" ).arg( parameter->
description() );
141 if ( outputPath.startsWith( QLatin1String(
"memory:" ) ) )
145 error = tr(
"This algorithm only supports disk-based outputs" );
154 QMap<QString, QVariant> options;
155 bool useWriter =
false;
158 QgsProcessingUtils::parseDestinationString( outputPath, providerKey, uri, layerName, format, options, useWriter, extension );
160 if ( providerKey != QLatin1String(
"ogr" ) )
164 error = tr(
"This algorithm only supports disk-based outputs" );
172 error = tr(
"“.%1” files are not supported as outputs for this algorithm" ).arg( extension );
179 QFileInfo fi( outputPath );
180 const QString extension = fi.completeSuffix();
183 error = tr(
"“.%1” files are not supported as outputs for this algorithm" ).arg( extension );
200 if ( supportedExtensions.contains( userDefault, Qt::CaseInsensitive ) )
205 else if ( !supportedExtensions.empty() )
207 return supportedExtensions.at( 0 );
213 return hasGeometry ? QStringLiteral(
"shp" ) : QStringLiteral(
"dbf" );
223 if ( supportedExtensions.contains( userDefault, Qt::CaseInsensitive ) )
228 else if ( !supportedExtensions.empty() )
230 return supportedExtensions.at( 0 );
235 return QStringLiteral(
"tif" );
virtual bool isSupportedOutputValue(const QVariant &outputValue, const QgsProcessingDestinationParameter *parameter, QgsProcessingContext &context, QString &error) const
Returns true if the specified outputValue is of a supported file format for the given destination par...
void refreshAlgorithms()
Refreshes the algorithms available from the provider, causing it to re-populate with all associated a...
static QString defaultVectorExtension()
Returns the default vector extension to use, in the absence of all other constraints (e....
static QString typeName()
Returns the type name for the parameter class.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
QString description() const
Returns the description for the parameter.
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 allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
Flags flags() const
Returns any flags associated with the parameter.
virtual QStringList supportedOutputTableExtensions() const
Returns a list of the table (geometry-less vector layers) file extensions supported by this provider.
static QString typeName()
Returns the type name for the parameter class.
virtual QIcon icon() const
Returns an icon for the provider.
This class is a composition of two QSettings instances:
const QgsProcessingAlgorithm * algorithm(const QString &name) const
Returns the matching algorithm by name, or nullptr if no matching algorithm is contained by this prov...
virtual Flags flags() const
Returns the flags indicating how and when the provider operates and should be exposed to users.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
virtual QString versionInfo() const
Returns a version information string for the provider, or an empty string if this is not applicable (...
static QString typeName()
Returns the type name for the parameter class.
Base class for all parameter definitions which represent file or layer destinations,...
virtual QString longName() const
Returns the longer version of the provider name, which can include extra details such as version numb...
bool addAlgorithm(QgsProcessingAlgorithm *algorithm)
Adds an algorithm to the provider.
virtual QString name() const =0
Returns the provider name, which is used to describe the provider within the GUI.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this provider.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
virtual QString name() const =0
Returns the algorithm name, used for identifying the algorithm.
Contains information about the context in which a processing algorithm is executed.
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported by this provider.
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
virtual QString svgIconPath() const
Returns a path to an SVG version of the provider's icon.
virtual void loadAlgorithms()=0
Loads all algorithms belonging to this provider.
virtual QString helpId() const
Returns the provider help id string, used for creating QgsHelp urls for algorithms belong to this pro...
void setProvider(QgsProcessingProvider *provider)
Associates this algorithm with its provider.
Abstract base class for processing algorithms.
virtual bool isActive() const
Returns true if the provider is active and able to run algorithms.
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
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).
~QgsProcessingProvider() override
QList< const QgsProcessingAlgorithm * > algorithms() const
Returns a list of algorithms supplied by this provider.
void algorithmsLoaded()
Emitted when the provider has loaded (or refreshed) its list of available algorithms.
virtual QString type() const =0
Unique parameter type name.
QgsProcessingProvider(QObject *parent=nullptr)
Constructor for QgsProcessingProvider.
@ FlagOptional
Parameter is optional.
virtual QString defaultVectorFileExtension(bool hasGeometry=true) const
Returns the default file extension to use for vector outputs created by the provider.
static QString defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e....
virtual bool supportsNonFileBasedOutput() const
Returns true if the provider supports non-file based outputs (such as memory layers or direct databas...
virtual QString defaultRasterFileExtension() const
Returns the default file extension to use for raster outputs created by the provider.
virtual void initAlgorithm(const QVariantMap &configuration=QVariantMap())=0
Initializes the algorithm using the specified configuration.