@wemap/routers 10.3.0-alpha.0 → 10.3.0

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.
package/index.d.ts CHANGED
@@ -119,4 +119,6 @@ declare module '@wemap/routers' {
119
119
  export function multiplyItineraryLevel(itinerary: Itinerary, levelFactor: number): void;
120
120
  export function multiplyRouterResponseLevel(routerResponse: RouterResponse, levelFactor: number): void;
121
121
 
122
+ // WemapRouterUtils
123
+ export function getTurnInfoFromAngle(angle: number): { direction: 'straight' | 'left' | 'right', directionExtra?: 'slight' | 'sharp' };
122
124
  }
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/routers"
13
13
  },
14
14
  "name": "@wemap/routers",
15
- "version": "10.3.0-alpha.0",
15
+ "version": "10.3.0",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -30,10 +30,10 @@
30
30
  "@turf/boolean-point-in-polygon": "^6.5.0",
31
31
  "@turf/convex": "^6.5.0",
32
32
  "@turf/helpers": "^6.5.0",
33
- "@wemap/geo": "^10.3.0-alpha.0",
33
+ "@wemap/geo": "^10.3.0",
34
34
  "@wemap/logger": "^10.0.0",
35
- "@wemap/maths": "^10.3.0-alpha.0",
36
- "@wemap/osm": "^10.3.0-alpha.0"
35
+ "@wemap/maths": "^10.3.0",
36
+ "@wemap/osm": "^10.3.0"
37
37
  },
38
- "gitHead": "d08f3459ff3cb996212da48efb454b1518c2f7fb"
38
+ "gitHead": "2435b4a1c0218f56a87ff1768e197f8cb738aa4d"
39
39
  }
package/src/model/Step.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Coordinates } from '@wemap/geo';
2
2
 
3
- import OsrmRemoteRouter from '../remote/osrm/OsrmRemoteRouter.js';
4
3
  import LevelChange from './LevelChange.js';
5
4
 
6
5
  class Step {
@@ -47,55 +46,6 @@ class Step {
47
46
  /** @type {!number} */
48
47
  _idCoordsInLeg = null;
49
48
 
50
-
51
- /** @type {{type: string, direction?: string}} */
52
- get instruction() {
53
-
54
- const modifier = OsrmRemoteRouter.getModifierFromAngle(this.angle);
55
- let type, direction, directionExtra;
56
-
57
- if (this.levelChange) {
58
- return {
59
- type: 'level-change',
60
- levelChange: this.levelChange
61
- };
62
- }
63
-
64
- switch (modifier) {
65
- case 'sharp right':
66
- case 'slight right':
67
- case 'right':
68
- type = 'turn';
69
- direction = 'right';
70
- break;
71
- case 'sharp left':
72
- case 'slight left':
73
- case 'left':
74
- type = 'turn';
75
- direction = 'left';
76
- break;
77
- case 'straight':
78
- type = 'continue';
79
- break;
80
- case 'u turn':
81
- type = 'u-turn';
82
- break;
83
- }
84
- if (modifier.includes('sharp')) {
85
- directionExtra = 'sharp';
86
- } else if (modifier.includes('slight')) {
87
- directionExtra = 'slight';
88
- }
89
-
90
- return {
91
- type,
92
- direction,
93
- directionExtra,
94
- name: this.name,
95
- indoor: this.coords.level !== null
96
- };
97
- }
98
-
99
49
  /**
100
50
  * @param {Step} obj1
101
51
  * @param {Step} obj2
@@ -1,4 +1,5 @@
1
1
  import { GraphItinerary } from '@wemap/geo';
2
+ import { diffAngleLines, positiveMod, rad2deg } from '@wemap/maths';
2
3
  import { OsmElement } from '@wemap/osm';
3
4
 
4
5
  import Constants from '../Constants.js';
@@ -50,3 +51,23 @@ export function createItineraryFromGraphItinerary(graphItinerary,
50
51
 
51
52
  return itinerary;
52
53
  }
54
+
55
+ export function getTurnInfoFromAngle(_angle) {
56
+
57
+ let direction, directionExtra;
58
+
59
+ const directionAngle = rad2deg(diffAngleLines(_angle, Math.PI));
60
+ if (directionAngle <= 20) {
61
+ direction = 'straight';
62
+ } else {
63
+ direction = positiveMod(_angle, 2 * Math.PI) > Math.PI ? 'left' : 'right';
64
+ if (directionAngle < 55) {
65
+ directionExtra = 'slight';
66
+ } else if (directionAngle > 120) {
67
+ directionExtra = 'sharp';
68
+ }
69
+ }
70
+
71
+
72
+ return { direction, directionExtra };
73
+ }