QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsfeaturesource.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturesource.h
3  ----------------
4  begin : May 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSFEATURESOURCE_H
19 #define QGSFEATURESOURCE_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgsfeaturerequest.h"
24 
25 class QgsFeatureIterator;
27 class QgsFields;
28 class QgsFeedback;
29 
37 class CORE_EXPORT QgsFeatureSource
38 {
39  public:
40 
51  {
54  FeaturesMaybeAvailable
55  };
56 
57  virtual ~QgsFeatureSource() = default;
58 
64  virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const = 0;
65 
69  virtual QString sourceName() const = 0;
70 
75 
79  virtual QgsFields fields() const = 0;
80 
84  virtual QgsWkbTypes::Type wkbType() const = 0;
85 
86 #ifdef SIP_RUN
87 
92  int __len__() const;
93  % MethodCode
94  sipRes = sipCpp->featureCount();
95  % End
96 
98  int __bool__() const;
99  % MethodCode
100  sipRes = true;
101  % End
102 #endif
103 
108  virtual long featureCount() const = 0;
109 
115  virtual FeatureAvailability hasFeatures() const;
116 
125  virtual QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const;
126 
134  virtual QVariant minimumValue( int fieldIndex ) const;
135 
143  virtual QVariant maximumValue( int fieldIndex ) const;
144 
150  virtual QgsRectangle sourceExtent() const;
151 
155  virtual QgsFeatureIds allFeatureIds() const;
156 
180  QgsVectorLayer *materialize( const QgsFeatureRequest &request,
181  QgsFeedback *feedback = nullptr ) SIP_FACTORY;
182 
188  {
189  SpatialIndexUnknown = 0,
190  SpatialIndexNotPresent = 1,
191  SpatialIndexPresent = 2,
192  };
193 
203  virtual SpatialIndexPresence hasSpatialIndex() const;
204 };
205 
207 
208 #endif // QGSFEATURESOURCE_H
QgsFeatureSource::sourceCrs
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
qgsfeaturerequest.h
QgsFeatureSource::FeaturesAvailable
@ FeaturesAvailable
There is at least one feature available in this source.
Definition: qgsfeaturesource.h:53
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsFeatureSource
An interface for objects which provide features via a getFeatures method.
Definition: qgsfeaturesource.h:38
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition: qgsfeaturerequest.h:76
QgsFeatureSource::sourceName
virtual QString sourceName() const =0
Returns a friendly display name for the source.
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsFeatureSource::SpatialIndexPresence
SpatialIndexPresence
Enumeration of spatial index presence states.
Definition: qgsfeaturesource.h:188
qgis_sip.h
QgsFeatureSource::getFeatures
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const =0
Returns an iterator for the features in the source.
QgsFeatureSource::NoFeaturesAvailable
@ NoFeaturesAvailable
There are certainly no features available in this source.
Definition: qgsfeaturesource.h:52
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsFeatureSource::fields
virtual QgsFields fields() const =0
Returns the fields associated with features in the source.
QgsFeatureSource::featureCount
virtual long featureCount() const =0
Returns the number of features contained in the source, or -1 if the feature count is unknown.
QgsFeatureSource::FeatureAvailability
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
Definition: qgsfeaturesource.h:51
QgsFeatureSource::~QgsFeatureSource
virtual ~QgsFeatureSource()=default
QgsFeatureSource::wkbType
virtual QgsWkbTypes::Type wkbType() const =0
Returns the geometry type for features returned by this source.
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition: qgsfeatureiterator.h:265