Skip to content

Honour British spelling of manoeuvre relation #5004

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

Merged
merged 4 commits into from
Apr 7, 2018
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- FIXED: Adjust Straight direction modifiers of side roads in driveway handler [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929)
- CHANGED: Added post process logic to collapse segregated turn instructions [#4925](https://github.com/Project-OSRM/osrm-backend/pull/4925)
- ADDED: Maneuver relation now supports `straight` as a direction [#4995](https://github.com/Project-OSRM/osrm-backend/pull/4995)
- FIXED: Support spelling maneuver relation with British spelling [#4950](https://github.com/Project-OSRM/osrm-backend/issues/4950)
- Tools:
- ADDED: `osrm-routed` accepts a new property `--memory_file` to store memory in a file on disk. [#4881](https://github.com/Project-OSRM/osrm-backend/pull/4881)
- ADDED: `osrm-datastore` accepts a new parameter `--dataset-name` to select the name of the dataset. [#4982](https://github.com/Project-OSRM/osrm-backend/pull/4982)
Expand Down
7 changes: 7 additions & 0 deletions features/guidance/maneuver-tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ Feature: Maneuver tag support
| maneuver | hij | i | cde | turn | sharp_left |
| maneuver | abc | c | cde | turn | slight_left |
| maneuver | cde | c | cgi | turn | straight |
| manoeuvre| cgi | c | abc | turn | right |

And the relations
| type | way:from | node:via | way:to | manoeuvre | maneuver | direction |
| maneuver | cgi | c | cde | fork | turn | slight_right |

When I route I should get
| waypoints | route | turns |
Expand All @@ -37,6 +42,8 @@ Feature: Maneuver tag support
# Testing re-awakening suppressed turns
| a,e | A Street,B Street,B Street | depart,turn slight left,arrive |
| e,i | B Street,C Street,C Street | depart,turn straight,arrive |
| i,e | C Street,B Street,B Street | depart,fork slight right,arrive |
| i,a | C Street,A Street,A Street | depart,turn right,arrive |

Scenario: single via-way
Given the node map
Expand Down
26 changes: 18 additions & 8 deletions src/extractor/maneuver_override_relation_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include <boost/regex.hpp>

#include <osmium/osm.hpp>
#include <osmium/tags/regex_filter.hpp>
#include <osmium/tags/filter.hpp>
#include <osmium/tags/taglist.hpp>

#include <algorithm>
#include <iterator>
Expand All @@ -31,16 +32,16 @@ ManeuverOverrideRelationParser::ManeuverOverrideRelationParser() {}
boost::optional<InputManeuverOverride>
ManeuverOverrideRelationParser::TryParse(const osmium::Relation &relation) const
{
osmium::tags::KeyFilter filter(false);
filter.add(true, "maneuver");

const osmium::TagList &tag_list = relation.tags();
// Support both American and British spellings of maneuver/manoeuvre
osmium::tags::KeyValueFilter filter{false};
filter.add(true, "type", "maneuver");
filter.add(true, "type", "manoeuvre");

osmium::tags::KeyFilter::iterator fi_begin(filter, tag_list.begin(), tag_list.end());
osmium::tags::KeyFilter::iterator fi_end(filter, tag_list.end(), tag_list.end());
const osmium::TagList &tag_list = relation.tags();

if (osmium::tags::match_none_of(tag_list, filter))
// if it's not a maneuver, continue;
if (std::distance(fi_begin, fi_end) == 0)
{
return boost::none;
}
Expand All @@ -49,7 +50,16 @@ ManeuverOverrideRelationParser::TryParse(const osmium::Relation &relation) const
// we can trim away the vector after parsing
InputManeuverOverride maneuver_override;

maneuver_override.maneuver = relation.tags().get_value_by_key("maneuver", "");
// Handle both spellings
if (relation.tags().has_key("manoeuvre"))
{
maneuver_override.maneuver = relation.tags().get_value_by_key("manoeuvre", "");
}
else
{
maneuver_override.maneuver = relation.tags().get_value_by_key("maneuver", "");
}

maneuver_override.direction = relation.tags().get_value_by_key("direction", "");

bool valid_relation = true;
Expand Down