Skip to content

fix: refresh GBR district geocoding and postcode formats - #115

Closed
jkrenge wants to merge 2 commits into
masterfrom
codex/gbr-geocode-20261104
Closed

jkrenge wants to merge 2 commits into
masterfrom
codex/gbr-geocode-20261104

Conversation

@jkrenge

@jkrenge jkrenge commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by consolidated postal geocoding PR #124. This PR's head commit is retained in the combined branch. Combined CI passes on Node.js 24/26 and static checks.


Summary

GBR compact and lowercase full postcodes currently miss the district lookup. Repeated district rows also make the selected coordinate depend on source order.

GBR postcode → trim + uppercase → outward code
GeoNames GB rows → distinct coordinate pairs per district → arithmetic mean

Refresh GBR from GeoNames GB.zip, retrieved 2026-11-04 (export index: 2026-11-04). CC BY 4.0, with GeoNames attribution and changes documented in docs/geocode-GBR.md. Convert 27,450 source rows to 3,002 unique district records, adding 17 districts and removing no existing district codes. Include a scoped generator with assertion checks.

Preserve [longitude, latitude] strings, exports, and other countries. Accept district, spaced/compact full postcode, lowercase, and surrounding whitespace for GBR. Reject malformed suffixes. Keep the source's legacy Crown dependency grouping explicit.

Evidence

  • Before: 27,431 rows / 2,985 distinct districts; compact SW1A0AA and lowercase sw1a 0aa miss; repeated codes select the first locality.
    After: 3,002 rows / unique districts; supported formats return ['-0.1328', '51.5018']. All district lookups and coordinate ranges are checked offline.
  • npm test: 100 tests pass. npm run lint, npm run format:check, and npm run validate:data pass. Data validation retains two existing AUT/BEL warnings. Generator rebuild is byte-for-byte identical.
  • Primary-source checks cover ONS postcode structure, Parliament/Westminster, Belfast, Shetland rural districts, and Hugh Town. These confirm locality/postcode matches, not a measured coordinate error bound.

Merge Danger

Door: two-way

Revert the country change to restore the previous data and normalization. No merge, publication, or deployment is part of this task.

Blast Radius: GBR

District representative points change from first-locality selection to a mean of distinct source points. These are not postal centroids. Large rural/island districts can have errors of tens of kilometres; within-district distances collapse to zero. Coverage and current full-postcode validity are not guaranteed. Do not use these points as proof of physical location or for fraud decisions. Shared overlap with concurrent country PRs is limited to the normalization block in lib/geocode.js.

@jkrenge
jkrenge requested a review from a team as a code owner November 4, 2026 22:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T22:04:18.087085Z 5c0473c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 5c0473c5e9

ℹ️ 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".

Comment thread test/geocode-gbr.test.js Outdated
'SW1A garbage',
'SW1A 0AA extra',
'SW 1A 0AA',
'JE1 1AA',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the supported Jersey postcode from rejection cases

JE1 1AA resolves to ['-2.1049', '49.1880'], as explicitly required by the acceptance test on line 11, so including the identical input here makes this test fail unconditionally once dependencies are installed. The implementation and documentation intentionally retain Crown dependency districts for compatibility. Remove this supported postcode from the rejection cases or replace it with a genuinely malformed input so that npm test, including the test job in .github/workflows/test.yml, can pass.

Useful? React with 👍 / 👎.

@jkrenge jkrenge closed this Nov 4, 2026
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