Class: QgsVectorLayerJoinBuffer¶
Manages joined fields for a vector layer.
Class Hierarchy¶
Base classes¶
An interface for objects which accept features via addFeature(s) methods. |
- class qgis.core.QgsVectorLayerJoinBuffer[source]¶
Bases:
QObject,QgsFeatureSink- abstract addFeatures(self, features: Iterable[QgsFeature], flags: QgsFeatureSink.Flags | QgsFeatureSink.Flag = QgsFeatureSink.Flags()) bool[source]¶
Adds a list of features in joined layers. Features given in parameter are those added in target layer. If a corresponding joined feature yet exists in a joined layer, then this feature is just updated. Note that if a corresponding joined feature has only empty fields, then it’s not created nor added.
- Parameters:
features (Iterable[QgsFeature]) – The list of features added in the target layer
flags (Union[QgsFeatureSink.Flags, QgsFeatureSink.Flag] = QgsFeatureSink.Flags()) – Unused parameter
- Return type:
bool
- Returns:
Falseif an error happened,Trueotherwise
- addJoin(self, joinInfo: QgsVectorLayerJoinInfo) bool[source]¶
Joins another vector layer to this layer
- Parameters:
joinInfo (QgsVectorLayerJoinInfo) – join object containing join layer id, target and source field
- Return type:
bool
- Returns:
(since 2.6) whether the join was successfully added
- changeAttributeValue(self, fid: int, field: int, newValue: Any, oldValue: Any = None) bool[source]¶
Changes attribute value in joined layers. The feature id given in parameter is the one added in target layer. If the corresponding joined feature does not exist in a joined layer, then it’s automatically created if its fields are not empty.
- Parameters:
fid (int) – The feature id
field (int) – The field to update
newValue (Any) – The new value of the attribute
oldValue (Any = None) – The old value of the attribute
- Return type:
bool
- Returns:
Falseif an error happened,Trueotherwise
- changeAttributeValues(self, fid: int, newValues: Dict[int, Any], oldValues: Dict[int, Any] = {}) bool[source]¶
Changes attributes’ values in joined layers. The feature id given in parameter is the one added in target layer. If the corresponding joined feature does not exist in a joined layer, then it’s automatically created if its fields are not empty.
- clone(self) QgsVectorLayerJoinBuffer | None[source]¶
Create a copy of the join buffer
- Return type:
Optional[QgsVectorLayerJoinBuffer]
- deleteFeature(self, fid: int, context: QgsVectorLayer.DeleteContext | None = None) bool[source]¶
Deletes a feature from joined layers. The feature id given in parameter is the one coming from the target layer.
- Parameters:
fid (int) – The feature id from the target layer to delete
context (Optional[QgsVectorLayer.DeleteContext] = None) – The chain of features which will be deleted for feedback and to avoid infinite recursions. Can be
None.
- Return type:
bool
- Returns:
Falseif an error happened,Trueotherwise
- deleteFeatures(self, fids: Any, context: QgsVectorLayer.DeleteContext | None = None) bool[source]¶
Deletes a list of features from joined layers. Feature ids given in a parameter are those coming from the target layer.
- Parameters:
fids (Any) – Feature ids from the target layer to delete
context (Optional[QgsVectorLayer.DeleteContext] = None) – The chain of features who will be deleted for feedback and to avoid infinite recursions. Can be
None.
- Return type:
bool
- Returns:
Falseif an error happened,Trueotherwise
- isAuxiliaryJoin(self, info: QgsVectorLayerJoinInfo) bool[source]¶
Returns
Trueif the join information is about auxiliary layer,Falseotherwise- Parameters:
info (QgsVectorLayerJoinInfo) – The join information
- Return type:
bool
- Returns:
Trueif the join information is about auxiliary layer,Falseotherwise
- joinForFieldIndex(self, index: int, fields: QgsFields)[source]¶
Finds the vector join for a layer field index.
- Parameters:
index (int) – this layers attribute index
fields (
QgsFields) -> (Optional[QgsVectorLayerJoinInfo]) – fields of the vector layer (including joined fields)
- Returns:
the vector layer join info
sourceFieldIndex: Output: field’s index in source layer
- static joinSubsetIndices(joinLayer: QgsVectorLayer | None, joinFieldsSubset: Iterable[str | None]) List[int]¶
Returns a vector of indices for use in join based on field names from the layer
joinSubsetIndices(joinLayerFields:
QgsFields, joinFieldsSubset: Iterable[Optional[str]]) -> List[int] Returns a vector of indices for use in join based on field names from the join layer’s fields.Added in version 3.20.
- Parameters:
joinLayer (Optional[QgsVectorLayer])
joinFieldsSubset (Iterable[Optional[str]])
- Return type:
List[int]
- joinedFeatureOf(self, info: QgsVectorLayerJoinInfo | None, feature: QgsFeature) QgsFeature[source]¶
Returns the joined feature corresponding to the feature.
- Parameters:
info (Optional[QgsVectorLayerJoinInfo]) – the vector join information
feature (QgsFeature) – the feature of the target layer
- Return type:
- signal joinedFieldsChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- joinedFieldsOffset(self, info: QgsVectorLayerJoinInfo | None, fields: QgsFields) int[source]¶
Find out what is the first index of the join within fields. Returns -1 if join is not present
- Parameters:
info (Optional[QgsVectorLayerJoinInfo])
fields (QgsFields)
- Return type:
int
- joinsWhereFieldIsId(self, field: QgsField) List[QgsVectorLayerJoinInfo]¶
Returns joins where the field of a target layer is considered as an id.
- Parameters:
field (QgsField) – the field of a target layer
- Return type:
- Returns:
a list of vector joins
- readXml(self, layer_node: QDomNode)[source]¶
Reads joins from project file. Does not resolve layer IDs to layers - call
resolveReferences()afterwards- Parameters:
layer_node (QDomNode)
- removeJoin(self, joinLayerId: str | None) bool[source]¶
Removes a vector layer join
- Return type:
bool
- Returns:
Trueif join was found and successfully removed- Parameters:
joinLayerId (Optional[str])
- resolveReferences(self, project: QgsProject | None)[source]¶
Resolves layer IDs of joined layers using given project’s available layers
- Parameters:
project (Optional[QgsProject])
- targetedFeatureOf(self, info: QgsVectorLayerJoinInfo | None, feature: QgsFeature) QgsFeature[source]¶
Returns the targeted feature corresponding to the joined feature.
- Parameters:
info (Optional[QgsVectorLayerJoinInfo]) – the vector join information
feature (QgsFeature) – the feature of the joined layer
- Return type:
- updateFields(self, fields: QgsFields)[source]¶
Updates field map with joined attributes
- Parameters:
fields (QgsFields) – map to append joined attributes
- vectorJoins(self) List[QgsVectorLayerJoinInfo]¶
- Return type: