QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsvectorlayerfeatureiterator.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerfeatureiterator.cpp
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  ***************************************************************************/
16 
17 #include "qgsmaplayerregistry.h"
18 #include "qgsvectordataprovider.h"
19 #include "qgsvectorlayer.h"
22 #include "qgsgeometrysimplifier.h"
23 #include "qgssimplifymethod.h"
24 
25 
27 {
29  mFields = layer->pendingFields();
31 
32  mCanBeSimplified = layer->hasGeometryType() && layer->geometryType() != QGis::Point;
33 
34  mHasEditBuffer = layer->editBuffer();
35  if ( mHasEditBuffer )
36  {
37 #if 0
38  // TODO[MD]: after merge
39  if ( request.filterType() == QgsFeatureRequest::FilterFid )
40  {
41 
42  // only copy relevant parts
43  if ( L->editBuffer()->addedFeatures().contains( request.filterFid() ) )
44  mAddedFeatures.insert( request.filterFid(), L->editBuffer()->addedFeatures()[ request.filterFid()] );
45 
46  if ( L->editBuffer()->changedGeometries().contains( request.filterFid() ) )
47  mChangedGeometries.insert( request.filterFid(), L->editBuffer()->changedGeometries()[ request.filterFid()] );
48 
49  if ( L->editBuffer()->deletedFeatureIds().contains( request.filterFid() ) )
50  mDeletedFeatureIds.insert( request.filterFid() );
51 
52  if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
53  mChangedAttributeValues.insert( request.filterFid(), L->editBuffer()->changedAttributeValues()[ request.filterFid()] );
54 
55  if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
56  mChangedFeaturesRequest.setFilterFids( QgsFeatureIds() << request.filterFid() );
57  }
58  else
59  {
60 #endif
65  mAddedAttributes = QList<QgsField>( layer->editBuffer()->addedAttributes() );
67 #if 0
68  }
69 #endif
70  }
71 }
72 
74 {
75  delete mJoinBuffer;
77 }
78 
80 {
81  // return feature iterator that does not own this source
82  return QgsFeatureIterator( new QgsVectorLayerFeatureIterator( this, false, request ) );
83 }
84 
85 
87  : QgsAbstractFeatureIteratorFromSource( source, ownSource, request )
88  , mEditGeometrySimplifier( 0 )
89 {
90 
91  // prepare joins: may add more attributes to fetch (in order to allow join)
93  prepareJoins();
94 
95  // by default provider's request is the same
97 
99  {
100  // prepare list of attributes to match provider fields
101  QgsAttributeList providerSubset;
103  int nPendingFields = mSource->mFields.count();
104  for ( int i = 0; i < subset.count(); ++i )
105  {
106  int attrIndex = subset[i];
107  if ( attrIndex < 0 || attrIndex >= nPendingFields ) continue;
108  if ( mSource->mFields.fieldOrigin( attrIndex ) == QgsFields::OriginProvider )
109  providerSubset << mSource->mFields.fieldOriginIndex( attrIndex );
110  }
111  mProviderRequest.setSubsetOfAttributes( providerSubset );
112  }
113 
114  if ( mSource->mHasEditBuffer )
115  {
118  }
119 
120  if ( request.filterType() == QgsFeatureRequest::FilterFid )
121  {
122  mFetchedFid = false;
123  }
124  else // no filter or filter by rect
125  {
126  if ( mSource->mHasEditBuffer )
127  {
129  }
130  else
131  {
133  }
134 
136  }
137 
139  {
141  }
142 }
143 
144 
146 {
149 
150  close();
151 }
152 
153 
154 
156 {
157  f.setValid( false );
158 
159  if ( mClosed )
160  return false;
161 
163  {
164  if ( mFetchedFid )
165  return false;
166  bool res = nextFeatureFid( f );
167  mFetchedFid = true;
168  return res;
169  }
170 
172  {
173  if ( fetchNextChangedGeomFeature( f ) )
174  return true;
175 
176  // no more changed geometries
177  }
178 
180  {
182  return true;
183 
184  // no more changed features
185  }
186 
187  while ( fetchNextAddedFeature( f ) )
188  {
189  return true;
190  }
191  // no more added features
192 
193  if ( mProviderIterator.isClosed() )
194  {
197  }
198 
199  while ( mProviderIterator.nextFeature( f ) )
200  {
201  if ( mFetchConsidered.contains( f.id() ) )
202  continue;
203 
204  // TODO[MD]: just one resize of attributes
205  f.setFields( &mSource->mFields );
206 
207  // update attributes
209 
210  if ( !mFetchJoinInfo.isEmpty() )
211  addJoinedAttributes( f );
212 
213  // update geometry
214  // TODO[MK]: FilterRect check after updating the geometry
217 
218  return true;
219  }
220  // no more provider features
221 
222  close();
223  return false;
224 }
225 
226 
227 
229 {
230  if ( mClosed )
231  return false;
232 
234  {
235  mFetchedFid = false;
236  }
237  else
238  {
241  }
242 
243  return true;
244 }
245 
247 {
248  if ( mClosed )
249  return false;
250 
252 
253  iteratorClosed();
254 
255  mClosed = true;
256  return true;
257 }
258 
259 
260 
261 
263 {
264  while ( mFetchAddedFeaturesIt-- != mSource->mAddedFeatures.constBegin() )
265  {
267 
268  if ( mFetchConsidered.contains( fid ) )
269  // must have changed geometry outside rectangle
270  continue;
271 
273  // skip features which are not accepted by the filter
274  continue;
275 
277 
278  return true;
279  }
280 
282  return false; // no more added features
283 }
284 
285 
287 {
288  f.setFeatureId( src.id() );
289  f.setValid( true );
290  f.setFields( &mSource->mFields );
291 
292  if ( src.geometry() && !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) )
293  {
294  f.setGeometry( *src.geometry() );
295 
296  // simplify the edited geometry using its simplifier configured
298  {
299  QgsGeometry* geometry = f.geometry();
300  QGis::GeometryType geometryType = geometry->type();
301  if ( geometryType == QGis::Line || geometryType == QGis::Polygon ) mEditGeometrySimplifier->simplifyGeometry( geometry );
302  }
303  }
304 
305  // TODO[MD]: if subset set just some attributes
306 
307  f.setAttributes( src.attributes() );
308 
309  if ( !mFetchJoinInfo.isEmpty() )
310  addJoinedAttributes( f );
311 }
312 
313 
314 
316 {
317  // check if changed geometries are in rectangle
319  {
320  QgsFeatureId fid = mFetchChangedGeomIt.key();
321 
322  if ( mFetchConsidered.contains( fid ) )
323  // skip deleted features
324  continue;
325 
326  mFetchConsidered << fid;
327 
328  if ( !mFetchChangedGeomIt->intersects( mRequest.filterRect() ) )
329  // skip changed geometries not in rectangle and don't check again
330  continue;
331 
333 
334  // return complete feature
336  return true;
337  }
338 
339  return false; // no more changed geometries
340 }
341 
343 {
345  {
346  mFetchConsidered << f.id();
347 
349 
350  if ( !mFetchJoinInfo.isEmpty() )
351  addJoinedAttributes( f );
352 
354  {
355  if ( mRequest.filterExpression()->evaluate( &f ).toBool() )
356  {
357  return true;
358  }
359  }
360  else
361  {
362  return true;
363  }
364  }
365 
366  return false;
367 }
368 
369 
371 {
372  f.setFeatureId( fid );
373  f.setValid( true );
374  f.setFields( &mSource->mFields );
375 
377  {
378  f.setGeometry( geom );
379 
380  // simplify the edited geometry using its simplifier configured
382  {
383  QgsGeometry* geometry = f.geometry();
384  QGis::GeometryType geometryType = geometry->type();
385  if ( geometryType == QGis::Line || geometryType == QGis::Polygon ) mEditGeometrySimplifier->simplifyGeometry( geometry );
386  }
387  }
388 
389  bool subsetAttrs = ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes );
390  if ( !subsetAttrs || ( subsetAttrs && mRequest.subsetOfAttributes().count() > 0 ) )
391  {
392  // retrieve attributes from provider
393  QgsFeature tmp;
394  //mDataProvider->featureAtId( fid, tmp, false, mFetchProvAttributes );
395  QgsFeatureRequest request;
397  if ( subsetAttrs )
398  {
400  }
402  if ( fi.nextFeature( tmp ) )
403  {
405  f.setAttributes( tmp.attributes() );
406  }
407  }
408 
409  if ( !mFetchJoinInfo.isEmpty() )
410  addJoinedAttributes( f );
411 }
412 
413 
414 
416 {
418 
421 }
422 
423 
424 
426 {
428  QgsAttributeList sourceJoinFields; // attributes that also need to be fetched from this layer in order to have joins working
429 
430  mFetchJoinInfo.clear();
431 
432  for ( QgsAttributeList::const_iterator attIt = fetchAttributes.constBegin(); attIt != fetchAttributes.constEnd(); ++attIt )
433  {
434  if ( !mSource->mFields.exists( *attIt ) )
435  continue;
436 
437  if ( mSource->mFields.fieldOrigin( *attIt ) != QgsFields::OriginJoin )
438  continue;
439 
440  int sourceLayerIndex;
441  const QgsVectorJoinInfo* joinInfo = mSource->mJoinBuffer->joinForFieldIndex( *attIt, mSource->mFields, sourceLayerIndex );
442  Q_ASSERT( joinInfo );
443 
444  QgsVectorLayer* joinLayer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( joinInfo->joinLayerId ) );
445  Q_ASSERT( joinLayer );
446 
447  if ( !mFetchJoinInfo.contains( joinLayer ) )
448  {
449  FetchJoinInfo info;
450  info.joinInfo = joinInfo;
451  info.joinLayer = joinLayer;
452 
453  if ( joinInfo->targetFieldName.isEmpty() )
454  info.targetField = joinInfo->targetFieldIndex; //for compatibility with 1.x
455  else
457 
458  if ( joinInfo->joinFieldName.isEmpty() )
459  info.joinField = joinInfo->joinFieldIndex; //for compatibility with 1.x
460  else
461  info.joinField = joinLayer->pendingFields().indexFromName( joinInfo->joinFieldName );
462 
463  info.indexOffset = *attIt - sourceLayerIndex;
464  if ( info.joinField < sourceLayerIndex )
465  info.indexOffset++;
466 
467  // for joined fields, we always need to request the targetField from the provider too
468  if ( !fetchAttributes.contains( info.targetField ) )
469  sourceJoinFields << info.targetField;
470 
471  mFetchJoinInfo.insert( joinLayer, info );
472  }
473 
474  // store field source index - we'll need it when fetching from provider
475  mFetchJoinInfo[ joinLayer ].attributes.push_back( sourceLayerIndex );
476  }
477 
478  // add sourceJoinFields if we're using a subset
481 }
482 
483 
485 {
486  // make sure we have space for newly added attributes
487  f.attributes().resize( mSource->mFields.count() ); // f.attributes().count() + mJoinedAttributesCount );
488 
489  QMap<QgsVectorLayer*, FetchJoinInfo>::const_iterator joinIt = mFetchJoinInfo.constBegin();
490  for ( ; joinIt != mFetchJoinInfo.constEnd(); ++joinIt )
491  {
492  const FetchJoinInfo& info = joinIt.value();
493  Q_ASSERT( joinIt.key() );
494 
495  QVariant targetFieldValue = f.attribute( info.targetField );
496  if ( !targetFieldValue.isValid() )
497  continue;
498 
499  const QHash< QString, QgsAttributes>& memoryCache = info.joinInfo->cachedAttributes;
500  if ( memoryCache.isEmpty() )
501  info.addJoinedAttributesDirect( f, targetFieldValue );
502  else
503  info.addJoinedAttributesCached( f, targetFieldValue );
504  }
505 }
506 
508 {
511 
512  // setup simplification for edited geometries to fetch
514  {
516  return mEditGeometrySimplifier != NULL;
517  }
518  return false;
519 }
520 
522 {
523 #if 0
524  // TODO[MD]: after merge
525  QgsVectorDataProvider* provider = L->dataProvider();
526 
527  if ( provider && methodType != QgsSimplifyMethod::NoSimplification )
528  {
529  int capabilities = provider->capabilities();
530 
531  if ( methodType == QgsSimplifyMethod::OptimizeForRendering )
532  {
533  return ( capabilities & QgsVectorDataProvider::SimplifyGeometries );
534  }
535  else if ( methodType == QgsSimplifyMethod::PreserveTopology )
536  {
538  }
539  }
540 #endif
541  return false;
542 }
543 
544 
546 {
547  const QHash<QString, QgsAttributes>& memoryCache = joinInfo->cachedAttributes;
548  QHash<QString, QgsAttributes>::const_iterator it = memoryCache.find( joinValue.toString() );
549  if ( it == memoryCache.constEnd() )
550  return; // joined value not found -> leaving the attributes empty (null)
551 
552  int index = indexOffset;
553 
554  const QgsAttributes& featureAttributes = it.value();
555  for ( int i = 0; i < featureAttributes.count(); ++i )
556  {
557  // skip the join field to avoid double field names (fields often have the same name)
558  if ( i == joinField )
559  continue;
560 
561  f.setAttribute( index++, featureAttributes[i] );
562  }
563 }
564 
565 
566 
568 {
569  // no memory cache, query the joined values by setting substring
570  QString subsetString = joinLayer->dataProvider()->subsetString(); // provider might already have a subset string
571  QString bkSubsetString = subsetString;
572  if ( !subsetString.isEmpty() )
573  {
574  subsetString.prepend( "(" ).append( ") AND " );
575  }
576 
577  QString joinFieldName;
578  if ( joinInfo->joinFieldName.isEmpty() && joinInfo->joinFieldIndex >= 0 && joinInfo->joinFieldIndex < joinLayer->pendingFields().count() )
579  joinFieldName = joinLayer->pendingFields().field( joinInfo->joinFieldIndex ).name(); // for compatibility with 1.x
580  else
581  joinFieldName = joinInfo->joinFieldName;
582 
583  subsetString.append( QString( "\"%1\"" ).arg( joinFieldName ) );
584 
585  if ( joinValue.isNull() )
586  {
587  subsetString += " IS NULL";
588  }
589  else
590  {
591  QString v = joinValue.toString();
592  switch ( joinValue.type() )
593  {
594  case QVariant::Int:
595  case QVariant::LongLong:
596  case QVariant::Double:
597  break;
598 
599  default:
600  case QVariant::String:
601  v.replace( "'", "''" );
602  v.prepend( "'" ).append( "'" );
603  break;
604  }
605  subsetString += "=" + v;
606  }
607 
608  joinLayer->dataProvider()->setSubsetString( subsetString, false );
609 
610  // select (no geometry)
611  QgsFeatureRequest request;
613  request.setSubsetOfAttributes( attributes );
614  QgsFeatureIterator fi = joinLayer->getFeatures( request );
615 
616  // get first feature
617  QgsFeature fet;
618  if ( fi.nextFeature( fet ) )
619  {
620  int index = indexOffset;
621  const QgsAttributes& attr = fet.attributes();
622  for ( int i = 0; i < attr.count(); ++i )
623  {
624  if ( i == joinField )
625  continue;
626 
627  f.setAttribute( index++, attr[i] );
628  }
629  }
630  else
631  {
632  // no suitable join feature found, keeping empty (null) attributes
633  }
634 
635  joinLayer->dataProvider()->setSubsetString( bkSubsetString, false );
636 }
637 
638 
639 
640 
642 {
643  QgsFeatureId featureId = mRequest.filterFid();
644 
645  // deleted already?
646  if ( mSource->mDeletedFeatureIds.contains( featureId ) )
647  return false;
648 
649  // has changed geometry?
650  if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) && mSource->mChangedGeometries.contains( featureId ) )
651  {
652  useChangedAttributeFeature( featureId, mSource->mChangedGeometries[featureId], f );
653  return true;
654  }
655 
656  // added features
657  for ( QgsFeatureMap::ConstIterator iter = mSource->mAddedFeatures.constBegin(); iter != mSource->mAddedFeatures.constEnd(); ++iter )
658  {
659  if ( iter->id() == featureId )
660  {
661  useAddedFeature( *iter, f );
662  return true;
663  }
664  }
665 
666  // regular features
668  if ( fi.nextFeature( f ) )
669  {
671 
672  if ( !mFetchJoinInfo.isEmpty() )
673  addJoinedAttributes( f );
674 
675  return true;
676  }
677 
678  return false;
679 }
680 
682 {
683  QgsAttributes& attrs = f.attributes();
684 
685  // remove all attributes that will disappear - from higher indices to lower
686  for ( int idx = mSource->mDeletedAttributeIds.count() - 1; idx >= 0; --idx )
687  {
688  attrs.remove( mSource->mDeletedAttributeIds[idx] );
689  }
690 
691  // adjust size to accommodate added attributes
692  attrs.resize( attrs.count() + mSource->mAddedAttributes.count() );
693 
694  // update changed attributes
695  if ( mSource->mChangedAttributeValues.contains( f.id() ) )
696  {
698  for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
699  attrs[it.key()] = it.value();
700  }
701 }
702 
704 {
705  if ( mSource->mChangedGeometries.contains( f.id() ) )
707 }
708 
QgsFeatureId id() const
Get the feature id for this feature.
Definition: qgsfeature.cpp:100
const QgsGeometryMap & changedGeometries()
Changed geometries which are not commited.
QgsAbstractFeatureSource * mProviderFeatureSource
Wrapper for iterator of features from vector data provider or vector layer.
void addJoinedAttributesDirect(QgsFeature &f, const QVariant &joinValue) const
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
Definition: qgsfeature.h:323
static unsigned index
bool acceptFeature(const QgsFeature &feature)
Check if a feature is accepted by this requests filter.
Filter using feature ID.
QgsVectorLayerJoinBuffer * mJoinBuffer
const Flags & flags() const
QString joinFieldName
Join field in the source layer.
field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
Definition: qgsfield.h:169
QString targetFieldName
Join field in the target layer.
GeometryType
Definition: qgis.h:155
QMap< int, QVariant > QgsAttributeMap
Definition: qgsfeature.h:98
QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt
QgsGeometryMap::ConstIterator mFetchChangedGeomIt
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
const QgsRectangle & filterRect() const
bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:325
supports simplification of geometries on provider side according to a distance tolerance ...
QgsVectorLayerFeatureIterator(QgsVectorLayerFeatureSource *source, bool ownSource, const QgsFeatureRequest &request)
int joinFieldIndex
Join field index in the source layer.
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
Definition: qgsfeature.cpp:112
const QgsChangedAttributesMap & changedAttributeValues()
Changed attributes values which are not commited.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QGis::GeometryType type()
Returns type of the vector.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request)
const QgsAttributeList & subsetOfAttributes() const
void setAttributes(const QgsAttributes &attrs)
Definition: qgsfeature.h:144
bool setAttribute(int field, const QVariant &attr)
Set an attribute by id.
Definition: qgsfeature.cpp:190
field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
Definition: qgsfield.h:168
bool mClosed
Set to true, as soon as the iterator is closed.
int targetFieldIndex
Join field index in the target layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
QgsVectorLayer * joinLayer
resolved pointer to the joined layer
bool isClosed() const
find out whether the iterator is still valid or closed already
Manages joined fields for a vector layer.
const QgsVectorJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index.
int joinField
index of field (of the joined layer) must have equal value
virtual bool simplifyGeometry(QgsGeometry *geometry) const =0
Simplifies the specified geometry.
virtual QgsAbstractFeatureSource * featureSource() const
Return feature source object that can be used for querying provider's data.
QMap< QgsVectorLayer *, FetchJoinInfo > mFetchJoinInfo
information about joins used in the current select() statement.
bool containsJoins() const
Quick way to test if there is any join at all.
void updateChangedAttributes(QgsFeature &f)
Update feature with uncommited attribute updates.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Set feature ID that should be fetched.
Simplify using the map2pixel data to optimize the rendering of geometries.
bool exists(int i) const
Return if a field index is valid.
Definition: qgsfield.h:201
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object (deep copy)
Definition: qgsfeature.cpp:134
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
void iteratorClosed()
to be called by from subclass in close()
void useAddedFeature(const QgsFeature &src, QgsFeature &f)
QgsFeatureRequest & setFilterFids(QgsFeatureIds fids)
Set feature ID that should be fetched.
void setFeatureId(QgsFeatureId id)
Set the feature id for this feature.
Definition: qgsfeature.cpp:128
const QgsVectorJoinInfo * joinInfo
cannonical source of information about the join
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
virtual bool fetchFeature(QgsFeature &feature)
fetch next feature, return true on success
void updateFeatureGeometry(QgsFeature &f)
Update feature with uncommited geometry updates.
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
Definition: qgsfield.h:217
virtual bool close()
end of iterating: free the resources / lock
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
const QgsFeatureIds deletedFeatureIds()
const QgsAttributes & attributes() const
Definition: qgsfeature.h:142
Filter using a rectangle, no need to set NoGeometry.
int count() const
Return number of items.
Definition: qgsfield.h:195
virtual bool rewind()
reset the iterator to the starting position
No simplification is applied.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
FilterType filterType() const
Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)
void setFields(const QgsFields *fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
Definition: qgsfeature.cpp:161
const QList< QgsField > & addedAttributes()
added attributes fields which are not commited
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
Definition: qgsfield.h:220
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
QgsVectorLayerFeatureSource(QgsVectorLayer *layer)
const QgsFeatureId & filterFid() const
int indexOffset
at what position the joined fields start
supports topological simplification of geometries on provider side according to a distance tolerance ...
void useChangedAttributeFeature(QgsFeatureId fid, const QgsGeometry &geom, QgsFeature &f)
const QgsFeatureMap & addedFeatures()
New features which are not commited.
void setValid(bool validity)
Set the validity of the feature.
Definition: qgsfeature.cpp:176
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
QgsFeatureRequest mRequest
A copy of the feature request.
bool hasGeometryType() const
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
virtual bool providerCanSimplify(QgsSimplifyMethod::MethodType methodType) const
returns whether the iterator supports simplify geometries on provider side
int targetField
index of field (of this layer) that drives the join
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) ...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
Definition: qgsfeature.cpp:230
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Definition: qgsfeature.h:320
QgsVectorLayerJoinBuffer * mJoinBuffer
QVector< QVariant > QgsAttributes
Definition: qgsfeature.h:100
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
Definition: qgsfield.h:215
static QgsAbstractGeometrySimplifier * createGeometrySimplifier(const QgsSimplifyMethod &simplifyMethod)
Creates a geometry simplifier according to specified method.
Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAtt...
qint64 QgsFeatureId
Definition: qgsfeature.h:30
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
void addJoinedAttributesCached(QgsFeature &f, const QVariant &joinValue) const
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
Simplify using the Douglas-Peucker algorithm ensuring that the result is a valid geometry.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request)=0
QgsVectorDataProvider * dataProvider()
Returns the data provider.
bool nextFeature(QgsFeature &f)
This is the base class for vector data providers.
QgsChangedAttributesMap mChangedAttributeValues
Geometry is not required. It may still be returned if e.g. required for a filter condition.
virtual bool prepareSimplification(const QgsSimplifyMethod &simplifyMethod)
Setup the simplification of geometries to fetch using the specified simplify method.
Represents a vector layer which manages a vector based data sets.
const QgsAttributeList & deletedAttributeIds()
deleted attributes fields which are not commited.
QgsFeatureRequest & setFlags(Flags flags)
Set flags that affect how features will be fetched.
QgsAbstractGeometrySimplifier * mEditGeometrySimplifier
optional object to locally simplify edited (changed or added) geometries fetched by this feature iter...
QString joinLayerId
Source layer.
QgsAttributeList allAttributesList() const
Utility function to get list of attribute indexes.
Definition: qgsfield.cpp:187
MethodType methodType() const
Gets the simplification type.
helper template that cares of two things: 1.
QgsExpression * filterExpression() const