From aeb066c03bd43c56c39c3f3e66b36be00725fa27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Sat, 28 Sep 2024 22:57:25 +0200 Subject: [PATCH] more robust matching --- include/osr/lookup.h | 10 ++++++---- src/route.cc | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/osr/lookup.h b/include/osr/lookup.h index cb068e6..51b89ee 100644 --- a/include/osr/lookup.h +++ b/include/osr/lookup.h @@ -84,13 +84,15 @@ struct lookup { match_t match(location const& query, bool const reverse, direction const search_dir, - double const max_match_distance, + double max_match_distance, bitvec const* blocked) const { auto way_candidates = get_way_candidates( query, reverse, search_dir, max_match_distance, blocked); - if (way_candidates.empty()) { - way_candidates = get_way_candidates( - query, reverse, search_dir, max_match_distance * 2U, blocked); + auto i = 0U; + while (way_candidates.empty() && i++ < 4U) { + max_match_distance *= 2U; + way_candidates = get_way_candidates(query, reverse, search_dir, + max_match_distance, blocked); } return way_candidates; } diff --git a/src/route.cc b/src/route.cc index a3e5923..f876863 100644 --- a/src/route.cc +++ b/src/route.cc @@ -230,7 +230,7 @@ best_candidate(ways const& w, std::optional try_direct(osr::location const& from, osr::location const& to) { auto const dist = geo::distance(from.pos_, to.pos_); - return dist < 5.0 + return dist < 8.0 ? std::optional{path{.cost_ = 60U, .dist_ = dist, .segments_ = {path::segment{