QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
An interface for objects which provide features via a getFeatures method. More...
#include <qgsfeaturesource.h>
Public Types | |
enum | FeatureAvailability { NoFeaturesAvailable, FeaturesAvailable, FeaturesMaybeAvailable } |
Possible return value for hasFeatures() to determine if a source is empty. More... | |
enum | SpatialIndexPresence { SpatialIndexUnknown = 0, SpatialIndexNotPresent = 1, SpatialIndexPresent = 2 } |
Enumeration of spatial index presence states. More... | |
Public Member Functions | |
virtual | ~QgsFeatureSource ()=default |
virtual QgsFeatureIds | allFeatureIds () const |
Returns a list of all feature IDs for features present in the source. More... | |
virtual long | featureCount () const =0 |
Returns the number of features contained in the source, or -1 if the feature count is unknown. More... | |
virtual QgsFields | fields () const =0 |
Returns the fields associated with features in the source. More... | |
virtual QgsFeatureIterator | getFeatures (const QgsFeatureRequest &request=QgsFeatureRequest()) const =0 |
Returns an iterator for the features in the source. More... | |
virtual FeatureAvailability | hasFeatures () const |
Determines if there are any features available in the source. More... | |
virtual SpatialIndexPresence | hasSpatialIndex () const |
Returns an enum value representing the presence of a valid spatial index on the source, if it can be determined. More... | |
QgsVectorLayer * | 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. More... | |
virtual QVariant | maximumValue (int fieldIndex) const |
Returns the maximum value for an attribute column or an invalid variant in case of error. More... | |
virtual QVariant | minimumValue (int fieldIndex) const |
Returns the minimum value for an attribute column or an invalid variant in case of error. More... | |
virtual QgsCoordinateReferenceSystem | sourceCrs () const =0 |
Returns the coordinate reference system for features in the source. More... | |
virtual QgsRectangle | sourceExtent () const |
Returns the extent of all geometries from the source. More... | |
virtual QString | sourceName () const =0 |
Returns a friendly display name for the source. More... | |
virtual QSet< QVariant > | uniqueValues (int fieldIndex, int limit=-1) const |
Returns the set of unique values contained within the specified fieldIndex from this source. More... | |
virtual QgsWkbTypes::Type | wkbType () const =0 |
Returns the geometry type for features returned by this source. More... | |
An interface for objects which provide features via a getFeatures method.
Definition at line 37 of file qgsfeaturesource.h.
Possible return value for hasFeatures() to determine if a source is empty.
It is implemented as a three-value logic, so it can return if there are features available for sure, if there are no features available for sure or if there might be features available but there is no guarantee for this.
Definition at line 50 of file qgsfeaturesource.h.
Enumeration of spatial index presence states.
Definition at line 187 of file qgsfeaturesource.h.
|
virtualdefault |
|
virtual |
Returns a list of all feature IDs for features present in the source.
Reimplemented in QgsProcessingFeatureSource.
Definition at line 115 of file qgsfeaturesource.cpp.
|
pure virtual |
Returns the number of features contained in the source, or -1 if the feature count is unknown.
Implemented in QgsVectorDataProvider, QgsVectorLayerSelectedFeatureSource, QgsProcessingFeatureSource, and QgsVectorLayer.
|
pure virtual |
Returns the fields associated with features in the source.
Implemented in QgsVectorDataProvider, QgsVectorLayerSelectedFeatureSource, QgsProcessingFeatureSource, and QgsVectorLayer.
|
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 QgsVectorDataProvider, QgsVectorLayerSelectedFeatureSource, QgsProcessingFeatureSource, and QgsVectorLayer.
|
virtual |
Determines if there are any features available in the source.
Reimplemented in QgsVectorDataProvider, QgsProcessingFeatureSource, and QgsVectorLayer.
Definition at line 26 of file qgsfeaturesource.cpp.
|
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.
Reimplemented in QgsVectorLayerSelectedFeatureSource, and QgsProcessingFeatureSource.
Definition at line 190 of file qgsfeaturesource.cpp.
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 132 of file qgsfeaturesource.cpp.
|
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.
Reimplemented in QgsVectorDataProvider, QgsVectorLayer, and QgsProcessingFeatureSource.
Definition at line 75 of file qgsfeaturesource.cpp.
|
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.
Reimplemented in QgsVectorDataProvider, QgsVectorLayer, and QgsProcessingFeatureSource.
Definition at line 52 of file qgsfeaturesource.cpp.
|
pure virtual |
Returns the coordinate reference system for features in the source.
Implemented in QgsVectorLayerSelectedFeatureSource, QgsVectorDataProvider, QgsProcessingFeatureSource, and QgsVectorLayer.
|
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 QgsVectorDataProvider, QgsProcessingFeatureSource, and QgsVectorLayer.
Definition at line 98 of file qgsfeaturesource.cpp.
|
pure virtual |
Returns a friendly display name for the source.
The returned value can be an empty string.
Implemented in QgsVectorLayerSelectedFeatureSource, QgsVectorDataProvider, QgsProcessingFeatureSource, and QgsVectorLayer.
|
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.
Reimplemented in QgsProcessingFeatureSource, and QgsVectorLayer.
Definition at line 31 of file qgsfeaturesource.cpp.
|
pure virtual |
Returns the geometry type for features returned by this source.
Implemented in QgsVectorDataProvider, QgsVectorLayerSelectedFeatureSource, QgsProcessingFeatureSource, and QgsVectorLayer.