QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsFeatureSource Class Referenceabstract

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

#include <qgsfeaturesource.h>

Inheritance diagram for QgsFeatureSource:
Inheritance graph
[legend]

Public Member Functions

virtual ~QgsFeatureSource ()=default
 
virtual QgsFeatureIds allFeatureIds () const
 Returns a list of all feature IDs for features present in the source.
 
virtual long long featureCount () const =0
 Returns the number of features contained in the source, or -1 if the feature count is unknown.
 
virtual QgsFields fields () const =0
 Returns the fields associated with features in the source.
 
virtual QgsFeatureIterator getFeatures (const QgsFeatureRequest &request=QgsFeatureRequest()) const =0
 Returns an iterator for the features in the source.
 
virtual Qgis::FeatureAvailability hasFeatures () const
 Determines if there are any features available in the source.
 
virtual Qgis::SpatialIndexPresence hasSpatialIndex () const
 Returns an enum value representing the presence of a valid spatial index on the source, if it can be determined.
 
QgsVectorLayermaterialize (const QgsFeatureRequest &request, QgsFeedback *feedback=nullptr)
 Materializes a request (query) made against this feature source, by running it over the source and returning a new memory based vector layer containing the result.
 
virtual QVariant maximumValue (int fieldIndex) const
 Returns the maximum value for an attribute column or an invalid variant in case of error.
 
virtual QVariant minimumValue (int fieldIndex) const
 Returns the minimum value for an attribute column or an invalid variant in case of error.
 
virtual QgsCoordinateReferenceSystem sourceCrs () const =0
 Returns the coordinate reference system for features in the source.
 
virtual QgsRectangle sourceExtent () const
 Returns the extent of all geometries from the source.
 
virtual QgsBox3D sourceExtent3D () const
 Returns the 3D extent of all geometries from the source.
 
virtual QString sourceName () const =0
 Returns a friendly display name for the source.
 
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 Qgis::WkbType wkbType () const =0
 Returns the geometry type for features returned by this source.
 

Detailed Description

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

Definition at line 36 of file qgsfeaturesource.h.

Constructor & Destructor Documentation

◆ ~QgsFeatureSource()

virtual QgsFeatureSource::~QgsFeatureSource ( )
virtualdefault

Member Function Documentation

◆ allFeatureIds()

QgsFeatureIds QgsFeatureSource::allFeatureIds ( ) const
virtual

Returns a list of all feature IDs for features present in the source.

Reimplemented in QgsProcessingFeatureSource.

Definition at line 120 of file qgsfeaturesource.cpp.

◆ featureCount()

virtual long long QgsFeatureSource::featureCount ( ) const
pure virtual

Returns the number of features contained in the source, or -1 if the feature count is unknown.

Implemented in QgsVectorLayer, QgsProcessingFeatureSource, QgsVectorLayerSelectedFeatureSource, and QgsVectorDataProvider.

◆ fields()

virtual QgsFields QgsFeatureSource::fields ( ) const
pure virtual

Returns the fields associated with features in the source.

Implemented in QgsVectorLayer, QgsProcessingFeatureSource, QgsVectorLayerSelectedFeatureSource, and QgsVectorDataProvider.

◆ getFeatures()

virtual QgsFeatureIterator QgsFeatureSource::getFeatures ( const QgsFeatureRequest request = QgsFeatureRequest()) const
pure virtual

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.

Implemented in QgsVectorLayer, QgsProcessingFeatureSource, QgsVectorLayerSelectedFeatureSource, and QgsVectorDataProvider.

◆ hasFeatures()

Qgis::FeatureAvailability QgsFeatureSource::hasFeatures ( ) const
virtual

Determines if there are any features available in the source.

Since
QGIS 3.2

Reimplemented in QgsVectorLayer, QgsProcessingFeatureSource, and QgsVectorDataProvider.

Definition at line 26 of file qgsfeaturesource.cpp.

◆ hasSpatialIndex()

Qgis::SpatialIndexPresence QgsFeatureSource::hasSpatialIndex ( ) const
virtual

