Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMTiles: Added field pmtiles:layer_properties #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
66 changes: 60 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,73 @@ 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\<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. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be exhaustive of all layer properties existing in the tileset (like in TileJSON), or only the properties/fields we want to visualize (like in the pmtiles:layers)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I guess the second...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that seems much more feasible than the former, though TileJSON vector_layers does not provide information about the possible enum values etc so the JSON Schema objects need to be constructed with outside knowledge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed. If we would have enough information in vector_layers, we would not need this construct at all.


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.

It is typical to assume a tile size of 256x256 pixels for raster tiles and 512x512 pixels for vector tiles,
m-mohr marked this conversation as resolved.
Show resolved Hide resolved
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 correspond 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.

JSON Schema draft-07 is the only officially supported JSON Schema version to align with the JSON Schemas provided by STAC.
Validation uses the JSON Schema meta-schema for draft-07.
It is allowed to use you use other versions of JSON Schema, but they may not get validated properly.

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.
Expand Down
29 changes: 28 additions & 1 deletion examples/item.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,34 @@
"type": "application/vnd.pmtiles",
"pmtiles:layers": [
"streets"
]
],
"pmtiles:layer_properties": {
"streets": {
"type": {
"title": "Street Type",
"type": "string",
"enum": [
"trunk",
"primary",
"secondary"
]
},
"lanes": {
"title": "Number of Lanes",
"type": "integer",
"minimum": 1,
"maximum": 10
},
"name": {
"title": "Street Name",
"type": "string"
},
"sidewalks": {
"title": "Has Sidewalks",
"type": "boolean"
}
}
}
}
],
"assets": {}
Expand Down
9 changes: 9 additions & 0 deletions json-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@
"type": "string",
"minLength": 1
}
},
"pmtiles:layer_properties": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"$ref": "http://json-schema.org/draft-07/schema"
}
}
}
}
}
Expand Down