From c1e764df7f5674551b571ca0c87b3200fbcdaa6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Sun, 6 Oct 2024 21:03:37 +0200 Subject: [PATCH] foot: don't walk on street if sidewalk is separate, punish walking on bike only routes --- include/osr/extract/tags.h | 12 +++++++++--- include/osr/routing/profiles/foot.h | 5 +++-- include/osr/ways.h | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/osr/extract/tags.h b/include/osr/extract/tags.h index c662cd2..947ffda 100644 --- a/include/osr/extract/tags.h +++ b/include/osr/extract/tags.h @@ -69,7 +69,13 @@ struct tags { } case cista::hash("name"): name_ = t.value(); break; case cista::hash("entrance"): is_entrance_ = true; break; - case cista::hash("sidewalk"): sidewalk_ = t.value(); break; + case cista::hash("sidewalk"): + case cista::hash("sidewalk:left"): [[fallthrough]]; + case cista::hash("sidewalk:right"): + if (t.value() == "separate"sv) { + sidewalk_separate_ = true; + } + break; case cista::hash("cycleway"): cycleway_ = t.value(); break; case cista::hash("motorcar"): motorcar_ = t.value(); @@ -148,7 +154,7 @@ struct tags { std::string_view highway_; // https://wiki.openstreetmap.org/wiki/Key:sidewalk - std::string_view sidewalk_; + bool sidewalk_separate_{false}; // https://wiki.openstreetmap.org/wiki/Key:cycleway std::string_view cycleway_; @@ -195,7 +201,7 @@ bool is_accessible(tags const& o, osm_obj_type const type) { struct foot_profile { static override access_override(tags const& t) { - if (t.is_route_) { + if (t.is_route_ || t.sidewalk_separate_) { return override::kBlacklist; } diff --git a/include/osr/routing/profiles/foot.h b/include/osr/routing/profiles/foot.h index 57714a4..d43c57a 100644 --- a/include/osr/routing/profiles/foot.h +++ b/include/osr/routing/profiles/foot.h @@ -296,8 +296,9 @@ struct foot { std::uint16_t const dist) { if ((e.is_foot_accessible() || e.is_bike_accessible()) && (!IsWheelchair || !e.is_steps())) { - return static_cast( - std::round(dist / (IsWheelchair ? 0.8 : 1.1F))); + return (!e.is_foot_accessible() ? 90 : 0) + + static_cast( + std::round(dist / (IsWheelchair ? 0.8 : 1.1F))); } else { return kInfeasible; } diff --git a/include/osr/ways.h b/include/osr/ways.h index 261d517..7f20368 100644 --- a/include/osr/ways.h +++ b/include/osr/ways.h @@ -32,7 +32,7 @@ namespace osr { -constexpr auto const kBinaryVersion = 1U; +constexpr auto const kBinaryVersion = 2U; struct resolved_restriction { enum class type { kNo, kOnly } type_;