@wemap/routers 10.10.0 → 10.11.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/helpers/InstructionManager.js +7 -2
- package/index.d.ts +5 -1
- package/package.json +2 -2
- package/src/model/Step.js +2 -1
- package/src/model/Step.spec.js +1 -1
- package/src/model/Step.type.spec.js +2 -1
- package/src/remote/osrm/OsrmRemoteRouter.js +9 -4
- package/src/wemap/WemapStepsGeneration.js +5 -1
|
@@ -39,7 +39,7 @@ export default class InstructionManager {
|
|
|
39
39
|
* @param {Step} step
|
|
40
40
|
* @returns {string}
|
|
41
41
|
*/
|
|
42
|
-
// eslint-disable-next-line max-statements
|
|
42
|
+
// eslint-disable-next-line max-statements, complexity
|
|
43
43
|
static getInstructionFromStep(step) {
|
|
44
44
|
|
|
45
45
|
const { direction, directionExtra } = getTurnInfoFromAngle(step.angle);
|
|
@@ -53,7 +53,12 @@ export default class InstructionManager {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
let suffix = '';
|
|
57
|
+
if (step.extras.isGate) {
|
|
58
|
+
suffix = ` on gate ${step.name}`;
|
|
59
|
+
} else if (step.name) {
|
|
60
|
+
suffix = ` on ${step.name}`;
|
|
61
|
+
}
|
|
57
62
|
|
|
58
63
|
if (step.levelChange) {
|
|
59
64
|
if (step.levelChange.direction === 'up') {
|
package/index.d.ts
CHANGED
|
@@ -26,7 +26,11 @@ declare module '@wemap/routers' {
|
|
|
26
26
|
duration?: number;
|
|
27
27
|
name: string | null;
|
|
28
28
|
levelChange?: LevelChange;
|
|
29
|
-
extras?: {
|
|
29
|
+
extras?: {
|
|
30
|
+
subwayEntrance?: boolean;
|
|
31
|
+
subwayEntranceRef?: string;
|
|
32
|
+
isGate?: boolean;
|
|
33
|
+
};
|
|
30
34
|
|
|
31
35
|
equals(obj: Step): boolean;
|
|
32
36
|
toJson(): object;
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/routers"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/routers",
|
|
15
|
-
"version": "10.
|
|
15
|
+
"version": "10.11.0",
|
|
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.10.0",
|
|
36
36
|
"@wemap/osm": "^10.10.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "2e30d73684ee8a1cefb0fef0df882b86afc2044f"
|
|
39
39
|
}
|
package/src/model/Step.js
CHANGED
|
@@ -40,7 +40,7 @@ class Step {
|
|
|
40
40
|
/** @type {?LevelChange} */
|
|
41
41
|
levelChange = null;
|
|
42
42
|
|
|
43
|
-
/** @type {?{?subwayEntrance: boolean, ?subwayEntranceRef: string}} */
|
|
43
|
+
/** @type {?{?subwayEntrance: boolean, ?subwayEntranceRef: string, ?isGate: boolean}} */
|
|
44
44
|
extras = {};
|
|
45
45
|
|
|
46
46
|
/** @type {!number} */
|
|
@@ -72,6 +72,7 @@ class Step {
|
|
|
72
72
|
obj1.extras !== null
|
|
73
73
|
&& obj1.extras.subwayEntrance === obj2.extras.subwayEntrance
|
|
74
74
|
&& obj1.extras.subwayEntranceRef === obj2.extras.subwayEntranceRef
|
|
75
|
+
&& obj1.extras.isGate === obj2.extras.isGate
|
|
75
76
|
)
|
|
76
77
|
)
|
|
77
78
|
&& obj1._idCoordsInLeg === obj2._idCoordsInLeg;
|
package/src/model/Step.spec.js
CHANGED
|
@@ -25,7 +25,7 @@ step2.firstStep = false;
|
|
|
25
25
|
step2.number = 2;
|
|
26
26
|
step2.coords = new Coordinates(1, 0);
|
|
27
27
|
step2.distance = step1.coords.distanceTo(step2.coords);
|
|
28
|
-
step2.extras = { subwayEntrance: true, subwayEntranceRef: 'toto' };
|
|
28
|
+
step2.extras = { subwayEntrance: true, subwayEntranceRef: 'toto', isGate: true };
|
|
29
29
|
step2._idCoordsInLeg = 1;
|
|
30
30
|
|
|
31
31
|
const step3 = new Step();
|
|
@@ -17,7 +17,7 @@ const isNullOrLevelChange = val => val === null || val instanceof LevelChange;
|
|
|
17
17
|
const isUndefinedOrBoolean = val => typeof val === 'undefined' || typeof val === 'boolean';
|
|
18
18
|
const isUndefinedOrString = val => typeof val === 'undefined' || typeof val === 'string';
|
|
19
19
|
|
|
20
|
-
const stepExtraProperties = ['subwayEntrance', 'subwayEntranceRef'];
|
|
20
|
+
const stepExtraProperties = ['subwayEntrance', 'subwayEntranceRef', 'isGate'];
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @param {Step} step
|
|
@@ -48,5 +48,6 @@ export default function checkStepType(step) {
|
|
|
48
48
|
}
|
|
49
49
|
expect(step.extras.subwayEntrance).satisfies(isUndefinedOrBoolean);
|
|
50
50
|
expect(step.extras.subwayEntranceRef).satisfies(isUndefinedOrString);
|
|
51
|
+
expect(step.extras.isGate).satisfies(isUndefinedOrBoolean);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -247,10 +247,15 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
247
247
|
step.distance = jsonStep.distance;
|
|
248
248
|
step.duration = jsonStep.duration;
|
|
249
249
|
|
|
250
|
-
if (jsonStep.extras
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
250
|
+
if (jsonStep.extras) {
|
|
251
|
+
if (jsonStep.extras.subwayEntrance) {
|
|
252
|
+
step.extras.subwayEntrance = true;
|
|
253
|
+
if (jsonStep.extras.subwayEntranceRef) {
|
|
254
|
+
step.extras.subwayEntranceRef = jsonStep.extras.subwayEntranceRef;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (jsonStep.extras.isGate) {
|
|
258
|
+
step.extras.isGate = true;
|
|
254
259
|
}
|
|
255
260
|
}
|
|
256
261
|
|
|
@@ -43,6 +43,7 @@ class WemapStepsGeneration {
|
|
|
43
43
|
const splitStepCondition = splitByAngle || splitByLevel;
|
|
44
44
|
|
|
45
45
|
const isSubwayEntrance = node ? node.builtFrom.tags.railway === 'subway_entrance' : false;
|
|
46
|
+
const isGate = node ? (node.builtFrom.tags.barrier === 'gate' || node.builtFrom.tags.aeroway === 'gate') : false;
|
|
46
47
|
|
|
47
48
|
// New step creation
|
|
48
49
|
if (isFirstStep || splitStepCondition || isSubwayEntrance) {
|
|
@@ -61,12 +62,15 @@ class WemapStepsGeneration {
|
|
|
61
62
|
|
|
62
63
|
if (isSubwayEntrance) {
|
|
63
64
|
currentStep.extras.subwayEntrance = true;
|
|
64
|
-
currentStep.name = node.builtFrom.tags.name;
|
|
65
65
|
if (node.builtFrom.tags.ref) {
|
|
66
66
|
currentStep.extras.subwayEntranceRef = node.builtFrom.tags.ref;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
if (isGate) {
|
|
71
|
+
currentStep.extras.gate = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
70
74
|
if (splitByLevel) {
|
|
71
75
|
currentStep.levelChange = WemapStepsGeneration.levelChangefromTwoNodes(node, nextNode);
|
|
72
76
|
}
|