Coarsen sub-national regions to a ~100km floor (v0.14.0) #28

Merged
kamilkrzywda merged 1 commits from feat/coarsen-regions into master 2026-10-12 11:59:39 +02:00
Owner

Part of #16

Coarsens the real sub-national regions so no region is smaller than ~100×100 km (10,000 km²), except islands — per the request to “join cities to the region around it.”

  • New scripts/coarsen-regions.mjs (npm run coarsen:regions): merges small same-country regions into their nearest surrounding neighbor using real boolean dissolves (@turf/union), cascading smallest-first to a fixed point. Regions with no same-country neighbor (islands) are left alone.
  • public/regions.geo.json: 4,138 → 1,796 regions (2,342 merged). Over-granular countries collapse to a few-to-tens: UK 232→16, Italy 107→19, France 110→42, Russia 200→80; median is now 7/country. Standalone cities are absorbed (Paris → Val-de-Marne cascade, London districts, DC → Maryland). 83 island regions are exempted from the floor.
  • @turf/union added as a devDependency (used only by the generator script, not the app bundle).
  • scripts/regions.test.ts +1 test (non-island regions below the floor < 1% of the dataset).
  • Map/LLM contract unchanged — WorldMap.tsx still resolves ownership via properties.parent, so the coarser data just renders coarser regions.

Part of #16 (the LLM sub-region-transfer piece is still pending).

Part of #16 Coarsens the real sub-national regions so no region is smaller than ~100×100 km (10,000 km²), except islands — per the request to “join cities to the region around it.” - New `scripts/coarsen-regions.mjs` (`npm run coarsen:regions`): merges small same-country regions into their nearest surrounding neighbor using **real boolean dissolves** (`@turf/union`), cascading smallest-first to a fixed point. Regions with no same-country neighbor (islands) are left alone. - `public/regions.geo.json`: 4,138 → **1,796 regions** (2,342 merged). Over-granular countries collapse to a few-to-tens: **UK 232→16**, Italy 107→19, France 110→42, Russia 200→80; median is now **7/country**. Standalone cities are absorbed (Paris → Val-de-Marne cascade, London districts, DC → Maryland). **83 island regions** are exempted from the floor. - `@turf/union` added as a devDependency (used only by the generator script, not the app bundle). - `scripts/regions.test.ts` +1 test (non-island regions below the floor < 1% of the dataset). - **Map/LLM contract unchanged** — `WorldMap.tsx` still resolves ownership via `properties.parent`, so the coarser data just renders coarser regions. Part of #16 (the LLM sub-region-transfer piece is still pending).
kamilkrzywda added 1 commit 2026-10-12 11:57:17 +02:00
Coarsen sub-national regions to ~100km floor (v0.14.0)
CI / build + unit + e2e (pull_request) Successful in 1m47s
7bf11fa5b9
Part of #16
kamilkrzywda scheduled this pull request to auto merge when all checks succeed 2026-10-12 11:59:37 +02:00
kamilkrzywda merged commit 69782aad69 into master 2026-10-12 11:59:39 +02:00
kamilkrzywda deleted branch feat/coarsen-regions 2026-10-12 11:59:39 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: OpenCode/History#28