QGIS API Documentation  2.99.0-Master (0cba29c)
qgscachedfeatureiterator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscachedfeatureiterator.h
3  --------------------------------------
4  Date : 12.2.2013
5  Copyright : (C) 2013 Matthias Kuhn
6  Email : matthias at opengis dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSCACHEDFEATUREITERATOR_H
17 #define QGSCACHEDFEATUREITERATOR_H
18 
19 #include "qgis_core.h"
20 #include "qgsfeature.h"
21 #include "qgsfeatureiterator.h"
22 
24 
31 {
32  public:
33 
40  QgsCachedFeatureIterator( QgsVectorLayerCache *vlCache, const QgsFeatureRequest &featureRequest );
41 
47  virtual bool rewind() override;
48 
54  virtual bool close() override;
55 
56  // QgsAbstractFeatureIterator interface
57  protected:
58 
67  virtual bool fetchFeature( QgsFeature &f ) override;
68 
75  virtual bool nextFeatureFilterFids( QgsFeature &f ) override { return fetchFeature( f ); }
76 
77  private:
78  QgsFeatureIds mFeatureIds;
79  QgsVectorLayerCache *mVectorLayerCache = nullptr;
80  QgsFeatureIds::ConstIterator mFeatureIdIterator;
81  QgsCoordinateTransform mTransform;
82  QgsRectangle mFilterRect;
83 };
84 
91 {
92  public:
93 
100  QgsCachedFeatureWriterIterator( QgsVectorLayerCache *vlCache, const QgsFeatureRequest &featureRequest );
101 
107  virtual bool rewind() override;
108 
114  virtual bool close() override;
115 
116  protected:
117 
126  virtual bool fetchFeature( QgsFeature &f ) override;
127 
128  private:
129  QgsFeatureIterator mFeatIt;
130  QgsVectorLayerCache *mVectorLayerCache = nullptr;
131  QgsFeatureIds mFids;
132  QgsCoordinateTransform mTransform;
133  QgsRectangle mFilterRect;
134 };
135 #endif // QGSCACHEDFEATUREITERATOR_H
Wrapper for iterator of features from vector data provider or vector layer.
virtual bool close()=0
end of iterating: free the resources / lock
A rectangle specified with double values.
Definition: qgsrectangle.h:38
virtual bool fetchFeature(QgsFeature &f)=0
If you write a feature iterator for your provider, this is the method you need to implement!! ...
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:519
virtual bool rewind()=0
reset the iterator to the starting position
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:61
Uses another iterator as backend and writes features to the cache.
Internal feature iterator to be implemented within data providers.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
This class caches features of a given QgsVectorLayer.
virtual bool nextFeatureFilterFids(QgsFeature &f) override
We have a local special iterator for FilterFids, no need to run the generic.
Class for doing transforms between two map coordinate systems.
Delivers features from the cache.