Skip to content

feat(postcodes/NZ): 900 New Zealand postcodes (#1039)#1519

Merged
dr5hn merged 1 commit into
masterfrom
feat/postcodes-new-zealand
May 5, 2026
Merged

feat(postcodes/NZ): 900 New Zealand postcodes (#1039)#1519
dr5hn merged 1 commit into
masterfrom
feat/postcodes-new-zealand

Conversation

@dr5hn
Copy link
Copy Markdown
Owner

@dr5hn dr5hn commented May 4, 2026

Summary

Source

State FK strategy

Source's name field is inconsistently structured — sometimes the second comma-separated field is the region; sometimes it's a sub-region district/city/community.

DESC_TO_ISO2 (33-entry hand map) handles:

  • 17 CSC regions in canonical English form (incl. Manawatū-Whanganui macron alias)
  • 16 sub-region descriptors mapping to parent CSC region:
    • Far North District → NTL
    • Christchurch / Christchurch City / 6 community labels → CAN
    • Lower Hutt / Porirua / Martinborough Community / South Wairarapa District → WGN
    • Napier City → HKB
    • Central Otago District / Queenstown-Lakes District → OTA
    • Southland District → STL

Distribution (top 5)

iso2 region rows
CAN Canterbury 137
AUK Auckland 128
WKO Waikato 117
MWT Manawatu-Whanganui 86
WGN Wellington 65

All 17 regions covered.

Test plan

  • python3 -m py_compile bin/scripts/sync/import_new_zealand_postcodes.py
  • All 900 codes match ^\d{4}$
  • 100% state_id valid; state.country_id == 158; state_code == state.iso2
  • No auto-managed fields (id, created_at, updated_at, flag)
  • Idempotent merge (re-run produces no diff)

🤖 Generated with Claude Code

Adds New Zealand's 4-digit postcodes from the
WaimateWihongi/nz-postcodes mirror (OpenStreetMap-derived, NOT
GeoNames-derived).

Why
---
Closes the NZ gap on issue #1039. NZ Post's bulk feed is paid; OSM
is the cleanest publicly redistributable mirror.

Coverage
--------
- 900 postcodes / 100% state FK
- All 17 CSC NZ regions covered
- Each row carries WGS-84 lat/lng centroid + structured locality

State FK strategy
-----------------
Source's 'name' field is inconsistently structured — sometimes the
second comma-separated field is the region (e.g. 'Whangarei District,
Northland, ...'); sometimes it's a sub-region district / city /
community.

DESC_TO_ISO2 (33-entry hand map) handles:
- 17 CSC regions in canonical English form (with a 'Manawatū-Whanganui'
  alias for the source's macron variant)
- 16 sub-region descriptors mapping to their parent CSC region:
  Far North District -> NTL
  Christchurch / Christchurch City / multiple 'X Community' -> CAN
  Lower Hutt / Porirua / Martinborough Community / S. Wairarapa -> WGN
  Napier City -> HKB
  Central Otago District / Queenstown-Lakes District -> OTA
  Southland District -> STL

License
-------
WaimateWihongi/nz-postcodes: no formal LICENSE.
Upstream: OpenStreetMap (per repo README, Nominatim-derived).
Tier 5 per #1039 license-tier policy. NOT GeoNames-derived.
Each row: source: "osm-via-waimate-wihongi"

Validation
----------
- python3 -m py_compile passes
- 100% regex match (^\d{4}$)
- 100% state_id valid + state.country_id == 158 + 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 size:XS This PR changes 0-9 lines, ignoring generated files. enhancement New feature or request labels May 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

CSC Validation Report

PR Format

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

Labels applied: data:postcodes, large-contribution

⚠️ Large Contribution

This PR contains 900 records. Large contributions require manual review.

Schema Validation (900 records)

✅ All records passed validation

Cross-Reference Validation

✅ 1800 reference(s) verified

Geo-Bounds Check

  • ⚠️ contributions/postcodes/NZ.json: Record 766: coordinates (-43.9535665, -176.556115) fall outside NZ bounds [-47.29, -34.39] x [166.51, 178.52] (with 0.45deg tolerance)
  • ⚠️ contributions/postcodes/NZ.json: Record 790: coordinates (-43.9509491, -176.5607157) fall outside NZ bounds [-47.29, -34.39] x [166.51, 178.52] (with 0.45deg tolerance)

Source URL Verification

✅ 2 source URL(s) accessible


0 errors, 2 warning(s) | Status: Ready for review (with warnings)

@dr5hn dr5hn merged commit 7694738 into master May 5, 2026
1 check passed
@dr5hn dr5hn deleted the feat/postcodes-new-zealand 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 large-contribution 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