qgisVectorLayer
extends qgisMapLayer
in package
Give access to qgis mapLayer configuration.
Tags
Table of Contents
Properties
- $abstract : mixed
- layer abstract.
- $aliases : array<string, string>
- $connection : null|jDbConnection
- $constraints : array<string|int, string>
- $datasource : mixed
- layer datasource.
- $dbFieldList : array<string|int, jDbFieldProperties>
- $dbFieldsInfo : mixed
- $dbProfile : string
- $defaultValues : array<string|int, string>
- $dtParams : null|object
- $fields : mixed
- $id : mixed
- layer id in the QGIS project file.
- $name : mixed
- layer name.
- $proj4 : mixed
- layer proj4.
- $project : Project|qgisProject
- $provider : mixed
- layer provider.
- $shortname : mixed
- layer short name.
- $srid : mixed
- layer srid.
- $title : mixed
- layer title.
- $type : mixed
- layer type.
- $webDavBaseUris : mixed
- $webDavFields : mixed
- $wfsFields : mixed
- $geometryDatatypeMap : mixed
Methods
- __construct() : mixed
- constructor.
- canCurrentUserEdit() : bool
- checkFeatureAgainstPolygonFilter() : bool
- Check if the given edited feature intersects the filtering polygon for the current user.
- deleteFeature() : int
- editableFeatures() : array<string|int, mixed>
- Get the layer editable features.
- getAbstract() : mixed
- getAliasFields() : array<string, string>
- list of aliases.
- getConstraints() : array<string|int, string>
- Get the QGIS constraints of the given field.
- getConstraintsList() : array<string|int, string>
- list of constraints.
- getDatasource() : mixed
- getDatasourceConnection() : jDbConnection
- getDatasourceParameters() : object
- getDatasourceProfile() : null|string
- Give the jDb profile name for the database connection.
- getDbFieldDefaultValues() : mixed
- getDbFieldDistinctValues() : mixed
- getDbFieldList() : array<string|int, jDbFieldProperties>
- getDbFieldsInfo() : null|qgisLayerDbFieldsInfo
- getDbFieldValues() : mixed
- getDefaultValue() : null|string
- Get the QGIS expression of the default value of the given field.
- getDefaultValues() : array<string|int, string>
- List of default values for each fields.
- getEditionCapabilities() : null|object
- getFields() : mixed
- getGeometryAsSql() : mixed
- getId() : mixed
- getName() : mixed
- getPolygonFilter() : string
- Returns the sql used to filter the layer data by polygon.
- getPolygonFilterExpression() : string
- Returns the expression used to filter the layer data by polygon.
- getPolygonFilterGeometry() : string
- Returns the geometry in eWKT of the authorized polygon for this layer and the current user.
- getPrimaryKeyValues() : mixed
- getProj4() : mixed
- getProject() : Project|qgisProject
- getProvider() : mixed
- getRealEditionCapabilities() : object
- getShortName() : mixed
- getSrid() : mixed
- getTitle() : mixed
- getType() : mixed
- getWebDavFieldConfiguration() : mixed
- getWfsFields() : mixed
- getWfsTypeName() : string
- Get the WFS typename for this layer.
- getXmlLayer() : null|SimpleXMLElement
- insertFeature() : array<string|int, mixed>
- insertRelations() : array<string|int, mixed>
- Link features between 2 tables by creating the needed lines in a third pivot table, for a many-to-many relation (n-m).
- isEditable() : mixed
- isFeatureEditable() : bool
- Get the layer editable features.
- linkChildren() : array<string|int, mixed>
- Link features between 2 tables: one parent layer and one child layer.
- unlinkChild() : mixed
- updateFeature() : array<string|int, mixed>
- getPkWhereClause() : mixed
- requestPolygonFilter() : array<string|int, mixed>
- Get the polygon filter expression and the polygon geometry eWKT representation as returned by Lizmap plugin for QGIS Server for the layer, depending on the authenticated (or not) user and groups.
Properties
$abstract
layer abstract.
protected
mixed
$abstract
= ''
$aliases
protected
array<string, string>
$aliases
= array()
list of aliases name for each fields
$connection
protected
null|jDbConnection
$connection
$constraints
protected
array<string|int, string>
$constraints
= array()
list of constraints for each fields (type of contraints and if it is notNull, unique and/or expression contraint)
$datasource
layer datasource.
protected
mixed
$datasource
= ''
$dbFieldList
protected
array<string|int, jDbFieldProperties>
$dbFieldList
$dbFieldsInfo
protected
mixed
$dbFieldsInfo
$dbProfile
protected
string
$dbProfile
the jDb profile to use for the connection
$defaultValues
protected
array<string|int, string>
$defaultValues
= array()
list of default value (as QGIS expressions) for each fields
$dtParams
protected
null|object
$dtParams
connection parameters
$fields
protected
mixed
$fields
= array()
$id
layer id in the QGIS project file.
protected
mixed
$id
= ''
$name
layer name.
protected
mixed
$name
= ''
$proj4
layer proj4.
protected
mixed
$proj4
= ''
$project
protected
Project|qgisProject
$project
$provider
layer provider.
protected
mixed
$provider
= ''
$shortname
layer short name.
protected
mixed
$shortname
= ''
$srid
layer srid.
protected
mixed
$srid
= 0
$title
layer title.
protected
mixed
$title
= ''
$type
layer type.
protected
mixed
$type
= 'vector'
$webDavBaseUris
protected
mixed
$webDavBaseUris
= array()
$webDavFields
protected
mixed
$webDavFields
= array()
$wfsFields
protected
mixed
$wfsFields
= array()
$geometryDatatypeMap
private
mixed
$geometryDatatypeMap
= array('point', 'linestring', 'polygon', 'multipoint', 'multilinestring', 'multipolygon', 'geometrycollection', 'geometry', 'geography')
Methods
__construct()
constructor.
public
__construct(Project|qgisProject $project, array<string|int, mixed> $propLayer) : mixed
Parameters
- $project : Project|qgisProject
- $propLayer : array<string|int, mixed>
-
list of properties values
canCurrentUserEdit()
public
canCurrentUserEdit() : bool
Return values
boolcheckFeatureAgainstPolygonFilter()
Check if the given edited feature intersects the filtering polygon for the current user.
public
checkFeatureAgainstPolygonFilter(array<string|int, mixed> $values) : bool
If there is no filter by polygon, this method returns true.
Parameters
- $values : array<string|int, mixed>
-
values computed from the form
Tags
Return values
bool —false when there is a filter by polygon and the geometry is outside the polygon(s)
deleteFeature()
public
deleteFeature(object $feature, null|array<string|int, mixed> $loginFilteredLayers[, null|jDbConnection $connection = null ]) : int
Parameters
- $feature : object
- $loginFilteredLayers : null|array<string|int, mixed>
-
array with these keys:
- where: SQL WHERE statement
- type: 'groups' or 'login'
- attribute: filter attribute from the layer
- $connection : null|jDbConnection = null
-
DBConnection, if not null then the parameter conneciton is used, default value null
Tags
Return values
inteditableFeatures()
Get the layer editable features.
public
editableFeatures() : array<string|int, mixed>
Used client-side (JS) to fetch the features which are editable by the authenticated user when there is a filter by login (or by polygon). This allows to deactivate the editing icon for the non-editable features inside the popup and attribute table.
Return values
array<string|int, mixed> —Data containing the status (restricted|unrestricted) and the features if restricted
getAbstract()
public
getAbstract() : mixed
getAliasFields()
list of aliases.
public
getAliasFields() : array<string, string>
Return values
array<string, string>getConstraints()
Get the QGIS constraints of the given field.
public
getConstraints(string $fieldName) : array<string|int, string>
Parameters
- $fieldName : string
Return values
array<string|int, string> —the constraints of the field
getConstraintsList()
list of constraints.
public
getConstraintsList() : array<string|int, string>
Return values
array<string|int, string>getDatasource()
public
getDatasource() : mixed
getDatasourceConnection()
public
getDatasourceConnection() : jDbConnection
Tags
Return values
jDbConnectiongetDatasourceParameters()
public
getDatasourceParameters() : object
Return values
objectgetDatasourceProfile()
Give the jDb profile name for the database connection.
public
getDatasourceProfile([int $timeout = 30 ][, bool $setSearchPathFromLayer = true ]) : null|string
This method is public so it can be used by custom modules. Sometimes getDatasourceConnection() is not useful, as we could need the profile to give to jDao or other components that need a profile, not a connection
Parameters
- $timeout : int = 30
-
default timeout for the connection
- $setSearchPathFromLayer : bool = true
-
If true, the layer schema is used to set the search_path. Default to True to keep the same behavior as did the previous version of this method.
Tags
Return values
null|string —null if there is an issue or no connection parameters
getDbFieldDefaultValues()
public
getDbFieldDefaultValues() : mixed
getDbFieldDistinctValues()
public
getDbFieldDistinctValues(mixed $field) : mixed
Parameters
- $field : mixed
getDbFieldList()
public
getDbFieldList() : array<string|int, jDbFieldProperties>
Return values
array<string|int, jDbFieldProperties>getDbFieldsInfo()
public
getDbFieldsInfo() : null|qgisLayerDbFieldsInfo
Return values
null|qgisLayerDbFieldsInfogetDbFieldValues()
public
getDbFieldValues(mixed $feature) : mixed
Parameters
- $feature : mixed
getDefaultValue()
Get the QGIS expression of the default value of the given field.
public
getDefaultValue(string $fieldName) : null|string
Parameters
- $fieldName : string
Return values
null|string —null if there is no default value
getDefaultValues()
List of default values for each fields.
public
getDefaultValues() : array<string|int, string>
Values are QGIS expressions or may be null when no default value is given
Return values
array<string|int, string>getEditionCapabilities()
public
getEditionCapabilities() : null|object
return the edition layer object to be compatible with external modules. It will returns the capabilities object in the future. Use getRealEditionCapabilities() for the moment.
Tags
Return values
null|object —the edition layer object
getFields()
public
getFields() : mixed
getGeometryAsSql()
public
getGeometryAsSql(mixed $value) : mixed
Parameters
- $value : mixed
getId()
public
getId() : mixed
getName()
public
getName() : mixed
getPolygonFilter()
Returns the sql used to filter the layer data by polygon.
public
getPolygonFilter([bool $editing_context = false ][, int $ttl = 60 ]) : string
It is requested from Lizmap plugin and used only when querying the data directly from PostgreSQL via a SQL query. The filter is added in the WHERE clause.
Parameters
- $editing_context : bool = false
-
If we are in a editing context or no. Default false
- $ttl : int = 60
-
Cache TTL in seconds. Default 60. Use -1 to deactivate the cache.
Return values
string —the expression to filter the layer by polygon
getPolygonFilterExpression()
Returns the expression used to filter the layer data by polygon.
public
getPolygonFilterExpression([bool $editing_context = false ][, int $ttl = 60 ]) : string
It is requested from Lizmap plugin and used only if a filter by polygon is active.
Parameters
- $editing_context : bool = false
-
If we are in a editing context or no. Default false
- $ttl : int = 60
-
Cache TTL in seconds. Default 60. Use -1 to deactivate the cache.
Return values
string —the geometry of the polygons in eWKT format
getPolygonFilterGeometry()
Returns the geometry in eWKT of the authorized polygon for this layer and the current user.
public
getPolygonFilterGeometry([bool $editing_context = false ][, int $ttl = 60 ]) : string
It is requested from Lizmap plugin and used only if a filter by polygon is active.
Parameters
- $editing_context : bool = false
-
If we are in a editing context or no. Default false
- $ttl : int = 60
-
Cache TTL in seconds. Default 60. Use -1 to deactivate the cache.
Return values
string —the geometry of the polygons in eWKT format
getPrimaryKeyValues()
public
getPrimaryKeyValues(mixed $feature) : mixed
Parameters
- $feature : mixed
getProj4()
public
getProj4() : mixed
getProject()
public
getProject() : Project|qgisProject
Return values
Project|qgisProjectgetProvider()
public
getProvider() : mixed
getRealEditionCapabilities()
public
getRealEditionCapabilities() : object
Return values
object —the capabilities object
getShortName()
public
getShortName() : mixed
getSrid()
public
getSrid() : mixed
getTitle()
public
getTitle() : mixed
getType()
public
getType() : mixed
getWebDavFieldConfiguration()
public
getWebDavFieldConfiguration() : mixed
getWfsFields()
public
getWfsFields() : mixed
getWfsTypeName()
Get the WFS typename for this layer.
public
getWfsTypeName() : string
We need to get either the shortname or the layer name and replace all spaces by underscore
Return values
string —The WFS typename of the layer
getXmlLayer()
public
getXmlLayer() : null|SimpleXMLElement
Return values
null|SimpleXMLElementinsertFeature()
public
insertFeature(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —list of primary keys with their values
insertRelations()
Link features between 2 tables by creating the needed lines in a third pivot table, for a many-to-many relation (n-m).
public
insertRelations(string $foreign_key_column_a, array<string|int, mixed> $parent_a_ids, string $foreign_key_column_b, array<string|int, mixed> $parent_b_ids) : array<string|int, mixed>
It runs one ore many SQL queries concerning the pivot layer table to insert the needed line(s): INSERT INTO pivot_table ("foreign_key_column_a" , "foreign_key_column_b") SELECT parent_a_id_value, parent_b_id_value WHERE NOT EXISTS ( SELECT "foreign_key_column_a" , "foreign_key_column_b" FROM pivot_table WHERE "foreign_key_column_a" = parent_a_id_value AND "foreign_key_column_b" = parent_b_id_value );
Parameters
- $foreign_key_column_a : string
-
name of the foreign key column referencing the parent A in the pivot table
- $parent_a_ids : array<string|int, mixed>
-
values of the ids of the selected features of the parent table A
- $foreign_key_column_b : string
-
name of the foreign key column referencing the parent B in the pivot table
- $parent_b_ids : array<string|int, mixed>
-
values of the ids of the selected features of the parent table B
Return values
array<string|int, mixed> —Results of the SQL INSERT queries
isEditable()
public
isEditable() : mixed
isFeatureEditable()
Get the layer editable features.
public
isFeatureEditable(mixed $feature) : bool
Used client-side (JS) to fetch the features which are editable by the authenticated user when there is a filter by login (or by polygon). This allows to deactivate the editing icon for the non-editable features inside the popup and attribute table.
Parameters
- $feature : mixed
Return values
bool —Data containing the status (restricted|unrestricted) and the features if restricted
linkChildren()
Link features between 2 tables: one parent layer and one child layer.
public
linkChildren(string $foreign_key_column, int $parent_id_value, string $child_pkey_column, array<string|int, mixed> $child_ids) : array<string|int, mixed>
It runs a SQL query concerning the child layer table: UPDATE child_table SET foreign_key_column = parent_id_value WHERE child_pkey_column = child_id;
Parameters
- $foreign_key_column : string
-
name of the foreign key column in the child layer we need in the update SET
- $parent_id_value : int
-
id value of the parent layer feature (only one ID allowed) used in the SET
- $child_pkey_column : string
-
name of the primary key column in the child layer, used in the WHERE clause
- $child_ids : array<string|int, mixed>
-
Primary key values of the child features to be linked. More than one allowed
Return values
array<string|int, mixed> —Results of the SQL UPDATE queries
unlinkChild()
public
unlinkChild(mixed $fkey, mixed $pkey, mixed $pval) : mixed
Parameters
- $fkey : mixed
- $pkey : mixed
- $pval : mixed
updateFeature()
public
updateFeature(object $feature, array<string|int, mixed> $values, null|array<string|int, mixed> $loginFilteredLayers) : array<string|int, mixed>
Parameters
- $feature : object
- $values : array<string|int, mixed>
- $loginFilteredLayers : null|array<string|int, mixed>
-
array with these keys:
- where: SQL WHERE statement
- type: 'groups' or 'login'
- attribute: filter attribute from the layer
Tags
Return values
array<string|int, mixed> —list of primary keys with their values
getPkWhereClause()
protected
getPkWhereClause(qgisLayerDbFieldsInfo $dbFieldsInfo, object $feature) : mixed
Parameters
- $dbFieldsInfo : qgisLayerDbFieldsInfo
- $feature : object
requestPolygonFilter()
Get the polygon filter expression and the polygon geometry eWKT representation as returned by Lizmap plugin for QGIS Server for the layer, depending on the authenticated (or not) user and groups.
protected
requestPolygonFilter([bool $editing_context = false ][, int $ttl = 60 ][, bool $get_expression = false ][, bool $use_cache = true ]) : array<string|int, mixed>
The filter expression will be used to filter the layer data by polygon. The geometry eWKT representation to check that the edited features intersects the polygon.
This is used only when querying the data directly from PostgreSQL via a SQL query (for WFS or in the editing related classes). For example, the filter is added in the WHERE clause when needed.
Parameters
- $editing_context : bool = false
-
If we are in a editing context or no. Default false
- $ttl : int = 60
-
Cache TTL in seconds. Default 60. Use -1 to deactivate the cache.
- $get_expression : bool = false
-
If we need the expression and not the SQL
- $use_cache : bool = true
-
If we need to not use cache
Return values
array<string|int, mixed> —associative array containing the keys 'expression' and 'polygon'