[gnome-maps/wip/mlundblad/additional-turn-icons] WIP: route, graphHopper: Add additional instructions




commit 9682a1105ab9ed56bb2b3b22bb4550e4830dc096
Author: Marcus Lundblad <ml update uu se>
Date:   Sun Oct 3 22:25:55 2021 +0200

    WIP: route, graphHopper: Add additional instructions

 src/graphHopper.js | 32 ++++++++++++++++++++++++--------
 src/route.js       | 38 +++++++++++++++++++++-----------------
 2 files changed, 45 insertions(+), 25 deletions(-)
---
diff --git a/src/graphHopper.js b/src/graphHopper.js
index 1fb4f479..20df5898 100644
--- a/src/graphHopper.js
+++ b/src/graphHopper.js
@@ -35,7 +35,10 @@ const Utils = imports.utils;
  * https://github.com/graphhopper/graphhopper/blob/master/docs/web/api-doc.md
  */
 var Sign = {
+    UTURN: -98,
+    UTURN_LEFT: -8,
     KEEP_LEFT: -7,
+    LEAVE_ROUNDABOUT: -6, // not currently used
     TURN_SHARP_LEFT: -3,
     TURN_LEFT: -2,
     TURN_SLIGHT_LEFT: -1,
@@ -46,7 +49,8 @@ var Sign = {
     FINISH: 4,
     REACHED_VIA: 5,
     USE_ROUNDABOUT: 6,
-    KEEP_RIGHT: 7
+    KEEP_RIGHT: 7,
+    UTURN_RIGHT: 8
 }
 
 var GraphHopper = class GraphHopper {
@@ -258,12 +262,24 @@ var GraphHopper = class GraphHopper {
     }
 
     _createTurnPointType(sign) {
-        let type = sign + 3;
-        let min  = Route.TurnPointType.SHARP_LEFT;
-        let max  = Route.TurnPointType.ROUNDABOUT;
-        if (min <= type && type <= max)
-            return type;
-        else
-            return undefined;
+        switch (sign) {
+            case Sign.UTURN:              return Route.TurnPointType.UTURN;
+            case Sign.UTURN_LEFT:         return Route.TurnPointType.UTURN_LEFT;
+            case Sign.KEEP_LEFT:          return Route.TurnPointType.KEEP_LEFT;
+            case Sign.LEAVE_ROUNDABOUT:   return Route.TurnPointType.LEAVE_ROUNDABOUT;
+            case Sign.TURN_SHARP_LEFT:    return Route.TurnPointType.SHARP_LEFT;
+            case Sign.TURN_LEFT:          return Route.TurnPointType.LEFT;
+            case Sign.TURN_SLIGHT_LEFT:   return Route.TurnPointType.SLIGHT_LEFT;
+            case Sign.CONTINUE_ON_STREET: return Route.TurnPointType.CONTINUE;
+            case Sign.TURN_SLIGHT_RIGHT:  return Route.TurnPointType.SLIGHT_RIGHT;
+            case Sign.TURN_RIGHT:         return Route.TurnPointType.RIGHT;
+            case Sign.TURN_SHARP_RIGHT:   return Route.TurnPointType.SHARP_RIGHT;
+            case Sign.FINISH:             return Route.TurnPointType.END;
+            case Sign.REACHED_VIA:        return Route.TurnPointType.VIA;
+            case Sign.USE_ROUNDABOUT:     return Route.TurnPointType.ROUNDABOUT;
+            case Sign.KEEP_RIGHT:         return Route.TurnPointType.KEEP_RIGHT;
+            case Sign.UTURN_RIGHT:        return Route.TurnPointType.UTURN_RIGHT;
+            default: return undefined;
+        }
     }
 };
diff --git a/src/route.js b/src/route.js
index 4115a4d4..89dd9198 100644
--- a/src/route.js
+++ b/src/route.js
@@ -25,23 +25,24 @@ const BoundingBox = imports.boundingBox;
 const Utils = imports.utils;
 
 var TurnPointType = {
-    SHARP_LEFT:    0,
-    LEFT:          1,
-    SLIGHT_LEFT:   2,
-    CONTINUE:      3,
-    SLIGHT_RIGHT:  4,
-    RIGHT:         5,
-    SHARP_RIGHT:   6,
-    END:           7,
-    VIA:           8,
-    ROUNDABOUT:    9,
-
-    // This one is not in GraphHopper, so choose
-    // a reasonably unlikely number for this
-    START:         10000,
-    ELEVATOR:      10001,
-    UTURN_LEFT:    10002,
-    UTURN_RIGHT:   10003
+    START:            0,
+    SHARP_LEFT:       1,
+    LEFT:             2,
+    SLIGHT_LEFT:      3,
+    KEEP_LEFT:        4,
+    CONTINUE:         5,
+    SLIGHT_RIGHT:     6,
+    RIGHT:            7,
+    SHARP_RIGHT:      8,
+    KEEP_RIGHT:       9,
+    END:              10,
+    VIA:              11,
+    ROUNDABOUT:       12,
+    LEAVE_ROUNDABOUT: 13,
+    UTURN:            14,
+    UTURN_LEFT:       15,
+    UTURN_RIGHT:      16,
+    ELEVATOR:         17
 };
 
 /* countries/terrotories driving on the left
@@ -136,6 +137,9 @@ var TurnPoint = class TurnPoint {
         case TurnPointType.END:          return 'maps-point-end-symbolic';
         case TurnPointType.ROUNDABOUT:   return this._getRoundaboutIconName(turnAngle);
         case TurnPointType.ELEVATOR:     return 'maps-direction-elevator-symbolic';
+        case TurnPointType.UTURN:        return this._isLeftHandTraffic() ?
+                                                'maps-direction-u-turn-right-symbolic':
+                                                'maps-direction-u-turn-left-symbolic';
         case TurnPointType.UTURN_LEFT:   return 'maps-direction-u-turn-left-symbolic';
         case TurnPointType.UTURN_RIGHT:  return 'maps-direction-u-turn-right-symbolic';
         default:                         return '';


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]