QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
22 typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap;
23 
24 class QgsVectorLayer;
26 struct QgsVectorJoinInfo;
27 
29 {
30  public:
32 
34 
36  virtual bool rewind();
37 
39  virtual bool close();
40 
41  protected:
43  virtual bool fetchFeature( QgsFeature& feature );
44 
47  inline virtual bool nextFeatureFilterExpression( QgsFeature &f ) { return fetchFeature( f ); }
48 
50  virtual bool prepareSimplification( const QgsSimplifyMethod& simplifyMethod );
51 
53 
58 
59 #if 0
60  // general stuff
61  bool mFetching;
62  QgsRectangle mFetchRect;
63  QgsAttributeList mFetchAttributes;
64  QgsAttributeList mFetchProvAttributes;
65  bool mFetchGeometry;
66 #endif
67 
68  // only related to editing
69  QSet<QgsFeatureId> mFetchConsidered;
70  QgsGeometryMap::ConstIterator mFetchChangedGeomIt;
71  QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt;
72 
73  bool mFetchedFid; // when iterating by FID: indicator whether it has been fetched yet or not
74 
75  void rewindEditBuffer();
76  void prepareJoins();
77  bool fetchNextAddedFeature( QgsFeature& f );
78  bool fetchNextChangedGeomFeature( QgsFeature& f );
79  bool fetchNextChangedAttributeFeature( QgsFeature& f );
80  void useAddedFeature( const QgsFeature& src, QgsFeature& f );
81  void useChangedAttributeFeature( QgsFeatureId fid, const QgsGeometry& geom, QgsFeature& f );
82  bool nextFeatureFid( QgsFeature& f );
83  void addJoinedAttributes( QgsFeature &f );
84 
86  void updateChangedAttributes( QgsFeature& f );
87 
89  void updateFeatureGeometry( QgsFeature& f );
90 
95  {
101  int joinField;
102 
103  void addJoinedAttributesCached( QgsFeature& f, const QVariant& joinValue ) const;
104  void addJoinedAttributesDirect( QgsFeature& f, const QVariant& joinValue ) const;
105  };
106 
107  // A deep-copy is only performed, if the original maps change
108  // see here https://github.com/qgis/Quantum-GIS/pull/673
109  // for explanation
113  QList<QgsField> mAddedAttributes;
116 
119  QMap<QgsVectorLayer*, FetchJoinInfo> mFetchJoinInfo;
120 
121  private:
124 
126  virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const;
127 };
128 
129 #endif // QGSVECTORLAYERFEATUREITERATOR_H
Wrapper for iterator of features from vector data provider or vector layer.
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
Definition: qgsfeature.h:320
virtual bool close()=0
end of iterating: free the resources / lock
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual bool nextFeatureFilterExpression(QgsFeature &f)
Overrides default method as we only need to filter features in the edit buffer while for others filte...
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!! ...
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:322
virtual bool providerCanSimplify(QgsSimplifyMethod::MethodType methodType) const
returns whether the iterator supports simplify geometries on provider side
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
virtual bool rewind()=0
reset the iterator to the starting position
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:114
QgsVectorLayer * joinLayer
resolved pointer to the joined layer
int joinField
index of field (of the joined layer) must have equal value
QMap< QgsVectorLayer *, FetchJoinInfo > mFetchJoinInfo
Informations about joins used in the current select() statement.
const QgsVectorJoinInfo * joinInfo
cannonical source of information about the join
Internal feature iterator to be implemented within data providers.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
int indexOffset
at what position the joined fields start
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
int targetField
index of field (of this layer) that drives the join
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Definition: qgsfeature.h:317
Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAtt...
qint64 QgsFeatureId
Definition: qgsfeature.h:30
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
Represents a vector layer which manages a vector based data sets.
QgsAbstractGeometrySimplifier * mEditGeometrySimplifier
optional object to locally simplify edited (changed or added) geometries fetched by this feature iter...
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.