From 83013f819b463b14332854dd80cc47629bea0d1a Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 28 Sep 2024 13:45:32 +0200 Subject: [PATCH] derive bbox size for postcode nodes from rank_search --- src/nominatim_api/v1/classtypes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/nominatim_api/v1/classtypes.py b/src/nominatim_api/v1/classtypes.py index 66708593..9e78c83b 100644 --- a/src/nominatim_api/v1/classtypes.py +++ b/src/nominatim_api/v1/classtypes.py @@ -48,7 +48,12 @@ def bbox_from_result(result: Union[ReverseResult, SearchResult]) -> Bbox: around the centroid according to dimensions derived from the search rank. """ + if result.category == ('place', 'postcode') and result.bbox is None: + return Bbox.from_point(result.centroid, + 0.05 - 0.012 * (result.rank_search - 21)) + if (result.osm_object and result.osm_object[0] == 'N') or result.bbox is None: + extent = NODE_EXTENT.get(result.category, 0.00005) return Bbox.from_point(result.centroid, extent) -- 2.39.5