| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   32 #include <QThreadStorage> 
   37   const QMutexLocker locker( &layer->mFeatureSourceConstructorMutex );
 
   62       if ( L->editBuffer()->addedFeatures().contains( request.filterFid() ) )
 
   63         mAddedFeatures.insert( request.filterFid(), L->editBuffer()->addedFeatures()[ request.filterFid()] );
 
   65       if ( L->editBuffer()->changedGeometries().contains( request.filterFid() ) )
 
   66         mChangedGeometries.insert( request.filterFid(), L->editBuffer()->changedGeometries()[ request.filterFid()] );
 
   68       if ( L->editBuffer()->deletedFeatureIds().contains( request.filterFid() ) )
 
   71       if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
 
   72         mChangedAttributeValues.insert( request.filterFid(), L->editBuffer()->changedAttributeValues()[ request.filterFid()] );
 
   74       if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
 
   75         mChangedFeaturesRequest.setFilterFids( 
QgsFeatureIds() << request.filterFid() );
 
  125   , mFetchedFid( false )
 
  157   bool canDelegateLimitToProvider = 
true;
 
  168         canDelegateLimitToProvider = 
false;
 
  188     for ( 
const int attrIndex : usedAttributeIndices )
 
  191         mDelegatedOrderByToProvider = 
false;
 
  231   if ( !mDelegatedOrderByToProvider )
 
  236   if ( !canDelegateLimitToProvider )
 
  244     QSet<int> providerSubset;
 
  247     for ( 
const int attrIndex : subset )
 
  249       if ( attrIndex < 0 || attrIndex >= nPendingFields )
 
  263       for ( 
const int attrIndex : usedAttributeIndices )
 
  265         providerSubset << attrIndex;
 
  276     for ( 
const QString &
field : constReferencedColumns )
 
  304       changedIds << attIt.key();
 
  369 class QgsThreadStackOverflowGuard
 
  373     QgsThreadStackOverflowGuard( QThreadStorage<QStack<QString>> &storage, 
const QString &stackFrameInformation, 
int maxDepth )
 
  374       : mStorage( storage )
 
  375       , mMaxDepth( maxDepth )
 
  377       if ( !storage.hasLocalData() )
 
  379         storage.setLocalData( QStack<QString>() );
 
  382       storage.localData().push( stackFrameInformation );
 
  385     ~QgsThreadStackOverflowGuard()
 
  387       mStorage.localData().pop();
 
  390     bool hasStackOverflow()
 const 
  392       if ( mStorage.localData().size() > mMaxDepth )
 
  398     QString topFrames()
 const 
  400       QStringList dumpStack;
 
  401       const QStack<QString> &stack = mStorage.localData();
 
  403       const int dumpSize = std::min( 
static_cast<int>( stack.size() ), 10 );
 
  404       for ( 
int i = 0; i < dumpSize; ++i )
 
  406         dumpStack += stack.at( i );
 
  409       return dumpStack.join( 
'\n' );
 
  414       return mStorage.localData().size();
 
  418     QThreadStorage<QStack<QString>> &mStorage;
 
  431   static QThreadStorage<QStack<QString>> sStack;
 
  433   const QgsThreadStackOverflowGuard guard( sStack, 
mSource->
id(), 4 );
 
  435   if ( guard.hasStackOverflow() )
 
  437     QgsMessageLog::logMessage( QObject::tr( 
"Stack overflow, too many nested feature iterators.\nIterated layers:\n%3\n..." ).arg( 
mSource->
id(), guard.topFrames() ), QObject::tr( 
"General" ), Qgis::MessageLevel::Critical );
 
  446     if ( res && postProcessFeature( f ) )
 
  523     if ( !postProcessFeature( f ) )
 
  570   mInterruptionChecker = interruptionChecker;
 
  597     if ( !postProcessFeature( f ) )
 
  651     if ( postProcessFeature( f ) )
 
  752   int sourceLayerIndex;
 
  754   Q_ASSERT( joinInfo );
 
  764     info.
