Closed simonw closed 3 years ago
It's going to have an interface at /-/tiles
which shows the list of available tile databases, and /-/tiles/db-name
will present a Leaflet map previewing those tiles. It will depend on datasette-leaflet
for that.
It will consult the _internal
database https://docs.datasette.io/en/stable/internals.html#the-internal-database to determine if a database is a valid MBTiles package, by looking for the following tables (or views):
CREATE TABLE tiles (zoom_level integer, tile_column integer, tile_row integer, tile_data blob);
CREATE TABLE metadata (name text, value text);
See https://github.com/mapbox/mbtiles-spec/blob/master/1.3/spec.md
For simplicity I'll just look for the tiles
database table:
select
columns.database_name,
columns.table_name,
group_concat(columns.name) as columns
from
columns
where
columns.table_name = "tiles"
group by
columns.database_name,
columns.table_name
order by
columns.table_name
Outputs:
database_name | table_name | columns |
---|---|---|
San_Francisco | tiles | tile_column,tile_data,tile_row,zoom_level |
basemap | tiles | tile_column,tile_data,tile_row,zoom_level |
This plugin will work by scanning all other attached databases to see if they are a valid MBTiles package. It will then make those tiles available at
/-/tiles/db-name/z/x/y.png