Lizmap Web Client 3.11.0

WFSRequest extends OGCRequest
in package

Tags
see
https://en.wikipedia.org/wiki/Web_Feature_Service.

Table of Contents

Constants

DEFAULT_OUTPUT_SRID  : mixed = 4326
Default output SRID when no SRSNAME is provided on the WFS GetFeature request (EPSG:4326 — the historical WFS default).

Properties

$genericGetFeatureParameters  : array<string, string>
$hitsGetFeatureParameters  : array<string, string>
$appContext  : AppContextInterface
$datasource  : null|object
$editingContext  : bool
$params  : array<string|int, mixed>
$project  : Project
$qgisLayer  : null|qgisVectorLayer
$repository  : Repository
$requestXml  : null|string
$selectFields  : array<string|int, string>
$services  : lizmapServices
$tplExceptions  : string
$wfs_typename  : null|string

Methods

__construct()  : mixed
constructor.
buildGetFeatureHitsParameters()  : array<string, string>
Build GetFeature request parameters to get number of features for a type name and optional other parameters.
buildGetFeatureParameters()  : array<string, string>
Build GetFeature request parameters for a type name and optional other parameters.
checkingTypename()  : int
getEditingContext()  : bool
param()  : mixed
Get the value of a request parameter. If not defined, gets its default value.
parameters()  : array<string, string>
Provide the parameters with the lizmap extra parameters for filtering the request.
process()  : object
Process the OGC Request Checks the request parameter and performs the right method.
requestedTypename()  : string
Get the requested typename based on TYPENAME or FEATUREID parameter.
setEditingContext()  : bool
Set the edition context for request.
buildQueryBase()  : string
Build the base SQL query to fetch data from the database.
constructUrl()  : string
Build the URL to request QGIS Server.
getBboxSql()  : string
Get the SQL clause to instersects bbox in the request parameters.
getDatasourceSql()  : string
Get the SQL filter configured in QGIS layer datasource.
getFeatureIdFilterExp()  : string
getfeaturePostgres()  : OGCResponse
Queries The PostGreSQL Server for getFeature.
getfeatureQgis()  : OGCResponse
Queries Qgis Server for getFeature.
getQueryFields()  : array<string|int, string>
Get the WFS fields the direct SQL query depends on.
getQueryOrder()  : string
Build the SQL ORDER BY clause for the request.
getRequestLoginFilters()  : array<string|int, mixed>
Get the SQL filters by login of the requested layers.
getSelectedFields()  : array<string|int, string>
Get the WFS fields selected by the PROPERTYNAME parameter.
getSortFields()  : array<string, string>
Get the sort fields and directions requested by the SORTBY parameter.
getWhereClause()  : false|string
Build the SQL WHERE clause for the request.
loadXmlString()  : mixed
logRequestIfError()  : mixed
Log if the HTTP code is a 4XX or 5XX error code.
parseExpFilter()  : false|string
Parse the expression filter parameter.
parseFeatureId()  : string
Build the SQL condition matching the FEATUREID parameter.
parseSrsnameSrid()  : null|int
Parse a WFS SRSNAME string and return its SRID.
process_describefeaturetype()  : OGCResponse
process_getcapabilities()  : OGCResponse
Perform an OGC GetCapabilities Request.
process_getfeature()  : OGCResponse
request()  : OGCResponse
Request QGIS Server.
serviceException()  : OGCResponse
Provide an OGC Service Exception result.
setGeojsonSql()  : string
validateClientExpFilter()  : bool
Validate the EXP_FILTER parameter sent by the client, before any combination.
validateFilter()  : false|string
Parses and validate a filter for postgresql.
getResultTypeHitsSql()  : string
Get the SQL used to count the features.

Constants

DEFAULT_OUTPUT_SRID

Default output SRID when no SRSNAME is provided on the WFS GetFeature request (EPSG:4326 — the historical WFS default).

protected mixed DEFAULT_OUTPUT_SRID = 4326

Properties

