QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 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
This class represents a coordinate reference system (CRS).
Wrapper for iterator of features from vector data provider or vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider).
An interface for objects which provide features via a getFeatures method.
virtual QgsFields fields() const =0
Returns the fields associated with features in the source.
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
SpatialIndexPresence
Enumeration of spatial index presence states.
virtual QgsWkbTypes::Type wkbType() const =0
Returns the geometry type for features returned by this source.
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
@ NoFeaturesAvailable
There are certainly no features available in this source.
@ FeaturesAvailable
There is at least one feature available in this source.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const =0
Returns an iterator for the features in the source.
virtual ~QgsFeatureSource()=default
virtual QString sourceName() const =0
Returns a friendly display name for 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.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Container of fields for a vector layer.
Definition: qgsfields.h:45
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Represents a vector layer which manages a vector based data sets.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
#define SIP_FACTORY
Definition: qgis_sip.h:76
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
Q_DECLARE_METATYPE(QgsMeshTimeSettings)