Skip to content

Commit

Permalink
join kNoLevel and level 0 in hashmap key to enable destination matching
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Nov 2, 2024
1 parent 0bcf6ce commit 02c6782
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions exe/backend/src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ int main(int argc, char const* argv[]) {
if (!fs::exists(platforms_check_path)) {
std::cout << platforms_check_path << " does not exist\n";
}
auto const pl = (!fs::exists(platforms_check_path))
? std::unique_ptr<platforms>{}
: std::make_unique<platforms>(
opt.data_dir_, cista::mmap::protection::READ);
auto const pl = fs::exists(platforms_check_path)
? std::make_unique<platforms>(
opt.data_dir_, cista::mmap::protection::READ)
: nullptr;
if (pl != nullptr) {
pl->build_rtree(w);
}
Expand Down
11 changes: 9 additions & 2 deletions include/osr/routing/profiles/foot.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ struct foot {
static constexpr auto const kOffroadPenalty = 3U;

struct node {
friend bool operator==(node, node) = default;
friend bool operator==(node const a, node const b) {
auto const is_zero = [](level_t const l) {
return l == kNoLevel || l == level_t{0.F};
};
return a.n_ == b.n_ &&
(a.lvl_ == b.lvl_ || (is_zero(a.lvl_) && is_zero(b.lvl_)));
}

static constexpr node invalid() noexcept {
return {.n_ = node_idx_t::invalid(), .lvl_{kNoLevel}};
Expand Down Expand Up @@ -90,7 +96,8 @@ struct foot {
auto operator()(node const n) const noexcept -> std::uint64_t {
using namespace ankerl::unordered_dense::detail;
return wyhash::mix(
wyhash::hash(static_cast<std::uint64_t>(to_idx(n.lvl_))),
wyhash::hash(static_cast<std::uint64_t>(
to_idx(n.lvl_ == kNoLevel ? level_t{0.F} : n.lvl_))),
wyhash::hash(static_cast<std::uint64_t>(to_idx(n.n_))));
}
};
Expand Down

0 comments on commit 02c6782

Please sign in to comment.