@wemap/routers 11.3.1 → 11.3.3

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.
@@ -55,21 +55,33 @@ export default class InstructionManager {
55
55
 
56
56
  if (step.levelChange) {
57
57
  if (step.levelChange.direction === 'up') {
58
- if (step.levelChange.type === 'conveyor') {
59
- return 'Go up the escalator';
60
- }
61
58
  if (step.levelChange.type === 'stairs') {
62
59
  return 'Go up the stairs';
63
60
  }
61
+ if (step.levelChange.type === 'escalator') {
62
+ return 'Go up the escalator';
63
+ }
64
+ if (step.levelChange.type === 'elevator') {
65
+ return 'Go up the elevator';
66
+ }
67
+ if (step.levelChange.type === 'moving walkway') {
68
+ return 'Go up the moving walkway';
69
+ }
64
70
  return 'Go up' + suffix;
65
71
  }
66
72
  if (step.levelChange.direction === 'down') {
67
- if (step.levelChange.type === 'conveyor') {
68
- return 'Go down the escalator';
69
- }
70
73
  if (step.levelChange.type === 'stairs') {
71
74
  return 'Go down the stairs';
72
75
  }
76
+ if (step.levelChange.type === 'escalator') {
77
+ return 'Go down the escalator';
78
+ }
79
+ if (step.levelChange.type === 'elevator') {
80
+ return 'Go down the elevator';
81
+ }
82
+ if (step.levelChange.type === 'moving walkway') {
83
+ return 'Go down the moving walkway';
84
+ }
73
85
  return 'Go down' + suffix;
74
86
  }
75
87
  if (step.extras?.subwayEntrance) {
@@ -32,7 +32,7 @@ export default class InstructionManagerV1 {
32
32
 
33
33
  if (step.levelChange) {
34
34
  if (step.levelChange.direction === 'up') {
35
- if (step.levelChange.type === 'conveyor') {
35
+ if (step.levelChange.type === 'escalator') {
36
36
  return 'Go up the escalator';
37
37
  }
38
38
  if (step.levelChange.type === 'stairs') {
@@ -41,7 +41,7 @@ export default class InstructionManagerV1 {
41
41
  return 'Go up' + suffix;
42
42
  }
43
43
  if (step.levelChange.direction === 'down') {
44
- if (step.levelChange.type === 'conveyor') {
44
+ if (step.levelChange.type === 'escalator') {
45
45
  return 'Go down the escalator';
46
46
  }
47
47
  if (step.levelChange.type === 'stairs') {
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/routers"
13
13
  },
14
14
  "name": "@wemap/routers",
15
- "version": "11.3.1",
15
+ "version": "11.3.3",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -34,10 +34,10 @@
34
34
  "@turf/convex": "^6.5.0",
35
35
  "@turf/helpers": "^6.5.0",
36
36
  "@types/mapbox__polyline": "^1.0.2",
37
- "@wemap/geo": "^11.3.1",
37
+ "@wemap/geo": "^11.3.3",
38
38
  "@wemap/logger": "^11.0.1",
39
39
  "@wemap/maths": "^11.0.1",
40
- "@wemap/osm": "^11.3.1",
40
+ "@wemap/osm": "^11.3.3",
41
41
  "@wemap/salesman.js": "^2.1.0"
42
42
  },
43
43
  "devDependencies": {
@@ -52,5 +52,5 @@
52
52
  },
53
53
  "./helpers/*": "./helpers/*"
54
54
  },
55
- "gitHead": "d2e603fe3846cfb5b2944ca35c06e74bce6fd6d2"
55
+ "gitHead": "e53e577cf8a7f4e9bd1e1be6639d2ebc68319bcc"
56
56
  }
@@ -19,8 +19,7 @@ const levelChange2: LevelChange = {
19
19
  const levelChange3: LevelChange = {
20
20
  direction: 'up',
21
21
  difference: 3,
22
- // TODO: change to 'escalator'
23
- type: 'conveyor'
22
+ type: 'escalator'
24
23
  };
25
24
 
26
25
  const levelChange4: LevelChange = {
@@ -1,5 +1,4 @@
1
- // TODO: remove conveying
2
- export type LevelChangeType = 'elevator' | 'escalator' | 'stairs' | 'moving walkway' | 'conveyor';
1
+ export type LevelChangeType = 'elevator' | 'escalator' | 'stairs' | 'moving walkway';
3
2
 
4
3
  export type LevelChange = {
5
4
  direction: 'up' | 'down';
@@ -40,35 +40,41 @@ const buildStepsRules = (graphItinerary: OsmItinerary): StepsGenerationRules =>
40
40
  if (edge.data.isElevator) {
41
41
  levelChangeType = 'elevator';
42
42
  } else if (edge.data instanceof OsmWay && edge.data.isConveying && edge.data.areStairs) {
43
- // TODO: change to escalator
44
- levelChangeType = 'conveyor';
45
- // levelChangeType = 'escalator';
43
+ levelChangeType = 'escalator';
46
44
  } else if (edge.data instanceof OsmWay && edge.data.areStairs) {
47
45
  levelChangeType = 'stairs';
48
46
  } else if (edge.data instanceof OsmWay && edge.data.isConveying) {
49
47
  levelChangeType = 'moving walkway';
50
48
  }
51
49
 
52
- // Handle stairs/elevator/conveyors without change in level coordinates
50
+ // Handle stairs/elevators/escalators/moving walkway without change in level coordinates
53
51
  let forceLevelChange: 'up' | 'down' | undefined;
54
52
  const edgeTags = edge.data.tags || {};
55
53
  if (
56
- edge.data instanceof OsmWay
57
- && edge.data.areStairs
54
+ (
55
+ edge.data instanceof OsmWay && edge.data.areStairs ||
56
+ edge.data.isElevator
57
+ )
58
58
  && ['up', 'down'].includes(edgeTags.incline)
59
59
  && !previousStep?.levelChange
60
60
  ) {
61
61
  forceLevelChange = edgeTags.incline as 'up' | 'down';
62
- for (const n of edge.data.nodes) {
63
- if (n !== vertex.data) continue;
64
- }
65
- const isReversed = edge.data.nodes.reduce((acc: boolean | null, n, idx, arr) => {
66
- if (n !== vertex.data) return acc;
67
- acc = !(idx + 1 < arr.length && arr[idx + 1] === nextVertex.data);
68
- return acc;
69
- }, null);
70
- if (isReversed) {
71
- forceLevelChange = forceLevelChange === 'up' ? 'down' : 'up';
62
+
63
+ if (edge.data instanceof OsmWay) {
64
+
65
+ for (const n of edge.data.nodes) {
66
+ if (n !== vertex.data) continue;
67
+ }
68
+
69
+ const isReversed = edge.data.nodes.reduce((acc: boolean | null, n, idx, arr) => {
70
+ if (n !== vertex.data) return acc;
71
+ acc = !(idx + 1 < arr.length && arr[idx + 1] === nextVertex.data);
72
+ return acc;
73
+ }, null);
74
+
75
+ if (isReversed) {
76
+ forceLevelChange = forceLevelChange === 'up' ? 'down' : 'up';
77
+ }
72
78
  }
73
79
  }
74
80
 
@@ -235,11 +241,11 @@ class WemapOsmRouter extends GeoGraphRouter<OsmVertexData, OsmEdgeData> {
235
241
  && edge.data instanceof OsmWay && edge.data.areStairs && !edge.data.isConveying) return false;
236
242
 
237
243
  // Verify escalators
238
- if (typeof options?.useEscalator !== 'undefined' && !options?.useEscalator
244
+ if (typeof options?.useEscalators !== 'undefined' && !options?.useEscalators
239
245
  && edge.data instanceof OsmWay && edge.data.areStairs && edge.data.isConveying) return false;
240
246
 
241
247
  // Verify elevator
242
- if (typeof options?.useElevator !== 'undefined' && !options?.useElevator && edge.data?.isElevator) return false;
248
+ if (typeof options?.useElevators !== 'undefined' && !options?.useElevators && edge.data?.isElevator) return false;
243
249
 
244
250
  return true;
245
251
  };
@@ -2,9 +2,9 @@ export type OsmRouterOptions = {
2
2
 
3
3
  useStairs?: boolean;
4
4
 
5
- useEscalator?: boolean;
5
+ useEscalators?: boolean;
6
6
 
7
- useElevator?: boolean;
7
+ useElevators?: boolean;
8
8
 
9
9
  isTrip?: boolean;
10
10