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 });
}