43 if ( L->editBuffer()->addedFeatures().contains( request.filterFid() ) )
44 mAddedFeatures.insert( request.filterFid(), L->editBuffer()->addedFeatures()[ request.filterFid()] );
46 if ( L->editBuffer()->changedGeometries().contains( request.filterFid() ) )
47 mChangedGeometries.insert( request.filterFid(), L->editBuffer()->changedGeometries()[ request.filterFid()] );
49 if ( L->editBuffer()->deletedFeatureIds().contains( request.filterFid() ) )
52 if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
53 mChangedAttributeValues.insert( request.filterFid(), L->editBuffer()->changedAttributeValues()[ request.filterFid()] );
55 if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
56 mChangedFeaturesRequest.setFilterFids(
QgsFeatureIds() << request.filterFid() );
88 , mEditGeometrySimplifier( 0 )
104 for (
int i = 0; i < subset.count(); ++i )
106 int attrIndex = subset[i];
107 if ( attrIndex < 0 || attrIndex >= nPendingFields )
continue;
432 for ( QgsAttributeList::const_iterator attIt = fetchAttributes.constBegin(); attIt != fetchAttributes.constEnd(); ++attIt )
440 int sourceLayerIndex;
442 Q_ASSERT( joinInfo );
445 Q_ASSERT( joinLayer );
468 if ( !fetchAttributes.contains( info.
targetField ) )
475 mFetchJoinInfo[ joinLayer ].attributes.push_back( sourceLayerIndex );
489 QMap<QgsVectorLayer*, FetchJoinInfo>::const_iterator joinIt =
mFetchJoinInfo.constBegin();
493 Q_ASSERT( joinIt.key() );
496 if ( !targetFieldValue.isValid() )
500 if ( memoryCache.isEmpty() )
548 QHash<QString, QgsAttributes>::const_iterator it = memoryCache.find( joinValue.toString() );
549 if ( it == memoryCache.constEnd() )
555 for (
int i = 0; i < featureAttributes.count(); ++i )
570 QString subsetString = joinLayer->dataProvider()->subsetString();
571 QString bkSubsetString = subsetString;
572 if ( !subsetString.isEmpty() )
574 subsetString.prepend(
"(" ).append(
") AND " );
577 QString joinFieldName;
578 if ( joinInfo->joinFieldName.isEmpty() && joinInfo->joinFieldIndex >= 0 && joinInfo->joinFieldIndex < joinLayer->pendingFields().count() )
579 joinFieldName = joinLayer->pendingFields().field( joinInfo->joinFieldIndex ).name();
581 joinFieldName = joinInfo->joinFieldName;
583 subsetString.append( QString(
"\"%1\"" ).arg( joinFieldName ) );
585 if ( joinValue.isNull() )
587 subsetString +=
" IS NULL";
591 QString v = joinValue.toString();
592 switch ( joinValue.type() )
595 case QVariant::LongLong:
596 case QVariant::Double:
600 case QVariant::String:
601 v.replace(
"'",
"''" );
602 v.prepend(
"'" ).append(
"'" );
605 subsetString +=
"=" + v;
608 joinLayer->dataProvider()->setSubsetString( subsetString,
false );
620 int index = indexOffset;
622 for (
int i = 0; i < attr.count(); ++i )
624 if ( i == joinField )
635 joinLayer->dataProvider()->setSubsetString( bkSubsetString,
false );
659 if ( iter->id() == featureId )
698 for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
699 attrs[it.key()] = it.value();
QgsFeatureId id() const
Get the feature id for this feature.
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
bool acceptFeature(const QgsFeature &feature)
Check if a feature is accepted by this requests filter.
bool fetchNextAddedFeature(QgsFeature &f)
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...
bool fetchNextChangedGeomFeature(QgsFeature &f)
QString targetFieldName
Join field in the target layer.
QgsFeatureIterator mProviderIterator
QMap< int, QVariant > QgsAttributeMap
void addJoinedAttributes(QgsFeature &f)
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
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.
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)
bool setAttribute(int field, const QVariant &attr)
Set an attribute by id.
~QgsVectorLayerFeatureIterator()
QList< QgsField > mAddedAttributes
field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
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...
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
QgsFeatureRequest mChangedFeaturesRequest
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.
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object (deep copy)
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
bool fetchNextChangedAttributeFeature(QgsFeature &f)
void iteratorClosed()
to be called by from subclass in close()
QgsVectorLayerFeatureSource * mSource
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.
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.
friend class QgsVectorLayerFeatureIterator
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
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
QgsFeatureRequest mProviderRequest
const QgsFeatureIds deletedFeatureIds()
const QgsAttributes & attributes() const
Filter using a rectangle, no need to set NoGeometry.
QgsGeometryMap mChangedGeometries
int count() const
Return number of items.
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
QgsFeatureIds mDeletedFeatureIds
QgsAttributeList mDeletedAttributeIds
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.
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.
QSet< QgsFeatureId > mFetchConsidered
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
bool nextFeatureFid(QgsFeature &f)
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.
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
~QgsVectorLayerFeatureSource()
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.
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
QgsVectorLayerJoinBuffer * mJoinBuffer
QVector< QVariant > QgsAttributes
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
QgsFeatureMap mAddedFeatures
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...
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.
MethodType methodType() const
Gets the simplification type.
QgsFeatureIterator mChangedFeaturesIterator
helper template that cares of two things: 1.
QgsExpression * filterExpression() const