]> git.openstreetmap.org Git - nominatim.git/commitdiff
use bbox size for secondary order of results
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 19 Nov 2024 09:38:50 +0000 (10:38 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 19 Nov 2024 09:38:50 +0000 (10:38 +0100)
Helps to return the largest object when deduplicating results.

src/nominatim_api/search/geocoder.py

index 195dd513ebc103b462d85bed236b4dccde858f72..efe5b7216853ba64c4983cd31801999c750c1512 100644 (file)
@@ -116,7 +116,7 @@ class ForwardGeocoder:
             limit to the configured number of results.
         """
         if results:
-            results.sort(key=lambda r: r.ranking)
+            results.sort(key=lambda r: (r.ranking, 0 if r.bbox is None else -r.bbox.area))
             min_rank = results[0].rank_search
             min_ranking = results[0].ranking
             results = SearchResults(r for r in results