check empty name string in findBasicTurnType

This commit is contained in:
karenzshea 2017-11-27 16:23:37 +01:00 committed by Patrick Niklaus
parent 978350c388
commit 8cf8f0d7d6
2 changed files with 41 additions and 5 deletions

View File

@ -1398,4 +1398,38 @@ Feature: Simple Turns
When I route I should get
| waypoints | route | turns |
| a,f | abc,cf,cf | depart,turn right,arrive |
| a,f | ,, | depart,turn right,arrive |
# https://www.openstreetmap.org/#map=18/52.24071/10.29066
Scenario: Turn for roads with no name, ref changes
Given the node map
"""
x
.
.
d
. .
. .
. .
e. . t . c . p. .f
. .
. .
. .
b
.
.
a
"""
And the ways
| nodes | highway | ref | name | oneway |
| abp | tertiary | K 23 | | yes |
| pdx | tertiary | K 23 | | yes |
| xdt | tertiary | K 23 | | yes |
| tba | tertiary | K 23 | | yes |
| etcpf | primary | B 1 | | no |
When I route I should get
| waypoints | route | turns |
| e,x | ,,, | depart,turn sharp left,turn right,arrive |
| f,a | ,, | depart,turn left,arrive |

View File

@ -71,17 +71,19 @@ TurnType::Enum IntersectionHandler::findBasicTurnType(const EdgeID via_edge,
if (!on_ramp && onto_ramp)
return TurnType::OnRamp;
const auto &in_name =
const auto &in_name_id =
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(via_edge).annotation_data)
.name_id;
const auto &out_name =
const auto &out_name_id =
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(road.eid).annotation_data)
.name_id;
const auto &in_name = name_table.GetNameForID(in_name_id).to_string();
const auto &out_name = name_table.GetNameForID(out_name_id).to_string();
const auto same_name = !util::guidance::requiresNameAnnounced(
in_name, out_name, name_table, street_name_suffix_table);
in_name_id, out_name_id, name_table, street_name_suffix_table);
if (in_name != EMPTY_NAMEID && out_name != EMPTY_NAMEID && same_name)
if (!in_name.empty() && !out_name.empty() && same_name)
{
return TurnType::Continue;
}