QGIS API Documentation  2.99.0-Master (19b062c)
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsVirtualLayerDefinition Class Reference

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::SourceLayerSourceLayers
 List of source layers. More...
 

Public Member Functions

 QgsVirtualLayerDefinition (const QString &filePath="")
 Constructor with an optional file path. More...
 
void addSource (const QString &name, const QString &ref)
 Add a live layer source layer. More...
 
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. More...
 
QgsFields fields () const
 Get field definitions. More...
 
QString filePath () const
 Get the file path. May be empty. More...
 
QString geometryField () const
 Get the name of the geometry field. Empty if no geometry field. More...
 
long geometrySrid () const
 Get the SRID of the geometry. More...
 
QgsWkbTypes::Type geometryWkbType () const
 Get the type of the geometry QgsWkbTypes::NoGeometry to hide any geometry QgsWkbTypes::Unknown for unknown types. More...
 
bool hasDefinedGeometry () const
 Convenient method to test if the geometry is defined (not NoGeometry and not Unknown) More...
 
bool hasReferencedLayers () const
 Convenience method to test whether the definition has referenced (live) layers. More...
 
bool hasSourceLayer (const QString &name) const
 Convenience method to test if a given source layer is part of the definition. More...
 
QString query () const
 Get the SQL query. More...
 
void setFields (const QgsFields &fields)
 Set field definitions. More...
 
void setFilePath (const QString &filePath)
 Set the file path. More...
 
void setGeometryField (const QString &geometryField)
 Set the name of the geometry field. More...
 
void setGeometrySrid (long srid)
 Set the SRID of the geometry. More...
 
void setGeometryWkbType (QgsWkbTypes::Type t)
 Set the type of the geometry. More...
 
void setQuery (const QString &query)
 Set the SQL query. More...
 
void setUid (const QString &uid)
 Set the name of the field with unique identifiers. More...
 
const QgsVirtualLayerDefinition::SourceLayerssourceLayers () const
 Get access to the source layers. More...
 
QString toString () const
 Convert into a QString that can be read by the virtual layer provider. More...
 
QUrl toUrl () const
 Convert the definition into a QUrl. More...
 
QString uid () const
 Get the name of the field with unique identifiers. More...
 

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. More...
 

Detailed Description

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.

Member Typedef Documentation

◆ SourceLayers

List of source layers.

Definition at line 114 of file qgsvirtuallayerdefinition.h.

Constructor & Destructor Documentation

◆ QgsVirtualLayerDefinition()

QgsVirtualLayerDefinition::QgsVirtualLayerDefinition ( const QString &  filePath = "")

Constructor with an optional file path.

Definition at line 25 of file qgsvirtuallayerdefinition.cpp.

Member Function Documentation

◆ addSource() [1/2]

void QgsVirtualLayerDefinition::addSource ( const QString &  name,
const QString &  ref 
)

Add a live layer source layer.

Definition at line 220 of file qgsvirtuallayerdefinition.cpp.

◆ addSource() [2/2]

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 225 of file qgsvirtuallayerdefinition.cpp.

◆ fields()

QgsFields QgsVirtualLayerDefinition::fields ( ) const
inline

Get field definitions.

Definition at line 154 of file qgsvirtuallayerdefinition.h.

◆ filePath()

QString QgsVirtualLayerDefinition::filePath ( ) const
inline

Get the file path. May be empty.

Definition at line 125 of file qgsvirtuallayerdefinition.h.

◆ fromUrl()

QgsVirtualLayerDefinition QgsVirtualLayerDefinition::fromUrl ( const QUrl &  url)
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

Definition at line 30 of file qgsvirtuallayerdefinition.cpp.

◆ geometryField()

QString QgsVirtualLayerDefinition::geometryField ( ) const
inline

Get the name of the geometry field. Empty if no geometry field.

Definition at line 135 of file qgsvirtuallayerdefinition.h.

◆ geometrySrid()

