Skip to content

Commit

Permalink
use admin_level 8 to identify city/region of address
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Nov 26, 2024
1 parent 4c32e01 commit a3b9db7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/endpoints/adr/suggestions_to_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::size_t>(
city_it == end(areas) ? -1 : std::distance(begin(areas), city_it));
Expand Down

0 comments on commit a3b9db7

Please sign in to comment.