joinSource = std::make_shared< QgsVectorLayerFeatureSource >( joinLayer );
 
  781   mFetchJoinInfo[ joinInfo ].attributes.push_back( sourceLayerIndex );
 
  782   mFetchJoinInfo[ joinInfo ].attributesSourceToDestLayerMap[sourceLayerIndex] = fieldIdx;
 
  788   static QThreadStorage<QStack<QString>> sStack;
 
  790   const QgsThreadStackOverflowGuard guard( sStack, 
mSource->
id(), 4 );
 
  792   if ( guard.hasStackOverflow() )
 
  801   std::unique_ptr<QgsExpression> exp = std::make_unique<QgsExpression>( exps[oi].cachedExpression );
 
  806   exp->setGeomCalculator( &da );
 
  810   if ( !mExpressionContext )
 
  811     createExpressionContext();
 
  812   exp->prepare( mExpressionContext.get() );
 
  813   const QSet<int> referencedColumns = exp->referencedAttributeIndexes( 
mSource->
fields() );
 
  817   for ( 
const int dependentFieldIdx : referencedColumns )
 
  821       requestedAttributes += dependentFieldIdx;
 
  824     if ( !mPreparedFields.contains( dependentFieldIdx ) && !mFieldsToPrepare.contains( dependentFieldIdx ) )
 
  825       mFieldsToPrepare << dependentFieldIdx;
 
  833   if ( exp->needsGeometry() )
 
  843   mPreparedFields.clear();
 
  844   mFieldsToPrepare.clear();
 
  846   mOrderedJoinInfoList.clear();
 
  848   mExpressionContext.reset();
 
  854   while ( !mFieldsToPrepare.isEmpty() )
 
  856     const int fieldIdx = mFieldsToPrepare.takeFirst();
 
  857     if ( mPreparedFields.contains( fieldIdx ) )
 
  860     mPreparedFields << fieldIdx;
 
  867     createOrderedJoinList();
 
  871 void QgsVectorLayerFeatureIterator::createOrderedJoinList()
 
  874   if ( mOrderedJoinInfoList.size() < 2 )
 
  879   QSet<int> resolvedFields; 
 
  882   QList< int >::const_iterator prepFieldIt = mPreparedFields.constBegin();
 
  883   for ( ; prepFieldIt != mPreparedFields.constEnd(); ++prepFieldIt )
 
  887       resolvedFields.insert( *prepFieldIt );
 
  894   const int maxIterations = ( mOrderedJoinInfoList.size() + 1 ) * mOrderedJoinInfoList.size() / 2.0;
 
  895   int currentIteration = 0;
 
  897   for ( 
int i = 0; i < mOrderedJoinInfoList.size() - 1; ++i )
 
  899     if ( !resolvedFields.contains( mOrderedJoinInfoList.at( i ).targetField ) )
 
  901       mOrderedJoinInfoList.append( mOrderedJoinInfoList.at( i ) );
 
  902       mOrderedJoinInfoList.removeAt( i );
 
  907       const int offset = mOrderedJoinInfoList.at( i ).indexOffset;
 
  908       const int joinField = mOrderedJoinInfoList.at( i ).joinField;
 
  910       const QgsAttributeList attributes = mOrderedJoinInfoList.at( i ).attributes;
 
  911       for ( 
int n = 0; n < attributes.size(); n++ )
 
  913         if ( n != joinField )
 
  915           resolvedFields.insert( joinField < n ? n + offset - 1 : n + offset );
 
  921     if ( currentIteration >= maxIterations )
 
  928 bool QgsVectorLayerFeatureIterator::postProcessFeature( 
QgsFeature &feature )
 
  930   bool result = checkGeometryValidity( feature );
 
  942 bool QgsVectorLayerFeatureIterator::checkGeometryValidity( 
const QgsFeature &feature )
 
  956         QgsMessageLog::logMessage( QObject::tr( 
"Geometry error: One or more input features have invalid geometry." ), QString(), Qgis::MessageLevel::Critical );
 
  969         QgsMessageLog::logMessage( QObject::tr( 
"Geometry error: One or more input features have invalid geometry." ), QString(), Qgis::MessageLevel::Critical );
 
 1007   QList< FetchJoinInfo >::const_iterator joinIt = mOrderedJoinInfoList.constBegin();
 
 1008   for ( ; joinIt != mOrderedJoinInfoList.constEnd(); ++joinIt )
 
 1010     const QVariant targetFieldValue = f.
