[gnome-maps/gnome-3-32] graphHopper: Declare sign constants with names
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/gnome-3-32] graphHopper: Declare sign constants with names
- Date: Wed, 17 Apr 2019 19:19:10 +0000 (UTC)
commit 511520302abf1c3c6f24e1fc72a38824ebd68b56
Author: Marcus Lundblad <ml update uu se>
Date: Mon Apr 15 22:50:45 2019 +0200
graphHopper: Declare sign constants with names
src/graphHopper.js | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/src/graphHopper.js b/src/graphHopper.js
index d0192ba..427419d 100644
--- a/src/graphHopper.js
+++ b/src/graphHopper.js
@@ -30,6 +30,25 @@ const Route = imports.route;
const RouteQuery = imports.routeQuery;
const Utils = imports.utils;
+/**
+ * Directional sign from the GraphHopper API.
+ * https://github.com/graphhopper/graphhopper/blob/master/docs/web/api-doc.md
+ */
+var Sign = {
+ KEEP_LEFT: -7,
+ TURN_SHARP_LEFT: -3,
+ TURN_LEFT: -2,
+ TURN_SLIGHT_LEFT: -1,
+ CONTINUE_ON_STREET: 0,
+ TURN_SLIGHT_RIGHT: 1,
+ TURN_RIGHT: 2,
+ TURN_SHARP_RIGHT: 3,
+ FINISH: 4,
+ REACHED_VIA: 5,
+ USE_ROUNDABOUT: 6,
+ KEEP_RIGHT: 7
+}
+
var GraphHopper = class GraphHopper {
get route() {
@@ -218,8 +237,13 @@ var GraphHopper = class GraphHopper {
let newSign = newInstruction.sign;
let newStreetname = newInstruction.street_name;
- if ((newSign === 0 || newSign === -7 || newSign === 7) &&
- newStreetname === currInstruction.street_name) {
+ /* if the direction is to continue straight, or keep left or keep
+ * right on the same street/road number, fold the instruction into
+ * the previous one
+ */
+ if (newSign === Sign.CONTINUE_ON_STREET ||
+ ((newSign === Sign.KEEP_LEFT || newSign === Sign.KEEP_RIGHT) &&
+ newStreetname === currInstruction.street_name)) {
currInstruction.distance += newInstruction.distance;
} else {
res.push(currInstruction);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]