``
- :samp:`{a} / {b}`
- Division (WFS 1 expression).
This allows to create complex filters, such as:
.. code-block:: xml
status
1
container_type
Other
container_type
Textile
container_type
Glass
container_type
Papier
container_type
Organic
container_type
Plastic
.. _functions:
Using Functions
~~~~~~~~~~~~~~~
Functions are executed in a ``
`` by using the tag ``..``.
This can be used anywhere as an expression instead of a ```` or ````.
Inside the function, the parameters are also given as expressions:
a ````, ```` or new ````.
As a simple example:
.. code-block:: xml
fieldname
As expressions can be functions, the following filter is possible:
.. code-block:: xml
name
0
4
cafe
Various functions are built-in available in the server, inspired by the filter functions found
in `GeoServer `_:
.. list-table:: String Functions
:header-rows: 1
:widths: 40 30 30
* - Function
- SQL equivalent
- Description
* - ``strConcat(string)``
- ``CONCAT()``
- Concatenates strings
* - ``strIndexOf(string, substring)``
- ``STRPOS() - 1``
- Finds the text inside a string, 0-based index.
* - ``strSubstring(string, begin, end)``
- ``SUBSTRING()``
- Removes characters before *begin* and after *end*.
* - ``strSubstringStart(string, begin)``
- ``SUBSTRING()``
- Removes characters before *begin*, 0-based index.
* - ``strToLowerCase(string)``
- ``LOWER()``
- Convert text to lowercase.
* - ``strToUpperCase(string)``
- ``UPPER()``
- Convert text to uppercase.
* - ``strTrim(string)``
- ``TRIM()``
- Remove white space at the beginning and end.
* - ``strLength(string)``
- ``LENGTH()`` / ``CHAR_LENGTH()``
- Determines text length.
* - ``length(string)``
- ``LENGTH()`` / ``CHAR_LENGTH()``
- Alias of ``strLength()``.
.. list-table:: Math Number Functions
:header-rows: 1
:widths: 40 30 30
* - Function
- SQL equivalent
- Description
* - ``abs(number)``
- ``ABS()``
- Invert negative numbers.
* - ``ceil(number)``
- ``CEIL()``
- Rounding up.
* - ``floor(number)``
- ``FLOOR()``
- Rounding down.
* - ``round(value)``
- ``ROUND()``
- Regular rounding.
* - ``min(value1, value2)``
- ``LEAST()``
- Uses the smallest number.
* - ``max(value1, value2)``
- ``GREATEST()``
- Uses the largest number.
* - ``pow(base, exponent)``
- ``POWER()``
- Exponentiation
* - ``exp(value)``
- ``EXP()``
- Exponent of 𝑒 (2,71828...; natural logarithm).
* - ``log(value)``
- ``LOG()``
- Logarithm; inverse of an exponent.
* - ``sqrt(value)``
- ``SQRT()``
- Square root, inverse of exponentiation.
.. list-table:: Math Trigonometry Functions
:header-rows: 1
:widths: 40 30 30
* - Function
- SQL equivalent
- Description
* - ``acos(value)``
- ``ACOS()``
- Arccosine; inverse of cosine.
* - ``asin(value)``
- ``ASIN()``
- Arcsine; inverse van sine.
* - ``atan(value)``
- ``ATAN()``
- Arctangent; inverse of tangent.
* - ``atan2(x, y)``
- ``ATAN2()``
- Arctangent, for usage outside the range of a circle.
* - ``cos(radians)``
- ``COS()``
- Cosine
* - ``sin(radians)``
- ``SIN()``
- Sine
* - ``tan(radians)``
- ``TAN()``
- Tangent
* - ``pi()``
- ``PI``
- The value of π (3,141592653...)
* - ``toDegrees(radians)``
- ``DEGREES()``
- Conversion of radians to degrees.
* - ``toRadians(degree)``
- ``RADIANS()``
- Conversion degrees to radians.
.. list-table:: Geometric Functions
:header-rows: 1
* - Function
- SQL equivalent
- Description
* - ``area(geometry)``
- ``ST_Area()``
- Convert geometry to area.
* - ``centroid(features)``
- ``ST_Centroid()``
- Return geometric center as "gravity point".
* - ``difference(geometry1, geometry2)``
- ``ST_Difference()``
- Parts of geometry 1 that do not overlap with geometry 2.
* - ``distance(geometry1, geometry2)``
- ``ST_Distance()``
- Minimum distance between 2 geometries.
* - ``envelope(geometry)``
- ``ST_Envelope()``
- Convert geometry to bounding box.
* - ``geomLength(geometry)``
- ``ST_Length()``
- The cartesian length for a linestring/curve.
* - ``intersection(geometry1, geometry2)``
- ``ST_Intersection()``
- Parts of geometry 1 that overlap with geometry 2.
* - ``isEmpty(geometry)``
- ``ST_IsEmpty()``
- Tests whether the geometry is empty.
* - ``isValid(geometry)``
- ``ST_IsValid()``
- Tests whether the geometry is valid.
* - ``numGeometries(geometry)``
- ``ST_NumGeometries()``
- Tests how many geometries are found in the collection.
* - ``numPoints(geometry)``
- ``ST_NumPoints()``
- Tests how many points are found in a linestring.
* - ``perimeter(geometry)``
- ``ST_Perimeter()``
- The 2D perimeter of the surface/polygon.
* - ``symDifference(geometry1, geometry1)``
- ``ST_SymDifference()``
- Parts of geometry 1 and 2 that don't intersect.
* - ``union(geometry1, geometry2)``
- ``ST_Union()``
- Merge Geometry 1 and 2.
Using XML POST Requests
-----------------------
When the filter length exceeds the query-string limits,
consider using an XML POST request instead of the KVP query-string format.
A GET request such as:
.. code-block:: urlencoded
?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature
&TYPENAMES=app:restaurant
&FILTER=...
&PROPERTYNAME=app:id,app:name,app:location
&SORTBY=app:name ASC
...can also be defined as XML-encoded POST request:
.. code-block:: xml
app:id
app:name
app:location
...
app:name
ASC
Support for Older Clients
-------------------------
Missing XML Namespaces
~~~~~~~~~~~~~~~~~~~~~~
Strictly speaking, XML namespaces are required in the filter. Since many clients omit them,
the server also supports requests without namespaces. For the sake of completeness,
a request with namespaces included looks like this:
.. code-block:: xml
stadsdeel/naam
Centrum
When a geometry filter is included, this also requires the GML namespace:
.. code-block:: xml
10 10 20 20 30 30 40 40 10 10
According to the XML rules, the "fes" namespace alias can be renamed here
or omitted if only ``xmlns="..."`` is used instead of ``xmlns:fes="..."``.
Older Filter Syntax
~~~~~~~~~~~~~~~~~~~
Several existing clients still use other WFS 1 elements, such as ```` instead of
of ````. For compatibility this tag is also supported.
The WFS 1 expressions ````, ````, ```` and ```` are also implemented
to support arithmetic operations from QGis (addition, subtraction, multiplication and division).