attribute( joinIt->targetField );
 
 1011     if ( !targetFieldValue.isValid() )
 
 1014     const QHash< QString, QgsAttributes> &memoryCache = joinIt->joinInfo->cachedAttributes;
 
 1015     if ( memoryCache.isEmpty() )
 
 1016       joinIt->addJoinedAttributesDirect( f, targetFieldValue );
 
 1018       joinIt->addJoinedAttributesCached( f, targetFieldValue );
 
 1032   QList< int > fetchedVirtualAttributes;
 
 1034   QMap<const QgsVectorLayerJoinInfo *, FetchJoinInfo>::const_iterator joinIt = 
mFetchJoinInfo.constBegin();
 
 1041       fetchedVirtualAttributes << joinIt->targetField;
 
 1054       if ( fetchedVirtualAttributes.contains( it.key() ) )
 
 1067     if ( !mExpressionContext )
 
 1068       createExpressionContext();
 
 1070     mExpressionContext->setFeature( f );
 
 1071     QVariant val = exp->
evaluate( mExpressionContext.get() );
 
 1083   Q_UNUSED( simplifyMethod )
 
 1089   Q_UNUSED( methodType )
 
 1097   const QHash<QString, QgsAttributes>::const_iterator it = memoryCache.find( joinValue.toString() );
 
 1098   if ( it == memoryCache.constEnd() )
 
 1104   for ( 
int i = 0; i < featureAttributes.count(); ++i )
 
 1114 #if 0 // this is not thread safe -- we cannot access the layer here as this will be called from non-main threads. 
 1116   if ( joinLayer && ! joinLayer->hasFeatures() )
 
 1123   QString subsetString;
 
 1125   const QString joinFieldName = joinInfo->joinFieldName();
 
 1127   subsetString.append( QStringLiteral( 
"\"%1\"" ).arg( joinFieldName ) );
 
 1129   if ( joinValue.isNull() )
 
 1131     subsetString += QLatin1String( 
" IS NULL" );
 
 1135     QString v = joinValue.toString();
 
 1136     switch ( joinValue.type() )
 
 1139       case QVariant::LongLong:
 
 1140       case QVariant::Double:
 
 1144       case QVariant::String:
 
 1145         v.replace( 
'\'', QLatin1String( 
"''" ) );
 
 1146         v.prepend( 
'\'' ).append( 
'\'' );
 
 1149     subsetString += 
'=' + v;
 
 1152   QList<int> joinedAttributeIndices;
 
 1156   if ( joinInfo->hasSubset() )
 
 1160     joinedAttributeIndices = qgis::setToList( qgis::listToSet( attributes ).intersect( qgis::listToSet( subsetIndices.toList() ) ) );
 
 1164     joinedAttributeIndices = attributes;
 
 1168   joinedAttributeIndices.removeAll( joinField );
 
 1179   const QList<int> sourceAttrIndexes = attributesSourceToDestLayerMap.keys();
 
 1185     for ( 
const int sourceAttrIndex : sourceAttrIndexes )
 
 1187       if ( sourceAttrIndex == joinField )
 
 1190       const int destAttrIndex = attributesSourceToDestLayerMap.value( sourceAttrIndex );
 
 1192       f.
