@wemap/geo 4.0.3 → 4.0.10
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.js +2 -0
- package/package.json +2 -2
- package/src/Utils.js +2 -2
- package/src/graph/Itinerary.js +5 -3
- package/src/graph/Itinerary.spec.js +4 -2
- package/src/graph/ItineraryInfo.js +29 -0
- package/src/graph/LevelChange.js +43 -0
- package/src/graph/Node.js +9 -0
- package/src/graph/Step.js +2 -1
- package/src/graph/StepsGeneration.js +4 -7
package/index.js
CHANGED
|
@@ -17,6 +17,8 @@ export { default as AbsoluteHeading } from './src/rotations/AbsoluteHeading.js';
|
|
|
17
17
|
export { default as Edge } from './src/graph/Edge.js';
|
|
18
18
|
export { default as GraphRouter } from './src/graph/GraphRouter.js';
|
|
19
19
|
export { default as Itinerary } from './src/graph/Itinerary.js';
|
|
20
|
+
export { default as ItineraryInfo } from './src/graph/ItineraryInfo.js';
|
|
21
|
+
export { default as LevelChange } from './src/graph/LevelChange.js';
|
|
20
22
|
export { default as Network } from './src/graph/Network.js';
|
|
21
23
|
export { default as Node } from './src/graph/Node.js';
|
|
22
24
|
export { default as MapMatching } from './src/graph/MapMatching.js';
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/geo"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/geo",
|
|
15
|
-
"version": "4.0.
|
|
15
|
+
"version": "4.0.10",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"@wemap/logger": "^4.0.0",
|
|
31
31
|
"@wemap/maths": "^4.0.3"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "684e1328f164054572b32f241e3e3b85cc3b1362"
|
|
34
34
|
}
|
package/src/Utils.js
CHANGED
|
@@ -90,14 +90,14 @@ export function trimRoute(route, startPosition = route[0], length = Number.MAX_V
|
|
|
90
90
|
const p1 = route[currentPointIndex - 1];
|
|
91
91
|
const p2 = route[currentPointIndex];
|
|
92
92
|
|
|
93
|
-
if (
|
|
93
|
+
if (Coordinates.equalsTo(startPosition, p1)) {
|
|
94
94
|
newRoute.push(p1);
|
|
95
95
|
previousPoint = p1;
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
const proj = startPosition.getSegmentProjection(p1, p2);
|
|
100
|
-
if (proj &&
|
|
100
|
+
if (proj && Coordinates.equalsTo(startPosition, proj) && !proj.equalsTo(p2)) {
|
|
101
101
|
newRoute.push(proj);
|
|
102
102
|
previousPoint = proj;
|
|
103
103
|
break;
|
package/src/graph/Itinerary.js
CHANGED
|
@@ -3,6 +3,7 @@ import Coordinates from '../coordinates/Coordinates.js';
|
|
|
3
3
|
import Level from '../coordinates/Level.js';
|
|
4
4
|
|
|
5
5
|
import Edge from './Edge.js';
|
|
6
|
+
import ItineraryInfo from './ItineraryInfo.js';
|
|
6
7
|
import MapMatching from './MapMatching.js';
|
|
7
8
|
import Network from './Network.js';
|
|
8
9
|
import Node from './Node.js';
|
|
@@ -249,7 +250,7 @@ class Itinerary extends Network {
|
|
|
249
250
|
|
|
250
251
|
/**
|
|
251
252
|
* @param {Coordinates} position
|
|
252
|
-
* @returns {
|
|
253
|
+
* @returns {ItineraryInfo}
|
|
253
254
|
*/
|
|
254
255
|
getInfo(position) {
|
|
255
256
|
|
|
@@ -290,7 +291,8 @@ class Itinerary extends Network {
|
|
|
290
291
|
|
|
291
292
|
}
|
|
292
293
|
|
|
293
|
-
|
|
294
|
+
const itineraryInfo = new ItineraryInfo();
|
|
295
|
+
return Object.assign(itineraryInfo, {
|
|
294
296
|
nextStep,
|
|
295
297
|
previousStep,
|
|
296
298
|
projection,
|
|
@@ -298,7 +300,7 @@ class Itinerary extends Network {
|
|
|
298
300
|
traveledPercentage: traveledDistance / totalDistance,
|
|
299
301
|
remainingDistance: totalDistance - traveledDistance,
|
|
300
302
|
remainingPercentage: 1 - traveledDistance / totalDistance
|
|
301
|
-
};
|
|
303
|
+
});
|
|
302
304
|
}
|
|
303
305
|
|
|
304
306
|
static fromNetworkNodes(nodes, start, end) {
|
|
@@ -506,6 +506,7 @@ describe('Multi - Level Itinerary (down)', () => {
|
|
|
506
506
|
new Edge(nodes[2], nodes[3], new Level(0, 1), 'e2'),
|
|
507
507
|
new Edge(nodes[3], nodes[4], new Level(0), 'e3')
|
|
508
508
|
];
|
|
509
|
+
edges[1].isStairs = true;
|
|
509
510
|
|
|
510
511
|
const itinerary = new Itinerary(nodes, edges);
|
|
511
512
|
itinerary.start = new Coordinates(43.6091367, 3.8839298, null, new Level(1));
|
|
@@ -528,7 +529,8 @@ describe('Multi - Level Itinerary (down)', () => {
|
|
|
528
529
|
expect(steps[1].nodes[0]).equal(nodes[1]);
|
|
529
530
|
expect(steps[1].levelChange).is.not.null;
|
|
530
531
|
expect(steps[1].levelChange.direction).equal('down');
|
|
531
|
-
expect(steps[1].levelChange.
|
|
532
|
+
expect(steps[1].levelChange.difference).equal(-1);
|
|
533
|
+
expect(steps[1].levelChange.type).equal('stairs');
|
|
532
534
|
expect(steps[1].nodes[1]).equal(nodes[2]);
|
|
533
535
|
expect(steps[1].nodes[2]).equal(nodes[3]);
|
|
534
536
|
|
|
@@ -579,7 +581,7 @@ describe('Multi - Level Itinerary (up)', () => {
|
|
|
579
581
|
expect(steps[1].nodes[0]).equal(nodes[1]);
|
|
580
582
|
expect(steps[1].levelChange).is.not.null;
|
|
581
583
|
expect(steps[1].levelChange.direction).equal('up');
|
|
582
|
-
expect(steps[1].levelChange.
|
|
584
|
+
expect(steps[1].levelChange.difference).equal(1);
|
|
583
585
|
expect(steps[1].nodes[1]).equal(nodes[2]);
|
|
584
586
|
expect(steps[1].nodes[2]).equal(nodes[3]);
|
|
585
587
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Projection from './Projection.js';
|
|
2
|
+
import Step from './Step.js';
|
|
3
|
+
|
|
4
|
+
class ItineraryInfo {
|
|
5
|
+
|
|
6
|
+
/** @type {Step} */
|
|
7
|
+
nextStep;
|
|
8
|
+
|
|
9
|
+
/** @type {Step} */
|
|
10
|
+
previousStep;
|
|
11
|
+
|
|
12
|
+
/** @type {Projection} */
|
|
13
|
+
projection;
|
|
14
|
+
|
|
15
|
+
/** @type {number} */
|
|
16
|
+
traveledDistance;
|
|
17
|
+
|
|
18
|
+
/** @type {number} */
|
|
19
|
+
traveledPercentage;
|
|
20
|
+
|
|
21
|
+
/** @type {number} */
|
|
22
|
+
remainingDistance;
|
|
23
|
+
|
|
24
|
+
/** @type {number} */
|
|
25
|
+
remainingPercentage;
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default ItineraryInfo;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Level from '../coordinates/Level.js';
|
|
2
|
+
import Network from './Network.js';
|
|
3
|
+
import Node from './Node.js';
|
|
4
|
+
|
|
5
|
+
class LevelChange {
|
|
6
|
+
|
|
7
|
+
/** @type {String} [up|down] */
|
|
8
|
+
direction;
|
|
9
|
+
|
|
10
|
+
/** @type {number} [-2, -1, 1, ...] */
|
|
11
|
+
difference;
|
|
12
|
+
|
|
13
|
+
/** @type {string} [elevator|conveyor|stairs] */
|
|
14
|
+
type = null;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {Node} firstNode
|
|
18
|
+
* @param {Node} secondNode
|
|
19
|
+
* @returns {LevelChange}
|
|
20
|
+
*/
|
|
21
|
+
static fromTwoNodes(firstNode, secondNode) {
|
|
22
|
+
|
|
23
|
+
const levelChange = new LevelChange();
|
|
24
|
+
|
|
25
|
+
const edge = Network.getEdgeByNodes(firstNode.edges, firstNode, secondNode);
|
|
26
|
+
|
|
27
|
+
if (edge.isElevator) {
|
|
28
|
+
levelChange.type = 'elevator';
|
|
29
|
+
} else if (edge.isConveying) {
|
|
30
|
+
levelChange.type = 'conveyor';
|
|
31
|
+
} else if (edge.isStairs) {
|
|
32
|
+
levelChange.type = 'stairs';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
levelChange.difference = Level.diff(firstNode.coords.level, secondNode.coords.level);
|
|
36
|
+
levelChange.direction = levelChange.difference > 0 ? 'up' : 'down';
|
|
37
|
+
|
|
38
|
+
return levelChange;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default LevelChange;
|
package/src/graph/Node.js
CHANGED
|
@@ -13,6 +13,9 @@ class Node {
|
|
|
13
13
|
/** @type {string} */
|
|
14
14
|
name = null;
|
|
15
15
|
|
|
16
|
+
/** @type {boolean} */
|
|
17
|
+
subwayEntrance = false;
|
|
18
|
+
|
|
16
19
|
/** @type {Edge[]} */
|
|
17
20
|
edges = [];
|
|
18
21
|
|
|
@@ -221,6 +224,9 @@ class Node {
|
|
|
221
224
|
if (this.name !== null) {
|
|
222
225
|
output.name = this.name;
|
|
223
226
|
}
|
|
227
|
+
if (this.subwayEntrance !== null) {
|
|
228
|
+
output.subwayEntrance = this.subwayEntrance;
|
|
229
|
+
}
|
|
224
230
|
return output;
|
|
225
231
|
}
|
|
226
232
|
|
|
@@ -231,6 +237,9 @@ class Node {
|
|
|
231
237
|
if (properties.name) {
|
|
232
238
|
this.name = properties.name;
|
|
233
239
|
}
|
|
240
|
+
if (properties.subwayEntrance) {
|
|
241
|
+
this.subwayEntrance = properties.subwayEntrance;
|
|
242
|
+
}
|
|
234
243
|
return this;
|
|
235
244
|
}
|
|
236
245
|
}
|
package/src/graph/Step.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Coordinates from '../coordinates/Coordinates.js';
|
|
2
2
|
|
|
3
3
|
import Edge from './Edge.js';
|
|
4
|
+
import LevelChange from './LevelChange.js';
|
|
4
5
|
import Node from './Node.js';
|
|
5
6
|
import { getDurationFromLength } from './Utils.js';
|
|
6
7
|
|
|
@@ -30,7 +31,7 @@ class Step {
|
|
|
30
31
|
/** @type {boolean} */
|
|
31
32
|
lastStep = false;
|
|
32
33
|
|
|
33
|
-
/** @type {
|
|
34
|
+
/** @type {LevelChange} */
|
|
34
35
|
levelChange = null;
|
|
35
36
|
|
|
36
37
|
/** @type {number} */
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
/* eslint-disable complexity */
|
|
1
2
|
/* eslint-disable max-statements */
|
|
2
3
|
import {
|
|
3
4
|
diffAngle, deg2rad
|
|
4
5
|
} from '@wemap/maths';
|
|
5
6
|
|
|
6
7
|
import Coordinates from '../coordinates/Coordinates.js';
|
|
7
|
-
import Level from '../coordinates/Level.js';
|
|
8
8
|
import Itinerary from './Itinerary.js';
|
|
9
|
+
import LevelChange from './LevelChange.js';
|
|
9
10
|
|
|
10
11
|
import Step from './Step.js';
|
|
11
12
|
|
|
@@ -52,7 +53,7 @@ class StepsGeneration {
|
|
|
52
53
|
const splitStepCondition = splitByAngle || splitByLevel;
|
|
53
54
|
|
|
54
55
|
// New step creation
|
|
55
|
-
if (isFirstStep || splitStepCondition) {
|
|
56
|
+
if (isFirstStep || splitStepCondition || node.isSubwayEntrance()) {
|
|
56
57
|
|
|
57
58
|
previousStep = currentStep;
|
|
58
59
|
|
|
@@ -63,11 +64,7 @@ class StepsGeneration {
|
|
|
63
64
|
currentStep.nextBearing = bearing;
|
|
64
65
|
|
|
65
66
|
if (splitByLevel) {
|
|
66
|
-
|
|
67
|
-
currentStep.levelChange = {
|
|
68
|
-
direction: diff > 0 ? 'up' : 'down',
|
|
69
|
-
diff
|
|
70
|
-
};
|
|
67
|
+
currentStep.levelChange = LevelChange.fromTwoNodes(node, nextNode);
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
currentStep.nodes.push(node);
|