31 #include <QThreadStorage>
36 QMutexLocker locker( &layer->mFeatureSourceConstructorMutex );
61 if ( L->editBuffer()->addedFeatures().contains( request.filterFid() ) )
62 mAddedFeatures.insert( request.filterFid(), L->editBuffer()->addedFeatures()[ request.filterFid()] );
64 if ( L->editBuffer()->changedGeometries().contains( request.filterFid() ) )
65 mChangedGeometries.insert( request.filterFid(), L->editBuffer()->changedGeometries()[ request.filterFid()] );
67 if ( L->editBuffer()->deletedFeatureIds().contains( request.filterFid() ) )
70 if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
71 mChangedAttributeValues.insert( request.filterFid(), L->editBuffer()->changedAttributeValues()[ request.filterFid()] );
73 if ( L->editBuffer()->changedAttributeValues().contains( request.filterFid() ) )
74 mChangedFeaturesRequest.setFilterFids(
QgsFeatureIds() << request.filterFid() );
124 , mFetchedFid( false )
153 for (
int attrIndex : usedAttributeIndices )
156 mDelegatedOrderByToProvider =
false;
196 if ( !mDelegatedOrderByToProvider )
204 QSet<int> providerSubset;
207 for (
int attrIndex : subset )
209 if ( attrIndex < 0 || attrIndex >= nPendingFields )
223 for (
int attrIndex : usedAttributeIndices )
225 providerSubset << attrIndex;
236 for (
const QString &
field : constReferencedColumns )
264 changedIds << attIt.key();
329 class QgsThreadStackOverflowGuard
333 QgsThreadStackOverflowGuard( QThreadStorage<QStack<QString>> &storage,
const QString &stackFrameInformation,
int maxDepth )
334 : mStorage( storage )
335 , mMaxDepth( maxDepth )
337 if ( !storage.hasLocalData() )
339 storage.setLocalData( QStack<QString>() );
342 storage.localData().push( stackFrameInformation );
345 ~QgsThreadStackOverflowGuard()
347 mStorage.localData().pop();
350 bool hasStackOverflow()
const
352 if ( mStorage.localData().size() > mMaxDepth )
358 QString topFrames()
const
360 QStringList dumpStack;
361 const QStack<QString> &stack = mStorage.localData();
363 int dumpSize = std::min(
static_cast<int>( stack.size() ), 10 );
364 for (
int i = 0; i < dumpSize; ++i )
366 dumpStack += stack.at( i );
369 return dumpStack.join(
'\n' );
374 return mStorage.localData().size();
378 QThreadStorage<QStack<QString>> &mStorage;
391 static QThreadStorage<QStack<QString>> sStack;
393 QgsThreadStackOverflowGuard guard( sStack,
mSource->
id(), 4 );
395 if ( guard.hasStackOverflow() )
397 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 );
406 if ( res && postProcessFeature( f ) )
483 if ( !postProcessFeature( f ) )
530 mInterruptionChecker = interruptionChecker;
556 if ( !postProcessFeature( f ) )
610 if ( postProcessFeature( f ) )
701 int sourceLayerIndex;
703 Q_ASSERT( joinInfo );
713 info.
joinSource = std::make_shared< QgsVectorLayerFeatureSource >( joinLayer );
730 mFetchJoinInfo[ joinInfo ].attributes.push_back( sourceLayerIndex );
731 mFetchJoinInfo[ joinInfo ].attributesSourceToDestLayerMap[sourceLayerIndex] = fieldIdx;
737 static QThreadStorage<QStack<QString>> sStack;
739 QgsThreadStackOverflowGuard guard( sStack,
mSource->
id(), 4 );
741 if ( guard.hasStackOverflow() )
750 std::unique_ptr<QgsExpression> exp = std::make_unique<QgsExpression>( exps[oi].cachedExpression );
755 exp->setGeomCalculator( &da );
759 if ( !mExpressionContext )
760 createExpressionContext();
761 exp->prepare( mExpressionContext.get() );
762 const QSet<int> referencedColumns = exp->referencedAttributeIndexes(
mSource->
fields() );
766 for (
int dependentFieldIdx : referencedColumns )
770 requestedAttributes += dependentFieldIdx;
773 if ( !mPreparedFields.contains( dependentFieldIdx ) && !mFieldsToPrepare.contains( dependentFieldIdx ) )
774 mFieldsToPrepare << dependentFieldIdx;
782 if ( exp->needsGeometry() )
792 mPreparedFields.clear();
793 mFieldsToPrepare.clear();
795 mOrderedJoinInfoList.clear();
797 mExpressionContext.reset();
803 while ( !mFieldsToPrepare.isEmpty() )
805 int fieldIdx = mFieldsToPrepare.takeFirst();
806 if ( mPreparedFields.contains( fieldIdx ) )
809 mPreparedFields << fieldIdx;
816 createOrderedJoinList();
820 void QgsVectorLayerFeatureIterator::createOrderedJoinList()
823 if ( mOrderedJoinInfoList.size() < 2 )
828 QSet<int> resolvedFields;
831 QList< int >::const_iterator prepFieldIt = mPreparedFields.constBegin();
832 for ( ; prepFieldIt != mPreparedFields.constEnd(); ++prepFieldIt )
836 resolvedFields.insert( *prepFieldIt );
843 int maxIterations = ( mOrderedJoinInfoList.size() + 1 ) * mOrderedJoinInfoList.size() / 2.0;
844 int currentIteration = 0;
846 for (
int i = 0; i < mOrderedJoinInfoList.size() - 1; ++i )
848 if ( !resolvedFields.contains( mOrderedJoinInfoList.at( i ).targetField ) )
850 mOrderedJoinInfoList.append( mOrderedJoinInfoList.at( i ) );
851 mOrderedJoinInfoList.removeAt( i );
856 int offset = mOrderedJoinInfoList.at( i ).indexOffset;
857 int joinField = mOrderedJoinInfoList.at( i ).joinField;
860 for (
int n = 0; n < attributes.size(); n++ )
862 if ( n != joinField )
864 resolvedFields.insert( joinField < n ? n + offset - 1 : n + offset );
870 if ( currentIteration >= maxIterations )
877 bool QgsVectorLayerFeatureIterator::postProcessFeature(
QgsFeature &feature )
879 bool result = checkGeometryValidity( feature );
885 bool QgsVectorLayerFeatureIterator::checkGeometryValidity(
const QgsFeature &feature )
899 QgsMessageLog::logMessage( QObject::tr(
"Geometry error: One or more input features have invalid geometry." ), QString(), Qgis::MessageLevel::Critical );
912 QgsMessageLog::logMessage( QObject::tr(
"Geometry error: One or more input features have invalid geometry." ), QString(), Qgis::MessageLevel::Critical );
950 QList< FetchJoinInfo >::const_iterator joinIt = mOrderedJoinInfoList.constBegin();
951 for ( ; joinIt != mOrderedJoinInfoList.constEnd(); ++joinIt )
953 QVariant targetFieldValue = f.
attribute( joinIt->targetField );
954 if ( !targetFieldValue.isValid() )
957 const QHash< QString, QgsAttributes> &memoryCache = joinIt->joinInfo->cachedAttributes;
958 if ( memoryCache.isEmpty() )
959 joinIt->addJoinedAttributesDirect( f, targetFieldValue );
961 joinIt->addJoinedAttributesCached( f, targetFieldValue );
975 QList< int > fetchedVirtualAttributes;
977 QMap<const QgsVectorLayerJoinInfo *, FetchJoinInfo>::const_iterator joinIt =
mFetchJoinInfo.constBegin();
984 fetchedVirtualAttributes << joinIt->targetField;
997 if ( fetchedVirtualAttributes.contains( it.key() ) )
1010 if ( !mExpressionContext )
1011 createExpressionContext();
1013 mExpressionContext->setFeature( f );
1014 QVariant val = exp->
evaluate( mExpressionContext.get() );
1026 Q_UNUSED( simplifyMethod )
1032 Q_UNUSED( methodType )
1040 QHash<QString, QgsAttributes>::const_iterator it = memoryCache.find( joinValue.toString() );
1041 if ( it == memoryCache.constEnd() )
1047 for (
int i = 0; i < featureAttributes.count(); ++i )
1059 if ( joinLayer && ! joinLayer->hasFeatures() )
1066 QString subsetString;
1068 QString joinFieldName = joinInfo->joinFieldName();
1070 subsetString.append( QStringLiteral(
"\"%1\"" ).arg( joinFieldName ) );
1072 if ( joinValue.isNull() )
1074 subsetString += QLatin1String(
" IS NULL" );
1078 QString v = joinValue.toString();
1079 switch ( joinValue.type() )
1082 case QVariant::LongLong:
1083 case QVariant::Double:
1087 case QVariant::String:
1088 v.replace(
'\'', QLatin1String(
"''" ) );
1089 v.prepend(
'\'' ).append(
'\'' );
1092 subsetString +=
'=' + v;
1095 QList<int> joinedAttributeIndices;
1099 if ( joinInfo->hasSubset() )
1103 joinedAttributeIndices = qgis::setToList( qgis::listToSet( attributes ).intersect( qgis::listToSet( subsetIndices.toList() ) ) );
1107 joinedAttributeIndices = attributes;
1111 joinedAttributeIndices.removeAll( joinField );
1122 const QList<int> sourceAttrIndexes = attributesSourceToDestLayerMap.keys();
1128 for (
const int sourceAttrIndex : sourceAttrIndexes )
1130 if ( sourceAttrIndex == joinField )
1133 int destAttrIndex = attributesSourceToDestLayerMap.value( sourceAttrIndex );
1135 f.
setAttribute( destAttrIndex, attr.at( sourceAttrIndex ) );
1165 if ( iter->id() == featureId )
1207 for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
1208 attrs[it.key()] = it.value();
1219 void QgsVectorLayerFeatureIterator::createExpressionContext()
1221 mExpressionContext = std::make_unique< QgsExpressionContext >();
1227 bool QgsVectorLayerFeatureIterator::prepareOrderBy(
const QList<QgsFeatureRequest::OrderByClause> &orderBys )
1229 Q_UNUSED( orderBys )
1230 return mDelegatedOrderByToProvider;
1240 , mSelectedFeatureIds( layer->selectedFeatureIds() )
1241 , mWkbType( layer->wkbType() )
1242 , mName( layer->name() )
1267 return QgsFeatureIterator(
new QgsVectorLayerSelectedFeatureIterator( mSelectedFeatureIds, req, mSource ) );
1272 return mSource.
crs();
1287 return mSelectedFeatureIds.count();
1298 return mLayer->createExpressionContextScope();
1306 return mLayer->hasSpatialIndex();
1318 , mSelectedFeatureIds( selectedFeatureIds )
1331 bool QgsVectorLayerSelectedFeatureIterator::rewind()
1333 return mIterator.
rewind();
1336 bool QgsVectorLayerSelectedFeatureIterator::close()
1338 return mIterator.close();
1341 bool QgsVectorLayerSelectedFeatureIterator::fetchFeature(
QgsFeature &f )
1343 while ( mIterator.nextFeature( f ) )
1345 if ( mSelectedFeatureIds.contains( f.
id() ) )
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.
void geometryToDestinationCrs(QgsFeature &feature, const QgsCoordinateTransform &transform) const
Transforms feature's geometry according to the specified coordinate transform.
QgsRectangle filterRectToSourceCrs(const QgsCoordinateTransform &transform) const SIP_THROW(QgsCsException)
Returns a rectangle representing the original request's QgsFeatureRequest::filterRect().
QgsFeatureRequest mRequest
A copy of the feature request.
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)
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.
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 & setLimit(long long limit)
Set the maximum number of features to request.
std::function< void(const QgsFeature &) > invalidGeometryCallback() const
Returns the callback function to use when encountering an invalid geometry and invalidGeometryCheck()...
@ GeometryNoCheck
No invalid geometry checking.
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ GeometrySkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
InvalidGeometryCheck invalidGeometryCheck() const
Returns the invalid geometry checking behavior.
QgsExpression * filterExpression() const
Returns the filter expression if set.
long long limit() const
Returns the maximum number of features to request, or -1 if no limit set.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets feature IDs that should be fetched.
OrderBy orderBy() const
Returns a list of order by clauses specified for this feature request.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
QgsExpressionContext * expressionContext()
Returns the expression context used to evaluate filter expressions.
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...
@ 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.
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...
QgsAttributeList subsetOfAttributes() const
Returns the subset of attributes which at least need to be fetched.
QgsFeatureRequest & disableFilter()
Disables filter conditions.
const QgsRectangle & filterRect() const
Returns the rectangle from which features will be taken.
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
FilterType filterType() const
Returns the filter type which is currently set on this request.
const QgsFeatureIds & filterFids() const
Gets feature IDs that should be fetched.
@ FilterFid
Filter using feature ID.
@ FilterNone
No filter is applied.
@ FilterExpression
Filter using expression.
const Flags & flags() const
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets feature ID that should be fetched.
QgsFeatureId filterFid() const
Gets the feature ID that should be fetched.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
SpatialIndexPresence
Enumeration of spatial index presence states.
@ SpatialIndexUnknown
Spatial index presence cannot be determined, index may or may not exist.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
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.
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.
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.
int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
@ OriginExpression
Field is calculated from an expression.
@ OriginEdit
Field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
@ OriginUnknown
It has not been specified where the field comes from.
@ OriginJoin
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
@ OriginProvider
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
int count() const
Returns number of items.
FieldOrigin fieldOrigin(int fieldIdx) const
Returns the field's origin (value from an enumeration).
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).
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
A geometry is the spatial representation of a feature.
bool isGeosValid(QgsGeometry::ValidityFlags flags=QgsGeometry::ValidityFlags()) const
Checks validity of the geometry using GEOS.
QgsCoordinateReferenceSystem crs
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
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 (all coordinates zero or after call to setMinimal()).
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
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.
QList< QgsField > addedAttributes() const
Returns a list of added attributes fields 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.
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
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)
~QgsVectorLayerFeatureIterator() override
bool fetchFeature(QgsFeature &feature) override
fetch next feature, return true on success
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
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.
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.
QgsVectorLayer * joinLayer() const
Returns joined layer (may be nullptr if the reference was set by layer ID and not resolved yet)
QStringList * joinFieldNamesSubset() const
Returns the subset of fields to be used from 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.
SpatialIndexPresence hasSpatialIndex() const override
Returns an enum value representing the presence of a valid spatial index on the source,...
QgsWkbTypes::Type wkbType() const override
Returns the geometry type for features returned by this 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.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
Q_INVOKABLE QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on.
Type
The WKB type describes the number of dimensions a geometry has.
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 joinField
Index of field (of the joined layer) must have equal value.
int indexOffset
At what position the joined fields start.
void addJoinedAttributesCached(QgsFeature &f, const QVariant &joinValue) const