setAttribute( destAttrIndex, attr.at( sourceAttrIndex ) );
 
 1222     if ( iter->id() == featureId )
 
 1264     for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
 
 1265       attrs[it.key()] = it.value();
 
 1276 void QgsVectorLayerFeatureIterator::createExpressionContext()
 
 1278   mExpressionContext = std::make_unique< QgsExpressionContext >();
 
 1285 bool QgsVectorLayerFeatureIterator::prepareOrderBy( 
const QList<QgsFeatureRequest::OrderByClause> &orderBys )
 
 1287   Q_UNUSED( orderBys )
 
 1288   return mDelegatedOrderByToProvider;
 
 1298   , mSelectedFeatureIds( layer->selectedFeatureIds() )
 
 1299   , mWkbType( layer->wkbType() )
 
 1300   , mName( layer->name() )
 
 1325   return QgsFeatureIterator( 
new QgsVectorLayerSelectedFeatureIterator( mSelectedFeatureIds, req, mSource ) );
 
 1330   return mSource.
crs();
 
 1345   return mSelectedFeatureIds.count();
 
 1356     return mLayer->createExpressionContextScope();
 
 1364     return mLayer->hasSpatialIndex();
 
 1376   , mSelectedFeatureIds( selectedFeatureIds )
 
 1389 bool QgsVectorLayerSelectedFeatureIterator::rewind()
 
 1391   return mIterator.
rewind();
 
 1394 bool QgsVectorLayerSelectedFeatureIterator::close()
 
 1396   return mIterator.close();
 
 1399 bool QgsVectorLayerSelectedFeatureIterator::fetchFeature( 
QgsFeature &f )
 
 1401   while ( mIterator.nextFeature( f ) )
 
 1403     if ( mSelectedFeatureIds.contains( f.
id() ) )
 
  
@ OriginProvider
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
 
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
 
bool fetchNextAddedFeature(QgsFeature &f)
 
std::function< void(const QgsFeature &) > invalidGeometryCallback() const
Returns the callback function to use when encountering an invalid geometry and invalidGeometryCheck()...
 
QgsCoordinateReferenceSystem crs
 
QgsExpressionContextScope mLayerScope
 
Q_INVOKABLE QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on.
 
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) override
Gets an iterator for features matching the specified request.
 
QgsFeatureIterator mChangedFeaturesIterator
 
void setInterruptionChecker(QgsFeedback *interruptionChecker) override
Attach an object that can be queried regularly by the iterator to check if it must stopped.
 
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.
 
@ OriginEdit
Field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
 
@ FilterFid
Filter using feature ID.
 
void prepareJoin(int fieldIdx)
 
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
 
const QgsFeatureIds & filterFids() const
Returns the feature IDs that should be fetched.
 
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
 
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
 
void addJoinedAttributesDirect(QgsFeature &f, const QVariant &joinValue) const
 
@ NoFilter
No spatial filtering of features.
 
QgsFeedback * feedback() const
Returns the feedback object that can be queried regularly by the iterator to check if it should be ca...
 
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when a destinationCrs() has been set and reprojection is requi...
 
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
 
bool acceptFeature(const QgsFeature &feature)
Check if a feature is accepted by this requests filter.
 
QgsCoordinateTransform mTransform
 
long long featureCount() const override
Returns the number of features contained in the source, or -1 if the feature count is unknown.
 
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
 
void setId(QgsFeatureId id)
Sets the feature id for this feature.
 
QgsVectorLayerFeatureIterator(QgsVectorLayerFeatureSource *source, bool ownSource, const QgsFeatureRequest &request)
 
QgsCoordinateReferenceSystem sourceCrs() const override
Returns the coordinate reference system for features in the source.
 
void addVirtualAttributes(QgsFeature &f)
Adds attributes that don't source from the provider but are added inside QGIS Includes.
 
QgsFeatureId filterFid() const
Returns the feature ID that should be fetched.
 
QgsFeatureMap mAddedFeatures
 
std::shared_ptr< QgsGeometryEngine > referenceGeometryEngine() const
Returns the reference geometry engine used for spatial filtering of features.
 
void iteratorClosed()
to be called by from subclass in close()
 
QMap< int, QgsExpression * > mExpressionFieldInfo
 
FilterType filterType() const
Returns the attribute/ID filter type which is currently set on this request.
 
