]> git.openstreetmap.org Git - nominatim.git/commitdiff
derive bbox size for postcode nodes from rank_search
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 28 Sep 2024 11:45:32 +0000 (13:45 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 30 Sep 2024 06:58:40 +0000 (08:58 +0200)
src/nominatim_api/v1/classtypes.py

index 66708593b331ec9bcab8a492925b0a03aa63c5a8..9e78c83b5a634eeb171c8396df6227403b8837df 100644 (file)
@@ -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)