QgsProcessingFeatureSource class

QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource, modifying results according to the settings in a QgsProcessingContext.

Base classes

class QgsFeatureSource
An interface for objects which provide features via a getFeatures method.

Public types

enum Flag { FlagSkipGeometryValidityChecks = 1 << 1 }
Flags controlling how QgsProcessingFeatureSource fetches features.

Constructors, destructors, conversion operators

QgsProcessingFeatureSource(QgsFeatureSource* originalSource, const QgsProcessingContext& context, bool ownsOriginalSource = false)
Constructor for QgsProcessingFeatureSource, accepting an original feature source originalSource and processing context.

Public functions

auto allFeatureIds() const -> QgsFeatureIds override
Returns a list of all feature IDs for features present in the source.
auto createExpressionContextScope() const -> QgsExpressionContextScope*
Returns an expression context scope suitable for this source.
auto featureCount() const -> long override
Returns the number of features contained in the source, or -1 if the feature count is unknown.
auto fields() const -> QgsFields override
Returns the fields associated with features in the source.
auto getFeatures(const QgsFeatureRequest& request, Flags flags) const -> QgsFeatureIterator
Returns an iterator for the features in the source, respecting the supplied feature flags.
auto getFeatures(const QgsFeatureRequest& request = QgsFeatureRequest()) const -> QgsFeatureIterator override
Returns an iterator for the features in the source.
auto hasFeatures() const -> QgsFeatureSource::FeatureAvailability override
Determines if there are any features available in the source.
auto maximumValue(int fieldIndex) const -> QVariant override
Returns the maximum value for an attribute column or an invalid variant in case of error.
auto minimumValue(int fieldIndex) const -> QVariant override
Returns the minimum value for an attribute column or an invalid variant in case of error.
auto sourceCrs() const -> QgsCoordinateReferenceSystem override
Returns the coordinate reference system for features in the source.
auto sourceExtent() const -> QgsRectangle override
Returns the extent of all geometries from the source.
auto sourceName() const -> QString override
Returns a friendly display name for the source.
auto uniqueValues(int fieldIndex, int limit = -1) const -> QSet<QVariant> override
Returns the set of unique values contained within the specified fieldIndex from this source.
auto wkbType() const -> QgsWkbTypes::Type override
Returns the geometry type for features returned by this source.

Enum documentation

enum QgsProcessingFeatureSource::Flag

Flags controlling how QgsProcessingFeatureSource fetches features.

Enumerators
FlagSkipGeometryValidityChecks

Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always require invalid geometries, regardless of any user settings (e.g. "repair geometry" type algorithms).

Function documentation

QgsProcessingFeatureSource::QgsProcessingFeatureSource(QgsFeatureSource* originalSource, const QgsProcessingContext& context, bool ownsOriginalSource = false)

Constructor for QgsProcessingFeatureSource, accepting an original feature source originalSource and processing context.

Ownership of originalSource is dictated by ownsOriginalSource. If ownsOriginalSource is false, ownership is not transferred, and callers must ensure that originalSource exists for the lifetime of this object. If ownsOriginalSource is true, then this object will take ownership of originalSource.

QgsFeatureIterator QgsProcessingFeatureSource::getFeatures(const QgsFeatureRequest& request, Flags flags) const

Returns an iterator for the features in the source, respecting the supplied feature flags.

An optional request can be used to optimise the returned iterator, eg by restricting the returned attributes or geometry.

QgsFeatureIterator QgsProcessingFeatureSource::getFeatures(const QgsFeatureRequest& request = QgsFeatureRequest()) const override

Returns an iterator for the features in the source.

An optional request can be used to optimise the returned iterator, eg by restricting the returned attributes or geometry.

QgsFeatureSource::FeatureAvailability QgsProcessingFeatureSource::hasFeatures() const override

Determines if there are any features available in the source.

QVariant QgsProcessingFeatureSource::maximumValue(int fieldIndex) const override

Returns the maximum value for an attribute column or an invalid variant in case of error.

The base class implementation uses a non-optimised approach of looping through all features in the source.

QVariant QgsProcessingFeatureSource::minimumValue(int fieldIndex) const override

Returns the minimum value for an attribute column or an invalid variant in case of error.

The base class implementation uses a non-optimised approach of looping through all features in the source.

QgsRectangle QgsProcessingFeatureSource::sourceExtent() const override

Returns the extent of all geometries from the source.

The base class implementation uses a non-optimised approach of looping through all features in the source.

QString QgsProcessingFeatureSource::sourceName() const override

Returns a friendly display name for the source.

The returned value can be an empty string.

QSet<QVariant> QgsProcessingFeatureSource::uniqueValues(int fieldIndex, int limit = -1) const override

Returns the set of unique values contained within the specified fieldIndex from this source.

If specified, the limit option can be used to limit the number of returned values. The base class implementation uses a non-optimised approach of looping through all features in the source.