Honour British spelling of manoeuvre relation (#5004)

* Support British spelling of manoeuvre to comply with OSM standards.
This commit is contained in:
Daniel Patterson 2018-04-06 17:08:30 -07:00 committed by GitHub
parent b08191b2c4
commit 282415bbc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 8 deletions

View File

@ -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)

View File

@ -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

View File

@ -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>
@ -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");
// 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;