18#ifndef QGSPROCESSINGUTILS_H
19#define QGSPROCESSINGUTILS_H
95 const QList< int > &sourceTypes = QList< int >(),
308 static QString normalizeLayerSource( const QString &source )
SIP_HOLDGIL;
317 static QString layerToStringIdentifier( const
QgsMapLayer *layer, const QString &layerName = QString() )
SIP_HOLDGIL;
325 static QString variantToPythonLiteral( const QVariant &value );
332 static QString stringToPythonLiteral( const QString &
string )
SIP_HOLDGIL;
357 const QVariantMap &createOptions = QVariantMap(),
358 const QStringList &datasourceOptions = QStringList(),
359 const QStringList &layerOptions = QStringList(),
407 static QVariant generateIteratingDestination( const QVariant &input, const QVariant &
id,
QgsProcessingContext &context );
421 static QString generateTempFilename( const QString &basename, const
QgsProcessingContext *context =
nullptr );
458 static QString convertToCompatibleFormat( const
QgsVectorLayer *layer,
459 bool selectedFeaturesOnly,
460 const QString &baseName,
461 const QStringList &compatibleFormats,
462 const QString &preferredFormat,
465 long long featureLimit = -1,
466 const QString &filterExpression = QString() );
502 static QString convertToCompatibleFormatAndLayerName( const
QgsVectorLayer *layer,
503 bool selectedFeaturesOnly,
504 const QString &baseName,
505 const QStringList &compatibleFormats,
506 const QString &preferredFormat,
510 long long featureLimit = -1,
511 const QString &filterExpression = QString() );
530 static QList<
int> fieldNamesToIndices( const QStringList &fieldNames, const
QgsFields &fields )
SIP_HOLDGIL;
550 static QString defaultVectorExtension();
564 static QString defaultRasterExtension();
577 static QString defaultPointCloudExtension();
590 static QString defaultVectorTileExtension();
598 static QVariantMap removePointerValuesFromMap( const QVariantMap &map );
607 static QVariantMap preprocessQgisProcessParameters( const QVariantMap ¶meters,
bool &ok, QString &error );
617 static QString resolveDefaultEncoding( const QString &defaultEncoding =
"System" );
628 const QList<
int > &sourceTypes = QList<
int >() );
642 template< typename T> static QList< T * > compatibleMapLayers(
QgsProject *project,
bool sort = true );
676 Q_DECL_DEPRECATED static
QgsMapLayer *loadMapLayerFromString( const QString &
string, LayerHint typeHint = LayerHint::UnknownType )
SIP_DEPRECATED ;
678 static
void parseDestinationString( QString &destination, QString &providerKey, QString &uri, QString &layerName, QString &format, QMap<QString, QVariant> &options,
bool &useWriter, QString &extension );
708 long long featureLimit = -1,
const QString &filterExpression = QString() );
727 QSet<QVariant>
uniqueValues(
int fieldIndex,
int limit = -1 )
const override;
758 bool mOwnsSource =
false;
767 std::function< void(
const QgsFeature & ) > mInvalidGeometryCallback;
768 std::function< void(
const QgsFeature & ) > mTransformErrorCallback;
770 std::function< void(
const QgsFeature & ) > mInvalidGeometryCallbackSkip;
771 std::function< void(
const QgsFeature & ) > mInvalidGeometryCallbackAbort;
773 long long mFeatureLimit = -1;
774 QString mFilterExpression;
826 bool mOwnsSink =
false;
SpatialIndexPresence
Enumeration of spatial index presence states.
@ Unknown
Spatial index presence cannot be determined, index may or may not exist.
FeatureAvailability
Possible return value for QgsFeatureSource::hasFeatures() to determine if a source is empty.
InvalidGeometryCheck
Methods for handling of features with invalid geometries.
@ NoCheck
No invalid geometry checking.
WkbType
The WKB type describes the number of dimensions a geometry has.
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
Represents a map layer containing a set of georeferenced annotations, e.g.
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Wrapper for iterator of features from vector data provider or vector layer.
Wraps a request for features to a vector layer (or directly its vector data provider).
An interface for objects which accept features via addFeature(s) methods.
QFlags< SinkFlag > SinkFlags
An interface for objects which provide features via a getFeatures method.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Container of fields for a vector layer.
A storage object for map layers, in which the layers are owned by the store and have their lifetime b...
Base class for all map layer types.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Base class for plugin layers.
Represents a map layer supporting display of point clouds.
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
void finalize() override
Finalizes the sink, flushing any buffered features to the destination.
QgsProcessingFeatureSink(QgsFeatureSink *originalSink, const QString &sinkName, QgsProcessingContext &context, bool ownsOriginalSink=false)
Constructor for QgsProcessingFeatureSink, accepting an original feature sink originalSink and process...
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a single feature to the sink.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
QgsRectangle sourceExtent() const override
Returns the extent of all geometries from the source.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const override
Returns the set of unique values contained within the specified fieldIndex from this source.
QgsExpressionContextScope * createExpressionContextScope() const
Returns an expression context scope suitable for this source.
QgsProcessingFeatureSource(QgsFeatureSource *originalSource, const QgsProcessingContext &context, bool ownsOriginalSource=false, long long featureLimit=-1, const QString &filterExpression=QString())
Constructor for QgsProcessingFeatureSource, accepting an original feature source originalSource and p...
void setInvalidGeometryCheck(Qgis::InvalidGeometryCheck method)
Overrides the default geometry check method for the source.
Qgis::InvalidGeometryCheck invalidGeometryCheck() const
Returns the geometry check method for the source.
QVariant maximumValue(int fieldIndex) const override
Returns the maximum value for an attribute column or an invalid variant in case of error.
QgsCoordinateReferenceSystem sourceCrs() const override
Returns the coordinate reference system for features in the source.
Qgis::WkbType wkbType() const override
Returns the geometry type for features returned by this source.
QVariant minimumValue(int fieldIndex) const override
Returns the minimum value for an attribute column or an invalid variant in case of error.
long long featureCount() const override
Returns the number of features contained in the source, or -1 if the feature count is unknown.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request, Qgis::ProcessingFeatureSourceFlags flags) const
Returns an iterator for the features in the source, respecting the supplied feature flags.
Qgis::FeatureAvailability hasFeatures() const override
Determines if there are any features available in the source.
QString sourceName() const override
Returns a friendly display name for the source.
QgsFeatureIds allFeatureIds() const override
Returns a list of all feature IDs for features present in the source.
Qgis::SpatialIndexPresence hasSpatialIndex() const override
Returns an enum value representing the presence of a valid spatial index on the source,...
QgsFields fields() const override
Returns the fields associated with features in the source.
Base class for providing feedback from a processing algorithm.
Utility functions for use with processing classes.
static QList< QgsTiledSceneLayer * > compatibleTiledSceneLayers(QgsProject *project, bool sort=true)
Returns a list of tiled scene layers from a project which are compatible with the processing framewor...
friend class TestQgsProcessing
static QList< QgsAnnotationLayer * > compatibleAnnotationLayers(QgsProject *project, bool sort=true)
Returns a list of annotation layers from a project which are compatible with the processing framework...
static QString encodeProviderKeyAndUri(const QString &providerKey, const QString &uri)
Encodes a provider key and layer uri to a single string, for use with decodeProviderKeyAndUri().
LayerHint
Layer type hints.
@ UnknownType
Unknown layer type.
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.
static QList< QgsPluginLayer * > compatiblePluginLayers(QgsProject *project, bool sort=true)
Returns a list of plugin layers from a project which are compatible with the processing framework.
static QList< QgsVectorLayer * > compatibleVectorLayers(QgsProject *project, const QList< int > &sourceTypes=QList< int >(), bool sort=true)
Returns a list of vector layers from a project which are compatible with the processing framework.
static bool decodeProviderKeyAndUri(const QString &string, QString &providerKey, QString &uri)
Decodes a provider key and layer uri from an encoded string, for use with encodeProviderKeyAndUri().
static QList< QgsVectorTileLayer * > compatibleVectorTileLayers(QgsProject *project, bool sort=true)
Returns a list of vector tile layers from a project which are compatible with the processing framewor...
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.
friend class QgsProcessingProvider
static QList< QgsPointCloudLayer * > compatiblePointCloudLayers(QgsProject *project, bool sort=true)
Returns a list of point cloud layers from a project which are compatible with the processing framewor...
static QList< QgsMeshLayer * > compatibleMeshLayers(QgsProject *project, bool sort=true)
Returns a list of mesh layers from a project which are compatible with the processing framework.
Contains enumerations and other constants for use in processing algorithms and parameters.
QFlags< LayerOptionsFlag > LayerOptionsFlags
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsProxyFeatureSink(QgsFeatureSink *sink)
Constructs a new QgsProxyFeatureSink which forwards features onto a destination sink.
Represents a raster layer.
A rectangle specified with double values.
Defines the parameters used to remap features when creating a QgsRemappingProxyFeatureSink.
Represents a map layer supporting display of tiled scene objects.
Represents a vector layer which manages a vector based dataset.
Implements a map layer that is dedicated to rendering of vector tiles.
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
#define SIP_MONKEYPATCH_SCOPEENUM
#define SIP_THROW(name,...)
QList< QgsFeature > QgsFeatureList
QSet< QgsFeatureId > QgsFeatureIds