Returns an enum value representing the presence of a valid spatial index on the source, if it can be determined.

If QgsFeatureSource::SpatialIndexUnknown is returned then the presence of an index cannot be determined.

Since
QGIS 3.10.1

Reimplemented in QgsProcessingFeatureSource, and QgsVectorLayerSelectedFeatureSource.

Definition at line 195 of file qgsfeaturesource.cpp.

◆ materialize()

QgsVectorLayer * QgsFeatureSource::materialize ( const QgsFeatureRequest request,
QgsFeedback feedback = nullptr 
)

Materializes a request (query) made against this feature source, by running it over the source and returning a new memory based vector layer containing the result.

All settings from feature request will be honored.

If a subset of attributes has been set for the request, then only those selected fields will be present in the output layer.

The CRS for the output layer will match the input layer, unless QgsFeatureRequest::setDestinationCrs() has been called with a valid QgsCoordinateReferenceSystem. In this case the output layer will match the QgsFeatureRequest::destinationCrs() CRS.

The returned layer WKB type will match wkbType(), unless the QgsFeatureRequest::NoGeometry flag is set on the request. In that case the returned layer will not be a spatial layer.

An optional feedback argument can be used to cancel the materialization before it has fully completed.

The returned value is a new instance and the caller takes responsibility for its ownership.

Definition at line 137 of file qgsfeaturesource.cpp.

◆ maximumValue()

QVariant QgsFeatureSource::maximumValue ( int  fieldIndex) const
virtual

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.

See also
minimumValue()
uniqueValues()

Reimplemented in QgsProcessingFeatureSource, QgsVectorLayer, and QgsVectorDataProvider.

Definition at line 75 of file qgsfeaturesource.cpp.

◆ minimumValue()

QVariant QgsFeatureSource::minimumValue ( int  fieldIndex) const
virtual

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.

See also
maximumValue()
uniqueValues()

Reimplemented in QgsProcessingFeatureSource, QgsVectorLayer, and QgsVectorDataProvider.

Definition at line 52 of file qgsfeaturesource.cpp.

◆ sourceCrs()

virtual QgsCoordinateReferenceSystem QgsFeatureSource::sourceCrs ( ) const
pure virtual

Returns the coordinate reference system for features in the source.

Implemented in QgsVectorLayer, QgsProcessingFeatureSource, QgsVectorDataProvider, and QgsVectorLayerSelectedFeatureSource.

◆ sourceExtent()

QgsRectangle QgsFeatureSource::sourceExtent ( ) const
virtual

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.

Reimplemented in QgsVectorLayer, QgsProcessingFeatureSource, and QgsVectorDataProvider.

Definition at line 98 of file qgsfeaturesource.cpp.

◆ sourceExtent3D()

QgsBox3D QgsFeatureSource::sourceExtent3D ( ) const
virtual

Returns the 3D extent of all geometries from the source.

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

Since
QGIS 3.36

Reimplemented in QgsVectorLayer, and QgsVectorDataProvider.

Definition at line 103 of file qgsfeaturesource.cpp.

◆ sourceName()

virtual QString QgsFeatureSource::sourceName ( ) const
pure virtual

Returns a friendly display name for the source.

The returned value can be an empty string.

Implemented in QgsVectorLayer, QgsProcessingFeatureSource, QgsVectorDataProvider, and QgsVectorLayerSelectedFeatureSource.

◆ uniqueValues()

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

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.

See also
minimumValue()
maximumValue()

Reimplemented in QgsVectorLayer, and QgsProcessingFeatureSource.

Definition at line 31 of file qgsfeaturesource.cpp.

◆ wkbType()

virtual Qgis::WkbType QgsFeatureSource::wkbType ( ) const
pure virtual

Returns the geometry type for features returned by this source.

Implemented in QgsVectorLayer, QgsProcessingFeatureSource, QgsVectorLayerSelectedFeatureSource, and QgsVectorDataProvider.


The documentation for this class was generated from the following files: