Improve OSRM directions for on and off ramps

Try and show both the name of the road being turned on to and the
destination depending on what is available.

Closes #1740
This commit is contained in:
Jamie Guthrie 2018-02-13 17:28:09 +00:00 committed by Tom Hughes
parent 97f75e82c0
commit 161ce947c3
2 changed files with 31 additions and 2 deletions

View file

@ -95,8 +95,10 @@ function OSRMEngine() {
Array.prototype.push.apply(line, step_geometry);
var instText = "<b>" + (idx + 1) + ".</b> ";
var destinations = "<b>" + step.destinations + "</b>";
var namedRoad = true;
var name;
if (step.name && step.ref) {
name = "<b>" + step.name + " (" + step.ref + ")</b>";
} else if (step.name) {
@ -105,10 +107,25 @@ function OSRMEngine() {
name = "<b>" + step.ref + "</b>";
} else {
name = I18n.t('javascripts.directions.instructions.unnamed');
namedRoad = false;
}
if (step.maneuver.type.match(/rotary|roundabout/)) {
instText += I18n.t(template + '_with_exit', { exit: step.maneuver.exit, name: name } );
} else if (step.maneuver.type.match(/on ramp|off ramp/)) {
if (step.destinations) {
if (namedRoad) {
instText += I18n.t(template + '_with_name_and_directions', { name: name, directions: destinations } );
} else {
instText += I18n.t(template + '_with_directions', { directions: destinations } );
}
} else {
if (namedRoad) {
instText += I18n.t(template + '_without_exit', { name: name });
} else {
instText += I18n.t(template + '_without_directions');
}
}
} else {
instText += I18n.t(template + '_without_exit', { name: name });
}

View file

@ -2331,7 +2331,13 @@ en:
continue_without_exit: Continue on %{name}
slight_right_without_exit: Slight right onto %{name}
offramp_right_without_exit: Take the ramp on the right onto %{name}
offramp_right_with_directions: Take the ramp on the right towards %{directions}
offramp_right_with_name_and_directions: Take the ramp on the right onto %{name}, towards %{directions}
offramp_right_without_directions: Take the ramp on the right
onramp_right_without_exit: Turn right on the ramp onto %{name}
onramp_right_with_directions: Turn right onto the ramp towards %{directions}
onramp_right_with_name_and_directions: Turn right on the ramp onto %{name}, towards %{directions}
onramp_right_without_directions: Turn right onto the ramp
endofroad_right_without_exit: At the end of the road turn right onto %{name}
merge_right_without_exit: Merge right onto %{name}
fork_right_without_exit: At the fork turn right onto %{name}
@ -2341,7 +2347,13 @@ en:
sharp_left_without_exit: Sharp left onto %{name}
turn_left_without_exit: Turn left onto %{name}
offramp_left_without_exit: Take the ramp on the left onto %{name}
offramp_left_with_directions: Take the ramp on the left towards %{directions}
offramp_left_with_name_and_directions: Take the ramp on the left onto %{name}, towards %{directions}
offramp_left_without_directions: Take the ramp on the left
onramp_left_without_exit: Turn left on the ramp onto %{name}
onramp_left_with_directions: Turn left onto the ramp towards %{directions}
onramp_left_with_name_and_directions: Turn left on the ramp onto %{name}, towards %{directions}
onramp_left_without_directions: Turn left onto the ramp
endofroad_left_without_exit: At the end of the road turn left onto %{name}
merge_left_without_exit: Merge left onto %{name}
fork_left_without_exit: At the fork turn left onto %{name}