Skip to content

fix: use geocoding field for geo data in address detail response#2

Open
sweets9 wants to merge 1 commit into
bradleyhodges:masterfrom
sweets9:fix/geo-field-geocoding-fallback
Open

fix: use geocoding field for geo data in address detail response#2
sweets9 wants to merge 1 commit into
bradleyhodges:masterfrom
sweets9:fix/geo-field-geocoding-fallback

Conversation

@sweets9
Copy link
Copy Markdown

@sweets9 sweets9 commented Mar 24, 2026

Fixes #1

Problem

GET /addresses/:id returns no geo coordinates even with ADDRESSKIT_ENABLE_GEO=1 set. The GNAF dataset stores geocoding data under structured.geocoding in OpenSearch, but the address detail handler was checking structured.geo — a field that doesn't exist in the indexed documents.

Root cause

In dist/cli.js (~line 40620), the handler that builds the address detail response:

// Before — only checks .geo, which is absent from GNAF documents
...(innerStruct.geo ?? struct.geo) !== void 0 && {
  geo: innerStruct.geo ?? struct.geo

Inspecting the OpenSearch index confirms the actual field name is geocoding:

{ "structured": { "geocoding": { ... }, ... } }

Fix

// After — checks geocoding first, falls back to geo for forward compat
...(innerStruct.geocoding ?? struct.geocoding ?? innerStruct.geo ?? struct.geo) !== void 0 && {
  geo: innerStruct.geocoding ?? struct.geocoding ?? innerStruct.geo ?? struct.geo

Testing

Verified against AddressKit v3.0.1 with GNAF Jan 2026 dataset on OpenSearch 2.11.0. After applying this patch, GET /addresses/:id correctly returns attributes.geo with latitude/longitude coordinates.

Note: this PR patches the compiled dist/cli.js as the TypeScript source doesn't appear to be in the repo. Happy to raise a source-level fix if you can point me to the right file.

The GNAF dataset stores geocoding data under structured.geocoding but
the address detail handler was only checking structured.geo, causing
attributes.geo to always be absent from GET /addresses/:id responses.

Fall back chain: geocoding → geo (for forward compat)

Fixes bradleyhodges#1
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.

GET /addresses/:id returns no geo coordinates — GNAF data uses 'geocoding' field, not 'geo'

1 participant