feat: tippecanoe + PMTiles tile pipeline#21
Conversation
- Replace 44,610 static .pbf files (187MB) with 2 PMTiles archives (54MB) - Add tippecanoe build pipeline (build-tiles.sh, prepare-*.mjs scripts) - Rewrite tile API routes to serve from PMTiles via pmtiles library - Add lib/pmtiles-server.ts for server-side PMTiles random-access reads - Update ExplorerMap to use API route tile URLs - Remove geojson-vt and vt-pbf dependencies - Remove old generate-tiles.mjs and generate-plant-tiles.mjs scripts Benefits: - 71% smaller repo footprint (187MB → 54MB) - Proper zoom-dependent simplification via tippecanoe - Shared border detection prevents gaps between territories - Single build command regenerates all tiles - Density-based point thinning for power plants at low zoom
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The old generate-tiles.mjs and generate-plant-tiles.mjs were removed in the PMTiles migration. Tiles are now pre-built via build-tiles.sh and committed as .pmtiles archives — no generation needed at build time.
- Remove types/vt-pbf.d.ts (no longer used) - Update comment in ExplorerMap (geojson-vt → tippecanoe)
No longer needed — geojson-vt and vt-pbf were removed in the PMTiles migration.
After syncing power plant data (annual or monthly), install tippecanoe and rebuild PMTiles archives so tiles stay in sync with the data.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c5f0fa95f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "scripts": { | ||
| "dev": "next dev", | ||
| "prebuild": "node scripts/copy-territories.mjs && node scripts/copy-power-plants.mjs && node scripts/generate-tiles.mjs && node scripts/generate-plant-tiles.mjs", | ||
| "prebuild": "node scripts/copy-territories.mjs && node scripts/copy-power-plants.mjs", |
There was a problem hiding this comment.
Regenerate PMTiles as part of the build pipeline
The prebuild script no longer runs any tile-generation step, but the API routes now serve only public/tiles/*.pmtiles, so data updates can ship with stale map tiles. In this repo, CI (.github/workflows/ci.yml) runs npm run build only, which means changes from flows like sync:power-plants can update JSON inputs without rebuilding PMTiles, producing inconsistent production results between tabular data and rendered map layers.
Useful? React with 👍 / 👎.
- Replace two-tier territory system (territories-large z7-8, territories-all z9+) with a single 'territories' layer starting at minZoom 0 - tippecanoe handles simplification and tiny polygon dropping at low zoom, so client-side customerCount filtering is no longer needed - Lower power plants minZoom from 8 to 5 (tippecanoe --drop-densest-as-needed already thins points at low zoom) - Remove minZoom: 7 gate from grid-boundaries geojson layer - Remove 'Zoom in to explore' hint banner and currentZoom state tracking - Rename territories-all -> territories for clarity (source stays territories-source) - Use fillOpacity 0.2 for territories (clean at all zoom levels)
Summary
Replace the static .pbf tile generation with a tippecanoe + PMTiles pipeline.
Before
After
--detect-shared-bordersprevents gaps between adjacent territoriesscripts/build-tiles.shcommand regenerates everythingArchitecture
scripts/prepare-territory-geojson.mjs— combines territory files + utility propertiesscripts/prepare-power-plants-geojson.mjs— converts power-plants.json to GeoJSONscripts/build-tiles.sh— orchestrates preparation + tippecanoe generationlib/pmtiles-server.ts— server-side PMTiles reader (Node.js file source)Removed
geojson-vtandvt-pbfdependenciesscripts/generate-tiles.mjsandscripts/generate-plant-tiles.mjsStill TODO