Skip to content

Latest commit

 

History

History
142 lines (130 loc) · 5.76 KB

data-source.md

File metadata and controls

142 lines (130 loc) · 5.76 KB
type Workspace Key
title Layer data source
description 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 ../../../apps/xyz/mod/query.js
tags
workspace
layer
xyz
sql
security
status draft
x-xyz-keys
key type
layer.dbs
string
key type required
layer.table
string
when or
layer.format
wkt
geojson
cluster
vector
layer.tables
layer.features
key type required description
layer.tables
object
when or
layer.format
mvt
layer.table
Tables by integer zoom level; null hides the layer at those levels.
key type
layer.tables.*
string
key type
layer.geom
string
key type
layer.geoms
object
key type
layer.geoms.*
string
key type pattern minimum required description
layer.srid
string
integer
^[0-9]+$
1
when
layer.format
wkt
geojson
cluster
vector
EPSG code of the geometry column. Write it as a string; mvt only accepts "3857" or no srid.
key type required description
layer.qID
string
when
layer.format
wkt
geojson
cluster
vector
Unique ID column of the layer table.
key type default open description
layer.params
object
true
Request params of every layer data query; custom query templates may read further params.
key type
layer.params.template
string
key type
layer.params.viewport
boolean
key type formats description
layer.params.z
boolean
wkt
geojson
cluster
vector
Sends the current map zoom as the z param.
key type formats
layer.params.default_fields
array
wkt
geojson
cluster
vector
mvt
key type description
layer.params.layer_template
string
Workspace template key which the XYZ API uses as the layer for this layer's queries.
key type
layer.queryparams
object
key type formats
layer.z_field
string
mvt
sources
id resource x-xyz-revision
wiki
3fc379b7ada42dff57f19e9f28694868e5a17cac
id resource
query
../../../apps/xyz/mod/query.js
id resource
getlayer
../../../apps/xyz/mod/workspace/getLayer.js
id resource
decorate
../../../apps/mapp/lib/layer/decorate.mjs
id resource
mvt
../../../apps/xyz/mod/workspace/templates/mvt.js
id resource
vector
../../../apps/mapp/lib/layer/format/vector.mjs
resource
../../../apps/mapp/lib/layer/format/mvt.mjs
resource
../../../apps/xyz/tests/mod/query.test.mjs

Layer data source

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 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

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

"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
  • 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

Examples

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

{
  "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"] }
      }
    }
  }
}

Footnotes

  1. query.js layerQuery and templateTables ↩ ↩2 ↩3 ↩4

  2. getLayer.js ↩ ↩2

  3. decorate.mjs tableCurrent, geomCurrent and changeEnd ↩

  4. templates/mvt.js ↩

  5. layer/format/vector.mjs reload ↩