From 9c08c5b4e260eb45da7d23e8e24b6d74617c02ba Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Tue, 3 Oct 2023 02:32:59 +0200 Subject: [PATCH] PMTiles: Added field `pmtiles:layer_properties` --- CHANGELOG.md | 2 +- README.md | 67 +++++++++++++++++++++++++++++++++++++---- json-schema/schema.json | 19 ++++++++++++ 3 files changed, 81 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0783675..09d9ce7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- PMTiles +- PMTiles: Added field `pmtiles:layer_properties` ### Changed diff --git a/README.md b/README.md index 4b018a1..71f9ff6 100644 --- a/README.md +++ b/README.md @@ -85,12 +85,13 @@ The `href` can contain an optional server placeholder `{s}`. If `{s}` is used, t Links to a [PMTiles](https://github.com/protomaps/PMTiles/blob/main/spec/v3/spec.md) file (versions 3.x). -| Field Name | Type | Description | -| --------------- | -------------------- | ----------- | -| rel | string | **REQUIRED**. Must be set to `pmtiles`. | -| href | string | **REQUIRED**. Link to a PMTiles file (usually ends with `.pmtiles`). | -| type | string | Recommended to be set to `application/vnd.pmtiles`. | -| pmtiles:layers | \[string] | For vector tiles, the layers to show on the map by default. If not provided, it's up to the discretion of the implementation to choose a layer from the `vector_layers` in the PMTiles metadata. | +| Field Name | Type | Description | +| ------------------------ | -------------------------------------------- | ----------- | +| rel | string | **REQUIRED**. Must be set to `pmtiles`. | +| href | string | **REQUIRED**. Link to a PMTiles file (usually ends with `.pmtiles`). | +| type | string | Recommended to be set to `application/vnd.pmtiles`. | +| pmtiles:layers | \[string] | For vector tiles, the layers to show on the map by default. If not provided, it's up to the discretion of the implementation to choose a layer from the `vector_layers` in the PMTiles metadata. | +| pmtiles:layer_properties | Map> | For vector tiles, the properties/fields available for each layer and their corresponding [JSON Schema](#json-schema-object) as an object. | The [Tile Type](https://github.com/protomaps/PMTiles/blob/main/spec/v3/spec.md#tile-type-tt) of the PMTiles data source can be read from the first 127 bytes of the the binary header. @@ -98,6 +99,60 @@ PMTiles data source can be read from the first 127 bytes of the the binary heade It is typical to assume a tile size of 256x256 pixels for raster tiles and 512x512 pixels for vector tiles, but they could also be inferred from the first file. +#### pmtiles:layer_properties + +Assuming the PMTiles file has a single layer `roads` with the following fields: +- `type` - a string with one of the following values: trunk, primary, secondary +- `lanes` - an integer with numbers between 1 and 10 +- `name` - a free-form text +- `sidewalks` - a boolean value + +The `pmtiles:layer_properties` value could be the following object: +```json +{ + "roads": { + "type": { + "title": "Road Type", + "type": "string", + "enum": [ + "trunk", + "primary", + "secondary" + ] + }, + "lanes": { + "title": "Number of Lanes", + "type": "integer", + "minimum": 1, + "maximum": 10 + }, + "name": { + "title": "Road Name", + "type": "string" + }, + "sidewalks": { + "title": "Has Sidewalks", + "type": "boolean" + } + } +} +``` + +The layer names (top-level keys) and property names (second level keys) must correcspond exactly to +the information provided in the `vector_layers` in the PMTiles metadata. + +##### JSON Schema Object + +Each schema must be valid against all corresponding values available for the property. +Empty schemas are discouraged. + +The following JSON Schema versions are supported: +- [draft-07](https://json-schema.org/specification-links#draft-7) (recommended to align with the JSON Schemas provided by STAC) +- [2019-09]()https://json-schema.org/specification-links#draft-2019-09-(formerly-known-as-draft-8) +- [2020-12](https://json-schema.org/specification-links#2020-12) + +For an introduction to JSON Schema, see "[Learn JSON Schema](https://json-schema.org/learn/)". + ### XYZ Links to a XYZ, also known as slippy map. diff --git a/json-schema/schema.json b/json-schema/schema.json index 12b7055..b2a8293 100644 --- a/json-schema/schema.json +++ b/json-schema/schema.json @@ -159,6 +159,25 @@ "type": "string", "minLength": 1 } + }, + "pmtiles:layer_properties": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "anyOf": [ + { + "$ref": "https://json-schema.org/draft-07/schema" + }, + { + "$ref": "https://json-schema.org/draft/2019-09/schema" + }, + { + "$ref": "https://json-schema.org/draft/2020-12/schema" + } + ] + } + } } } }