]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/directions/fossgis_osrm.js
Add OSRM ferry support
[rails.git] / app / assets / javascripts / index / directions / fossgis_osrm.js
index 53043e06d35366df94da0505c333360f68d6bdf4..a97bc25a5e78d1ea8b5d9c12f5a5c369e38dc345 100644 (file)
@@ -30,6 +30,7 @@
         "rotary": "roundabout",
         "exit roundabout": "exit_roundabout",
         "exit rotary": "exit_roundabout",
         "rotary": "roundabout",
         "exit roundabout": "exit_roundabout",
         "exit rotary": "exit_roundabout",
+        "ferry": "ferry",
         "depart": "start",
         "arrive": "destination"
       };
         "depart": "start",
         "arrive": "destination"
       };
     }
 
     function _processDirections(leg) {
     }
 
     function _processDirections(leg) {
-      function getManeuverId(maneuver) {
+      function getManeuverId({ maneuver, mode, intersections }) {
         // special case handling
         // special case handling
+        if (mode === "ferry") return "ferry";
+        if (intersections.some(i => i.classes?.includes("ferry"))) return "ferry";
         switch (maneuver.type) {
           case "on ramp":
           case "off ramp":
         switch (maneuver.type) {
           case "on ramp":
           case "off ramp":
         "rotary": "roundabout",
         "exit roundabout": "roundabout",
         "exit rotary": "roundabout",
         "rotary": "roundabout",
         "exit roundabout": "roundabout",
         "exit rotary": "roundabout",
+        "ferry": "ferry",
         "depart": "start",
         "arrive": "destination"
       };
 
         "depart": "start",
         "arrive": "destination"
       };
 
-      for (const step of leg.steps) step.maneuverId = getManeuverId(step.maneuver);
+      for (const step of leg.steps) step.maneuverId = getManeuverId(step);
 
       const steps = leg.steps.map(step => [
         ICON_MAP[step.maneuverId],
 
       const steps = leg.steps.map(step => [
         ICON_MAP[step.maneuverId],