Skip to content

Commit

Permalink
foot: don't walk on street if sidewalk is separate, punish walking on…
Browse files Browse the repository at this point in the history
… bike only routes
  • Loading branch information
felixguendling committed Oct 6, 2024
1 parent a0ab3c1 commit c1e764d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
12 changes: 9 additions & 3 deletions include/osr/extract/tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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_;
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions include/osr/routing/profiles/foot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<cost_t>(
std::round(dist / (IsWheelchair ? 0.8 : 1.1F)));
return (!e.is_foot_accessible() ? 90 : 0) +
static_cast<cost_t>(
std::round(dist / (IsWheelchair ? 0.8 : 1.1F)));
} else {
return kInfeasible;
}
Expand Down
2 changes: 1 addition & 1 deletion include/osr/ways.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down

0 comments on commit c1e764d

Please sign in to comment.