From c92178d90f96bce874eff3a6014136cdc27b3434 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 29 Apr 2026 17:21:38 +0000 Subject: [PATCH] fix(place): handle boundary/administrative for wiki lookup Add place/linked_place to extratags so wiki enrichment can detect actual place type (e.g. boundary:administrative with place=city should match wiki_places osm_key=place, osm_value=city). Co-Authored-By: Claude Opus 4.5 --- lib/place_detail.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/place_detail.py b/lib/place_detail.py index 6db7a4c..8bb2330 100644 --- a/lib/place_detail.py +++ b/lib/place_detail.py @@ -364,6 +364,15 @@ def _enrich_with_wiki_index(result): state = address.get('state', '') country_code = address.get('country_code', '') + # Handle boundary/administrative - get actual place type from extratags + # (e.g. boundary:administrative with extratags.place='city' -> place:city) + extratags = result.get('extratags', {}) + if osm_class == 'boundary' and osm_type_tag == 'administrative': + place_tag = extratags.get('place') or extratags.get('linked_place') + if place_tag: + osm_class = 'place' + osm_type_tag = place_tag + if not name or not osm_class or not osm_type_tag: return result @@ -503,6 +512,8 @@ def _parse_nominatim(data): 'wheelchair': raw_extra.get('wheelchair'), 'fee': raw_extra.get('fee'), 'takeaway': raw_extra.get('takeaway'), + 'place': raw_extra.get('place'), + 'linked_place': raw_extra.get('linked_place'), } # Category: use extratags.place for boundaries (e.g. "city"), else class/type