Introduction
This documentation defines the query language used in Louhi. The language is functionally equivalent to the OGC Filter Encoding specification 2.0 (http://www.opengeospatial.org/standards/filter). This language is used in style rules, filtering layers on the server and WFS where clause in admin. Some of the features only work when filtering layers and not in styles (marked with ).
Operations
Boolean Logic
OP1 && OP2 - and
OP1 || OP2 - or
! OP - not
Comparisons
EXPR1 == EXPR2 - equals
EXPR1 != EXPR2 - not equals
EXPR1 < EXPR2 - less than
EXPR1 > EXPR2 - greater than
EXPR1 <= EXPR2 - less than or equal to
EXPR1 >= EXPR2 - greater than or equal to
EXPR1 between EXPR2 and EXPR3 – between comparison
Nil operation
Checks if the expression value is nil (the normal “is null” operation in sql languages)
EXPR is nil
Null operation
Checks if the field exists in the feature
EXPR is null
Like operation
EXPR like String
Checks if EXPR is like the string query. Same as SQL like queries. You can use the following placeholders in the string:
% - one or more characters
_ - one character
Parenthesis
(operation) – parenthesis can be used
Spatial Operations
BBOX 'ENVELOPE(mine,minn,maxe,maxn)' – BBOX operation
An id which references a geometry field or a geometry literal can be used with these. The other operand in these is always the primary geometry field in the layer:
EQUALS EXPR1 – spatially equals
DISJOINT EXPR1 – spatially disjoint
INTERSECTS EXPR1 – spatially intersects
TOUCHES EXPR1 – spatially touches
CROSSES EXPR1 – spatially crosses
WITHIN EXPR1 – spatially within
CONTAINS EXPR1 – spatially contains
OVERLAPS EXPR1 – spatially overlaps
Distance operations
STRING DWITHIN range
STRING BEYOND range
These can be used to filter geometries where the distance of a given geometry and the primary geometry is within or beyond a certain range of meters.
One example of using dwithin as a request parameter: &query='Point(428888 7255555)' DWITHIN 100000
ID-operation
Checks if the id of the feature is in a certain collection of id values. This operation cannot be grouped with Boolean logic or other operations as is defined in the OGC filter language spec.
idin(ID1,ID2,ID3,…)
Expressions
Literals
Number – Numbers can be inputted as is. The system supports integers and decimals, scientific notation, and normal.
String – strings start and end with a single quote. “\” is the escape character.
Date - #DateString#. Date string format is in english format. UTC date-time strings can be also used.
Geometry – Geometries are strings which are encoded in WKT format.
Identifiers
Fields in the layer can be accessed by writing the field name.
If the data source is a WFS:
- Remember to include the local namespace of field names (xxx:yyy)
- Use “/” in field names to reference attributes below the feature root.
Extensions to Filter language
In operation
ID in (LITERAL1,LITERAL2,LITERAL3,…)
Comparable to IN operation in SQL. Degenerates to multiple equality checks if the data source does not support in clauses.
Is descendant of
EXPR1 isdescendantof LITERAL
SQL Server isDescendantOf operation. Can be used to make queries to hierarchical data. In other SQL datasources translates into clause “(EXPR1=LITERAL or EXPR1 like ‘LITERAL%’)”. Is not supported other data sources.