From 3078ff0b08a550522c502ae2bd376f2be18012bd Mon Sep 17 00:00:00 2001 From: J Guthrie Date: Mon, 12 Feb 2018 07:22:05 +0000 Subject: [PATCH 1/2] Fixed on ramps and off ramps leading onto unnamed roads - On and off ramps now reference the direction that the ramp is heading in. - i.e. the directions text now says 'Take the ramp on the left towards Baltimore, I58' instead of 'Take the ramp on the left onto unnamed road' --- app/assets/javascripts/index/directions/osrm.js | 3 +++ config/locales/en.yml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/app/assets/javascripts/index/directions/osrm.js b/app/assets/javascripts/index/directions/osrm.js index e7c91e9dc7..183b1decd5 100644 --- a/app/assets/javascripts/index/directions/osrm.js +++ b/app/assets/javascripts/index/directions/osrm.js @@ -98,6 +98,9 @@ function OSRMEngine() { var name = step.name ? "" + step.name + "" : I18n.t('javascripts.directions.instructions.unnamed'); 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/) && step.destinations) { + var destinations = "" + step.destinations + ""; + instText += I18n.t(template + '_with_directions', { directions: destinations } ); } else { instText += I18n.t(template + '_without_exit', { name: name }); } diff --git a/config/locales/en.yml b/config/locales/en.yml index 036f8de35d..c1fd3e0c64 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2331,7 +2331,9 @@ 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} onramp_right_without_exit: Turn right on the ramp onto %{name} + onramp_right_with_directions: Turn right on the ramp towards %{directions} 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 +2343,9 @@ 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} onramp_left_without_exit: Turn left on the ramp onto %{name} + onramp_left_with_directions: Turn left on the ramp towards %{directions} 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} From 05b6e5928fe435742493201e0f6318cde5231bd7 Mon Sep 17 00:00:00 2001 From: J Guthrie Date: Mon, 12 Feb 2018 12:38:41 +0000 Subject: [PATCH 2/2] Added without_directions-option for on and off ramps onto unnamed roads --- .../javascripts/index/directions/osrm.js | 33 ++++++++++++++++--- config/locales/en.yml | 12 +++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/index/directions/osrm.js b/app/assets/javascripts/index/directions/osrm.js index 183b1decd5..5c29f6c4d4 100644 --- a/app/assets/javascripts/index/directions/osrm.js +++ b/app/assets/javascripts/index/directions/osrm.js @@ -95,12 +95,37 @@ function OSRMEngine() { Array.prototype.push.apply(line, step_geometry); var instText = "" + (idx + 1) + ". "; - var name = step.name ? "" + step.name + "" : I18n.t('javascripts.directions.instructions.unnamed'); + var destinations = "" + step.destinations + ""; + var namedRoad = true; + var name; + + if (step.name && step.ref) { + name = "" + step.name + " (" + step.ref + ")"; + } else if (step.name) { + name = "" + step.name + ""; + } else if (step.ref) { + name = "" + step.ref + ""; + } 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/) && step.destinations) { - var destinations = "" + step.destinations + ""; - instText += I18n.t(template + '_with_directions', { directions: destinations } ); + } 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 }); } diff --git a/config/locales/en.yml b/config/locales/en.yml index c1fd3e0c64..69e9041d4a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2332,8 +2332,12 @@ en: 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 on the ramp towards %{directions} + 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} @@ -2344,8 +2348,12 @@ en: 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 on the ramp towards %{directions} + 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}