18 #ifndef QGSPROCESSINGUTILS_H 19 #define QGSPROCESSINGUTILS_H 21 #include "qgis_core.h" 61 static QList< QgsRasterLayer * > compatibleRasterLayers(
QgsProject *project,
bool sort =
true );
78 static QList< QgsVectorLayer * > compatibleVectorLayers(
QgsProject *project,
79 const QList< int > &sourceTypes = QList< int >(),
95 static QList<QgsMeshLayer *> compatibleMeshLayers(
QgsProject *project,
bool sort =
true );
106 static QList< QgsMapLayer * > compatibleLayers(
QgsProject *project,
bool sort =
true );
151 static QString normalizeLayerSource(
const QString &source );
159 static QString variantToPythonLiteral(
const QVariant &value );
166 static QString stringToPythonLiteral(
const QString &
string );
191 const QVariantMap &createOptions = QVariantMap(),
192 QgsFeatureSink::SinkFlags sinkFlags =
nullptr )
SIP_FACTORY;
238 static QVariant generateIteratingDestination(
const QVariant &input,
const QVariant &
id,
QgsProcessingContext &context );
244 static QString tempFolder();
252 static QString generateTempFilename(
const QString &basename );
277 static QString convertToCompatibleFormat(
const QgsVectorLayer *layer,
278 bool selectedFeaturesOnly,
279 const QString &baseName,
280 const QStringList &compatibleFormats,
281 const QString &preferredFormat,
315 static QString convertToCompatibleFormatAndLayerName(
const QgsVectorLayer *layer,
316 bool selectedFeaturesOnly,
317 const QString &baseName,
318 const QStringList &compatibleFormats,
319 const QString &preferredFormat,
341 static QList<int> fieldNamesToIndices(
const QStringList &fieldNames,
const QgsFields &fields );
347 static QgsFields indicesToFields(
const QList<int> &indices,
const QgsFields &fields );
359 static QString defaultVectorExtension();
371 static QString defaultRasterExtension();
377 const QList< int > &sourceTypes = QList< int >() );
413 static void parseDestinationString( QString &destination, QString &providerKey, QString &uri, QString &layerName, QString &format, QMap<QString, QVariant> &options,
bool &useWriter, QString &extension );
415 friend class TestQgsProcessing;
434 FlagSkipGeometryValidityChecks = 1 << 1,
436 Q_DECLARE_FLAGS( Flags,
Flag )
462 long featureCount()
const override;
463 QString sourceName()
const override;
464 QSet<QVariant> uniqueValues(
int fieldIndex,
int limit = -1 )
const override;
465 QVariant minimumValue(
int fieldIndex )
const override;
466 QVariant maximumValue(
int fieldIndex )
const override;
478 bool mOwnsSource = false;
480 std::function<
void( const
QgsFeature & ) > mInvalidGeometryCallback;
481 std::function<
void( const
QgsFeature & ) > mTransformErrorCallback;
514 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags =
nullptr )
override;
515 bool addFeatures(
QgsFeatureList &features, QgsFeatureSink::Flags flags =
nullptr )
override;
516 bool addFeatures(
QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags =
nullptr )
override;
522 bool mOwnsSink =
false;
527 #endif // QGSPROCESSINGUTILS_H Wrapper for iterator of features from vector data provider or vector layer.
A rectangle specified with double values.
Base class for all map layer types.
QSet< QgsFeatureId > QgsFeatureIds
Base class for providing feedback from a processing algorithm.
A simple feature sink which proxies feature addition on to another feature sink.
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
LayerHint
Layer type hints.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QList< QgsFeature > QgsFeatureList
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.
#define SIP_MONKEYPATCH_SCOPEENUM
Abstract base class for processing providers.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
const QgsCoordinateReferenceSystem & crs
Abstract base class for processing algorithms.
Utility functions for use with processing classes.
Type
The WKB type describes the number of dimensions a geometry has.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Custom exception class for processing related exceptions.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Contains information about the context in which a coordinate transform is executed.
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
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).
Represents a mesh layer supporting display of data on structured or unstructured meshes.
A storage object for map layers, in which the layers are owned by the store and have their lifetime b...
Represents a vector layer which manages a vector based data sets.
Contains information about the context in which a processing algorithm is executed.