bool mClosed
Sets to true, as soon as the iterator is closed.
 
int count() const
Returns number of items.
 
Container of fields for a vector layer.
 
QSet< int > referencedAttributeIndexes(const QgsFields &fields) const
Returns a list of field name indexes obtained from the provided fields.
 
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
 
@ DistanceWithinMustBeCheckedManually
The distance within request cannot be losslessly updated to the source CRS, and callers will need to ...
 
QgsAttributeList mDeletedAttributeIds
 
QgsCoordinateTransformContext transformContext
 
void setValid(bool validity)
Sets the validity of the feature.
 
QgsFields fields() const
Returns the fields that will be available for features that are retrieved from this source.
 
QgsRectangle filterRect() const
Returns the rectangle from which features will be taken.
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
 
QStringList * joinFieldNamesSubset() const
Returns the subset of fields to be used from joined layer.
 
QgsVectorLayerFeatureSource * mSource
 
QgsChangedAttributesMap mChangedAttributeValues
 
bool fetchNextChangedAttributeFeature(QgsFeature &f)
 
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the context.
 
Type
The WKB type describes the number of dimensions a geometry has.
 
QgsFeatureIterator mProviderIterator
 
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for feature's geometries, or an invalid QgsCoordi...
 
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
 
QgsFeatureRequest mRequest
A copy of the feature request.
 
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
 
void addExpressionAttribute(QgsFeature &f, int attrIndex)
Adds an expression based attribute to a feature.
 
QString sourceName() const override
Returns a friendly display name for the source.
 
bool isClosed() const
find out whether the iterator is still valid or closed already
 
@ GeometrySkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
 
void addJoinedAttributes(QgsFeature &f)
 
QgsGeometryMap::ConstIterator mFetchChangedGeomIt
 
QList< int > QgsAttributeList
 
@ SubsetOfAttributes
Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)
 
QgsFeatureRequest & disableFilter()
Disables any attribute/ID filtering.
 
Helper template that cares of two things: 1. automatic deletion of source if owned by iterator,...
 
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets the feature ID that should be fetched.
 
QgsExpressionContext * expressionContext()
Returns the expression context used to evaluate filter expressions.
 
Flags flags() const
Returns the flags which affect how features are fetched.
 
QgsGeometryMap mChangedGeometries
 
void addJoinedAttributesCached(QgsFeature &f, const QVariant &joinValue) const
 
QgsVectorLayerSelectedFeatureSource(QgsVectorLayer *layer)
Constructor for QgsVectorLayerSelectedFeatureSource, for selected features from the specified layer.
 
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
 
QString targetFieldName() const
Returns name of the field of our layer that will be used for join.
 
QgsFields fields() const FINAL
Returns the list of fields of this layer.
 
QgsWkbTypes::Type wkbType() const override
Returns the geometry type for features returned by this source.
 
bool fetchFeature(QgsFeature &feature) override
fetch next feature, return true on success
 
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
 
This class wraps a request for features to a vector layer (or directly its vector data provider).
 
QgsFeatureRequest mChangedFeaturesRequest
 
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
 
Custom exception class for Coordinate Reference System related exceptions.
 
void prepareField(int fieldIdx)
 
long long limit() const
Returns the maximum number of features to request, or -1 if no limit set.
 
bool prepareSimplification(const QgsSimplifyMethod &simplifyMethod) override
Setup the simplification of geometries to fetch using the specified simplify method.
 
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
 
QgsExpressionContextScope * createExpressionContextScope() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
 
QgsAttributeList deletedAttributeIds() const
Returns a list of deleted attributes fields which are not committed.
 
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching)
 
void setFields(const QgsFields &fields, bool initAttributes=false)
Assigns a field map with the feature to allow attribute access by attribute name.
 
bool exists(int i) const
Returns if a field index is valid.
 
double distanceWithin() const
Returns the maximum distance from the referenceGeometry() of fetched features, if spatialFilterType()...
 
QgsFields fields() const override
Returns the fields associated with features in the source.
 
