Skip to content

Add basemap tile storage: Bicep infra and GPKG extraction script#4

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/set-up-tile-serving-api
Open

Add basemap tile storage: Bicep infra and GPKG extraction script#4
Copilot wants to merge 3 commits into
mainfrom
copilot/set-up-tile-serving-api

Conversation

Copilot AI commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Serve Lantmäteriet topowebb raster tiles directly to MapLibre from Azure Blob Storage — no Azure Function proxy needed. Tiles are extracted once from a GeoPackage and stored at {z}/{x}/{y} paths with public anonymous read access.

infra/basemap.bicep

  • Standard LRS StorageV2 account with allowBlobPublicAccess: true
  • CORS: GET/HEAD/OPTIONS from any origin, 24h max-age
  • basemap-tiles container with publicAccess: Blob
  • Outputs tilesBaseUrl for direct use in MapLibre config

Backend/Scripts/extract-gpkg-tiles.py

One-time population script (pure sqlite3, no GDAL):

  • Reads (zoom_level, tile_column, tile_row, tile_data) from the GPKG tile table
  • TMS → OSM Y-flip: osm_y = (2^z - 1) - gpkg_tile_row
  • Detects Content-Type from magic bytes (PNG/JPEG/WebP); sets Cache-Control: public, max-age=86400
  • 16 parallel upload threads; skips existing blobs unless --overwrite
python extract-gpkg-tiles.py \
    --gpkg topowebb.gpkg \
    --connection-string "DefaultEndpointsProtocol=https;AccountName=...;..." \
    --zoom 0,1,2,3,4,5,6,7,8,9,10,11,12

MapLibre tile source:

{
  "type": "raster",
  "tiles": ["https://<account>.blob.core.windows.net/basemap-tiles/{z}/{x}/{y}"],
  "tileSize": 256
}

@Yeetii Yeetii force-pushed the copilot/set-up-tile-serving-api branch from 9cfcf44 to 71c18e1 Compare April 9, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants