Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle sidewalk:{both,left,right} tags #42

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/preprocessing/osm/way_info.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstring>
#include <string_view>

#include "ppr/preprocessing/clamp.h"
#include "ppr/preprocessing/names.h"
Expand All @@ -14,6 +15,8 @@
#include "ppr/preprocessing/osm/wheelchair.h"
#include "ppr/preprocessing/osm/width.h"

using namespace std::literals;

namespace ppr::preprocessing::osm {

bool is_street_with_sidewalks(street_type const street) {
Expand Down Expand Up @@ -134,6 +137,14 @@ way_info get_platform_info(osmium::Way const& way, osmium::TagList const& tags,
return {info_idx, false, false, width, layer};
}

bool should_generate_sidewalk(char const* value, bool const def) {
if (value == nullptr) {
return def;
}
// possible values: yes, no, separate
return value == "yes"sv;
}

way_info get_highway_info(osmium::Way const& way, osmium::TagList const& tags,
osm_graph& graph) {
auto const* highway = tags["highway"];
Expand All @@ -153,6 +164,7 @@ way_info get_highway_info(osmium::Way const& way, osmium::TagList const& tags,
type = edge_type::CROSSING;
} else if (is_street_with_sidewalks(street)) {
type = edge_type::STREET;

auto const* sidewalk = tags["sidewalk"];
if (sidewalk != nullptr) {
if (strcmp(sidewalk, "left") == 0) {
Expand All @@ -169,6 +181,16 @@ way_info get_highway_info(osmium::Way const& way, osmium::TagList const& tags,
sidewalk_left = true;
sidewalk_right = true;
}

auto const* sidewalk_both = tags["sidewalk:both"];
sidewalk_left = should_generate_sidewalk(sidewalk_both, sidewalk_left);
sidewalk_right = should_generate_sidewalk(sidewalk_both, sidewalk_right);

sidewalk_left =
should_generate_sidewalk(tags["sidewalk:left"], sidewalk_left);
sidewalk_right =
should_generate_sidewalk(tags["sidewalk:right"], sidewalk_right);

if ((street == street_type::LIVING || street == street_type::RESIDENTIAL ||
street == street_type::SERVICE ||
street == street_type::UNCLASSIFIED) &&
Expand Down
Loading