Skip to content

Layer data source ​

Workspace Key draft workspace layer xyz sql security

Keys that tell the XYZ API where a layer's data is, which ID and geometry to use and how queries are restricted; use for every data layer.

Resource and sources

These keys connect a layer to a table. The XYZ API reads them from the workspace layer and fills the matching query params with them.[1]

  • dbs names the connection, a DBS_* environment variable. Without it the layer uses the locale's, then the workspace's dbs.[2]
  • table is the schema-qualified table, eg. geodata.uk_glx_open_retail_points.
  • geom is the geometry column and srid its EPSG code, best as a string such as "4326". qID is the unique ID column; locations are requested by it.
  • params are sent with every layer data request: template replaces the format's default query template, viewport restricts queries to the map extent, z sends the current zoom, and default_fields adds columns to the features. layer_template names a workspace template which the XYZ API loads as the layer for queries, instead of the layer itself.[1:1] Other params are passed to the query template. params.fields is generated before every request from default_fields and the theme, label, hover, icon scaling and cluster label fields, so a configured value is overwritten.
  • queryparams are assigned to layer queries and location entry queries. The locale's queryparams are merged in; layer values win.[2:1]

Zoom ranges ​

tables replaces table with a table per integer zoom level, and geoms replaces geom with a geometry column per zoom level. Below the smallest or above the largest key, the value of that key applies. A null table hides the layer at those zoom levels and shows it again when a table applies.[3]

json
"tables": { "7": null, "8": "schema.table_low", "11": "schema.table_high", "14": null }

z_field, on MVT layers, names an integer column; a feature is only in a tile when its value is lower than the tile's zoom.[4]

Constraints ​

  • A request's table param must be a table named in the layer: any table value or tables entry anywhere in the layer, including location entries. Other tables are rejected with 403.[1:2]
  • Vector formats need srid and qID, and table, tables or inline features; without a table for the current zoom no data is requested.[5] MVT needs table or tables, and srid must be absent or the string "3857". See layer formats.
  • A viewport query fails with 400 without geom and srid, or when srid is not an integer or a string of digits.[1:3]

Examples ​

The retail points are hidden below zoom 6 and loaded from the same table from zoom 6.

json
{
  "dbs": "DEVDB",
  "locale": {
    "layers": {
      "retail_points": {
        "display": true,
        "format": "wkt",
        "tables": { "5": null, "6": "geodata.uk_glx_open_retail_points" },
        "geom": "geom_p_4326",
        "srid": "4326",
        "qID": "id",
        "params": { "default_fields": ["retailer"] }
      }
    }
  }
}

  1. query.js layerQuery and templateTables ↩︎ ↩︎ ↩︎ ↩︎

  2. getLayer.js ↩︎ ↩︎

  3. decorate.mjs tableCurrent, geomCurrent and changeEnd ↩︎

  4. templates/mvt.js ↩︎

  5. layer/format/vector.mjs reload ↩︎

XYZ v5.1.0. Generated from knowledge/ at dd7a6fa27736502733499c1bf485f15659b10338. Concepts marked draft are not reviewed.