tinySQL

# Bavaria demo — real OpenStreetMap tiles, every one a SQL row

WASM · runs entirely in this tab
0 tiles loaded via SQL — pan or zoom for more

## How this map is served

Same idea as the generative-art tiles demo, with real data: tinySQL, compiled to WebAssembly, holds one `tiles` table and every vector tile MapLibre GL requests is the result of one query, run in this tab through a custom `tinysql://` protocol:

SELECT tile_data FROM tiles WHERE zoom_level = z AND tile_column = x AND tile_row = TILE_FLIP_Y(y, z)

Nothing is preloaded: the snapshot below is just a `tiles` table sitting in memory, and every one of its rows is only turned into a rendered tile the moment MapLibre actually asks for it. Because that query runs in-process, it resolves in well under a millisecond — too fast to notice on its own — so watch for the flash: every tile just fetched briefly lights up teal (found and drawn) or red (queried, nothing there) right on the map, then fades. Pan or zoom to a fresh area and you'll see it light up tile by tile, one `SELECT` per square; pan back to somewhere already decoded and nothing flashes, because no new query ran — that's MapLibre's own client-side tile cache, not tinySQL's.

The tileset itself is Landkreis Dingolfing-Landau, extracted monthly from Geofabrik's `niederbayern-latest.osm.pbf` by a GitHub Actions job (osmium-tool clips the region, tippecanoe builds the vector tiles), then imported through tinySQL's real `ImportMBTiles` — see build-bavaria-tiles.sh and cmd/mbtilesregion.

Tileset release Open full SQL playground

## Explore a point

Click anywhere on the map. This runs `TILE_ZXY`, `TILE_QUADKEY`, `TILE_BBOX` and `TILE_PARENT` for that point at the current zoom, checks whether a tile is actually stored there, and outlines it in teal. It also lists the real OSM tags of whatever feature sits under the pixel you clicked.

click the map…
no feature inspected yet…

## Layers

Every layer below is filtered live from the same `osm` vector tiles by one OSM tag (`["has","building"]`, etc.) — toggle them to see the tileset feature by feature.

Landuse & land cover Water Waterways Roads (by class) & paths Buildings Place labels

## Choropleth: population density

A real, live SQL query — `GEO_BUFFER`, `GEO_POLYGON_AREA`, and a window-function classifier — run against a small `towns` table (real population figures, from each municipality's German Wikipedia infobox), not client-side JavaScript math. Each town's colored region is a uniform 3 km buffer circle standing in for a real municipal boundary polygon, since this tileset carries per-OSM-element data, not administrative boundaries. Inspired by a similar real address-density choropleth.

Classify by

## Attribution & license

Map data © OpenStreetMap contributors, ODbL. Extract via Geofabrik. Unlike the generative-art demo, this page shows real geographic data.

## Zoom levels

The vector source's `minzoom`/`maxzoom` and the buttons below come from this tileset's own `tiles_metadata` row (tippecanoe's `-zg` picks it from the actual data density), not a guessed constant.

Current zoom–
Tileset zoom range–

## Live queries

Tiles rendered 0
Repeat SQL text (cache-eligible)0%
Avg. query time–

## Tile density by zoom

A real `GROUP BY` aggregate over the `tiles` table, one bar per zoom level:

SELECT zoom_level, COUNT(*) FROM tiles GROUP BY zoom_level ORDER BY zoom_level

Loading…

## Jump to a town

A few real municipalities inside Landkreis Dingolfing-Landau, as a starting point for exploring the tileset.

## Tileset metadata

Loading tinySQL WASM…