18 #ifndef QGSPROCESSINGUTILS_H 19 #define QGSPROCESSINGUTILS_H 21 #include "qgis_core.h" 58 static QList< QgsRasterLayer * > compatibleRasterLayers(
QgsProject *project,
bool sort =
true );
74 static QList< QgsVectorLayer * > compatibleVectorLayers(
QgsProject *project,
75 const QList< int > &sourceTypes = QList< int >(),
87 static QList< QgsMapLayer * > compatibleLayers(
QgsProject *project,
bool sort =
true );
118 static QString normalizeLayerSource(
const QString &source );
123 static QString stringToPythonLiteral(
const QString &
string );
144 QString &destination,
149 const QVariantMap &createOptions = QVariantMap() )
SIP_FACTORY;
185 static QVariant generateIteratingDestination(
const QVariant &input,
const QVariant &
id,
QgsProcessingContext &context );
191 static QString tempFolder();
199 static QString generateTempFilename(
const QString &basename );
219 static QString convertToCompatibleFormat(
const QgsVectorLayer *layer,
220 bool selectedFeaturesOnly,
221 const QString &baseName,
222 const QStringList &compatibleFormats,
223 const QString &preferredFormat,
244 static QList<int> fieldNamesToIndices(
const QStringList &fieldNames,
const QgsFields &fields );
250 static QgsFields indicesToFields(
const QList<int> &indices,
const QgsFields &fields );
256 const QList< int > &sourceTypes = QList< int >() );
276 static QgsMapLayer *loadMapLayerFromString(
const QString &
string );
278 static void parseDestinationString( QString &destination, QString &providerKey, QString &uri, QString &layerName, QString &format, QMap<QString, QVariant> &options,
bool &useWriter );
280 friend class TestQgsProcessing;
298 FlagSkipGeometryValidityChecks = 1 << 1,
300 Q_DECLARE_FLAGS( Flags,
Flag )
326 QSet<QVariant>
uniqueValues(
int fieldIndex,
int limit = -1 )
const override;
340 bool mOwnsSource = false;
342 std::function<
void( const
QgsFeature & ) > mInvalidGeometryCallback;
343 std::function<
void( const
QgsFeature & ) > mTransformErrorCallback;
384 bool mOwnsSink =
false;
389 #endif // QGSPROCESSINGUTILS_H Wrapper for iterator of features from vector data provider or vector layer.
virtual QgsRectangle sourceExtent() const
Returns the extent of all geometries from the source.
A rectangle specified with double values.
Base class for all map layer types.
Base class for providing feedback from a processing algorithm.
virtual QgsFields fields() const =0
Returns the fields associated with features in the source.
A simple feature sink which proxies feature addition on to another feature sink.
QSet< QgsFeatureId > QgsFeatureIds
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QList< QgsFeature > QgsFeatureList
virtual QgsWkbTypes::Type wkbType() const =0
Returns the geometry type for features returned by this source.
An interface for objects which accept features via addFeature(s) methods.
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.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Abstract base class for processing algorithms.
Utility functions for use with processing classes.
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr) override
Adds a list of features to the sink.
Type
The WKB type describes the number of dimensions a geometry has.
virtual QVariant minimumValue(int fieldIndex) const
Returns the minimum value for an attribute column or an invalid variant in case of error...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Custom exception class for processing related exceptions.
Reads and writes project states.
Single scope for storing variables and functions for use within a QgsExpressionContext.
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
virtual QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const
Returns the set of unique values contained within the specified fieldIndex from this source...
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
QgsProxyFeatureSink subclass which reports feature addition errors to a QgsProcessingContext.
An interface for objects which provide features via a getFeatures method.
This class represents a coordinate reference system (CRS).
A storage object for map layers, in which the layers are owned by the store and have their lifetime b...
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr) override
Adds a single feature to the sink.
virtual QVariant maximumValue(int fieldIndex) const
Returns the maximum value for an attribute column or an invalid variant in case of error...
virtual QString sourceName() const =0
Returns a friendly display name for the source.
Represents a vector layer which manages a vector based data sets.
virtual QgsFeatureIds allFeatureIds() const
Returns a list of all feature IDs for features present in the source.
Contains information about the context in which a processing algorithm is executed.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const =0
Returns an iterator for the features in the source.
virtual long featureCount() const =0
Returns the number of features contained in the source, or -1 if the feature count is unknown...