QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
74  virtual QgsCoordinateReferenceSystem sourceCrs() const = 0;
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
qgsfeaturerequest.h
QgsFeatureSource::FeaturesAvailable
@ FeaturesAvailable
There is at least one feature available in this source.
Definition: qgsfeaturesource.h:53
QgsFields
Definition: qgsfields.h:44
QgsFeatureSource
Definition: qgsfeaturesource.h:37
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
QgsRectangle
Definition: qgsrectangle.h:41
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
QgsFeatureRequest
Definition: qgsfeaturerequest.h:75
QgsFeedback
Definition: qgsfeedback.h:43
QgsFeatureSource::SpatialIndexPresence
SpatialIndexPresence
Enumeration of spatial index presence states.
Definition: qgsfeaturesource.h:187
qgis_sip.h
QgsFeatureSource::NoFeaturesAvailable
@ NoFeaturesAvailable
There are certainly no features available in this source.
Definition: qgsfeaturesource.h:52
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsFeatureSource::FeatureAvailability
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
Definition: qgsfeaturesource.h:50
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsFeatureIterator
Definition: qgsfeatureiterator.h:263