QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsmemoryfeatureiterator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmemoryfeatureiterator.h
3 ---------------------
4 begin : Juli 2012
5 copyright : (C) 2012 by Martin Dobias
6 email : wonder dot sk at gmail dot com
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#ifndef QGSMEMORYFEATUREITERATOR_H
16#define QGSMEMORYFEATUREITERATOR_H
17
18#define SIP_NO_FILE
19
20#include "qgsfeatureiterator.h"
22#include "qgsfields.h"
23#include "qgsgeometry.h"
25
27
28class QgsMemoryProvider;
29
30typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap;
31
32class QgsSpatialIndex;
33
34
35class QgsMemoryFeatureSource final: public QgsAbstractFeatureSource
36{
37 public:
38 explicit QgsMemoryFeatureSource( const QgsMemoryProvider *p );
39
40 QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) override;
41
42 QgsExpressionContext *expressionContext();
43
44 private:
45 QgsFields mFields;
46 QgsFeatureMap mFeatures;
47 std::unique_ptr< QgsSpatialIndex > mSpatialIndex;
48 QString mSubsetString;
49 std::unique_ptr< QgsExpressionContext > mExpressionContext;
51
52 friend class QgsMemoryFeatureIterator;
53};
54
55
56class QgsMemoryFeatureIterator final: public QgsAbstractFeatureIteratorFromSource<QgsMemoryFeatureSource>
57{
58 public:
59 QgsMemoryFeatureIterator( QgsMemoryFeatureSource *source, bool ownSource, const QgsFeatureRequest &request );
60
61 ~QgsMemoryFeatureIterator() override;
62
63 bool rewind() override;
64 bool close() override;
65
66 protected:
67
68 bool fetchFeature( QgsFeature &feature ) override;
69
70 private:
71 bool nextFeatureUsingList( QgsFeature &feature );
72 bool nextFeatureTraverseAll( QgsFeature &feature );
73
74 QgsGeometry mSelectRectGeom;
75 std::unique_ptr< QgsGeometryEngine > mSelectRectEngine;
76 QgsGeometry mDistanceWithinGeom;
77 std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine;
78 QgsRectangle mFilterRect;
79 QgsFeatureMap::const_iterator mSelectIterator;
80 bool mUsingFeatureIdList = false;
81 QList<QgsFeatureId> mFeatureIdList;
82 QList<QgsFeatureId>::const_iterator mFeatureIdListIterator;
83 std::unique_ptr< QgsExpression > mSubsetExpression;
84 QgsCoordinateTransform mTransform;
85
86};
87
89
90#endif // QGSMEMORYFEATUREITERATOR_H
Helper template that cares of two things: 1.
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.
Base class that can be used for any class that is capable of returning features.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())=0
Gets an iterator for features matching the specified request.
This class represents a coordinate reference system (CRS).
Class for doing transforms between two map coordinate systems.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
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).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Container of fields for a vector layer.
Definition qgsfields.h:46
A geometry is the spatial representation of a feature.
A rectangle specified with double values.
A spatial index for QgsFeature objects.
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap