Skip to content

feat: tippecanoe + PMTiles tile pipeline#21

Merged
victorquinn merged 6 commits intomainfrom
feat/pmtiles-tippecanoe
Feb 25, 2026
Merged

feat: tippecanoe + PMTiles tile pipeline#21
victorquinn merged 6 commits intomainfrom
feat/pmtiles-tippecanoe

Conversation

@victorquinn
Copy link
Member

Summary

Replace the static .pbf tile generation with a tippecanoe + PMTiles pipeline.

Before

  • 44,610 individual .pbf files (187MB) generated by geojson-vt
  • No zoom-dependent simplification — same geometry detail at all zoom levels
  • Territory boundary gaps from independent polygon simplification

After

  • 2 PMTiles archives (54MB total) generated by tippecanoe
  • 71% smaller repo footprint
  • Proper zoom-dependent simplification (rough at low zoom, crisp at high zoom)
  • --detect-shared-borders prevents gaps between adjacent territories
  • Density-based point thinning for power plants at low zoom
  • Single scripts/build-tiles.sh command regenerates everything

Architecture

  • scripts/prepare-territory-geojson.mjs — combines territory files + utility properties
  • scripts/prepare-power-plants-geojson.mjs — converts power-plants.json to GeoJSON
  • scripts/build-tiles.sh — orchestrates preparation + tippecanoe generation
  • lib/pmtiles-server.ts — server-side PMTiles reader (Node.js file source)
  • API routes rewritten to serve tiles from PMTiles via random-access reads

Removed

  • geojson-vt and vt-pbf dependencies
  • scripts/generate-tiles.mjs and scripts/generate-plant-tiles.mjs
  • All static .pbf tile directories

Still TODO

  • Update GitHub Actions workflow for tile rebuild
  • Visual smoke test on Vercel preview

- 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
@vercel
Copy link

vercel bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
opengrid Ready Ready Preview, Comment Feb 25, 2026 8:12pm

Request Review

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.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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)
@victorquinn victorquinn merged commit 2e4f3ec into main Feb 25, 2026
3 checks passed
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.

1 participant