virtual QgsAbstractFeatureSource * featureSource() const =0
Returns feature source object that can be used for querying provider's data.
 
std::unique_ptr< QgsAbstractFeatureSource > mProviderFeatureSource
 
Base class for feedback objects to be used for cancellation of something running in a worker thread.
 
@ OriginUnknown
It has not been specified where the field comes from.
 
QString id() const
Returns the layer id of the source layer.
 
QList< QgsField > mAddedAttributes
 
QgsChangedAttributesMap changedAttributeValues() const
Returns a map of features with changed attributes values which are not committed.
 
SpatialIndexPresence
Enumeration of spatial index presence states.
 
QgsExpression * filterExpression() const
Returns the filter expression (if set).
 
QgsVectorLayerJoinBuffer * clone() const
Create a copy of the join buffer.
 
void updateFeatureGeometry(QgsFeature &f)
Update feature with uncommitted geometry updates.
 
FieldOrigin fieldOrigin(int fieldIdx) const
Returns the field's origin (value from an enumeration).
 
void updateChangedAttributes(QgsFeature &f)
Update feature with uncommitted attribute updates.
 
QMap< int, QVariant > QgsAttributeMap
 
~QgsVectorLayerFeatureIterator() override
 
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).
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
 
void useAddedFeature(const QgsFeature &src, QgsFeature &f)
 
QString joinFieldName() const
Returns name of the field of joined layer that will be used for join.
 
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
 
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
 
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets the feature IDs that should be fetched.
 
void createJoinCaches()
Calls cacheJoinLayer() for all vector joins.
 
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
 
bool nextFeatureFid(QgsFeature &f)
 
void prepareExpression(int fieldIdx)
 
Defines left outer join from our vector layer to some other vector layer. The join is done based on [...
 
Buffers information about expression fields for a vector layer.
 
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
 
@ FilterExpression
Filter using expression.
 
QgsGeometry mDistanceWithinGeom
 
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
 
int indexOffset
At what position the joined fields start.
 
void geometryToDestinationCrs(QgsFeature &feature, const QgsCoordinateTransform &transform) const
Transforms feature's geometry according to the specified coordinate transform.
 
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
 
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
 
QSet< QgsFeatureId > QgsFeatureIds
 
Qgis::SpatialFilterType spatialFilterType() const
Returns the spatial filter type which is currently set on this request.
 
This class represents a coordinate reference system (CRS).
 
QgsCoordinateReferenceSystem mCrs
 
QVariant evaluate()
Evaluate the feature and return the result.
 
Single scope for storing variables and functions for use within a QgsExpressionContext....
 
int targetField
Index of field (of this layer) that drives the join.
 
QSet< int > CORE_EXPORT usedAttributeIndices(const QgsFields &fields) const
Returns a set of used, validated attribute indices.
 
QgsFeatureRequest mProviderRequest
 
Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAtt...
 
QgsFeatureIds deletedFeatureIds() const
Returns a list of deleted feature IDs which are not committed.
 
friend class QgsVectorLayerFeatureIterator
 
QgsAttributeList allAttributesList() const
Utility function to get list of attribute indexes.
 
bool setAttribute(int field, const QVariant &attr)
Sets an attribute's value by field index.
 
bool rewind() override
reset the iterator to the starting position
 
@ OriginExpression
Field is calculated from an expression.
 
Represents a list of OrderByClauses, with the most important first and the least important last.
 
bool nextFeature(QgsFeature &f)
 
A geometry is the spatial representation of a feature.
 
bool mHasVirtualAttributes
 
@ SpatialIndexUnknown
Spatial index presence cannot be determined, index may or may not exist.
 
InvalidGeometryCheck invalidGeometryCheck() const
Returns the invalid geometry checking behavior.
 
OrderBy orderBy() const
Returns a list of order by clauses specified for this feature request.
 
Represents a vector layer which manages a vector based data sets.
 
bool hasGeometry() const
Returns true if the feature has an associated geometry.
 
QgsFeatureRequest & setLimit(long long limit)
Set the maximum number of features to request.
 
@ BoundingBox
Filter using a bounding box.
 
QSet< QgsFeatureId > mFetchConsidered
 
QgsAttributeList subsetOfAttributes() const
Returns the subset of attributes which at least need to be fetched.
 
Partial snapshot of vector layer's state (only the members necessary for access to features)
 
QgsVectorLayer * joinLayer() const
Returns joined layer (may be nullptr if the reference was set by layer ID and not resolved yet)
 
QgsGeometryMap changedGeometries() const
Returns a map of features with changed geometries which are not committed.
 
std::shared_ptr< QgsVectorLayerFeatureSource > joinSource
Feature source for join.
 
int fieldOriginIndex(int fieldIdx) const
Returns the field's origin index (its meaning is specific to each type of origin).
 
std::unique_ptr< QgsExpressionFieldBuffer > mExpressionFieldBuffer
 
QgsVectorLayerFeatureSource(const QgsVectorLayer *layer)
Constructor for QgsVectorLayerFeatureSource.
 
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
 
@ GeometryNoCheck
No invalid geometry checking.
 
bool containsJoins() const
Quick way to test if there is any join at all.
 
std::shared_ptr< QgsGeometryEngine > mDistanceWithinEngine
 
void useChangedAttributeFeature(QgsFeatureId fid, const QgsGeometry &geom, QgsFeature &f)
 
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
 
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
 
A vector of attributes. Mostly equal to QVector<QVariant>.
 
~QgsVectorLayerFeatureSource() override
 
@ FilterNone
No filter is applied.
 
QgsFields joinLayerFields
Fields from joined layer.
 
bool close() override
end of iterating: free the resources / lock
 
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
 
This is the base class for vector data providers.
 
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
 
void setInterruptionChecker(QgsFeedback *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped.
 
bool isValid() const override
Returns if this iterator is valid.
 
RequestToSourceCrsResult updateRequestToSourceCrs(QgsFeatureRequest &request, const QgsCoordinateTransform &transform) const SIP_THROW(QgsCsException)
Update a QgsFeatureRequest so that spatial filters are transformed to the source's coordinate referen...
 
QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system for features retrieved from this source.
 
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
 
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Returns an iterator for the features in the source.
 
SpatialIndexPresence hasSpatialIndex() const override
Returns an enum value representing the presence of a valid spatial index on the source,...
 
const QgsVectorLayerJoinInfo * joinInfo
Canonical source of information about the join.
 
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
 
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
 
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
 
QList< QgsField > addedAttributes() const
Returns a list of added attributes fields which are not committed.
 
Class for parsing and evaluation of expressions (formerly called "search strings")....
 
Wrapper for iterator of features from vector data provider or vector layer.
 
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
 
const QgsAttributeList & attributeIndexes
 
bool fetchNextChangedGeomFeature(QgsFeature &f)
 
Internal feature iterator to be implemented within data providers.
 
QgsFeatureIds mDeletedFeatureIds
 
QMap< const QgsVectorLayerJoinInfo *, QgsVectorLayerFeatureIterator::FetchJoinInfo > mFetchJoinInfo
Information about joins used in the current select() statement.
 
QgsFeatureMap addedFeatures() const
Returns a map of new features which are not committed.
 
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
 
std::unique_ptr< QgsVectorLayerJoinBuffer > mJoinBuffer
 
bool convertCompatible(QVariant &v, QString *errorMessage=nullptr) const
Converts the provided variant to a compatible format.
 
bool isValid() const
Will return if this iterator is valid.
 
int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
 
QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt
 
@ OriginJoin
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
 
@ DistanceWithin
Filter by distance to reference geometry.
 
QgsGeometry referenceGeometry() const
Returns the reference geometry used for spatial filtering of features.
 
@ Success
Request was successfully updated to the source CRS, or no changes were required.
 
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
 
bool isGeosValid(Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const
Checks validity of the geometry using GEOS.
 
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.