Skip to content

feat: add UK country boundaries#300

Merged
joaquimds merged 1 commit intomainfrom
feat/countries
Jan 30, 2026
Merged

feat: add UK country boundaries#300
joaquimds merged 1 commit intomainfrom
feat/countries

Conversation

@joaquimds
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for UK country boundaries (UKC24) across the backend area model, import tooling, frontend choropleth configuration, and backfills existing geocoded records with derived UKC24 codes.

Changes:

  • Add UKC24 to area set / group enums and labels, plus size ordering.
  • Add a new importCountries CLI command and Mapbox choropleth layer config for countries.
  • Add a migration to populate geocode_result.areas.UKC24 based on existing UKR18 codes.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/server/models/AreaSet.ts Adds UKC24 to area set + group enums and size ranking.
src/server/commands/importCountries.ts New importer to load countries GeoJSON into the area table under UKC24.
src/labels.ts Adds UKC24 labels; updates group labels for multi-zoom groups.
src/app/map/[id]/components/Choropleth/configs.ts Adds Mapbox choropleth config for UK country boundaries (UKC24).
src/app/map/[id]/components/Choropleth/areas.ts Adjusts valid boundary group selection logic when a data source is geocoded by area code.
migrations/1769777340048_geocode_ukc24_by_ukr18.ts Backfills UKC24 in data_record.geocode_result based on UKR18 prefix.
bin/cmd.ts Registers the importCountries CLI command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

);
if (!fs.existsSync(countriesGeojsonPath)) {
logger.error(
`File not found: ${countriesGeojsonPath}. Download from https://www.data.gov.uk/dataset/96f3e623-6e54-4df2-808c-48dba5c98b55/countries-december-2021-boundaries-uk-bgc`,
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The missing-file message points to the “countries December 2021 boundaries” dataset, but this importer expects CTRY24CD/CTRY24NM properties (and the area set code is UKC24). Downloading the linked 2021 dataset is very likely to produce different property names and make the import fail or insert null codes. Update the URL/message to match the expected 2024 country boundaries (or update the expected property names to match the intended source).

Suggested change
`File not found: ${countriesGeojsonPath}. Download from https://www.data.gov.uk/dataset/96f3e623-6e54-4df2-808c-48dba5c98b55/countries-december-2021-boundaries-uk-bgc`,
`File not found: ${countriesGeojsonPath}. Download from https://www.data.gov.uk/dataset/96f3e623-6e54-4df2-808c-48dba5c98b55/countries-december-2024-boundaries-uk-bgc`,

Copilot uses AI. Check for mistakes.
ON CONFLICT (code, area_set_id) DO UPDATE SET geography = EXCLUDED.geography;
`.execute(db);

const percentComplete = Math.floor((i * 100) / count);
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

percentComplete never reaches 100% because it uses i (0-based) rather than the number of processed features. Use (i + 1) (or special-case the final iteration) so the last log shows 100% complete.

Suggested change
const percentComplete = Math.floor((i * 100) / count);
const percentComplete = Math.floor(((i + 1) * 100) / count);

Copilot uses AI. Check for mistakes.
@joaquimds joaquimds merged commit 8a42b63 into main Jan 30, 2026
1 check passed
@joaquimds joaquimds deleted the feat/countries branch January 30, 2026 13:15
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