From: Sarah Hoffmann Date: Tue, 19 Nov 2024 09:38:50 +0000 (+0100) Subject: use bbox size for secondary order of results X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/0770eaa5d04200aec75653b1ec495ba1a214eaab?ds=sidebyside;hp=c172ca8c6c060f188ad626bca631a7c2cd908e7d use bbox size for secondary order of results Helps to return the largest object when deduplicating results. --- diff --git a/src/nominatim_api/search/geocoder.py b/src/nominatim_api/search/geocoder.py index 195dd513..efe5b721 100644 --- a/src/nominatim_api/search/geocoder.py +++ b/src/nominatim_api/search/geocoder.py @@ -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