QGIS API Documentation  3.15.0-Master (61a1801e3d)
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
Wrapper for iterator of features from vector data provider or vector layer.
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
Container of fields for a vector layer.
Definition: qgsfields.h:44
There is at least one feature available in this source.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Definition: qgsfeedback.h:43
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:69
There are certainly no features available in this source.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
#define SIP_FACTORY
Definition: qgis_sip.h:76
An interface for objects which provide features via a getFeatures method.
This class represents a coordinate reference system (CRS).
SpatialIndexPresence
Enumeration of spatial index presence states.
Represents a vector layer which manages a vector based data sets.