Skip to content

feat: add Mexico postal coordinate lookup - #119

Closed
jkrenge wants to merge 1 commit into
masterfrom
codex/mex-postal-geocoding
Closed

jkrenge wants to merge 1 commit into
masterfrom
codex/mex-postal-geocoding

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

Return-location distance analysis needs postal coordinates for Mexico. MEX currently returns undefined for every code. This adds full five-digit lookup for 32,447 codes.

GeoNames MX.txt (144,655 rows / 32,448 codes)
  → distinct coordinate pairs per code
  → unweighted mean, rounded to six decimals
  → exclude known misplaced 23300
  → 32,447 representative points

Source: GeoNames MX.zip, retrieved 2026-11-04; Last-Modified 2026-11-04 02:54:07 UTC; CC BY 4.0, attributed in docs/geocode-MEX.md. The source represents all 32 states; complete or current national coverage is not established. Points are estimates, not postal-area centroids. Source row repetition does not affect weighting.

MEX accepts five-digit strings and surrounding whitespace, keeps leading zeros, and returns legacy coordinate strings in [longitude, latitude] order. Invalid, unknown, and excluded codes return undefined. Other countries, public exports, and types retain their behavior. Only lib/geocode.js overlaps other country work; this branch starts at default-branch commit 8a7bd9b and includes no other country changes.

Evidence

  • Before: coordinates('MEX', '01000') returns undefined.
    After: returns ['-99.203300', '19.358700']; rural 99998 returns the mean of three distinct points. Tests cover aliases, leading zero, whitespace, malformed/unknown codes, exclusion, uniqueness, and all coordinate ranges.
  • npm test: 100 pass, 0 fail.
  • npm run lint, npm run format:check, npm run validate:data: pass. Data validation retains two known AUT/BEL warnings.
  • Generator assert checks pass; a second generation produces the same output SHA-256.
  • Government sources confirm sample postal identities and identify the misplaced 23300 points. These checks do not independently establish accuracy of all coordinates. Source hashes, method, sample links, and limits are in docs/geocode-MEX.md.

Merge Danger

Door: two-way. Revert removes MEX lookup support; no stored user data changes.

Blast Radius: MEX. GeoNames estimates can have large errors. 23300 is deliberately omitted because its mean is about 41 km from the official Todos Santos reference. Other source errors may remain. Do not treat the points as address locations or fraud evidence. No merge, deployment, or package publication is part of this PR.

@jkrenge
jkrenge requested a review from a team as a code owner November 4, 2026 22:03
@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:32.907075Z b86d5ef 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.

@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