44 if ( L->editBuffer()->addedFeatures().contains( request.filterFid() ) )
45 mAddedFeatures.
insert( request.filterFid(), L->editBuffer()->addedFeatures()[ request.filterFid()] );
47 if ( L->editBuffer()->changedGeometries().contains( request.filterFid() ) )
50 if ( L->editBuffer()->deletedFeatureIds().contains( request.filterFid() ) )
53 if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
56 if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
57 mChangedFeaturesRequest.setFilterFids(
QgsFeatureIds() << request.filterFid() );
90 , mFetchedFid( false )
91 , mEditGeometrySimplifier( 0 )
110 for (
int i = 0; i < subset.
count(); ++i )
112 int attrIndex = subset[i];
113 if ( attrIndex < 0 || attrIndex >= nPendingFields )
continue;
153 delete mEditGeometrySimplifier;
154 mEditGeometrySimplifier = NULL;
306 if ( mEditGeometrySimplifier )
390 if ( mEditGeometrySimplifier )
449 int sourceLayerIndex;
451 Q_ASSERT( joinInfo );
454 Q_ASSERT( joinLayer );
481 mFetchJoinInfo[ joinInfo ].attributes.push_back( sourceLayerIndex );
532 Q_ASSERT( joinIt.
key() );
535 if ( !targetFieldValue.isValid() )
572 delete mEditGeometrySimplifier;
573 mEditGeometrySimplifier = NULL;
579 return mEditGeometrySimplifier != NULL;
586 Q_UNUSED( methodType );
619 for (
int i = 0; i < featureAttributes.
count(); ++i )
630 QString subsetString = joinLayer->dataProvider()->subsetString();
631 QString bkSubsetString = subsetString;
638 if ( joinInfo->joinFieldName.isEmpty() && joinInfo->joinFieldIndex >= 0 && joinInfo->joinFieldIndex < joinLayer->pendingFields().count() )
639 joinFieldName = joinLayer->pendingFields().field( joinInfo->joinFieldIndex ).name();
641 joinFieldName = joinInfo->joinFieldName;
643 subsetString.
append(
QString(
"\"%1\"" ).arg( joinFieldName ) );
647 subsetString +=
" IS NULL";
652 switch ( joinValue.
type() )
655 case QVariant::LongLong:
656 case QVariant::Double:
660 case QVariant::String:
665 subsetString +=
"=" + v;
668 joinLayer->dataProvider()->setSubsetString( subsetString,
false );
672 bool hasSubset = joinInfo->joinFieldNamesSubset();
687 int index = indexOffset;
691 for (
int i = 0; i < subsetIndices.
count(); ++i )
697 for (
int i = 0; i < attr.
count(); ++i )
699 if ( i == joinField )
711 joinLayer->dataProvider()->setSubsetString( bkSubsetString,
false );
735 if ( iter->id() == featureId )
775 for ( QgsAttributeMap::const_iterator it = map.
begin(); it != map.
end(); ++it )
776 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
Class for parsing and evaluation of expressions (formerly called "search strings").
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)
QString & append(QChar ch)
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...
QStringList referencedColumns() const
Get list of columns referenced by the expression.
bool fetchNextChangedGeomFeature(QgsFeature &f)
QString targetFieldName
Join field in the target layer.
bool contains(const Key &key) const
QgsFeatureIterator mProviderIterator
void addJoinedAttributes(QgsFeature &f)
QList< T > values() const
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 ...
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name - case insensitive TODO: sort out case sensitive (indexFromName()) vs...
QString & prepend(QChar ch)
QgsVectorLayerFeatureIterator(QgsVectorLayerFeatureSource *source, bool ownSource, const QgsFeatureRequest &request)
int joinFieldIndex
Join field index in the source layer.
const_iterator constBegin() const
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() const
Returns type of the geometry as a QGis::GeometryType.
A geometry is the spatial representation of a feature.
const QgsAttributeList & subsetOfAttributes() const
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index.
QMap< int, QgsExpression * > mExpressionFieldInfo
~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.
const_iterator insert(const T &value)
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
QMap< const QgsVectorJoinInfo *, FetchJoinInfo > mFetchJoinInfo
information about joins used in the current select() statement.
const QgsVectorJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index.
int joinedFieldsOffset(const QgsVectorJoinInfo *info, const QgsFields &fields)
Find out what is the first index of the join within fields.
QgsVectorLayerJoinBuffer * clone() const
Create a copy of the join buffer.
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.
bool containsJoins() const
Quick way to test if there is any join at all.
QList< Key > keys() const
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.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
int count(const T &value) const
bool fetchNextChangedAttributeFeature(QgsFeature &f)
void iteratorClosed()
to be called by from subclass in close()
QgsVectorLayerFeatureSource * mSource
void append(const T &value)
void useAddedFeature(const QgsFeature &src, QgsFeature &f)
QgsFeatureRequest & setFilterFids(QgsFeatureIds fids)
Set feature ID that should be fetched.
const_iterator constEnd() const
void setFeatureId(QgsFeatureId id)
Sets the feature ID for this feature.
const QgsVectorJoinInfo * joinInfo
cannonical source of information about the join
QgsAttributes attributes() const
Returns the feature's attributes.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
void updateFeatureGeometry(QgsFeature &f)
Update feature with uncommited geometry updates.
virtual bool prepareSimplification(const QgsSimplifyMethod &simplifyMethod) override
Setup the simplification of geometries to fetch using the specified simplify method.
friend class QgsVectorLayerFeatureIterator
const_iterator constEnd() const
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
virtual bool fetchFeature(QgsFeature &feature) override
fetch next feature, return true on success
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void prepareExpressions()
QList< int > QgsAttributeList
QgsFeatureRequest mProviderRequest
const QgsFeatureIds deletedFeatureIds()
Filter using a rectangle, no need to set NoGeometry.
QgsGeometryMap mChangedGeometries
int count() const
Return number of items.
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)
QgsExpressionFieldBuffer * mExpressionFieldBuffer
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
Q_DECL_DEPRECATED 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
const T value(const Key &key) const
iterator find(const Key &key)
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
bool nextFeatureFid(QgsFeature &f)
bool contains(const T &value) const
QgsGeometry * geometry()
Get the geometry object associated with this feature.
QgsVectorLayerFeatureSource(QgsVectorLayer *layer)
bool contains(const T &value) const
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.
const Key key(const T &value) const
void setValid(bool validity)
Sets the validity of the feature.
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
QString & replace(int position, int n, QChar after)
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...
int targetField
index of field (of this layer) that drives the join
~QgsVectorLayerFeatureSource()
Buffers information about expression fields for a vector layer.
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.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request) override
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
QgsFeatureMap mAddedFeatures
virtual bool rewind() override
reset the iterator to the starting position
virtual bool close() override
end of iterating: free the resources / lock
static QVector< int > joinSubsetIndices(QgsVectorLayer *joinLayer, const QStringList &joinFieldsSubset)
Return a vector of indices for use in join based on field names from the layer.
int count(const T &value) const
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
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.
iterator insert(const Key &key, const T &value)
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.
const_iterator constEnd() const
bool nextFeature(QgsFeature &f)
const_iterator constBegin() const
This is the base class for vector data providers.
bool mHasVirtualAttributes
QgsChangedAttributesMap mChangedAttributeValues
Geometry is not required. It may still be returned if e.g. required for a filter condition.
const QList< ExpressionField > & expressions() const
Represents a vector layer which manages a vector based data sets.
const QgsAttributeList & deletedAttributeIds()
deleted attributes fields which are not commited.
field is calculated from an expression
QgsFeatureRequest & setFlags(Flags flags)
Set flags that affect how features will be fetched.
QString joinLayerId
Source layer.
QgsAttributeList allAttributesList() const
Utility function to get list of attribute indexes.
MethodType methodType() const
Gets the simplification type.
void addVirtualAttributes(QgsFeature &f)
Adds attributes that don't source from the provider but are added inside QGIS Includes.
QgsFeatureIterator mChangedFeaturesIterator
helper template that cares of two things: 1.
const T value(const Key &key) const
QgsExpression * filterExpression() const