long QgsVirtualLayerDefinition::geometrySrid ( ) const
inline

Get the SRID of the geometry.

Definition at line 149 of file qgsvirtuallayerdefinition.h.

◆ geometryWkbType()

QgsWkbTypes::Type QgsVirtualLayerDefinition::geometryWkbType ( ) const
inline

Get the type of the geometry QgsWkbTypes::NoGeometry to hide any geometry QgsWkbTypes::Unknown for unknown types.

Definition at line 144 of file qgsvirtuallayerdefinition.h.

◆ hasDefinedGeometry()

bool QgsVirtualLayerDefinition::hasDefinedGeometry ( ) const
inline

Convenient method to test if the geometry is defined (not NoGeometry and not Unknown)

Definition at line 165 of file qgsvirtuallayerdefinition.h.

◆ hasReferencedLayers()

bool QgsVirtualLayerDefinition::hasReferencedLayers ( ) const

Convenience method to test whether the definition has referenced (live) layers.

Definition at line 242 of file qgsvirtuallayerdefinition.cpp.

◆ hasSourceLayer()

bool QgsVirtualLayerDefinition::hasSourceLayer ( const QString &  name) const

Convenience method to test if a given source layer is part of the definition.

Definition at line 230 of file qgsvirtuallayerdefinition.cpp.

◆ query()

QString QgsVirtualLayerDefinition::query ( ) const
inline

Get the SQL query.

Definition at line 120 of file qgsvirtuallayerdefinition.h.

◆ setFields()

void QgsVirtualLayerDefinition::setFields ( const QgsFields fields)
inline

Set field definitions.

Definition at line 156 of file qgsvirtuallayerdefinition.h.

◆ setFilePath()

void QgsVirtualLayerDefinition::setFilePath ( const QString &  filePath)
inline

Set the file path.

Definition at line 127 of file qgsvirtuallayerdefinition.h.

◆ setGeometryField()

void QgsVirtualLayerDefinition::setGeometryField ( const QString &  geometryField)
inline

Set the name of the geometry field.

Definition at line 137 of file qgsvirtuallayerdefinition.h.

◆ setGeometrySrid()

void QgsVirtualLayerDefinition::setGeometrySrid ( long  srid)
inline

Set the SRID of the geometry.

Definition at line 151 of file qgsvirtuallayerdefinition.h.

◆ setGeometryWkbType()

void QgsVirtualLayerDefinition::setGeometryWkbType ( QgsWkbTypes::Type  t)
inline

Set the type of the geometry.

Definition at line 146 of file qgsvirtuallayerdefinition.h.

◆ setQuery()

void QgsVirtualLayerDefinition::setQuery ( const QString &  query)
inline

Set the SQL query.

Definition at line 122 of file qgsvirtuallayerdefinition.h.

◆ setUid()

void QgsVirtualLayerDefinition::setUid ( const QString &  uid)
inline

Set the name of the field with unique identifiers.

Definition at line 132 of file qgsvirtuallayerdefinition.h.

◆ sourceLayers()

const QgsVirtualLayerDefinition::SourceLayers& QgsVirtualLayerDefinition::sourceLayers ( ) const
inline

Get access to the source layers.

Definition at line 117 of file qgsvirtuallayerdefinition.h.

◆ toString()

QString QgsVirtualLayerDefinition::toString ( ) const

Convert into a QString that can be read by the virtual layer provider.

Definition at line 215 of file qgsvirtuallayerdefinition.cpp.

◆ toUrl()

QUrl QgsVirtualLayerDefinition::toUrl ( ) const

Convert the definition into a QUrl.

Definition at line 166 of file qgsvirtuallayerdefinition.cpp.

◆ uid()

QString QgsVirtualLayerDefinition::uid ( ) const
inline

Get the name of the field with unique identifiers.

Definition at line 130 of file qgsvirtuallayerdefinition.h.


The documentation for this class was generated from the following files: