@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.
- package/dist/index.js +17 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -15
- package/dist/index.mjs.map +1 -1
- package/helpers/InstructionManager.ts +18 -6
- package/helpers/InstructionManagerV1.ts +2 -2
- package/package.json +4 -4
- package/src/model/LevelChange.spec.ts +1 -2
- package/src/model/LevelChange.ts +1 -2
- package/src/wemap-osm/OsmRouter.ts +24 -18
- package/src/wemap-osm/OsmRouterOptions.ts +2 -2
|
@@ -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 === '
|
|
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 === '
|
|
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.
|
|
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.
|
|
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.
|
|
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": "
|
|
55
|
+
"gitHead": "e53e577cf8a7f4e9bd1e1be6639d2ebc68319bcc"
|
|
56
56
|
}
|
package/src/model/LevelChange.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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/
|
|
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
|
-
|
|
57
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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?.
|
|
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?.
|
|
248
|
+
if (typeof options?.useElevators !== 'undefined' && !options?.useElevators && edge.data?.isElevator) return false;
|
|
243
249
|
|
|
244
250
|
return true;
|
|
245
251
|
};
|