From 282415bbc1920a95763cdbc65c6900f5b1ee1da9 Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Fri, 6 Apr 2018 17:08:30 -0700 Subject: [PATCH] Honour British spelling of manoeuvre relation (#5004) * Support British spelling of manoeuvre to comply with OSM standards. --- CHANGELOG.md | 1 + features/guidance/maneuver-tag.feature | 7 +++++ .../maneuver_override_relation_parser.cpp | 26 +++++++++++++------ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ec12bd4b..32a588a0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/features/guidance/maneuver-tag.feature b/features/guidance/maneuver-tag.feature index 29aa95f4d..6a4fab9f7 100644 --- a/features/guidance/maneuver-tag.feature +++ b/features/guidance/maneuver-tag.feature @@ -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 | @@ -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 diff --git a/src/extractor/maneuver_override_relation_parser.cpp b/src/extractor/maneuver_override_relation_parser.cpp index 812b8136a..94542eafb 100644 --- a/src/extractor/maneuver_override_relation_parser.cpp +++ b/src/extractor/maneuver_override_relation_parser.cpp @@ -11,7 +11,8 @@ #include #include -#include +#include +#include #include #include @@ -31,16 +32,16 @@ ManeuverOverrideRelationParser::ManeuverOverrideRelationParser() {} boost::optional ManeuverOverrideRelationParser::TryParse(const osmium::Relation &relation) const { - osmium::tags::KeyFilter filter(false); - filter.add(true, "maneuver"); + + // Support both American and British spellings of maneuver/manoeuvre + osmium::tags::KeyValueFilter filter{false}; + filter.add(true, "type", "maneuver"); + filter.add(true, "type", "manoeuvre"); const osmium::TagList &tag_list = relation.tags(); - 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()); - + 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; } @@ -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;