QGIS API Documentation 3.43.0-Master (b60ef06885e)
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"
23#include "qgsvectorlayercache.h"
24#include <QPointer>
25
27
34{
35 public:
36
43 QgsCachedFeatureIterator( QgsVectorLayerCache *vlCache, const QgsFeatureRequest &featureRequest );
44
46
52 bool rewind() override;
53
59 bool close() override;
60
61 // QgsAbstractFeatureIterator interface
62 protected:
63
70 bool fetchFeature( QgsFeature &f ) override;
71
78 bool nextFeatureFilterFids( QgsFeature &f ) override { return fetchFeature( f ); }
79
80 private:
81#ifdef SIP_RUN
83#endif
84
85 QList< QgsFeatureId > mFeatureIds;
86 QPointer< QgsVectorLayerCache > mVectorLayerCache = nullptr;
87 QList< QgsFeatureId >::ConstIterator mFeatureIdIterator;
88 QgsCoordinateTransform mTransform;
89 QgsRectangle mFilterRect;
90
91 QgsGeometry mDistanceWithinGeom;
92 std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine;
93 double mDistanceWithin = 0;
94};
95
103{
104 public:
105
113
119 bool rewind() override;
120
126 bool close() override;
127
128 protected:
129
136 bool fetchFeature( QgsFeature &f ) override;
137
138 private:
139 QgsFeatureIterator mFeatIt;
140 QPointer< QgsVectorLayerCache > mVectorLayerCache;
141 QgsFeatureIds mFids;
142 QgsCoordinateTransform mTransform;
143 QgsRectangle mFilterRect;
144
145};
146#endif // QGSCACHEDFEATUREITERATOR_H
Internal feature iterator to be implemented within data providers.
virtual bool rewind()=0
Resets the iterator to the starting position.
virtual bool fetchFeature(QgsFeature &f)=0
If you write a feature iterator for your provider, this is the method you need to implement!...
virtual bool close()=0
Call to end the iteration.
Delivers features from the cache.
~QgsCachedFeatureIterator() override
bool nextFeatureFilterFids(QgsFeature &f) override
We have a local special iterator for FilterFids, no need to run the generic.
Uses another iterator as backend and writes features to the cache.
Handles coordinate transforms between two coordinate systems.
Wrapper for iterator of features from vector data provider or vector layer.
Wraps a request for features to a vector layer (or directly its vector data provider).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A geometry is the spatial representation of a feature.
A rectangle specified with double values.
Caches features for a given QgsVectorLayer.
QSet< QgsFeatureId > QgsFeatureIds