@wemap/routers 10.5.1 → 10.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,8 +94,7 @@ export default class InstructionManager {
94
94
  }
95
95
  }
96
96
 
97
-
98
- return '';
97
+ return 'Continue straight';
99
98
  }
100
99
 
101
100
 
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/routers"
13
13
  },
14
14
  "name": "@wemap/routers",
15
- "version": "10.5.1",
15
+ "version": "10.5.2",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -35,5 +35,5 @@
35
35
  "@wemap/maths": "^10.3.1",
36
36
  "@wemap/osm": "^10.5.1"
37
37
  },
38
- "gitHead": "ce2d0e4a541b521098e5382bd665dc54805f1c27"
38
+ "gitHead": "befe244ba1bc8d1761522e2458f611efe8cee598"
39
39
  }
package/src/Utils.js CHANGED
@@ -68,3 +68,31 @@ export function multiplyRouterResponseLevel(routerResponse, levelFactor) {
68
68
  }
69
69
 
70
70
 
71
+ /**
72
+ * @param {Itinerary} itinerary
73
+ * @param {number} levelFactor
74
+ */
75
+ export function forceUnknownItineraryLevelTo0(itinerary) {
76
+
77
+ itinerary.from.level ||= 0;
78
+ itinerary.to.level ||= 0;
79
+
80
+ for (const leg of itinerary.legs) {
81
+ leg.from.coords.level ||= 0;
82
+ leg.to.coords.level ||= 0;
83
+ for (const coords of leg.coords) {
84
+ coords.level ||= 0;
85
+ }
86
+ if (leg.steps) {
87
+ for (const step of leg.steps) {
88
+ step.coords.level ||= 0;
89
+ }
90
+ }
91
+ }
92
+
93
+ if (itinerary._coords) {
94
+ for (const coords of itinerary._coords) {
95
+ coords.level ||= 0;
96
+ }
97
+ }
98
+ }
@@ -1,5 +1,5 @@
1
1
  import { GraphItinerary } from '@wemap/geo';
2
- import { diffAngleLines, positiveMod, rad2deg } from '@wemap/maths';
2
+ import { diffAngle, rad2deg } from '@wemap/maths';
3
3
  import { OsmElement } from '@wemap/osm';
4
4
 
5
5
  import Constants from '../Constants.js';
@@ -56,18 +56,18 @@ export function getTurnInfoFromAngle(_angle) {
56
56
 
57
57
  let direction, directionExtra;
58
58
 
59
- const directionAngle = rad2deg(diffAngleLines(_angle, Math.PI));
60
- if (directionAngle <= 20) {
59
+ const directionAngle = rad2deg(diffAngle(_angle, Math.PI));
60
+ const directionAngleAbs = Math.abs(directionAngle);
61
+ if (directionAngleAbs <= 20) {
61
62
  direction = 'straight';
62
63
  } else {
63
- direction = positiveMod(_angle, 2 * Math.PI) > Math.PI ? 'left' : 'right';
64
- if (directionAngle < 55) {
64
+ direction = directionAngle > 0 ? 'left' : 'right';
65
+ if (directionAngleAbs < 55) {
65
66
  directionExtra = 'slight';
66
- } else if (directionAngle > 120) {
67
+ } else if (directionAngleAbs > 120) {
67
68
  directionExtra = 'sharp';
68
69
  }
69
70
  }
70
71
 
71
-
72
72
  return { direction, directionExtra };
73
73
  }