diff --git a/3.0.0/README.md b/3.0.0/README.md index 7c51d4a..d2aa56f 100644 --- a/3.0.0/README.md +++ b/3.0.0/README.md @@ -7,24 +7,25 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S 1. [Purpose](#1-purpose) 1. [File format](#2-file-format) 1. [Structure](#3-structure) - 1. [attribution](#31-attribution) - 1. [bounds](#32-bounds) - 1. [center](#33-center) - 1. [data](#34-data) - 1. [description](#35-description) - 1. [fillzoom](#36-fillzoom) - 1. [grids](#36-grids) - 1. [legend](#37-legend) - 1. [maxzoom](#38-maxzoom) - 1. [minzoom](#39-minzoom) - 1. [name](#310-name) - 1. [scheme](#311-scheme) - 1. [template](#312-template) - 1. [tilejson](#313-tilejson) - 1. [tiles](#314-tiles) - 1. [vector_layers](#315-vector_layers) - 1. [version](#316-version) + 1. [tilejson](#31-tilejson) + 1. [tiles](#32-tiles) + 1. [vector_layers](#33-vector_layers) + 1. [attribution](#34-attribution) + 1. [bounds](#35-bounds) + 1. [center](#36-center) + 1. [data](#37-data) + 1. [description](#38-description) + 1. [fillzoom](#39-fillzoom) + 1. [grids](#310-grids) + 1. [legend](#311-legend) + 1. [maxzoom](#312-maxzoom) + 1. [minzoom](#313-minzoom) + 1. [name](#314-name) + 1. [scheme](#315-scheme) + 1. [template](#316-template) + 1. [version](#317-version) 1. [Examples](#4-examples) +1. [Caching](#5-caching) # 1. Purpose @@ -36,13 +37,108 @@ TileJSON manifest files use the JSON format as described in [RFC 8259](https://t # 3. Structure -Implementations MUST treat unknown keys as if they weren't present. However, implementations MUST expose unknown key/values so users can optionally handle these keys. Implementations MUST treat invalid values for keys as if they weren’t present. If the the field is an optional field and the value is invalid, the default value MAY be applied. If the key is required, implementations MUST treat the entire TileJSON manifest file as invalid and refuse operation. +The following describes the structure of a TileJSON object. Implementations MUST treat unknown keys as if they weren't present. However, implementations MUST expose unknown key value pairs so users can optionally handle these keys. Implementations MUST treat invalid values for keys as if they weren’t present. If the the key is optional and the value is invalid, the default value MAY be applied. If the key is required, implementations MUST treat the entire TileJSON manifest file as invalid and refuse operation. -## 3.1 `attribution` +*The word "implementation" in the following sections refers to services or tools that serve, generate, or validate TileJSON objects.* + +## 3.1 `tilejson` + +REQUIRED. + +A semver.org style version number as a string. Describes the version of the TileJSON spec that is implemented by this JSON object. + +```JSON +{ + "tilejson": "3.0.0" +} +``` + +## 3.2 `tiles` + +REQUIRED. + +An array of tile endpoints. {z}, {x} and {y}, if present, are replaced with the corresponding integers. If multiple endpoints are specified, clients may use any combination of endpoints. All endpoint urls MUST be absolute. All endpoints MUST return the same content for the same URL. The array MUST contain at least one endpoint. The tile extension is NOT limited to any particular format. Some of the more popular are: mvt, vector.pbf, png, webp, and jpg. + +```JSON +{ + "tiles": [ + "http://localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.mvt" + ] +} +``` + +## 3.3 `vector_layers` + +REQUIRED. + +A JSON object whose value is an array of JSON objects. Each of those JSON objects describes one layer of vector tile data. A `vector_layer` object MUST contain the `id` and `fields` keys, and MAY contain the `description`, `minzoom`, or `maxzoom` keys. + +#### 3.3.1 `id` + +REQUIRED. + +A string value representing the the layer id. For added context, this is referred to as the `name` of the layer in the [Mapbox Vector Tile spec](https://github.com/mapbox/vector-tile-spec/tree/master/2.1#41-layers). + +#### 3.3.2 `fields` + +REQUIRED. + +A JSON object whose keys and values are the names and descriptions of attributes available in this layer. Each value (description) MUST be a string that describes the underlying data. If no fields are present, the `fields` key MUST be an empty object. + +#### 3.3.3 `description` + +OPTIONAL. + +A string representing a human-readable description of the entire layer's contents. + +#### 3.3.4 `minzoom` and `maxzoom` + +OPTIONAL. + +A number representing the lowest/highest zoom level whose tiles this layer appears in. `minzoom` MUST be greater than or equal to the set of tiles' `minzoom`. `maxzoom` MUST be less than or equal to the set of tiles' `maxzoom`. + +These keys are used to describe the situation where different sets of vector layers appear in different zoom levels of the same set of tiles, for example in a case where a "minor roads" layer is only present at high zoom levels. + +```JSON +{ + "vector_layers": [ + { + "id": "roads", + "description": "Roads and their attributes", + "minzoom": 2, + "maxzoom": 16, + "fields": { + "type": "One of: trunk, primary, secondary", + "lanes": "Number", + "name": "String", + "sidewalks": "Boolean" + } + }, + { + "id": "countries", + "description": "Admin 0 (country) boundaries", + "minzoom": 0, + "maxzoom": 16, + "fields": { + "iso": "ISO 3166-1 Alpha-2 code", + "name": "English name of the country", + "name_ar": "Arabic name of the country" + } + }, + { + "id": "buildings", + "description": "A layer with an empty fields object", + "fields": {} + } + ] +} +``` + +## 3.4 `attribution` OPTIONAL. Default: null. -Contains an attribution to be displayed when the map is shown to a user. Implementations MAY decide to treat this as HTML or literal text. For security reasons, make absolutely sure that this field can't be abused as a vector for XSS or beacon tracking. +Contains an attribution to be displayed when the map is shown to a user. Implementations MAY decide to treat this as HTML or literal text. For security reasons, make absolutely sure that this content can't be abused as a vector for XSS or beacon tracking. ```JSON { @@ -50,7 +146,7 @@ Contains an attribution to be displayed when the map is shown to a user. Impleme } ``` -## 3.2 `bounds` +## 3.5 `bounds` OPTIONAL. Default: [ -180, -85.05112877980659, 180, 85.0511287798066 ] (xyz-compliant tile bounds) @@ -62,7 +158,15 @@ The maximum extent of available map tiles. Bounds MUST define an area covered by } ``` -## 3.3 `center` +Bounds where longitude east & west, and latitude east & west are the same are considered valid. This case typically represents a single point geometry in the entire tileset. For example: + +```JSON +{ + "bounds": [-122.34, 47.65, -122.34, 47.65] +} +``` + +## 3.6 `center` OPTIONAL. Default: null. @@ -74,7 +178,7 @@ The first value is the longitude, the second is latitude (both in WGS:84 values) } ``` -## 3.4 `data` +## 3.7 `data` OPTIONAL. Default: []. @@ -88,11 +192,11 @@ An array of data files in GeoJSON format. {z}, {x} and {y}, if present, are repl } ``` -## 3.5 `description` +## 3.8 `description` OPTIONAL. Default: null. -A text description of the tileset. The description can contain any valid unicode character as described by the JSON specification [RFC 8259](https://tools.ietf.org/html/rfc8259). +A text description of the set of tiles. The description can contain any valid unicode character as described by the JSON specification [RFC 8259](https://tools.ietf.org/html/rfc8259). ```JSON { @@ -100,25 +204,27 @@ A text description of the tileset. The description can contain any valid unicode } ``` -## 3.6 `fillzoom` +## 3.9 `fillzoom` OPTIONAL. Default: null. -An integer specifying the zoom level at which to generate overzoomed tiles from. Implementations may generate overzoomed tiles from parent tiles if the requested zoom level does not exist. In most cases, overzoomed tiles are generated from the maximum zoom level of the tileset. If fillzoom is specified, the overzoomed tile is generated from the fillzoom level. +An integer specifying the zoom level at which to generate overzoomed tiles from. Implementations may generate overzoomed tiles from parent tiles if the requested zoom level does not exist. In most cases, overzoomed tiles are generated from the maximum zoom level of the set of tiles. If fillzoom is specified, the overzoomed tile is generated from the fillzoom level. -For example, in a tileset with maxzoom 10 and _no_ fillzoom specified, if a request for a z11 tile comes through, the implementation will use the maximum z10 parent tiles to generate the new, overzoomed z11 tile. If the same tilejson had fillzoom specified at z7, a request for a z11 tile would use the z7 tile instead of z10. +For example, in a set of tiles with maxzoom 10 and _no_ fillzoom specified, if a request for a z11 tile comes through, the implementation will use the maximum z10 parent tiles to generate the new, overzoomed z11 tile. If the same TileJSON object had fillzoom specified at z7, a request for a z11 tile would use the z7 tile instead of z10. ```JSON { - "fillzoom": "8" + "fillzoom": 7 } ``` -## 3.6 `grids` +## 3.10 `grids` OPTIONAL. Default: []. -An array of interactivity endpoints. {z}, {x} and {y}, if present, are replaced with the corresponding integers. If multiple endpoints are specified, clients may use any combination of endpoints. All endpoints MUST return the same content for the same URL. If the array doesn't contain any entries, UTF-Grid interactivity is not supported for this tileset. See https://github.com/mapbox/utfgrid-spec/tree/master/1.2 for the interactivity specification. +An array of interactivity endpoints. {z}, {x} and {y}, if present, are replaced with the corresponding integers. If multiple endpoints are specified, clients may use any combination of endpoints. All endpoints MUST return the same content for the same URL. If the array doesn't contain any entries, UTF-Grid interactivity is not supported for this set of tiles. See https://github.com/mapbox/utfgrid-spec/tree/master/1.2 for the interactivity specification. + +*Note: UTF-Grid interactivity predates GL-based map rendering and interaction. Map interactivity is now generally defined outside of the TileJSON specification and is dependent on the tile rendering library's features.* ```JSON { @@ -128,7 +234,7 @@ An array of interactivity endpoints. {z}, {x} and {y}, if present, are replaced } ``` -## 3.7 `legend` +## 3.11 `legend` OPTIONAL. Default: null. @@ -140,7 +246,7 @@ Contains a legend to be displayed with the map. Implementations MAY decide to tr } ``` -## 3.8 `maxzoom` +## 3.12 `maxzoom` OPTIONAL. Default: 30. >= 0, <= 30. @@ -148,11 +254,11 @@ An integer specifying the maximum zoom level. MUST be >= minzoom. ```JSON { - "maxzoom": "11" + "maxzoom": 11 } ``` -## 3.9 `minzoom` +## 3.13 `minzoom` OPTIONAL. Default: 0. >= 0, <= 30. @@ -160,15 +266,15 @@ An integer specifying the minimum zoom level. MUST be <= maxzoom ```JSON { - "minzoom": "0" + "minzoom": 0 } ``` -## 3.10 `name` +## 3.14 `name` OPTIONAL. Default: null. -A name describing the tileset. The name can contain any legal character. Implementations SHOULD NOT interpret the name as HTML. +A name describing the set of tiles. The name can contain any legal character. Implementations SHOULD NOT interpret the name as HTML. ```JSON { @@ -176,7 +282,7 @@ A name describing the tileset. The name can contain any legal character. Impleme } ``` -## 3.11 `scheme` +## 3.15 `scheme` OPTIONAL. Default: "xyz". @@ -188,7 +294,7 @@ Either "xyz" or "tms". Influences the y direction of the tile coordinates. The g } ``` -## 3.12 `template` +## 3.16 `template` OPTIONAL. Default: null. @@ -200,101 +306,7 @@ Contains a mustache template to be used to format data from grids for interactio } ``` -## 3.13 `tilejson` - -REQUIRED. - -A semver.org style version number as a string. Describes the version of the TileJSON spec that is implemented by this JSON object. - -```JSON -{ - "tilejson": "3.0.0" -} -``` - -## 3.14 `tiles` - -REQUIRED. - -An array of tile endpoints. {z}, {x} and {y}, if present, are replaced with the corresponding integers. If multiple endpoints are specified, clients may use any combination of endpoints. All endpoints MUST return the same content for the same URL. The array MUST contain at least one endpoint. The tile extension is NOT limited to any particular format. Some of the more popular are: mvt, vector.pbf, png, webp, and jpg. - -```JSON -{ - "tiles": [ - "http://localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.mvt" - ] -} -``` - -## 3.15 `vector_layers` - -REQUIRED. - -A JSON object whose value is an array of JSON objects. Each of those JSON objects describes one layer of vector tile data. A `vector_layer` object MUST contain the `id` and `fields` keys, and MAY contain the `description`, `minzoom`, or `maxzoom` keys. - -#### 3.15.1 `id` - -REQUIRED. - -A string value representing the the layer id. For added context, this is referred to as the `name` of the layer in the [Mapbox Vector Tile spec](https://github.com/mapbox/vector-tile-spec/tree/master/2.1#41-layers). - -#### 3.15.2 `fields` - -REQUIRED. - -A JSON object whose keys and values are the names and descriptions of attributes available in this layer. Each value (description) MUST be a string that describes the underlying data. If no fields are present the `fields` key MUST be an empty object. - -#### 3.15.3 `description` - -OPTIONAL. - -A string representing a human-readable description of the entire layer's contents. - -#### 3.15.4 `minzoom` and `maxzoom` - -OPTIONAL. - -A number representing the lowest/highest zoom level whose tiles this layer appears in. `minzoom` MUST be greater than or equal to the tileset's `minzoom`. `maxzoom` MUST be less than or equal to the tileset's `maxzoom`. - -These keys are used to describe the situation where different sets of vector layers appear in different zoom levels of the same tileset, for example in a case where a "minor roads" layer is only present at high zoom levels. - -```JSON -{ - "vector_layers": [ - { - "id": "roads", - "description": "Roads and their attributes", - "minzoom": 2, - "maxzoom": 16, - "fields": { - "type": "One of: trunk, primary, secondary", - "lanes": "Number", - "name": "String", - "sidewalks": "Boolean" - } - }, - { - "id": "countries", - "description": "Admin 0 (country) boundaries", - "minzoom": 0, - "maxzoom": 16, - "fields": { - "iso": "ISO 3166-1 Alpha-2 code", - "name": "English name of the country", - "name_ar": "Arabic name of the country" - } - }, - { - "id": "buildings", - "description": "A layer with an empty fields object", - "fields": {} - } - ] -} -``` - - -## 3.16 `version` +## 3.17 `version` OPTIONAL. Default: "1.0.0". @@ -308,4 +320,8 @@ A [semver.org](https://semver.org) style version number of the tiles. When chang # 4. Examples -Examples can be found in the example/ directory. +Examples can be found in the [examples directory](/example). + +# 5. Caching + +Clients MAY cache files retrieved from a remote server. When implementations decide to perform caching, they MUST honor valid cache control HTTP headers as defined in the HTTP specification for both tile images and the TileJSON manifest file. diff --git a/3.0.0/example/osm.json b/3.0.0/example/osm.json new file mode 100644 index 0000000..477ce39 --- /dev/null +++ b/3.0.0/example/osm.json @@ -0,0 +1,42 @@ +{ + "tilejson": "3.0.0", + "name": "OpenStreetMap", + "description": "A free editable map of the whole world.", + "version": "1.0.0", + "attribution": "(c) OpenStreetMap contributors, CC-BY-SA", + "scheme": "xyz", + "tiles": [ + "https://a.tile.custom-osm-tiles.org/{z}/{x}/{y}.mvt", + "https://b.tile.custom-osm-tiles.org/{z}/{x}/{y}.mvt", + "https://c.tile.custom-osm-tiles.org/{z}/{x}/{y}.mvt" + ], + "minzoom": 0, + "maxzoom": 18, + "bounds": [ -180, -85, 180, 85 ], + "fillzoom": 6, + "something_custom": "this is my unique field", + "vector_layers": [ + { + "id": "telephone", + "fields": { + "phone_number": "the phone number", + "payment": "how to pay" + } + }, + { + "id": "bicycle_parking", + "fields": { + "type": "the type of bike parking", + "year_installed": "the year the bike parking was installed" + } + }, + { + "id": "showers", + "fields": { + "water_temperature": "the maximum water temperature", + "wear_sandles": "whether you should wear sandles or not", + "wheelchair": "is the shower wheelchair friendly?" + } + } + ] +} diff --git a/3.0.0/schema.json b/3.0.0/schema.json index 1c12cf9..507a77c 100644 --- a/3.0.0/schema.json +++ b/3.0.0/schema.json @@ -1 +1,105 @@ -schema +{ + "name": "TileJSON", + "type": "object", + "properties": { + "tilejson": { + "type": "string", + "pattern": "\\d+\\.\\d+\\.\\d+\\w?[\\w\\d]*" + }, + "tiles": { + "type": "array", + "items": { + "type": "string" + } + }, + "vector_layers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "fields": { + "type": "object", + "additionalProperties": { "type": "string" } + }, + "description": { + "type": "string" + }, + "maxzoom": { + "type": "integer" + }, + "minzoom": { + "type": "integer" + } + }, + "required": [ "id", "fields" ], + "additionalProperties": true + } + }, + "attribution": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "number" + } + }, + "center": { + "type": "array", + "items": { + "type": "number" + } + }, + "data": { + "type": "array", + "items": { + "type": "string" + } + }, + "description": { + "type": "string" + }, + "fillzoom": { + "minimum": 0, + "maximum": 30, + "type": "integer" + }, + "grids": { + "type": "array", + "items": { + "type": "string" + } + }, + "legend": { + "type": "string" + }, + "maxzoom": { + "minimum": 0, + "maximum": 30, + "type": "integer" + }, + "minzoom": { + "minimum": 0, + "maximum": 30, + "type": "integer" + }, + "name": { + "type": "string" + }, + "scheme": { + "type": "string" + }, + "template": { + "type": "string" + }, + "version": { + "type": "string", + "pattern": "\\d+\\.\\d+\\.\\d+\\w?[\\w\\d]*" + } + }, + "required": ["tilejson", "tiles", "vector_layers"], + "additionalProperties": true +}