QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
Class to manipulate the definition of a virtual layer. More...
#include <qgsvirtuallayerdefinition.h>
Classes | |
class | SourceLayer |
A SourceLayer is either a reference to a live layer in the registry or all the parameters needed to load it (provider key, source, etc.) More... | |
Public Types | |
typedef QList< QgsVirtualLayerDefinition::SourceLayer > | SourceLayers |
List of source layers. | |
Public Member Functions | |
QgsVirtualLayerDefinition (const QString &filePath="") | |
Constructor with an optional file path. | |
void | addSource (const QString &name, const QString &ref) |
Add a live layer source layer. | |
void | addSource (const QString &name, const QString &source, const QString &provider, const QString &encoding="") |
Add a layer with a source, a provider and an encoding. | |
QgsFields | fields () const |
Gets field definitions. | |
QString | filePath () const |
Gets the file path. May be empty. | |
QString | geometryField () const |
Gets the name of the geometry field. Empty if no geometry field. | |
long | geometrySrid () const |
Gets the SRID of the geometry. | |
Qgis::WkbType | geometryWkbType () const |
Gets the type of the geometry QgsWkbTypes::NoGeometry to hide any geometry QgsWkbTypes::Unknown for unknown types. | |
bool | hasDefinedGeometry () const |
Convenient method to test if the geometry is defined (not NoGeometry and not Unknown) | |
bool | hasReferencedLayers () const |
Convenience method to test whether the definition has referenced (live) layers. | |
bool | hasSourceLayer (const QString &name) const |
Convenience method to test if a given source layer is part of the definition. | |
bool | isLazy () const |
Returns the lazy mode. | |
QString | query () const |
Gets the SQL query. | |
void | setFields (const QgsFields &fields) |
Sets field definitions. | |
void | setFilePath (const QString &filePath) |
Sets the file path. | |
void | setGeometryField (const QString &geometryField) |
Sets the name of the geometry field. | |
void | setGeometrySrid (long srid) |
Sets the SRID of the geometry. | |
void | setGeometryWkbType (Qgis::WkbType t) |
Sets the type of the geometry. | |
void | setLazy (bool lazy) |
Sets the lazy mode. | |
void | setQuery (const QString &query) |
Sets the SQL query. | |
void | setSubsetString (const QString &subsetString) |
Sets the subsetString. | |
void | setUid (const QString &uid) |
Sets the name of the field with unique identifiers. | |
const QgsVirtualLayerDefinition::SourceLayers & | sourceLayers () const |
Gets access to the source layers. | |
QString | subsetString () const |
Returns the subset string. | |
QString | toString () const |
Convert into a QString that can be read by the virtual layer provider. | |
QUrl | toUrl () const |
Convert the definition into a QUrl. | |
QString | uid () const |
Gets the name of the field with unique identifiers. | |
Static Public Member Functions | |
static QgsVirtualLayerDefinition | fromUrl (const QUrl &url) |
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 to manipulate 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.
Definition at line 31 of file qgsvirtuallayerdefinition.h.
List of source layers.
Definition at line 115 of file qgsvirtuallayerdefinition.h.
QgsVirtualLayerDefinition::QgsVirtualLayerDefinition | ( | const QString & | filePath = "" | ) |
Constructor with an optional file path.
Definition at line 26 of file qgsvirtuallayerdefinition.cpp.
void QgsVirtualLayerDefinition::addSource | ( | const QString & | name, |
const QString & | ref | ||
) |
Add a live layer source layer.
Definition at line 252 of file qgsvirtuallayerdefinition.cpp.
void QgsVirtualLayerDefinition::addSource | ( | const QString & | name, |
const QString & | source, | ||
const QString & | provider, | ||
const QString & | encoding = "" |
||
) |
Add a layer with a source, a provider and an encoding.
Definition at line 257 of file qgsvirtuallayerdefinition.cpp.
|
inline |
Gets field definitions.
Definition at line 173 of file qgsvirtuallayerdefinition.h.
|
inline |
Gets the file path. May be empty.
Definition at line 126 of file qgsvirtuallayerdefinition.h.
|
static |
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
Definition at line 31 of file qgsvirtuallayerdefinition.cpp.
|
inline |
Gets the name of the geometry field. Empty if no geometry field.
Definition at line 154 of file qgsvirtuallayerdefinition.h.
|
inline |
Gets the SRID of the geometry.
Definition at line 168 of file qgsvirtuallayerdefinition.h.
|
inline |
Gets the type of the geometry QgsWkbTypes::NoGeometry to hide any geometry QgsWkbTypes::Unknown for unknown types.
Definition at line 163 of file qgsvirtuallayerdefinition.h.
|
inline |
Convenient method to test if the geometry is defined (not NoGeometry and not Unknown)
Definition at line 184 of file qgsvirtuallayerdefinition.h.
bool QgsVirtualLayerDefinition::hasReferencedLayers | ( | ) | const |
Convenience method to test whether the definition has referenced (live) layers.
Definition at line 275 of file qgsvirtuallayerdefinition.cpp.
bool QgsVirtualLayerDefinition::hasSourceLayer | ( | const QString & | name | ) | const |
Convenience method to test if a given source layer is part of the definition.
Definition at line 262 of file qgsvirtuallayerdefinition.cpp.
|
inline |
Returns the lazy mode.
true
if the loading is delayed, false
otherwise. Definition at line 151 of file qgsvirtuallayerdefinition.h.
|
inline |
Gets the SQL query.
Definition at line 121 of file qgsvirtuallayerdefinition.h.
|
inline |
Sets field definitions.
Definition at line 175 of file qgsvirtuallayerdefinition.h.
|
inline |
Sets the file path.
Definition at line 128 of file qgsvirtuallayerdefinition.h.
|
inline |
Sets the name of the geometry field.
Definition at line 156 of file qgsvirtuallayerdefinition.h.
|
inline |
Sets the SRID of the geometry.
Definition at line 170 of file qgsvirtuallayerdefinition.h.
|
inline |
Sets the type of the geometry.
Definition at line 165 of file qgsvirtuallayerdefinition.h.
|
inline |
Sets the lazy mode.
If lazy is true
, then the loading is delayed until an explicit reloading of the layer.
lazy | true to delay the loading, false otherwise |
Definition at line 143 of file qgsvirtuallayerdefinition.h.
|
inline |
Sets the SQL query.
Definition at line 123 of file qgsvirtuallayerdefinition.h.
void QgsVirtualLayerDefinition::setSubsetString | ( | const QString & | subsetString | ) |
|
inline |
Sets the name of the field with unique identifiers.
Definition at line 133 of file qgsvirtuallayerdefinition.h.
|
inline |
Gets access to the source layers.
Definition at line 118 of file qgsvirtuallayerdefinition.h.
QString QgsVirtualLayerDefinition::subsetString | ( | ) | const |
Returns the subset string.
Definition at line 288 of file qgsvirtuallayerdefinition.cpp.
QString QgsVirtualLayerDefinition::toString | ( | ) | const |
Convert into a QString that can be read by the virtual layer provider.
Definition at line 247 of file qgsvirtuallayerdefinition.cpp.
QUrl QgsVirtualLayerDefinition::toUrl | ( | ) | const |
Convert the definition into a QUrl.
Definition at line 176 of file qgsvirtuallayerdefinition.cpp.
|
inline |
Gets the name of the field with unique identifiers.
Definition at line 131 of file qgsvirtuallayerdefinition.h.