Skip to content

feat(postcodes/VI): 6 USVI ZIPs (#1039)#1524

Merged
dr5hn merged 1 commit into
masterfrom
feat/postcodes-us-virgin-islands
May 5, 2026
Merged

feat(postcodes/VI): 6 USVI ZIPs (#1039)#1524
dr5hn merged 1 commit into
masterfrom
feat/postcodes-us-virgin-islands

Conversation

@dr5hn
Copy link
Copy Markdown
Owner

@dr5hn dr5hn commented May 5, 2026

Summary

  • Mirrors USVI-mapped ZIPs from US.json into VI's own country namespace for Can we add a postcode for this? #1039
  • 6 codes / 100% state FK across all 3 USVI states (Saint Thomas / Saint John / Saint Croix)

Source

  • US Census ZCTA Gazetteer (Tier 1, CC-0 public domain) — already shipped in US.json under state_code='VI'
  • This PR derives a companion VI.json so consumers querying by country_code='VI' get the data directly

State FK

Centroid-distance match against cities/VI.json (20 USVI localities), then FK to that city's state_id (ST/SJ/SC).

All 6 codes

code locality island
00802 Charlotte Amalie ST
00820 Christiansted SC
00830 Coral Bay SJ
00840 Northcentral SC
00850 Southcentral SC
00851 Sion Farm SC

Test plan

  • python3 -m py_compile bin/scripts/sync/import_us_virgin_islands_postcodes.py
  • All 6 codes match ^008\d{2}(?:-\d{4})?$
  • 100% state_id valid; state.country_id == 242; state_code == state.iso2
  • No auto-managed fields
  • Idempotent merge

🤖 Generated with Claude Code

Mirrors VI-mapped ZIPs from US.json into the separate USVI country
namespace, FK'd to nearest USVI city by centroid distance.

Why
---
USVI uses US ZIPs in the 008xx range, but CSC represents USVI as
its own country (iso2=VI, country_id=242) with 3 island states
(Saint Thomas / Saint John / Saint Croix). Without this mirror,
postcode lookups for VI return empty.

Coverage
--------
- 6 ZIPs / 100% state FK
- All 3 USVI states represented (ST: 00802, SC: 4 codes, SJ: 00830)

State FK strategy
-----------------
Centroid-distance matching against cities/VI.json (20 USVI
localities), then FK to that city's state_id (one of 3 islands).

License
-------
Original source: US Census ZCTA (CC-0).
Each row: source: "us-census-via-vi-mirror"

Validation
----------
- python3 -m py_compile passes
- 100% regex match (^008\d{2}(?:-\d{4})?$)
- 100% state_id valid + state.country_id == 242 + state_code agrees
- No auto-managed fields (id, created_at, updated_at, flag)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 5, 2026
@dosubot dosubot Bot added the enhancement New feature or request label May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

CSC Validation Report

PR Format

  • ✅ Description provided
  • ✅ Data source linked
  • ✅ Issue linked (recommended for data changes)
  • ✅ Justification / context provided

Labels applied: data:postcodes

Schema Validation (6 records)

✅ All records passed validation

Cross-Reference Validation

✅ 12 reference(s) verified

Source URL Verification

✅ 1 source URL(s) accessible


All checks passed | Status: Ready for review

@dr5hn dr5hn merged commit b019a00 into master May 5, 2026
1 check passed
@dr5hn dr5hn deleted the feat/postcodes-us-virgin-islands branch May 5, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:postcodes enhancement New feature or request ready-for-review size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant