Class: QgsVirtualLayerDefinition¶
Manipulates the definition of a virtual layer.
It is used to extract parameters from an initial virtual layer definition as well as to store the complete, expanded definition once types have been detected.
List of all members, including inherited members
Classes
Either a reference to a live layer in the registry or all the parameters needed to load it (provider key, source, etc.). |
Methods
Add a live layer source layer |
|
Gets field definitions |
|
Gets the file path. |
|
Gets the name of the geometry field. |
|
Gets the SRID of the geometry |
|
Gets the type of the geometry |
|
Convenient method to test if the geometry is defined (not NoGeometry and not Unknown) |
|
Convenience method to test whether the definition has referenced (live) layers |
|
Convenience method to test if a given source layer is part of the definition |
|
Returns the lazy mode. |
|
Gets the SQL query |
|
Sets field definitions |
|
Sets the file path |
|
Sets the name of the geometry field |
|
Sets the SRID of the geometry |
|
Sets the type of the geometry |
|
Sets the lazy mode. |
|
Sets the SQL query |
|
Sets the subsetString |
|
Sets the name of the field with unique identifiers |
|
Gets access to the source layers |
|
Returns the subset string. |
|
Converts the definition into a string that can be read by the virtual layer provider |
|
Convert the definition into a QUrl |
|
Gets the name of the field with unique identifiers |
Static Methods
Constructor to build a definition from a QUrl The path part of the URL is extracted as well as the following optional keys: layer_ref=layer_id[:name] represents a live layer referenced by its ID. |
- class qgis.core.QgsVirtualLayerDefinition[source]¶
Bases:
object- __init__(filePath: str | None = '')
Constructor with an optional file path
- Parameters:
filePath (Optional[str] = '')
- __init__(a0: QgsVirtualLayerDefinition)
- Parameters:
- class SourceLayer[source]¶
Bases:
objectEither a reference to a live layer in the registry or all the parameters needed to load it (provider key, source, etc.).
- __init__(name: str | None, ref: str | None)
Constructor variant to build a live layer reference
- Parameters:
name (Optional[str])
ref (Optional[str])
- __init__(name: str | None, source: str | None, provider: str | None, encoding: str | None)
Constructor variant to build a layer with a provider and a source
- Parameters:
name (Optional[str])
source (Optional[str])
provider (Optional[str])
encoding (Optional[str])
- __init__(a0: QgsVirtualLayerDefinition.SourceLayer)
- Parameters:
- addSource(self, name: str | None, ref: str | None)[source]¶
Add a live layer source layer
addSource(self, name: Optional[str], source: Optional[str], provider: Optional[str], encoding: Optional[str] = ‘’) Add a layer with a source, a provider and an encoding
- Parameters:
name (Optional[str])
ref (Optional[str])
- static fromUrl(url: QUrl) QgsVirtualLayerDefinition[source]¶
Constructor to build a definition from a QUrl The path part of the URL is extracted as well as the following optional keys: layer_ref=layer_id[:name] represents a live layer referenced by its ID. An optional name can be given layer=provider:source[:name[:encoding]] represents a layer given by its provider key, its source url (URL-encoded). An optional name and encoding can be given geometry=column_name[:type:srid] gives the definition of the geometry column. Type can be either a WKB type code or a string (point, linestring, etc.) srid is an integer uid=column_name is the name of a column with unique integer values. nogeometry is a flag to force the layer to be a non-geometry layer query=sql represents the SQL query. Must be URL-encoded field=column_name:[int|real|text] represents a field with its name and its type subsetstring=subset_string represents the subsetstring
- Parameters:
url (QUrl)
- Return type:
- geometryField(self) str[source]¶
Gets the name of the geometry field. Empty if no geometry field
- Return type:
str
- geometryWkbType(self) Qgis.WkbType[source]¶
Gets the type of the geometry
QgsWkbTypes.NoGeometry to hide any geometryQgsWkbTypes.Unknown for unknown types- Return type:
- hasDefinedGeometry(self) bool[source]¶
Convenient method to test if the geometry is defined (not NoGeometry and not Unknown)
- Return type:
bool
- hasReferencedLayers(self) bool[source]¶
Convenience method to test whether the definition has referenced (live) layers
- Return type:
bool
- hasSourceLayer(self, name: str | None) bool[source]¶
Convenience method to test if a given source layer is part of the definition
- Parameters:
name (Optional[str])
- Return type:
bool
- isLazy(self) bool[source]¶
Returns the lazy mode.
- Return type:
bool
- Returns:
Trueif the loading is delayed,Falseotherwise.
See also
Added in version 3.2.
- setFilePath(self, filePath: str | None)[source]¶
Sets the file path
- Parameters:
filePath (Optional[str])
- setGeometryField(self, geometryField: str | None)[source]¶
Sets the name of the geometry field
- Parameters:
geometryField (Optional[str])
- setGeometryWkbType(self, t: Qgis.WkbType)[source]¶
Sets the type of the geometry
- Parameters:
t (Qgis.WkbType)
- setLazy(self, lazy: bool)[source]¶
Sets the lazy mode. If
lazyisTrue, then the loading is delayed until an explicit reloading of the layer.- Parameters:
lazy (bool) –
Trueto delay the loading,Falseotherwise
See also
See also
Added in version 3.2.
- setSubsetString(self, subsetString: str | None)[source]¶
Sets the
subsetStringAdded in version 3.16.
- Parameters:
subsetString (Optional[str])
- setUid(self, uid: str | None)[source]¶
Sets the name of the field with unique identifiers
- Parameters:
uid (Optional[str])
- sourceLayers(self) list[QgsVirtualLayerDefinition.SourceLayer]¶
Gets access to the source layers
- Return type: