]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #3593 from lonvia/order-by-bbox
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 19 Nov 2024 10:50:55 +0000 (11:50 +0100)
committerGitHub <noreply@github.com>
Tue, 19 Nov 2024 10:50:55 +0000 (11:50 +0100)
Use bbox size for secondary order of 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