$genericGetFeatureParameters

public static array<string, string> $genericGetFeatureParameters = array('SERVICE' => 'WFS', 'VERSION' => '1.0.0', 'REQUEST' => 'GetFeature', 'OUTPUTFORMAT' => 'GeoJSON')

Generic GetFeature request parameters

$hitsGetFeatureParameters

public static array<string, string> $hitsGetFeatureParameters = array('RESULTTYPE' => 'hits')

The special hits GetFeature request parameters to get number of features

$datasource

protected null|object $datasource

datasource parameters

$editingContext

protected bool $editingContext = false

apply edition context for request

$params

protected array<string|int, mixed> $params

$selectFields

protected array<string|int, string> $selectFields = array()

the fields to select

$tplExceptions

protected string $tplExceptions = 'lizmap~wfs_exception'

selector of a template

$wfs_typename

protected null|string $wfs_typename

the requested typename

Methods

__construct()

constructor.

public __construct(Project $project, array<string|int, mixed> $params, lizmapServices $services[, null|string $requestXml = null ]) : mixed
Parameters
$project : Project

the project

$params : array<string|int, mixed>

the params array

$services : lizmapServices
$requestXml : null|string = null

the params array

buildGetFeatureHitsParameters()

Build GetFeature request parameters to get number of features for a type name and optional other parameters.

public static buildGetFeatureHitsParameters(string $typeName[, array<string, string> $otherParameters = array() ]) : array<string, string>
Parameters
$typeName : string

The type name of features

$otherParameters : array<string, string> = array()

Optional, other parameters to add to the request

Return values
array<string, string> —

The parameters

buildGetFeatureParameters()

Build GetFeature request parameters for a type name and optional other parameters.

public static buildGetFeatureParameters(string $typeName[, array<string, string> $otherParameters = array() ]) : array<string, string>
Parameters
$typeName : string

The type name of features

$otherParameters : array<string, string> = array()

Other parameters to add to the request

Return values
array<string, string> —

The parameters

checkingTypename()

public checkingTypename() : int
Return values
int —

An HTTP code

getEditingContext()

public getEditingContext() : bool
Return values
bool —

The edition context for request

param()

Get the value of a request parameter. If not defined, gets its default value.

public param(string $name[, mixed $defaultValue = null ][, bool $useDefaultIfEmpty = false ]) : mixed
Parameters
$name : string

the name of the request parameter

$defaultValue : mixed = null

the default returned value if the parameter doesn't exists

$useDefaultIfEmpty : bool = false

true: says to return the default value if the parameter value is ""

Return values
mixed —

the request parameter value

parameters()

Provide the parameters with the lizmap extra parameters for filtering the request.

public parameters() : array<string, string>

Lizmap_User, Lizmap_User_Groups, Lizmap_Override_Filter have been added to the OGC request parameters. The filter by login is not added to the EXP_FILTER parameter: it is applied by the lizmap_server plugin of QGIS Server, and added as a SQL filter when the data is queried directly in the database, see getWhereClause().

Return values
array<string, string> —

the WFS request parameters with Lizmap extra parameters for filtering request

process()

Process the OGC Request Checks the request parameter and performs the right method.

public process() : object
Return values
object —

The request result with HTTP code, response mime-type, response data (properties $code, $mime, $data, $cached)

requestedTypename()

Get the requested typename based on TYPENAME or FEATUREID parameter.

public requestedTypename() : string
Return values
string —

the requested typename

setEditingContext()

Set the edition context for request.

public setEditingContext(bool $editingContext) : bool
Parameters
$editingContext : bool

The edition context for request

Return values
bool —

The edition context for request

buildQueryBase()

Build the base SQL query to fetch data from the database.

protected buildQueryBase(mixed $cnx, mixed $params, mixed $wfsFields[, bool $isHitsRequest = false ]) : string
Parameters
$cnx : mixed

Database connection

$params : mixed

Request parameters

$wfsFields : mixed

List of WFS fields

$isHitsRequest : bool = false

