]> git.openstreetmap.org Git - rails.git/commitdiff
Improve OSRM directions for on and off ramps
authorJamie Guthrie <jamie.guthrie@gmail.com>
Tue, 13 Feb 2018 17:28:09 +0000 (17:28 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 13 Feb 2018 17:32:57 +0000 (17:32 +0000)
Try and show both the name of the road being turned on to and the
destination depending on what is available.

Closes #1740

app/assets/javascripts/index/directions/osrm.js
config/locales/en.yml

index 3d32f07e33a5b0582b9dc544c98f228dba4b15c7..5c29f6c4d4a55cf758309860baccb2bd00e957d2 100644 (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 });
         }
index 036f8de35d6aab5c1aa5d292496a8558aeba4028..69e9041d4a282919c4b1b07e0bb69ab106b6e6d7 100644 (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}