WFSAggregateRequest
extends WFSRequest
in package
Compute aggregates (GROUP BY) on the features of a layer with a direct SQL query to PostgreSQL, instead of getting all the features with WFS.
The features are selected exactly as with a WFS GetFeature request: the same checks of the layer publication and access rights, and the same SQL WHERE clause (datasource filter, BBOX, EXP_FILTER, filter by login, filter by polygon, FEATUREID).
The aggregation is not always possible: not a PostgreSQL layer, OGC FILTER parameter, expression filter not translatable to SQL, numeric function on a non numeric field, database error... In these cases, aggregate() and aggregateColumns() return null and the caller must use a GetFeature request instead. The reason is given by getFailureReason().
Usage: $request = new WFSAggregateRequest($project, array( 'TYPENAME' => 'my_layer', 'EXP_FILTER' => '"type" = 'A'', ), $services); $rows = $request->aggregate( array('category'), array(array('sum', 'value'), array('count', null)), ); // $rows = array(array(array('A'), array(12.5, 3)), ...)
The groups are sorted by their values, ascending, with the null values last, as the features of a GetFeature request with SORTBY.
For many groups, aggregateColumns() gives the same values as JSON arrays built by PostgreSQL, one per column, which do not need to be decoded.
The extent of the selected features is given by extent(), without getting their geometries.
Table of Contents
Constants
- AVG : mixed = 'avg'
- Mean of the numeric values
- COUNT : mixed = 'count'
- Number of features
- FIRST : mixed = 'first'
- Value of the first feature
- FIRST_NOT_EMPTY : mixed = 'first_not_empty'
- First value which is not null nor an empty string
- LAST : mixed = 'last'
- Value of the last feature
- MAX : mixed = 'max'
- Maximum of the numeric values
- MEDIAN : mixed = 'median'
- Median of the numeric values
- MIN : mixed = 'min'
- Minimum of the numeric values
- STDDEV : mixed = 'stddev'
- Population standard deviation of the numeric values
- SUM : mixed = 'sum'
- Sum of the numeric values, 0 if none
- DEFAULT_OUTPUT_SRID : mixed = 4326
- Default output SRID when no SRSNAME is provided on the WFS GetFeature request (EPSG:4326 — the historical WFS default).
- FEATURE_ORDER_FUNCTIONS : mixed = array(self::FIRST, self::LAST, self::FIRST_NOT_...
- Aggregate functions which use the order of the features.
- FUNCTIONS : mixed = array(self::COUNT, self::SUM, self::AVG, self::...
- All the supported aggregate functions.
- NUMERIC_FUNCTIONS : mixed = array(self::SUM, self::AVG, self::MIN, self::MA...
- Aggregate functions which only use numeric values.
Properties
- $genericGetFeatureParameters : array<string, string>
- $hitsGetFeatureParameters : array<string, string>
- $appContext : AppContextInterface
- $datasource : null|object
- $editingContext : bool
- $failureReason : null|string
- $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
- Create the request.
- aggregate() : null|array<int, array{0: list, 1: list}>
- Aggregate the features by group.
-
aggregateColumns()
: null|array{count: int, groups: list
, aggregates: list } - Aggregate the features by group, and get each column as a JSON array.
- 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
- extent() : null|array<int, float>
- Get the extent of the selected features.
- getEditingContext() : bool
- getFailureReason() : null|string
- Get the reason why the last aggregation was not possible.
- 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.
- buildAggregateSql() : string
- Build the SQL query aggregating the features.
- buildExtentSql() : string
- Build the SQL query computing the extent of the features.
- buildQueryBase() : string
- Build the base SQL query to fetch data from the database.
- checkSqlLayer() : bool
- Check that the features of the layer can be requested with SQL.
- constructUrl() : string
- Build the URL to request QGIS Server.
- fail() : null
- Store the reason why the aggregation is not possible.
- getAggregatableFields() : null|array<string, jDbFieldProperties>
- Check that the layer can be aggregated with SQL, and get its fields.
- getAggregateSql() : string
- Get the SQL expression of an aggregate function.
- 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.
- isNumericField() : bool
- Tell if a database field is numeric.
- 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
- validateAggregation() : bool
- Check the fields and the functions of the aggregation.
- validateClientExpFilter() : bool
- Validate the EXP_FILTER parameter sent by the client, before any combination.
- validateFilter() : false|string
- Parses and validate a filter for postgresql.
Constants
AVG
Mean of the numeric values
public
mixed
AVG
= 'avg'
COUNT
Number of features
public
mixed
COUNT
= 'count'
FIRST
Value of the first feature
public
mixed
FIRST
= 'first'
FIRST_NOT_EMPTY
First value which is not null nor an empty string
public
mixed
FIRST_NOT_EMPTY
= 'first_not_empty'
LAST
Value of the last feature
public
mixed
LAST
= 'last'
MAX
Maximum of the numeric values
public
mixed
MAX
= 'max'
MEDIAN
Median of the numeric values
public
mixed
MEDIAN
= 'median'
MIN
Minimum of the numeric values
public
mixed
MIN
= 'min'
STDDEV
Population standard deviation of the numeric values
public
mixed
STDDEV
= 'stddev'
SUM
Sum of the numeric values, 0 if none
public
mixed
SUM
= 'sum'
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
FEATURE_ORDER_FUNCTIONS
Aggregate functions which use the order of the features.
private
mixed
FEATURE_ORDER_FUNCTIONS
= array(self::FIRST, self::LAST, self::FIRST_NOT_EMPTY)
FUNCTIONS
All the supported aggregate functions.
private
mixed
FUNCTIONS
= array(self::COUNT, self::SUM, self::AVG, self::MIN, self::MAX, self::STDDEV, self::MEDIAN, self::FIRST, self::LAST, self::FIRST_NOT_EMPTY)
NUMERIC_FUNCTIONS
Aggregate functions which only use numeric values.
private
mixed
NUMERIC_FUNCTIONS
= array(self::SUM, self::AVG, self::MIN, self::MAX, self::STDDEV, self::MEDIAN)
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
$appContext
protected
AppContextInterface
$appContext
$datasource
protected
null|object
$datasource
datasource parameters
$editingContext
protected
bool
$editingContext
= false
apply edition context for request
$failureReason
protected
null|string
$failureReason
Why the last aggregation was not possible
$params
protected
array<string|int, mixed>
$params
$project
protected
Project
$project
$qgisLayer
protected
null|qgisVectorLayer
$qgisLayer
$repository
protected
Repository
$repository
$requestXml
protected
null|string
$requestXml
$selectFields
protected
array<string|int, string>
$selectFields
= array()
the fields to select
$services
protected
lizmapServices
$services
$tplExceptions
protected
string
$tplExceptions
= 'lizmap~wfs_exception'
selector of a template
$wfs_typename
protected
null|string
$wfs_typename
the requested typename
Methods
__construct()
Create the request.
public
__construct(Project $project, array<string|int, mixed> $params, lizmapServices $services) : mixed
Parameters
- $project : Project
-
the Lizmap project
- $params : array<string|int, mixed>
-
the WFS GetFeature parameters selecting the features: TYPENAME (mandatory), EXP_FILTER, BBOX, FEATUREID...
- $services : lizmapServices
-
the Lizmap services
aggregate()
Aggregate the features by group.
public
aggregate(array<int, string> $groupFields, array<int, array{0: string, 1: ?string}> $aggregates[, array<int, string> $notNullFields = array() ]) : null|array<int, array{0: list, 1: list}>
Each aggregate is a function and a field name. The field is not used by the count function. The numeric functions (sum, avg, min, max, stddev, median) need a numeric field.
The groups with a null value for one of the $notNullFields are ignored.
All the values are decoded: for a large number of groups, prefer aggregateColumns() which returns them as JSON arrays.
Parameters
- $groupFields : array<int, string>
-
the fields to group by
- $aggregates : array<int, array{0: string, 1: ?string}>
-
the aggregates: function and field
- $notNullFields : array<int, string> = array()
-
the group fields which must not be null
Return values
null|array<int, array{0: list, 1: list}> —for each group, sorted by value, the group values and the aggregated values, in the order of the parameters; null if the aggregation is not possible
aggregateColumns()
Aggregate the features by group, and get each column as a JSON array.
public
aggregateColumns(array<int, string> $groupFields, array<int, array{0: string, 1: ?string}> $aggregates[, array<int, string> $notNullFields = array() ]) : null|array{count: int, groups: list, aggregates: list}
The parameters are the same as aggregate(). The JSON arrays are built by PostgreSQL: the values can be sent to a client without being decoded, which keeps a low memory usage when there are many groups. The values of a group have the same position in all the arrays. JSON keeps the types of the values (number, string, boolean).
Parameters
- $groupFields : array<int, string>
-
the fields to group by
- $aggregates : array<int, array{0: string, 1: ?string}>
-
the aggregates: function and field
- $notNullFields : array<int, string> = array()
-
the group fields which must not be null
Return values
null|array{count: int, groups: listthe number of groups, the JSON array of each group field and of each aggregate; null if not possible
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
extent()
Get the extent of the selected features.
public
extent([int $srid = self::DEFAULT_OUTPUT_SRID ]) : null|array<int, float>
The extent is computed by PostgreSQL from the envelope of each geometry, transformed into the output CRS, as the "extent" GEOMETRYNAME of a GetFeature request. The features without geometry are ignored.
Parameters
- $srid : int = self::DEFAULT_OUTPUT_SRID
-
the SRID of the output CRS, EPSG:4326 by default as for GeoJSON
Return values
null|array<int, float> —the extent [xmin, ymin, xmax, ymax], an empty array if no feature has a geometry; null if not possible, see getFailureReason()
getEditingContext()
public
getEditingContext() : bool
Return values
bool —The edition context for request
getFailureReason()
Get the reason why the last aggregation was not possible.
public
getFailureReason() : null|string
Return values
null|string —the reason, null if the aggregation succeeded
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
buildAggregateSql()
Build the SQL query aggregating the features.
protected
buildAggregateSql(jDbConnection $cnx, string $whereClause, array<int, string> $groupFields, array<int, array{0: string, 1: ?string}> $aggregates, array<int, string> $notNullFields) : string
The query returns one row: the number of groups "lizmap_group_count", then one JSON array per group field (g0, g1...) and per aggregate (a0, a1...), with the values of the groups in the same order: sorted by the group values, ascending, the null values last. JSON keeps the types of the values (number, string, boolean).
The position of each feature, given by the primary key, is computed only for the functions using it: first, last and first not empty.
Parameters
- $cnx : jDbConnection
-
the database connection
- $whereClause : string
-
the WHERE clause selecting the features
- $groupFields : array<int, string>
-
the fields to group by, already validated
- $aggregates : array<int, array{0: string, 1: ?string}>
-
the aggregates, already validated
- $notNullFields : array<int, string>
-
the group fields which must not be null
Return values
string —the SQL query
buildExtentSql()
Build the SQL query computing the extent of the features.
protected
buildExtentSql(jDbConnection $cnx, string $whereClause, int $srid) : string
The query returns one row with the columns xmin, ymin, xmax and ymax, null if no feature has a geometry.
Parameters
- $cnx : jDbConnection
-
the database connection
- $whereClause : string
-
the WHERE clause selecting the features
- $srid : int
-
the SRID of the output CRS
Return values
string —the SQL query
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
stringcheckSqlLayer()
Check that the features of the layer can be requested with SQL.
protected
checkSqlLayer() : bool
The conditions are the ones used by process_getfeature() and getfeaturePostgres() to request PostgreSQL directly instead of QGIS Server, including the fields of the expression filter, which must be table fields. The layer and its datasource are stored in the qgisLayer and datasource properties.
Return values
bool —true if possible, false with a failure reason otherwise
constructUrl()
Build the URL to request QGIS Server.
protected
constructUrl() : string
Return values
string —The URL to use to request QGIS Server
fail()
Store the reason why the aggregation is not possible.
protected
fail(string $reason) : null
It always returns null, so the callers can return its result directly.
Parameters
- $reason : string
-
the reason
Return values
nullgetAggregatableFields()
Check that the layer can be aggregated with SQL, and get its fields.
protected
getAggregatableFields() : null|array<string, jDbFieldProperties>
Return values
null|array<string, jDbFieldProperties> —the database fields published in WFS, null if not possible
getAggregateSql()
Get the SQL expression of an aggregate function.
protected
getAggregateSql(jDbConnection $cnx, string $function, null|string $field) : string
Parameters
- $cnx : jDbConnection
-
the database connection
- $function : string
-
the aggregate function, already validated
- $field : null|string
-
the field, already validated
Return values
string —the SQL expression
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
getfeaturePostgres()
Queries The PostGreSQL Server for getFeature.
protected
getfeaturePostgres() : OGCResponse
Tags
Return values
OGCResponsegetfeatureQgis()
Queries Qgis Server for getFeature.
protected
getfeatureQgis() : OGCResponse
Tags
Return values
OGCResponsegetQueryFields()
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
isNumericField()
Tell if a database field is numeric.
protected
static isNumericField(jDbFieldProperties $field) : bool
Parameters
- $field : jDbFieldProperties
-
the field
Return values
bool —true if the field values are numbers
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
process_describefeaturetype()
protected
process_describefeaturetype() : OGCResponse
Tags
Return values
OGCResponseprocess_getcapabilities()
Perform an OGC GetCapabilities Request.
protected
process_getcapabilities() : OGCResponse
Tags
Return values
OGCResponse —The request result with HTTP code, response mime-type, response data (properties $code, $mime, $data, $cached)
process_getfeature()
protected
process_getfeature() : OGCResponse
Tags
Return values
OGCResponserequest()
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
stringvalidateAggregation()
Check the fields and the functions of the aggregation.
protected
validateAggregation(array<string, jDbFieldProperties> $fields, array<int, string> $groupFields, array<int, array{0: string, 1: ?string}> $aggregates, array<int, string> $notNullFields) : bool
The field names are checked against the fields published in WFS: they are safe to be used in the SQL query once enclosed.
Parameters
- $fields : array<string, jDbFieldProperties>
-
the available fields
- $groupFields : array<int, string>
-
the fields to group by
- $aggregates : array<int, array{0: string, 1: ?string}>
-
the aggregates: function and field
- $notNullFields : array<int, string>
-
the group fields which must not be null
Return values
bool —true if the aggregation is valid
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