QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 #include "qgscoordinatetransform.h"
23 
25 
33 {
34  public:
35 
42  QgsCachedFeatureIterator( QgsVectorLayerCache *vlCache, const QgsFeatureRequest &featureRequest );
43 
44  ~QgsCachedFeatureIterator() override;
45 
51  bool rewind() override;
52 
58  bool close() override;
59 
60  // QgsAbstractFeatureIterator interface
61  protected:
62 
71  bool fetchFeature( QgsFeature &f ) override;
72 
79  bool nextFeatureFilterFids( QgsFeature &f ) override { return fetchFeature( f ); }
80 
81  private:
82 #ifdef SIP_RUN
84 #endif
85 
86  QList< QgsFeatureId > mFeatureIds;
87  QgsVectorLayerCache *mVectorLayerCache = nullptr;
88  QList< QgsFeatureId >::ConstIterator mFeatureIdIterator;
89  QgsCoordinateTransform mTransform;
90  QgsRectangle mFilterRect;
91 
92  QgsGeometry mDistanceWithinGeom;
93  std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine;
94  double mDistanceWithin = 0;
95 };
96 
104 {
105  public:
106 
113  QgsCachedFeatureWriterIterator( QgsVectorLayerCache *vlCache, const QgsFeatureRequest &featureRequest );
114 
120  bool rewind() override;
121 
127  bool close() override;
128 
129  protected:
130 
139  bool fetchFeature( QgsFeature &f ) override;
140 
141  private:
142  QgsFeatureIterator mFeatIt;
143  QgsVectorLayerCache *mVectorLayerCache = nullptr;
144  QgsFeatureIds mFids;
145  QgsCoordinateTransform mTransform;
146  QgsRectangle mFilterRect;
147 
148 };
149 #endif // QGSCACHEDFEATUREITERATOR_H
QgsCachedFeatureWriterIterator
Uses another iterator as backend and writes features to the cache.
Definition: qgscachedfeatureiterator.h:103
QgsVectorLayerCache
This class caches features of a given QgsVectorLayer.
Definition: qgsvectorlayercache.h:46
qgsfeatureiterator.h
qgsfeature.h
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition: qgsfeaturerequest.h:83
qgscoordinatetransform.h
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
QgsAbstractFeatureIterator::rewind
virtual bool rewind()=0
reset the iterator to the starting position
QgsCachedFeatureIterator
Delivers features from the cache.
Definition: qgscachedfeatureiterator.h:32
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsAbstractFeatureIterator::fetchFeature
virtual bool fetchFeature(QgsFeature &f)=0
If you write a feature iterator for your provider, this is the method you need to implement!...
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
QgsCachedFeatureIterator::nextFeatureFilterFids
bool nextFeatureFilterFids(QgsFeature &f) override
We have a local special iterator for FilterFids, no need to run the generic.
Definition: qgscachedfeatureiterator.h:79
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition: qgsfeatureiterator.h:289
QgsAbstractFeatureIterator
Internal feature iterator to be implemented within data providers.
Definition: qgsfeatureiterator.h:28
QgsAbstractFeatureIterator::close
virtual bool close()=0
end of iterating: free the resources / lock