QGIS API Documentation
3.0.2-Girona (307d082)
|
Utility functions for use with processing classes. More...
#include <qgsprocessingutils.h>
Static Public Member Functions | |
static QgsFields | combineFields (const QgsFields &fieldsA, const QgsFields &fieldsB) |
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner). More... | |
static QgsRectangle | combineLayerExtents (const QList< QgsMapLayer *> &layers, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) |
Combines the extent of several map layers. More... | |
static QList< QgsMapLayer *> | compatibleLayers (QgsProject *project, bool sort=true) |
Returns a list of map layers from a project which are compatible with the processing framework. More... | |
static QList< QgsRasterLayer *> | compatibleRasterLayers (QgsProject *project, bool sort=true) |
Returns a list of raster layers from a project which are compatible with the processing framework. More... | |
static QList< QgsVectorLayer *> | compatibleVectorLayers (QgsProject *project, const QList< QgsWkbTypes::GeometryType > &geometryTypes=QList< QgsWkbTypes::GeometryType >(), bool sort=true) |
Returns a list of vector layers from a project which are compatible with the processing framework. More... | |
static QString | convertToCompatibleFormat (const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback) |
Converts a source vector layer to a file path to a vector layer of compatible format. More... | |
static QgsFeatureSink * | createFeatureSink (QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap()) |
Creates a feature sink ready for adding features. More... | |
static void | createFeatureSinkPython (QgsFeatureSink **sink, QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap()) |
Creates a feature sink ready for adding features. More... | |
static QString | formatHelpMapAsHtml (const QVariantMap &map, const QgsProcessingAlgorithm *algorithm) |
Returns a HTML formatted version of the help text encoded in a variant map for a specified algorithm. More... | |
static QVariant | generateIteratingDestination (const QVariant &input, const QVariant &id, QgsProcessingContext &context) |
Converts an input parameter value for use in source iterating mode, where one individual sink is created per input feature. More... | |
static QString | generateTempFilename (const QString &basename) |
Returns a temporary filename for a given file, putting it into a temporary folder (creating that folder in the process), but not changing the basename. More... | |
static QgsMapLayer * | mapLayerFromString (const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true) |
Interprets a string as a map layer within the supplied context. More... | |
static QString | normalizeLayerSource (const QString &source) |
Normalizes a layer source string for safe comparison across different operating system environments. More... | |
static QString | stringToPythonLiteral (const QString &string) |
Converts a string to a Python string literal. More... | |
static QString | tempFolder () |
Returns a session specific processing temporary folder for use in processing algorithms. More... | |
static QgsProcessingFeatureSource * | variantToSource (const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant()) |
Converts a variant value to a new feature source. More... | |
Friends | |
class | TestQgsProcessing |
Utility functions for use with processing classes.
Definition at line 43 of file qgsprocessingutils.h.
|
static |
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
Duplicate field names will be altered to "name_2", "name_3", etc, finding the first non-duplicate name.
Definition at line 614 of file qgsprocessingutils.cpp.
|
static |
Combines the extent of several map layers.
If specified, the target crs will be used to transform the layer's extent to the desired output reference system.
Definition at line 450 of file qgsprocessingutils.cpp.
|
static |
Returns a list of map layers from a project which are compatible with the processing framework.
If the sort argument is true then the layers will be sorted by their QgsMapLayer::name() value.
Definition at line 76 of file qgsprocessingutils.cpp.
|
static |
Returns a list of raster layers from a project which are compatible with the processing framework.
If the sort argument is true then the layers will be sorted by their QgsMapLayer::name() value.
Definition at line 32 of file qgsprocessingutils.cpp.
|
static |
Returns a list of vector layers from a project which are compatible with the processing framework.
If the geometryTypes list is non-empty then the layers will be sorted so that only layers with geometry types included in the list will be returned. Leaving the geometryTypes list empty will cause all vector layers, regardless of their geometry type, to be returned.
If the sort argument is true then the layers will be sorted by their QgsMapLayer::name() value.
Definition at line 54 of file qgsprocessingutils.cpp.
|
static |
Converts a source vector layer to a file path to a vector layer of compatible format.
If the specified layer is not of the format listed in the compatibleFormats argument, then the layer will first be exported to a compatible format in a temporary location using baseName. The function will then return the path to that temporary file.
compatibleFormats should consist entirely of lowercase file extensions, e.g. 'shp'.
The preferredFormat argument is used to specify to desired file extension to use when a temporary layer export is required. This defaults to shapefiles.
Definition at line 578 of file qgsprocessingutils.cpp.
|
static |
Creates a feature sink ready for adding features.
The destination specifies a destination URI for the resultant layer. It may be updated in place to reflect the actual destination for the layer.
Sink parameters such as desired encoding, fields, geometryType and crs must be specified.
The createOptions map can be used to specify additional sink creation options, which are passed to the underlying provider when creating new layers. Known options also include 'fileEncoding', which is used to specify a file encoding to use for created files. If 'fileEncoding' is not specified, the default encoding from the context will be used.
If a layer is created for the feature sink, the layer will automatically be added to the context's temporary layer store.
The caller takes responsibility for deleting the returned sink.
Definition at line 363 of file qgsprocessingutils.cpp.
|
static |
Creates a feature sink ready for adding features.
The destination specifies a destination URI for the resultant layer. It may be updated in place to reflect the actual destination for the layer.
Sink parameters such as desired fields, geometryType and crs must be specified.
The createOptions map can be used to specify additional sink creation options, which are passed to the underlying provider when creating new layers. Known options also include 'fileEncoding', which is used to specify a file encoding to use for created files. If 'fileEncoding' is not specified, the default encoding from the context will be used.
If a layer is created for the feature sink, the layer will automatically be added to the context's temporary layer store.
Definition at line 444 of file qgsprocessingutils.cpp.
|
static |
Returns a HTML formatted version of the help text encoded in a variant map for a specified algorithm.
Definition at line 546 of file qgsprocessingutils.cpp.
|
static |
Converts an input parameter value for use in source iterating mode, where one individual sink is created per input feature.
The id parameter represents the unique ID for this output, which is embedded into the resulting parameter value.
Definition at line 484 of file qgsprocessingutils.cpp.
|
static |
Returns a temporary filename for a given file, putting it into a temporary folder (creating that folder in the process), but not changing the basename.
Definition at line 534 of file qgsprocessingutils.cpp.
|
static |
Interprets a string as a map layer within the supplied context.
The method will attempt to load a layer matching the passed string. E.g. if the string matches a layer ID or name within the context's project or temporary layer store then this layer will be returned. If the string is a file path and allowLoadingNewLayers is true, then the layer at this file path will be loaded and added to the context's temporary layer store. Ownership of the layer remains with the context or the context's current project.
Definition at line 196 of file qgsprocessingutils.cpp.
|
static |
Normalizes a layer source string for safe comparison across different operating system environments.
Definition at line 295 of file qgsprocessingutils.cpp.
|
static |
Converts a string to a Python string literal.
E.g. by replacing ' with \'.
Definition at line 302 of file qgsprocessingutils.cpp.
|
static |
Returns a session specific processing temporary folder for use in processing algorithms.
Definition at line 518 of file qgsprocessingutils.cpp.
|
static |
Converts a variant value to a new feature source.
Sources will either be taken from context's active project, or loaded from external sources and stored temporarily in the context.
The optional fallbackValue can be used to specify a "default" value which is used if value cannot be successfully converted to a source.
This function creates a new object and the caller takes responsibility for deleting the returned object.
Definition at line 229 of file qgsprocessingutils.cpp.
|
friend |
Definition at line 272 of file qgsprocessingutils.h.