True if the request must only get the features count

Return values
string

constructUrl()

Build the URL to request QGIS Server.

protected constructUrl() : string
Return values
string —

The URL to use to request QGIS Server

getBboxSql()

Get the SQL clause to instersects bbox in the request parameters.

protected getBboxSql(array<string, string> $params) : string
Parameters
$params : array<string, string>

the request parameters

Return values
string —

the SQL clause to instersects bbox in the request parameters or empty string

getDatasourceSql()

Get the SQL filter configured in QGIS layer datasource.

protected getDatasourceSql() : string
Return values
string —

The SQL filter enclosed with parenthesis

getFeatureIdFilterExp()

protected getFeatureIdFilterExp(string $featureid, string $typename, qgisVectorLayer $qgisLayer) : string
Parameters
$featureid : string

The FEATUREID parameter

$typename : string

The layer's typename from TYPENAME or FEATUREID parameter

$qgisLayer : qgisVectorLayer

The QGIS layer based on typename

Return values
string —

The QGIS expression based on FEATUREID parameter

getQueryFields()

Get the WFS fields the direct SQL query depends on.

protected getQueryFields(array<string|int, mixed> $params, array<string|int, string> $wfsFields[, bool $isHitsRequest = false ]) : array<string|int, string>

The query reads the fields selected by PROPERTYNAME (except for a hits request), sorts on the fields of SORTBY and filters on the fields cited in EXP_FILTER. A field is considered cited in EXP_FILTER when its name appears as a whole word, so a name inside a string literal is also returned: the request is then sent to QGIS Server, which is always correct.

Parameters
$params : array<string|int, mixed>

The request parameters

$wfsFields : array<string|int, string>

The WFS fields of the layer

$isHitsRequest : bool = false

True if the request only counts the features

Return values
array<string|int, string> —

The WFS fields used by the SQL query, without duplicates

getQueryOrder()

Build the SQL ORDER BY clause for the request.

protected getQueryOrder(jDbConnection $cnx, array<string|int, mixed> $params, array<string|int, mixed> $wfsFields) : string
Parameters
$cnx : jDbConnection

The database connection

$params : array<string|int, mixed>

The request parameters

$wfsFields : array<string|int, mixed>

The WFS fields

Return values
string —

The SQL ORDER BY clause

getRequestLoginFilters()

Get the SQL filters by login of the requested layers.

protected getRequestLoginFilters() : array<string|int, mixed>

They are used when the data is queried directly in the database. Otherwise, the filter by login is applied by the lizmap_server plugin of QGIS Server.

Return values
array<string|int, mixed> —

the filters by login, by layer name, empty if the user can override them

getSelectedFields()

Get the WFS fields selected by the PROPERTYNAME parameter.

protected getSelectedFields(array<string|int, mixed> $params, array<string|int, string> $wfsFields) : array<string|int, string>

Requested fields which are not WFS fields are ignored. Without PROPERTYNAME, every WFS field is selected. The primary keys are not added.

Parameters
$params : array<string|int, mixed>

The request parameters

$wfsFields : array<string|int, string>

The WFS fields of the layer

Return values
array<string|int, string> —

The selected WFS fields

getSortFields()

Get the sort fields and directions requested by the SORTBY parameter.

protected getSortFields(array<string|int, mixed> $params, array<string|int, string> $wfsFields) : array<string, string>

SORTBY is a comma separated list of fields, each one optionally followed by a space and a direction, for example id a,name d. The direction is ascending by default. Fields which are not WFS fields are ignored.

A field name can be enclosed in double quotes, with inner double quotes doubled, as in QGIS expressions: "Sewer type" d. Without quotes, a name with spaces is accepted if the whole item is a WFS field.

Parameters
$params : array<string|int, mixed>

The request parameters

$wfsFields : array<string|int, string>

The WFS fields of the layer

Return values
array<string, string> —

The sort direction, ASC or DESC, by field name

getWhereClause()

Build the SQL WHERE clause for the request.

protected getWhereClause(jDbConnection $cnx, array<string|int, mixed> $params) : false|string

It combines the datasource SQL filter, the BBOX parameter, the EXP_FILTER parameter, and the FEATUREID parameter

Parameters
$cnx : jDbConnection

The database connection

$params : array<string|int, mixed>

The request parameters

Return values
false|string —

The SQL Where clause if the expression filter is valid, false otherwise

loadXmlString()

protected loadXmlString(mixed $xmldata, mixed $name) : mixed
Parameters
$xmldata : mixed
$name : mixed

logRequestIfError()

Log if the HTTP code is a 4XX or 5XX error code.

protected logRequestIfError(int $code, array<string, string> $headers) : mixed
Parameters
$code : int

The HTTP code of the request

$headers : array<string, string>

The headers of the response

parseExpFilter()

Parse the expression filter parameter.

protected parseExpFilter(jDbConnection $cnx, array<string|int, mixed> $params) : false|string
Parameters
$cnx : jDbConnection

The database connection

$params : array<string|int, mixed>

The request parameters

Return values
false|string —

The SQL filter enclosed with parenthesis if the expression filter is valid, false otherwise

parseFeatureId()

Build the SQL condition matching the FEATUREID parameter.

protected parseFeatureId(jDbConnection $cnx, array<string|int, mixed> $params) : string

The returned condition is not a single self contained block, it has to be put under paranthesis with an AND operator before being used in a WHERE clause.

Parameters
$cnx : jDbConnection

The database connection

$params : array<string|int, mixed>

The request parameters

Return values
string —

The SQL condition or an empty string

parseSrsnameSrid()

Parse a WFS SRSNAME string and return its SRID.

protected parseSrsnameSrid(string $srsname) : null|int

Accepts the colon-separated forms used by WFS clients: "EPSG:4326", "urn:ogc:def:crs:EPSG::4326" The last colon-separated segment must be a positive integer.

Parameters
$srsname : string

the raw SRSNAME value

Return values
null|int —

the SRID on success, null if the input is empty or malformed

request()

Request QGIS Server.

protected request([bool $post = false ][, bool $stream = false ]) : OGCResponse
Parameters
$post : bool = false

Force to use POST request

$stream : bool = false

Get data as stream

Return values
OGCResponse —

The request result with HTTP code, response mime-type and response data (properties $code, $mime, $data)

serviceException()

Provide an OGC Service Exception result.

protected serviceException([int $code = 400 ]) : OGCResponse
Parameters
$code : int = 400

The HTTP code to return

Return values
OGCResponse —

The request result with HTTP code, response mime-type, response data (properties $code, $mime, $data, $cached)

setGeojsonSql()

protected setGeojsonSql(string $sql, jDbConnection $cnx, mixed $typename, mixed $geometryname[, int $outputSrid = 4326 ]) : string
Parameters
$sql : string
$cnx : jDbConnection
$typename : mixed
$geometryname : mixed
$outputSrid : int = 4326
Return values
string

validateClientExpFilter()

Validate the EXP_FILTER parameter sent by the client, before any combination.

protected validateClientExpFilter() : bool

The client filter is put between parenthesis and combined with the other filters, e.g. the filter by login. Validating only a combined filter is not enough: a client filter like 1=1 ) OR ( 1=1 would get out of its parenthesis. The client filter is therefore validated alone, so that its parenthesis are balanced, and between parenthesis, so that a final comment cannot hide the closing parenthesis.

Return values
bool —

true if there is no client filter or if it is valid

validateFilter()

Parses and validate a filter for postgresql.

protected validateFilter(string $filter) : false|string
Parameters
$filter : string

The filter to parse

Return values
false|string —

returns the validate filter if the expression does not contains dangerous chars

getResultTypeHitsSql()

Get the SQL used to count the features.

private getResultTypeHitsSql(string $sql) : string

This is used for RESULTTYPE=hits

Parameters
$sql : string
Return values
string
On this page

Search results