QGIS API Documentation 3.99.0-Master (c22de0620c0)
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
21#include "qgsfeatureiterator.h"
22#include "qgsfields.h"
23#include "qgsgeometry.h"
24
25#define SIP_NO_FILE
26
28
29class QgsMemoryProvider;
30
31typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap;
32
33class QgsSpatialIndex;
34
35
36class QgsMemoryFeatureSource final: public QgsAbstractFeatureSource
37{
38 public:
39 explicit QgsMemoryFeatureSource( const QgsMemoryProvider *p );
40
41 QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) override;
42
43 QgsExpressionContext *expressionContext();
44
45 private:
46 QgsFields mFields;
47 QgsFeatureMap mFeatures;
48 std::unique_ptr< QgsSpatialIndex > mSpatialIndex;
49 QString mSubsetString;
50 std::unique_ptr< QgsExpressionContext > mExpressionContext;
52
53 friend class QgsMemoryFeatureIterator;
54};
55
56
57class QgsMemoryFeatureIterator final: public QgsAbstractFeatureIteratorFromSource<QgsMemoryFeatureSource>
58{
59 public:
60 QgsMemoryFeatureIterator( QgsMemoryFeatureSource *source, bool ownSource, const QgsFeatureRequest &request );
61
62 ~QgsMemoryFeatureIterator() override;
63
64 bool rewind() override;
65 bool close() override;
66
67 protected:
68
69 bool fetchFeature( QgsFeature &feature ) override;
70
71 private:
72 bool nextFeatureUsingList( QgsFeature &feature );
73 bool nextFeatureTraverseAll( QgsFeature &feature );
74
75 QgsGeometry mSelectRectGeom;
76 std::unique_ptr< QgsGeometryEngine > mSelectRectEngine;
77 QgsGeometry mDistanceWithinGeom;
78 std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine;
79 QgsRectangle mFilterRect;
80 QgsFeatureMap::const_iterator mSelectIterator;
81 bool mUsingFeatureIdList = false;
82 QList<QgsFeatureId> mFeatureIdList;
83 QList<QgsFeatureId>::const_iterator mFeatureIdListIterator;
84 std::unique_ptr< QgsExpression > mSubsetExpression;
85 QgsCoordinateTransform mTransform;
86
87};
88
90
91#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.
Represents a coordinate reference system (CRS).
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.
Wraps a request for features to a vector layer (or directly its vector data provider).
Container of fields for a vector layer.
Definition qgsfields.h:46
A spatial index for QgsFeature objects.
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap