33#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
34#include <QThreadStorage>
41 const QMutexLocker locker( &layer->mFeatureSourceConstructorMutex );
58 source.
joinSource = std::make_shared< QgsVectorLayerFeatureSource >( joinLayer );
72 if ( request.filterType() == QgsFeatureRequest::FilterFid )
76 if ( L->editBuffer()->addedFeatures().contains( request.filterFid() ) )
77 mAddedFeatures.insert( request.filterFid(), L->editBuffer()->addedFeatures()[ request.filterFid()] );
79 if ( L->editBuffer()->changedGeometries().contains( request.filterFid() ) )
80 mChangedGeometries.insert( request.filterFid(), L->editBuffer()->changedGeometries()[ request.filterFid()] );
82 if ( L->editBuffer()->deletedFeatureIds().contains( request.filterFid() ) )
85 if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
86 mChangedAttributeValues.insert( request.filterFid(), L->editBuffer()->changedAttributeValues()[ request.filterFid()] );
88 if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
89 mChangedFeaturesRequest.setFilterFids(
QgsFeatureIds() << request.filterFid() );
139 , mFetchedFid( false )
169 bool canDelegateLimitToProvider =
true;
180 canDelegateLimitToProvider =
false;
200 for (
const int attrIndex : usedAttributeIndices )
203 mDelegatedOrderByToProvider =
false;
244 if ( !mDelegatedOrderByToProvider )
249 if ( !canDelegateLimitToProvider )
257 QSet<int> providerSubset;
260 for (
const int attrIndex : subset )
262 if ( attrIndex < 0 || attrIndex >= nPendingFields )
276 for (
const int attrIndex : usedAttributeIndices )
278 providerSubset << attrIndex;
289 for (
const QString &field : constReferencedColumns )
317 changedIds << attIt.key();
382class QgsThreadStackOverflowGuard
386#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
387 QgsThreadStackOverflowGuard( QThreadStorage<std::deque<QString>> &storage,
const QString &stackFrameInformation,
int maxDepth )
389 QgsThreadStackOverflowGuard( std::deque<QString> &storage,
const QString &stackFrameInformation,
int maxDepth )
391 : mStorage( storage )
392 , mMaxDepth( maxDepth )
394#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
395 if ( !storage.hasLocalData() )
397 storage.setLocalData( std::deque<QString>() );
400 storage.localData().emplace_back( stackFrameInformation );
402 storage.emplace_back( stackFrameInformation );
406 ~QgsThreadStackOverflowGuard()
408#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
409 mStorage.localData().pop_back();
415 bool hasStackOverflow()
const
417#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
418 if ( mStorage.localData().size() > mMaxDepth )
420 if ( mStorage.size() > mMaxDepth )
427 QString topFrames()
const
429 QStringList dumpStack;
430#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
431 const std::deque<QString> &stack = mStorage.localData();
433 const std::deque<QString> &stack = mStorage;
436 const int dumpSize = std::min(
static_cast<int>( stack.size() ), 10 );
437 auto stackIt = stack.begin();
438 for (
int i = 0; i < dumpSize; ++i, stackIt++ )
440 dumpStack += *stackIt;
443 return dumpStack.join(
'\n' );
446 std::size_t depth()
const
448#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
449 return mStorage.localData().size();
451 return mStorage.size();
456#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
457 QThreadStorage<std::deque<QString>> &mStorage;
459 std::deque<QString> &mStorage;
461 std::size_t mMaxDepth;
473#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
474 static QThreadStorage<std::deque<QString>> sStack;
476 static thread_local std::deque<QString> sStack;
479 const QgsThreadStackOverflowGuard guard( sStack,
mSource->
id(), 4 );
481 if ( guard.hasStackOverflow() )
492 if ( res && postProcessFeature( f ) )
571 if ( !postProcessFeature( f ) )
618 mInterruptionChecker = interruptionChecker;
645 if ( !postProcessFeature( f ) )
701 if ( postProcessFeature( f ) )
802 int sourceLayerIndex;
804 Q_ASSERT( joinInfo );
831 mFetchJoinInfo[ joinInfo ].attributes.push_back( sourceLayerIndex );
832 mFetchJoinInfo[ joinInfo ].attributesSourceToDestLayerMap[sourceLayerIndex] = fieldIdx;
838#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
839 static QThreadStorage<std::deque<QString>> sStack;
841 static thread_local std::deque<QString> sStack;
844 const QgsThreadStackOverflowGuard guard( sStack,
mSource->
id(), 4 );
846 if ( guard.hasStackOverflow() )
855 std::unique_ptr<QgsExpression> exp = std::make_unique<QgsExpression>( exps[oi].cachedExpression );
860 exp->setGeomCalculator( &da );
864 if ( !mExpressionContext )
865 createExpressionContext();
866 exp->prepare( mExpressionContext.get() );
867 const QSet<int> referencedColumns = exp->referencedAttributeIndexes(
mSource->
fields() );
871 for (
const int dependentFieldIdx : referencedColumns )
875 requestedAttributes += dependentFieldIdx;
878 if ( !mPreparedFields.contains( dependentFieldIdx ) && !mFieldsToPrepare.contains( dependentFieldIdx ) )
879 mFieldsToPrepare << dependentFieldIdx;
887 if ( exp->needsGeometry() )
897 mPreparedFields.clear();
898 mFieldsToPrepare.clear();
900 mOrderedJoinInfoList.clear();
902 mExpressionContext.reset();
908 while ( !mFieldsToPrepare.isEmpty() )
910 const int fieldIdx = mFieldsToPrepare.takeFirst();
911 if ( mPreparedFields.contains( fieldIdx ) )
914 mPreparedFields << fieldIdx;
921 createOrderedJoinList();
926void QgsVectorLayerFeatureIterator::createOrderedJoinList()
929 if ( mOrderedJoinInfoList.size() < 2 )
934 QSet<int> resolvedFields;
937 QList< int >::const_iterator prepFieldIt = mPreparedFields.constBegin();
938 for ( ; prepFieldIt != mPreparedFields.constEnd(); ++prepFieldIt )
942 resolvedFields.insert( *prepFieldIt );
949 const int maxIterations = ( mOrderedJoinInfoList.size() + 1 ) * mOrderedJoinInfoList.size() / 2.0;
950 int currentIteration = 0;
952 for (
int i = 0; i < mOrderedJoinInfoList.size() - 1; ++i )
954 if ( !resolvedFields.contains( mOrderedJoinInfoList.at( i ).targetField ) )
956 mOrderedJoinInfoList.append( mOrderedJoinInfoList.at( i ) );
957 mOrderedJoinInfoList.removeAt( i );
962 const int offset = mOrderedJoinInfoList.at( i ).indexOffset;
963 const int joinField = mOrderedJoinInfoList.at( i ).joinField;
965 const QgsAttributeList attributes = mOrderedJoinInfoList.at( i ).attributes;
966 for (
int n = 0; n < attributes.size(); n++ )
968 if ( n != joinField )
970 resolvedFields.insert( joinField < n ? n + offset - 1 : n + offset );
976 if ( currentIteration >= maxIterations )
983bool QgsVectorLayerFeatureIterator::postProcessFeature(
QgsFeature &feature )
985 bool result = checkGeometryValidity( feature );
997bool QgsVectorLayerFeatureIterator::checkGeometryValidity(
const QgsFeature &feature )
1065 QList< FetchJoinInfo >::const_iterator joinIt = mOrderedJoinInfoList.constBegin();
1066 for ( ; joinIt != mOrderedJoinInfoList.constEnd(); ++joinIt )
1068 const QVariant targetFieldValue = f.
attribute( joinIt->targetField );
1069 if ( !targetFieldValue.isValid() )
1072 const QHash< QString, QgsAttributes> &memoryCache = joinIt->joinInfo->cachedAttributes;
1073 if ( memoryCache.isEmpty() )
1074 joinIt->addJoinedAttributesDirect( f, targetFieldValue );
1076 joinIt->addJoinedAttributesCached( f, targetFieldValue );
1090 QList< int > fetchedVirtualAttributes;
1092 QMap<const QgsVectorLayerJoinInfo *, FetchJoinInfo>::const_iterator joinIt =
mFetchJoinInfo.constBegin();
1099 fetchedVirtualAttributes << joinIt->targetField;
1112 if ( fetchedVirtualAttributes.contains( it.key() ) )
1125 if ( !mExpressionContext )
1126 createExpressionContext();
1128 mExpressionContext->setFeature( f );
1129 QVariant val = exp->
evaluate( mExpressionContext.get() );
1141 Q_UNUSED( simplifyMethod )
1147 Q_UNUSED( methodType )
1155 const QHash<QString, QgsAttributes>::const_iterator it = memoryCache.find( joinValue.toString() );
1156 if ( it == memoryCache.constEnd() )
1162 for (
int i = 0; i < featureAttributes.count(); ++i )
1174 if ( joinLayer && ! joinLayer->hasFeatures() )
1181 QString subsetString;
1183 const QString joinFieldName = joinInfo->joinFieldName();
1185 subsetString.append( QStringLiteral(
"\"%1\"" ).arg( joinFieldName ) );
1189 subsetString += QLatin1String(
" IS NULL" );
1193 QString v = joinValue.toString();
1194 switch ( joinValue.userType() )
1196 case QMetaType::Type::Int:
1197 case QMetaType::Type::LongLong:
1198 case QMetaType::Type::Double:
1202 case QMetaType::Type::QString:
1203 v.replace(
'\'', QLatin1String(
"''" ) );
1204 v.prepend(
'\'' ).append(
'\'' );
1207 subsetString +=
'=' + v;
1210 QList<int> joinedAttributeIndices;
1214 if ( joinInfo->hasSubset() )
1218 joinedAttributeIndices = qgis::setToList( qgis::listToSet( attributes ).intersect( qgis::listToSet( subsetIndices.toList() ) ) );
1222 joinedAttributeIndices = attributes;
1226 joinedAttributeIndices.removeAll( joinField );
1237 const QList<int> sourceAttrIndexes = attributesSourceToDestLayerMap.keys();
1243 for (
const int sourceAttrIndex : sourceAttrIndexes )
1245 if ( sourceAttrIndex == joinField )
1248 const int destAttrIndex = attributesSourceToDestLayerMap.value( sourceAttrIndex );
1250 f.
setAttribute( destAttrIndex, attr.at( sourceAttrIndex ) );
1280 if ( iter->id() == featureId )
1324 for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
1325 attrs[it.key()] = it.value();
1336void QgsVectorLayerFeatureIterator::createExpressionContext()
1338 mExpressionContext = std::make_unique< QgsExpressionContext >();
1345bool QgsVectorLayerFeatureIterator::prepareOrderBy(
const QList<QgsFeatureRequest::OrderByClause> &orderBys )
1347 Q_UNUSED( orderBys )
1348 return mDelegatedOrderByToProvider;
1358 , mSelectedFeatureIds( layer->selectedFeatureIds() )
1359 , mWkbType( layer->wkbType() )
1360 , mName( layer->name() )
1385 return QgsFeatureIterator(
new QgsVectorLayerSelectedFeatureIterator( mSelectedFeatureIds, req, mSource ) );
1390 return mSource.
crs();
1405 return mSelectedFeatureIds.count();
1416 return mLayer->createExpressionContextScope();
1424 return mLayer->hasSpatialIndex();
1436 , mSelectedFeatureIds( selectedFeatureIds )
1449bool QgsVectorLayerSelectedFeatureIterator::rewind()
1451 return mIterator.
rewind();
1454bool QgsVectorLayerSelectedFeatureIterator::close()
1456 return mIterator.close();
1459bool QgsVectorLayerSelectedFeatureIterator::fetchFeature(
QgsFeature &f )
1461 while ( mIterator.nextFeature( f ) )
1463 if ( mSelectedFeatureIds.contains( f.
id() ) )
@ Fid
Filter using feature ID.
@ Expression
Filter using expression.
@ NoFilter
No filter is applied.
SpatialIndexPresence
Enumeration of spatial index presence states.
@ Unknown
Spatial index presence cannot be determined, index may or may not exist.
@ SubsetOfAttributes
Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
@ Critical
Critical/error message.
@ DistanceWithin
Filter by distance to reference geometry.
@ BoundingBox
Filter using a bounding box.
@ NoFilter
No spatial filtering of features.
@ Provider
Field originates from the underlying data provider of the vector layer.
@ Edit
Field has been temporarily added in editing mode.
@ Unknown
The field origin has not been specified.
@ Expression
Field is calculated from an expression.
@ Join
Field originates from a joined layer.
@ NoCheck
No invalid geometry checking.
@ AbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ SkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
WkbType
The WKB type describes the number of dimensions a geometry has.
Helper template that cares of two things: 1.
void iteratorClosed()
to be called by from subclass in close()
QgsVectorLayerFeatureSource * mSource
Internal feature iterator to be implemented within data providers.
@ Success
Request was successfully updated to the source CRS, or no changes were required.
@ DistanceWithinMustBeCheckedManually
The distance within request cannot be losslessly updated to the source CRS, and callers will need to ...
void geometryToDestinationCrs(QgsFeature &feature, const QgsCoordinateTransform &transform) const
Transforms feature's geometry according to the specified coordinate transform.
QgsFeatureRequest mRequest
A copy of the feature request.
RequestToSourceCrsResult updateRequestToSourceCrs(QgsFeatureRequest &request, const QgsCoordinateTransform &transform) const
Update a QgsFeatureRequest so that spatial filters are transformed to the source's coordinate referen...
bool mClosed
Sets to true, as soon as the iterator is closed.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Custom exception class for Coordinate Reference System related exceptions.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
Single scope for storing variables and functions for use within a QgsExpressionContext.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the context.
Buffers information about expression fields for a vector layer.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
QVariant evaluate()
Evaluate the feature and return the result.
QSet< int > referencedAttributeIndexes(const QgsFields &fields) const
Returns a list of field name indexes obtained from the provided fields.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
bool isClosed() const
find out whether the iterator is still valid or closed already
void setInterruptionChecker(QgsFeedback *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped.
bool isValid() const
Will return if this iterator is valid.
bool close()
Call to end the iteration.
bool rewind()
Resets the iterator to the starting position.
Represents a list of OrderByClauses, with the most important first and the least important last.
QSet< int > CORE_EXPORT usedAttributeIndices(const QgsFields &fields) const
Returns a set of used, validated attribute indices.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setLimit(long long limit)
Set the maximum number of features to request.
QgsFeatureRequest & setCoordinateTransform(const QgsCoordinateTransform &transform)
Sets the coordinate transform which will be used to transform the feature's geometries.
QgsRectangle filterRect() const
Returns the rectangle from which features will be taken.
QgsFeedback * feedback() const
Returns the feedback object that can be queried regularly by the iterator to check if it should be ca...
long long limit() const
Returns the maximum number of features to request, or -1 if no limit set.
QgsExpressionContext * expressionContext()
Returns the expression context used to evaluate filter expressions.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets the feature IDs that should be fetched.
OrderBy orderBy() const
Returns a list of order by clauses specified for this feature request.
std::function< void(const QgsFeature &) > invalidGeometryCallback() const
Returns the callback function to use when encountering an invalid geometry and invalidGeometryCheck()...
Qgis::FeatureRequestFilterType filterType() const
Returns the attribute/ID filter type which is currently set on this request.
QgsGeometry referenceGeometry() const
Returns the reference geometry used for spatial filtering of features.
Qgis::FeatureRequestFlags flags() const
Returns the flags which affect how features are fetched.
QgsFeatureRequest & disableFilter()
Disables any attribute/ID filtering.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsExpression * filterExpression() const
Returns the filter expression (if set).
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for feature's geometries, or an invalid QgsCoordi...
QgsCoordinateTransform coordinateTransform() const
Returns the coordinate transform which will be used to transform the feature's geometries.
bool acceptFeature(const QgsFeature &feature)
Check if a feature is accepted by this requests filter.
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when a destinationCrs() has been set and reprojection is requi...
QgsCoordinateTransform calculateTransform(const QgsCoordinateReferenceSystem &sourceCrs) const
Calculates the coordinate transform to use to transform geometries when they are originally in source...
std::shared_ptr< QgsGeometryEngine > referenceGeometryEngine() const
Returns the reference geometry engine used for spatial filtering of features.
Qgis::SpatialFilterType spatialFilterType() const
Returns the spatial filter type which is currently set on this request.
double distanceWithin() const
Returns the maximum distance from the referenceGeometry() of fetched features, if spatialFilterType()...
QgsAttributeList subsetOfAttributes() const
Returns the subset of attributes which at least need to be fetched.
Qgis::InvalidGeometryCheck invalidGeometryCheck() const
Returns the invalid geometry checking behavior.
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
const QgsFeatureIds & filterFids() const
Returns the feature IDs that should be fetched.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets the feature ID that should be fetched.
QgsFeatureId filterFid() const
Returns the feature ID that should be fetched.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE bool setAttribute(int field, const QVariant &attr)
Sets an attribute's value by field index.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
void setFields(const QgsFields &fields, bool initAttributes=false)
Assigns a field map with the feature to allow attribute access by attribute name.
int attributeCount() const
Returns the number of attributes attached to the feature.
void padAttributes(int count)
Resizes the attributes attached to this feature by appending the specified count of NULL values to th...
void setId(QgsFeatureId id)
Sets the feature id for this feature.
void setValid(bool validity)
Sets the validity of the feature.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool convertCompatible(QVariant &v, QString *errorMessage=nullptr) const
Converts the provided variant to a compatible format.
Container of fields for a vector layer.
QgsAttributeList allAttributesList() const
Utility function to get list of attribute indexes.
Q_INVOKABLE int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
Qgis::FieldOrigin fieldOrigin(int fieldIdx) const
Returns the field's origin (value from an enumeration).
Q_INVOKABLE bool exists(int i) const
Returns if a field index is valid.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
int fieldOriginIndex(int fieldIdx) const
Returns the field's origin index (its meaning is specific to each type of origin).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
bool isGeosValid(Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const
Checks validity of the geometry using GEOS.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsCoordinateReferenceSystem crs
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsCoordinateTransformContext transformContext
bool isNull() const
Test if the rectangle is null (holding no spatial information).
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
This is the base class for vector data providers.
virtual QgsAbstractFeatureSource * featureSource() const =0
Returns feature source object that can be used for querying provider's data.
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
QgsFeatureIds deletedFeatureIds() const
Returns a list of deleted feature IDs which are not committed.
QgsChangedAttributesMap changedAttributeValues() const
Returns a map of features with changed attributes values which are not committed.
QgsFeatureMap addedFeatures() const
Returns a map of new features which are not committed.
QgsGeometryMap changedGeometries() const
Returns a map of features with changed geometries which are not committed.
QList< QgsField > addedAttributes() const
Returns a list of added attributes fields which are not committed.
QgsAttributeList deletedAttributeIds() const
Returns a list of deleted attributes fields which are not committed.
void updateChangedAttributes(QgsFeature &f)
Update feature with uncommitted attribute updates.
void prepareExpression(int fieldIdx)
void useAddedFeature(const QgsFeature &src, QgsFeature &f)
QMap< const QgsVectorLayerJoinInfo *, QgsVectorLayerFeatureIterator::FetchJoinInfo > mFetchJoinInfo
Information about joins used in the current select() statement.
void prepareField(int fieldIdx)
QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt
bool mHasVirtualAttributes
QgsFeatureRequest mProviderRequest
QSet< QgsFeatureId > mFetchConsidered
void setInterruptionChecker(QgsFeedback *interruptionChecker) override
Attach an object that can be queried regularly by the iterator to check if it must stopped.
void addVirtualAttributes(QgsFeature &f)
Adds attributes that don't source from the provider but are added inside QGIS Includes.
bool close() override
end of iterating: free the resources / lock
void updateFeatureGeometry(QgsFeature &f)
Update feature with uncommitted geometry updates.
bool nextFeatureFid(QgsFeature &f)
QgsFeatureRequest mChangedFeaturesRequest
QgsGeometry mDistanceWithinGeom
QgsFeatureIterator mChangedFeaturesIterator
bool fetchNextAddedFeature(QgsFeature &f)
void addExpressionAttribute(QgsFeature &f, int attrIndex)
Adds an expression based attribute to a feature.
QMap< int, QgsExpression * > mExpressionFieldInfo
QgsGeometryMap::ConstIterator mFetchChangedGeomIt
bool prepareSimplification(const QgsSimplifyMethod &simplifyMethod) override
Setup the simplification of geometries to fetch using the specified simplify method.
void prepareJoin(int fieldIdx)
void useChangedAttributeFeature(QgsFeatureId fid, const QgsGeometry &geom, QgsFeature &f)
bool fetchFeature(QgsFeature &feature) override
fetch next feature, return true on success
~QgsVectorLayerFeatureIterator() override
std::shared_ptr< QgsGeometryEngine > mDistanceWithinEngine
void addJoinedAttributes(QgsFeature &f)
bool isValid() const override
Returns if this iterator is valid.
bool rewind() override
reset the iterator to the starting position
bool fetchNextChangedGeomFeature(QgsFeature &f)
QgsFeatureIterator mProviderIterator
QgsCoordinateTransform mTransform
bool fetchNextChangedAttributeFeature(QgsFeature &f)
QgsVectorLayerFeatureIterator(QgsVectorLayerFeatureSource *source, bool ownSource, const QgsFeatureRequest &request)
Partial snapshot of vector layer's state (only the members necessary for access to features)
QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system for features retrieved from this source.
QgsChangedAttributesMap mChangedAttributeValues
QgsCoordinateReferenceSystem mCrs
QList< QgsField > mAddedAttributes
std::unique_ptr< QgsAbstractFeatureSource > mProviderFeatureSource
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) override
Gets an iterator for features matching the specified request.
QgsVectorLayerFeatureSource(const QgsVectorLayer *layer)
Constructor for QgsVectorLayerFeatureSource.
~QgsVectorLayerFeatureSource() override
QgsFeatureIds mDeletedFeatureIds
QString id() const
Returns the layer id of the source layer.
QgsAttributeList mDeletedAttributeIds
QgsExpressionContextScope mLayerScope
QgsFields fields() const
Returns the fields that will be available for features that are retrieved from this source.
std::unique_ptr< QgsVectorLayerJoinBuffer > mJoinBuffer
std::unique_ptr< QgsExpressionFieldBuffer > mExpressionFieldBuffer
QMap< QString, JoinLayerSource > mJoinSources
Contains prepared join sources by layer ID.
friend class QgsVectorLayerFeatureIterator
QgsFeatureMap mAddedFeatures
QgsGeometryMap mChangedGeometries
bool containsJoins() const
Quick way to test if there is any join at all.
QgsVectorLayerJoinBuffer * clone() const
Create a copy of the join buffer.
void createJoinCaches()
Calls cacheJoinLayer() for all vector joins.
static QVector< int > joinSubsetIndices(QgsVectorLayer *joinLayer, const QStringList &joinFieldsSubset)
Returns a vector of indices for use in join based on field names from the layer.
Defines left outer join from our vector layer to some other vector layer.
QStringList * joinFieldNamesSubset() const
Returns the subset of fields to be used from joined layer.
QString joinFieldName() const
Returns name of the field of joined layer that will be used for join.
QString targetFieldName() const
Returns name of the field of our layer that will be used for join.
QString joinLayerId() const
ID of the joined layer - may be used to resolve reference to the joined layer.
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching)
long long featureCount() const override
Returns the number of features contained in the source, or -1 if the feature count is unknown.
Qgis::WkbType wkbType() const override
Returns the geometry type for features returned by this source.
Qgis::SpatialIndexPresence hasSpatialIndex() const override
Returns an enum value representing the presence of a valid spatial index on the source,...
QgsFields fields() const override
Returns the fields associated with features in the source.
QgsCoordinateReferenceSystem sourceCrs() const override
Returns the coordinate reference system for features in the source.
QgsVectorLayerSelectedFeatureSource(QgsVectorLayer *layer)
Constructor for QgsVectorLayerSelectedFeatureSource, for selected features from the specified layer.
QgsExpressionContextScope * createExpressionContextScope() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QString sourceName() const override
Returns a friendly display name for the source.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Returns an iterator for the features in the source.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
QMap< int, QVariant > QgsAttributeMap
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QList< int > QgsAttributeList
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
const QgsAttributeList & attributeIndexes
Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAtt...
void addJoinedAttributesDirect(QgsFeature &f, const QVariant &joinValue) const
std::shared_ptr< QgsVectorLayerFeatureSource > joinSource
Feature source for join.
QgsFields joinLayerFields
Fields from joined layer.
int targetField
Index of field (of this layer) that drives the join.
const QgsVectorLayerJoinInfo * joinInfo
Canonical source of information about the join.
int indexOffset
At what position the joined fields start.
void addJoinedAttributesCached(QgsFeature &f, const QVariant &joinValue) const
Contains join layer source information prepared in a thread-safe way, ready for vector layer feature ...
std::shared_ptr< QgsVectorLayerFeatureSource > joinSource
Feature source for join.
QgsFields joinLayerFields
Fields from joined layer.