Query languages

It is possible to perform custom queries on the database using either the advanced query language or classical SQL.

SQL

The database use Postgis as a RDMBS and the labels are within a JSONB columns. Therefore, SQL queries use the classical postgres syntax and any operators from postgis and jsonb are available.

Please refer to data model page for informations about the database schema.

Advanced Query Language

Query

A query is a set of filters.

A set of filters must contains at least one geo filter and optionally additional filters.

All filters are not case sensitive.

1{
2    geo filter
3    filters
4}

Geo filters

Within

Filter all Zone elements within a bounding box. This includes all elements intersecting with the bounding box.

1WITHIN(north, west, south, east)

Contains

Get all Zone elements containing the given point.

1CONTAINS(lon, lat)

Radius

Get all Zone elements within a given radius of a point. This includes all elements intersecting with the bounding box. Slow query, prefer using WITHIN instead.

1RADIUS(lon, lat, radius)

Filters

Source

Filter all elements from the given source (by source unique key).

1SOURCE("key")

Label exact

Get all elements with the label exact value (any type).

1LABEL_EX("key", "value")

Label approx

Get all elements with the approximate value (SQL LIKE).

1LABEL_APP(key, value)

Label inferior

Get all elements with a value (nunber) below the searched value. Ignore elements without the key or if the key is not a number.

1LABEL_INF(key, value)

Label superior

Get all elements with a value (number) above the searched value. Ignore elements without the key or if the key is not a number.

1LABEL_SUP(key, value)

Label OR

Get the elements matching one filter or (logical) another. A filter could be any query filter except WITHIN

1filter1 OR filter2

Label AND

Get the elements matching one filter and the other. A filter could be any query filter except WITHIN

1filter1 AND filter2

Query examples

Get the “cadastre” of a GPS point

To be executed within this context.

1{
2    CONTAINS(-1.6381376981735232, 48.11645349249121)
3    SOURCE("cadastre_parcelles")
4}

Get the publicly owned historical monument.

To be executed within this context.

1{
2        WITHIN(-1.64395809173584, 48.10112645522384, -1.705756187438965, 48.12493709601254)
3        SOURCE("monuments_historiques_monuments")
4        LABEL_EX("statut_juridique_de_l_edifice", "propriété de la commune")
5}