Skip to content

Commit 236d684

Browse files
committed
PMTiles: Added field pmtiles:layer_properties
1 parent 8fe7482 commit 236d684

File tree

3 files changed

+70
-7
lines changed

3 files changed

+70
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Added
1010

11-
- PMTiles
11+
- PMTiles: Added field `pmtiles:layer_properties`
1212

1313
### Changed
1414

README.md

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,73 @@ The `href` can contain an optional server placeholder `{s}`. If `{s}` is used, t
8585

8686
Links to a [PMTiles](https://github.com/protomaps/PMTiles/blob/main/spec/v3/spec.md) file (versions 3.x).
8787

88-
| Field Name | Type | Description |
89-
| --------------- | -------------------- | ----------- |
90-
| rel | string | **REQUIRED**. Must be set to `pmtiles`. |
91-
| href | string | **REQUIRED**. Link to a PMTiles file (usually ends with `.pmtiles`). |
92-
| type | string | Recommended to be set to `application/vnd.pmtiles`. |
93-
| 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. |
88+
| Field Name | Type | Description |
89+
| ------------------------ | -------------------------------------------- | ----------- |
90+
| rel | string | **REQUIRED**. Must be set to `pmtiles`. |
91+
| href | string | **REQUIRED**. Link to a PMTiles file (usually ends with `.pmtiles`). |
92+
| type | string | Recommended to be set to `application/vnd.pmtiles`. |
93+
| 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. |
94+
| pmtiles:layer_properties | Map<string, Map<string, JSON Schema Object>> | For vector tiles, the properties/fields available for each layer and their corresponding [JSON Schema](#json-schema-object) as an object. |
9495

9596
The [Tile Type](https://github.com/protomaps/PMTiles/blob/main/spec/v3/spec.md#tile-type-tt) of the
9697
PMTiles data source can be read from the first 127 bytes of the the binary header.
9798

9899
It is typical to assume a tile size of 256x256 pixels for raster tiles and 512x512 pixels for vector tiles,
99100
but they could also be inferred from the first file.
100101

102+
#### pmtiles:layer_properties
103+
104+
Assuming the PMTiles file has a single layer `roads` with the following fields:
105+
- `type` - a string with one of the following values: trunk, primary, secondary
106+
- `lanes` - an integer with numbers between 1 and 10
107+
- `name` - a free-form text
108+
- `sidewalks` - a boolean value
109+
110+
The `pmtiles:layer_properties` value could be the following object:
111+
```json
112+
{
113+
"roads": {
114+
"type": {
115+
"title": "Road Type",
116+
"type": "string",
117+
"enum": [
118+
"trunk",
119+
"primary",
120+
"secondary"
121+
]
122+
},
123+
"lanes": {
124+
"title": "Number of Lanes",
125+
"type": "integer",
126+
"minimum": 1,
127+
"maximum": 10
128+
},
129+
"name": {
130+
"title": "Road Name",
131+
"type": "string"
132+
},
133+
"sidewalks": {
134+
"title": "Has Sidewalks",
135+
"type": "boolean"
136+
}
137+
}
138+
}
139+
```
140+
141+
The layer names (top-level keys) and property names (second level keys) must correcspond exactly to
142+
the information provided in the `vector_layers` in the PMTiles metadata.
143+
144+
##### JSON Schema Object
145+
146+
Each schema must be valid against all corresponding values available for the property.
147+
Empty schemas are discouraged.
148+
149+
JSON Schema draft-07 is the only officially supported JSON Schema version to align with the JSON Schemas provided by STAC.
150+
Validation uses the JSON Schema meta-schema for draft-07.
151+
It is allowed to use you use other versions of JSON Schema, but they may not get validated properly.
152+
153+
For an introduction to JSON Schema, see "[Learn JSON Schema](https://json-schema.org/learn/)".
154+
101155
### XYZ
102156

103157
Links to a XYZ, also known as slippy map.

json-schema/schema.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@
159159
"type": "string",
160160
"minLength": 1
161161
}
162+
},
163+
"pmtiles:layer_properties": {
164+
"type": "object",
165+
"additionalProperties": {
166+
"type": "object",
167+
"additionalProperties": {
168+
"$ref": "http://json-schema.org/draft-07/schema"
169+
}
170+
}
162171
}
163172
}
164173
}

0 commit comments

Comments
 (0)