From a3b9db70ea67fb532588f97569f791bc2b26b591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Tue, 26 Nov 2024 19:00:07 +0100 Subject: [PATCH] use admin_level 8 to identify city/region of address --- src/endpoints/adr/suggestions_to_response.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/endpoints/adr/suggestions_to_response.cc b/src/endpoints/adr/suggestions_to_response.cc index 5f695cbae..8c03f5f07 100644 --- a/src/endpoints/adr/suggestions_to_response.cc +++ b/src/endpoints/adr/suggestions_to_response.cc @@ -54,10 +54,11 @@ api::geocode_response suggestions_to_response( auto const city_it = std::min_element(begin(areas), end(areas), [&](auto&& a, auto&& b) { + constexpr auto const kCloseTo = 8; auto const x = to_idx(t.area_admin_level_[a]); auto const y = to_idx(t.area_admin_level_[b]); - return (x > 7 ? 10 : 1) * std::abs(x - 7) < - (y > 7 ? 10 : 1) * std::abs(y - 7); + return (x > kCloseTo ? 10 : 1) * std::abs(x - kCloseTo) < + (y > kCloseTo ? 10 : 1) * std::abs(y - kCloseTo); }); auto const city_idx = static_cast( city_it == end(areas) ? -1 : std::distance(begin(areas), city_it));