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

docs: research on empty tile responses across map clients #2831

Merged
merged 24 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
93 changes: 93 additions & 0 deletions docs/api/empty-tiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Sparse Datasets and empty tiles

## TLDR

Basemaps should serve Transparent images for areas that do not have any data for maximum compatibility for clients, once clients upgrade and fix bugs either `204 No Content` or `200 Ok` with a 0 byte payload are both appropriate.
blacha marked this conversation as resolved.
Show resolved Hide resolved

Further investigation should also be done on `OATiles-hint: empty` and converting more clients to TileJSON which can specify a bounding box to restrict a client requests to.
blacha marked this conversation as resolved.
Show resolved Hide resolved

# Background

LINZ has imagery datasets that are very sparse with large gaps between the sections of valid data, for example Gisborne Urban 2022-2023
blacha marked this conversation as resolved.
Show resolved Hide resolved

[![Gisborne 2023](./static/2023-06-26-gisborne-2023.png)](https://basemaps.linz.govt.nz/?i=gisborne-2022-2023-0.1m)

Even when providing a bounding box for the imagery there are a huge amount of empty areas.
blacha marked this conversation as resolved.
Show resolved Hide resolved

# Question

What is the best way to tell clients that the area they are requesting has no data.
blacha marked this conversation as resolved.
Show resolved Hide resolved

# Response Options

The server can use different responses to clients to signal that there is no data, the following section is specifically for imagery responses PNG, Jpeg and WebP.
blacha marked this conversation as resolved.
Show resolved Hide resolved

For Mapbox vector tiles a 0 byte response either `204 No Content` or `200 Ok` both works as a 0 byte vector tile is a valid vector tile.
blacha marked this conversation as resolved.
Show resolved Hide resolved

## 200 Transparent Image

Serve a valid image in the request format for example if a client requests a png serve a fully transparent PNG back to the user
blacha marked this conversation as resolved.
Show resolved Hide resolved

Pros:

- ✔️ Supported Everywhere
blacha marked this conversation as resolved.
Show resolved Hide resolved

Cons:

- ❌ Jpeg does not support transparency so users get a black image
blacha marked this conversation as resolved.
Show resolved Hide resolved
- ❌ Much larger responses 1KB vs 0 byte payload
blacha marked this conversation as resolved.
Show resolved Hide resolved
- ❌ Difficult to know in logs if the tile request was for a valid region

## 200 - 0 Byte

Serve HTTP 200 Ok, With a `content-length: 0` which is a 0 byte response.
blacha marked this conversation as resolved.
Show resolved Hide resolved

Pros:

- ✔️ Supported in GIS ArcGIS/QGIS
blacha marked this conversation as resolved.
Show resolved Hide resolved
- ✔️ Supported by ArcGIS Online, Leaflet, OpenLayers
blacha marked this conversation as resolved.
Show resolved Hide resolved
- ✔️ Supported by HTTP RFC "May return 0 byte 200"
blacha marked this conversation as resolved.
Show resolved Hide resolved
- ✔️ Recommended option from OGC Tile API

Cons:

- ❌ Not supported by maplibre/mapbox
- ❌ HTTP RFC suggests that while valid servers "ought to return 204 No content"
blacha marked this conversation as resolved.
Show resolved Hide resolved

## 204 No Content

return HTTP 204 No Content with no body
blacha marked this conversation as resolved.
Show resolved Hide resolved

Pros:

- ✔️ Supported in GIS ArcGIS/QGIS
blacha marked this conversation as resolved.
Show resolved Hide resolved
- ✔️ Supported by LeafLet, OpenLayers
blacha marked this conversation as resolved.
Show resolved Hide resolved
- ✔️ Supported by HTTP RFC "ought to return 204"
blacha marked this conversation as resolved.
Show resolved Hide resolved
- ✔️ Recommended option from OGC Tile API

Cons:

- ❌ Not supported by ArcGIS Online
- ❌ Not supported by maplibre
- https://github.com/maplibre/maplibre-gl-js/pull/2325
- https://github.com/maplibre/maplibre-gl-js/pull/1586
- ❌ Not supported by mapbox gl
- https://github.com/mapbox/mapbox-gl-js/issues/9304

blacha marked this conversation as resolved.
Show resolved Hide resolved
204 No content not always cached by browser
blacha marked this conversation as resolved.
Show resolved Hide resolved

## 404 Tile Not found

Return a error state saying the tile is not found

- ❌ Is a error state
blacha marked this conversation as resolved.
Show resolved Hide resolved
- ❌ Not always Cached, Browsers/CDN often ignore caching 404
blacha marked this conversation as resolved.
Show resolved Hide resolved

# References

- https://github.com/opengeospatial/ogcapi-tiles/issues/63 - `OATiles-hint: empty` `OATiles-hint: full`
- https://github.com/opengeospatial/ogcapi-tiles/issues/21

Simple proxy that converts `204 No Content` into different results.

- https://github.com/blacha/tile-status-code
Binary file added docs/api/static/2023-06-26-gisborne-2023.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.