Skip to content

Commit

Permalink
walk should be walking. Added logic for roundabouts. Use name for rou…
Browse files Browse the repository at this point in the history
…ndabout if available.
  • Loading branch information
gknisely committed Mar 16, 2018
1 parent 8f0e5e1 commit 1bdc0b5
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/tyr/route_serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ namespace {
json::MapPtr osrm_maneuver(const valhalla::odin::TripDirections::Maneuver& maneuver,
std::list<odin::TripPath>::const_iterator path_leg,
const PointLL& man_ll, const bool depart, const bool arrive,
const uint32_t count, const std::string mode, const std::string prev_mode) {
const uint32_t count, const std::string mode, const std::string prev_mode,
const std::string name) {
auto osrm_man = json::map({});

// Set the location
Expand Down Expand Up @@ -526,7 +527,8 @@ namespace {
const auto& current_edge = path_leg->node(idx).edge();
bool new_name = maneuver.type() == odin::TripDirections_Maneuver_Type_kContinue ||
maneuver.type() == odin::TripDirections_Maneuver_Type_kBecomes;
bool roundabout = false;
bool roundabout = maneuver.type() == odin::TripDirections_Maneuver_Type_kRoundaboutEnter ||
maneuver.type() == odin::TripDirections_Maneuver_Type_kRoundaboutExit;
bool ramp = current_edge.use() == odin::TripPath_Use_kRampUse;
bool fork = path_leg->node(idx).fork();
bool merge = prior_edge.use() == odin::TripPath_Use_kRampUse &&
Expand All @@ -541,8 +543,18 @@ namespace {
maneuver_type = ramp_type(prior_edge, idx, path_leg);
} else if (new_name) {
maneuver_type = "new name";
} else if (roundabout) {
maneuver_type = "roundabout";
} else if (maneuver.type() == odin::TripDirections_Maneuver_Type_kRoundaboutEnter) {

if (!name.empty())
maneuver_type = name;
else
maneuver_type = "roundabout";
// Roundabout count
if (maneuver.has_roundabout_exit_count()) {
osrm_man->emplace("exit", static_cast<uint64_t>(maneuver.roundabout_exit_count()));
}
} else if (maneuver.type() == odin::TripDirections_Maneuver_Type_kRoundaboutExit) {
maneuver_type = "exit roundabout";
}

// Are there any intersecting edges
Expand Down Expand Up @@ -629,7 +641,7 @@ namespace {
return "driving";
}
case TripDirections_TravelMode_kPedestrian: {
return "walk";
return "walking";
}
case TripDirections_TravelMode_kBicycle: {
return "cycling";
Expand Down Expand Up @@ -718,7 +730,7 @@ namespace {
// Iterate through maneuvers - convert to OSRM steps
uint32_t index = 0;
uint32_t count = 0;
std::string prev_name, prev_ref, mode, prev_mode;
std::string prev_name, prev_ref, mode, prev_mode, prev_maneuver;
auto steps = json::array({});
std::unordered_map<std::string, float> maneuvers;
for (const auto& maneuver : leg.maneuver()) {
Expand Down Expand Up @@ -785,7 +797,7 @@ namespace {
// Add OSRM maneuver
step->emplace("maneuver", osrm_maneuver(maneuver, path_leg,
shape[maneuver.begin_shape_index()], depart,
arrive, count, mode, prev_mode));
arrive, count, mode, prev_mode, nr.first));

// Add destinations and exits
std::string dest = destinations(maneuver);
Expand Down

0 comments on commit 1bdc0b5

Please sign in to comment.