QGIS API Documentation  2.12.0-Lyon
qgsvectorlayerfeatureiterator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerfeatureiterator.h
3  ---------------------
4  begin : Dezember 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 QGSVECTORLAYERFEATUREITERATOR_H
16 #define QGSVECTORLAYERFEATUREITERATOR_H
17 
18 #include "qgsfeatureiterator.h"
19 
20 #include <QSet>
21 
23 
25 class QgsVectorLayer;
28 struct QgsVectorJoinInfo;
30 
32 
35 {
36  public:
39 
40  virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request ) override;
41 
43 
44  protected:
45 
47 
49 
51 
53 
55 
57 
58  // A deep-copy is only performed, if the original maps change
59  // see here https://github.com/qgis/Quantum-GIS/pull/673
60  // for explanation
67 };
68 
69 
70 class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsVectorLayerFeatureSource>
71 {
72  public:
73  QgsVectorLayerFeatureIterator( QgsVectorLayerFeatureSource* source, bool ownSource, const QgsFeatureRequest& request );
74 
76 
78  virtual bool rewind() override;
79 
81  virtual bool close() override;
82 
83  protected:
85  virtual bool fetchFeature( QgsFeature& feature ) override;
86 
89  inline virtual bool nextFeatureFilterExpression( QgsFeature &f ) override { return fetchFeature( f ); }
90 
92  virtual bool prepareSimplification( const QgsSimplifyMethod& simplifyMethod ) override;
93 
94 
99 
100 
101  // only related to editing
105 
106  bool mFetchedFid; // when iterating by FID: indicator whether it has been fetched yet or not
107 
108  void rewindEditBuffer();
109  void prepareJoins();
110  void prepareExpressions();
111  bool fetchNextAddedFeature( QgsFeature& f );
112  bool fetchNextChangedGeomFeature( QgsFeature& f );
113  bool fetchNextChangedAttributeFeature( QgsFeature& f );
114  void useAddedFeature( const QgsFeature& src, QgsFeature& f );
115  void useChangedAttributeFeature( QgsFeatureId fid, const QgsGeometry& geom, QgsFeature& f );
116  bool nextFeatureFid( QgsFeature& f );
117  void addJoinedAttributes( QgsFeature &f );
126  void addVirtualAttributes( QgsFeature &f );
127 
129  void updateChangedAttributes( QgsFeature& f );
130 
132  void updateFeatureGeometry( QgsFeature& f );
133 
138  {
144  int joinField;
145 
146  void addJoinedAttributesCached( QgsFeature& f, const QVariant& joinValue ) const;
147  void addJoinedAttributesDirect( QgsFeature& f, const QVariant& joinValue ) const;
148  };
149 
153 
155 
157 
158  private:
160  QgsAbstractGeometrySimplifier* mEditGeometrySimplifier;
161 
162  QScopedPointer<QgsExpressionContext> mExpressionContext;
163 
165  virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const override;
166 };
167 
168 #endif // QGSVECTORLAYERFEATUREITERATOR_H
QgsAbstractFeatureSource * mProviderFeatureSource
Wrapper for iterator of features from vector data provider or vector layer.
virtual bool close()=0
end of iterating: free the resources / lock
QgsVectorLayerJoinBuffer * mJoinBuffer
QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt
QgsGeometryMap::ConstIterator mFetchChangedGeomIt
virtual bool fetchFeature(QgsFeature &f)=0
If you write a feature iterator for your provider, this is the method you need to implement!! ...
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
virtual bool rewind()=0
reset the iterator to the starting position
Container of fields for a vector layer.
Definition: qgsfield.h:177
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
QMap< int, QgsExpression * > mExpressionFieldInfo
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:176
QgsVectorLayer * joinLayer
resolved pointer to the joined layer
QMap< const QgsVectorJoinInfo *, FetchJoinInfo > mFetchJoinInfo
Information about joins used in the current select() statement.
Manages joined fields for a vector layer.
int joinField
index of field (of the joined layer) must have equal value
const QgsVectorJoinInfo * joinInfo
cannonical source of information about the join
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsExpressionFieldBuffer * mExpressionFieldBuffer
Base class that can be used for any class that is capable of returning features.
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
QgsVectorLayerFeatureSource(QgsVectorLayer *layer)
int indexOffset
at what position the joined fields start
int targetField
index of field (of this layer) that drives the join
Buffers information about expression fields for a vector layer.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request) override
Get an iterator for features matching the specified request.
Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAtt...
qint64 QgsFeatureId
Definition: qgsfeature.h:31
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
virtual bool nextFeatureFilterExpression(QgsFeature &f) override
Overrides default method as we only need to filter features in the edit buffer while for others filte...
QgsChangedAttributesMap mChangedAttributeValues
Represents a vector layer which manages a vector based data sets.
virtual bool prepareSimplification(const QgsSimplifyMethod &simplifyMethod)
Setup the simplification of geometries to fetch using the specified simplify method.
Abstract base class for simplify geometries using a specific algorithm.
Helper template that cares of two things: 1.