atriusmaps-node-sdk 1.0.0 → 3.2.28
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/README.md +76 -0
- package/config/rollup.config.cjs.js +31 -0
- package/dist/cjs/_virtual/_empty_module_placeholder.js +5 -0
- package/dist/cjs/deploy/nodeEntry.js +15 -0
- package/dist/cjs/deploy/prepareSDKConfig.js +9 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/package.json.js +11 -0
- package/dist/cjs/plugins/clientAPI/src/clientAPI.js +9 -0
- package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +33 -0
- package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +36 -0
- package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +31 -0
- package/dist/cjs/plugins/sdkServer/src/sdkServer.js +13 -0
- package/dist/cjs/plugins/sdkServer/src/util.js +10 -0
- package/dist/cjs/plugins/searchService/src/poiSearch.js +28 -0
- package/dist/cjs/plugins/searchService/src/searchService.js +37 -0
- package/dist/cjs/plugins/searchService/src/searchTypeahead.js +8 -0
- package/dist/cjs/plugins/searchService/src/utils.js +13 -0
- package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +36 -0
- package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +34 -0
- package/dist/cjs/plugins/wayfinder/src/findRoute.js +30 -0
- package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +5 -0
- package/dist/cjs/plugins/wayfinder/src/navGraph.js +13 -0
- package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +30 -0
- package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +5 -0
- package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +32 -0
- package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +5 -0
- package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +10 -0
- package/dist/cjs/plugins/wayfinder/src/wayfinder.js +40 -0
- package/dist/cjs/src/app.js +44 -0
- package/dist/cjs/src/auth/Auth.js +23 -0
- package/dist/cjs/src/configs/postproc-mol-url-parms.js +9 -0
- package/dist/cjs/src/configs/postproc-stateTracking.js +31 -0
- package/dist/cjs/src/configs/sdkHeadless.json.js +47 -0
- package/dist/cjs/src/controller.js +14 -0
- package/dist/cjs/src/debugTools.js +30 -0
- package/dist/cjs/src/env.js +7 -0
- package/dist/cjs/src/extModules/bustle.js +13 -0
- package/dist/cjs/src/extModules/flexapi/src/help.js +9 -0
- package/dist/cjs/src/extModules/flexapi/src/index.js +13 -0
- package/dist/cjs/src/extModules/flexapi/src/validate.js +10 -0
- package/dist/cjs/src/extModules/geohasher.js +8 -0
- package/dist/cjs/src/extModules/log.js +7 -0
- package/dist/cjs/src/historyManager.js +7 -0
- package/dist/cjs/src/utils/bounds.js +10 -0
- package/dist/cjs/src/utils/buildStructureLookup.js +29 -0
- package/dist/cjs/src/utils/configUtils.js +8 -0
- package/dist/cjs/src/utils/dom.js +10 -0
- package/dist/cjs/src/utils/funcs.js +15 -0
- package/dist/cjs/src/utils/geodesy.js +8 -0
- package/dist/cjs/src/utils/geom.js +35 -0
- package/dist/cjs/src/utils/i18n.js +14 -0
- package/dist/cjs/src/utils/observable.js +5 -0
- package/dist/cjs/src/utils/rand.js +8 -0
- package/lib/_virtual/_empty_module_placeholder.js +1 -0
- package/lib/deploy/nodeEntry.js +1 -58
- package/lib/deploy/prepareSDKConfig.js +1 -112
- package/lib/package.json.js +1 -143
- package/lib/plugins/clientAPI/src/clientAPI.js +1 -14
- package/lib/plugins/dynamicPois/src/dynamicPois.js +1 -131
- package/lib/plugins/poiDataManager/src/poiDataManager.js +1 -207
- package/lib/plugins/sdkServer/src/sdkHeadless.js +1 -53
- package/lib/plugins/sdkServer/src/sdkServer.js +1 -211
- package/lib/plugins/sdkServer/src/util.js +1 -18
- package/lib/plugins/searchService/src/poiSearch.js +1 -39
- package/lib/plugins/searchService/src/searchService.js +1 -234
- package/lib/plugins/searchService/src/searchTypeahead.js +1 -63
- package/lib/plugins/searchService/src/utils.js +1 -30
- package/lib/plugins/venueDataLoader/src/venueDataLoader.js +1 -465
- package/lib/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -84
- package/lib/plugins/wayfinder/src/findRoute.js +1 -134
- package/lib/plugins/wayfinder/src/minPriorityQueue.js +1 -89
- package/lib/plugins/wayfinder/src/navGraph.js +1 -370
- package/lib/plugins/wayfinder/src/navGraphDebug.js +1 -95
- package/lib/plugins/wayfinder/src/segmentBadges.js +1 -29
- package/lib/plugins/wayfinder/src/segmentBuilder.js +1 -241
- package/lib/plugins/wayfinder/src/segmentCategories.js +1 -30
- package/lib/plugins/wayfinder/src/stepBuilder.js +1 -236
- package/lib/plugins/wayfinder/src/wayfinder.js +1 -452
- package/lib/src/app.js +1 -150
- package/lib/src/auth/Auth.js +1 -35
- package/lib/src/configs/postproc-mol-url-parms.js +1 -58
- package/lib/src/configs/postproc-stateTracking.js +1 -40
- package/lib/src/configs/sdkHeadless.json.js +1 -42
- package/lib/src/controller.js +1 -45
- package/lib/src/debugTools.js +1 -108
- package/lib/src/env.js +1 -17
- package/lib/src/extModules/bustle.js +1 -126
- package/lib/src/extModules/flexapi/src/help.js +1 -21
- package/lib/src/extModules/flexapi/src/index.js +1 -66
- package/lib/src/extModules/flexapi/src/validate.js +1 -131
- package/lib/src/extModules/geohasher.js +1 -90
- package/lib/src/extModules/log.js +1 -70
- package/lib/src/historyManager.js +1 -30
- package/lib/src/utils/bounds.js +1 -23
- package/lib/src/utils/buildStructureLookup.js +1 -17
- package/lib/src/utils/configUtils.js +1 -61
- package/lib/src/utils/dom.js +1 -46
- package/lib/src/utils/funcs.js +1 -50
- package/lib/src/utils/geodesy.js +1 -35
- package/lib/src/utils/geom.js +1 -141
- package/lib/src/utils/i18n.js +1 -70
- package/lib/src/utils/observable.js +1 -76
- package/lib/src/utils/rand.js +1 -82
- package/package.json +23 -6
- package/lib/_virtual/_empty_module_placeholder +0 -3
|
@@ -1,95 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Visits all nodes (breadth-first) from the nodes2visit
|
|
5
|
-
* array, adding them to vnodes and adding their connected
|
|
6
|
-
* nodes to nodes2visit - until nodes2visit is empty.
|
|
7
|
-
* Nothing is returned - but the vnodes array will have been
|
|
8
|
-
* altered.
|
|
9
|
-
* @param {Object.<id:node>} nodes - the node pool you wish to scan
|
|
10
|
-
* @param {Node} startingNode - which node to start the scan
|
|
11
|
-
*/
|
|
12
|
-
function visitAll (nodes, startingNode) {
|
|
13
|
-
// initialize nodes2visit with the specified node to start
|
|
14
|
-
const nodes2visit = [startingNode];
|
|
15
|
-
const vnodes = new Set(); // visited nodes
|
|
16
|
-
|
|
17
|
-
while (nodes2visit.length) {
|
|
18
|
-
const node = nodes2visit.splice(0, 1)[0]; // next node to visit
|
|
19
|
-
if (node && !vnodes.has(node)) {
|
|
20
|
-
vnodes.add(node);
|
|
21
|
-
node.edges.forEach(edge => {
|
|
22
|
-
if (!vnodes.has(nodes[edge.dst]))
|
|
23
|
-
nodes2visit.push(nodes[edge.dst]);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return vnodes
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @param {Object.<id:node>} nodes - the node pool you wish to scan
|
|
33
|
-
* @param {Node} [startingNode] - which node to start the scan (default: "first" node)
|
|
34
|
-
* @returns two arrays of nodes in an object, { orphaned, connected }
|
|
35
|
-
*/
|
|
36
|
-
function orphanTest (nodes, startingNode) {
|
|
37
|
-
const nodesArray = Object.values(nodes); // Convert to array
|
|
38
|
-
|
|
39
|
-
const vnodes = visitAll(nodes, startingNode || nodesArray[0]); // If no node is specified, use the first one we find
|
|
40
|
-
const onodes = nodesArray.filter(n => !vnodes.has(n));
|
|
41
|
-
|
|
42
|
-
console.log(`${onodes.length} Orphaned nodes found from ${nodesArray.length} total`);
|
|
43
|
-
|
|
44
|
-
return { orphaned: onodes, orphanedByFloor: R.groupBy(R.prop('floorId'), onodes), connected: Array.from(vnodes) }
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const enrichDebugNavGraph = (nodes) => ({
|
|
48
|
-
nodes: toOrphanedNodesArray(nodes),
|
|
49
|
-
edges: getNavEdgeFeatures(nodes)
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const transformNodes = isOrphaned =>
|
|
53
|
-
R.map(R.pipe(R.assoc('isOrphaned', isOrphaned), R.dissoc('edges')));
|
|
54
|
-
|
|
55
|
-
const toOrphanedNodesArray = R.pipe(
|
|
56
|
-
orphanTest,
|
|
57
|
-
R.pick(['connected', 'orphaned']),
|
|
58
|
-
R.evolve({
|
|
59
|
-
connected: transformNodes(false),
|
|
60
|
-
orphaned: transformNodes(true)
|
|
61
|
-
}),
|
|
62
|
-
R.values,
|
|
63
|
-
R.flatten
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const getNavEdgeFeatures = nodes =>
|
|
67
|
-
Object.values(nodes).flatMap(node => node.edges)
|
|
68
|
-
.map(edge => mapEdge(edge, nodes));
|
|
69
|
-
|
|
70
|
-
const mapEdge = ({ src, dst, type, isDriveway }, nodeMap) => ({
|
|
71
|
-
startCoordinates: [nodeMap[src].lng, nodeMap[src].lat],
|
|
72
|
-
endCoordinates: [nodeMap[dst].lng, nodeMap[dst].lat],
|
|
73
|
-
isDriveway,
|
|
74
|
-
ordinal: nodeMap[src].ordinal,
|
|
75
|
-
category: getEdgeCategory(type),
|
|
76
|
-
defaultStrokeColor: getStrokeColorForMissingCategory(type)
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const getStrokeColorForMissingCategory = R.cond([
|
|
80
|
-
[R.equals('Stairs'), R.always('#EFBC9B')],
|
|
81
|
-
[R.equals('Elevator'), R.always('#A491D3')],
|
|
82
|
-
[R.equals('Escalator'), R.always('#563F1B')],
|
|
83
|
-
[R.equals('Ramp'), R.always('#DBD053')],
|
|
84
|
-
[R.T, R.always('#FF0000')]
|
|
85
|
-
]);
|
|
86
|
-
|
|
87
|
-
const getEdgeCategory = R.cond([
|
|
88
|
-
[R.equals('Train'), R.always('nav.train')],
|
|
89
|
-
[R.equals('Bus'), R.always('nav.transit')],
|
|
90
|
-
[R.equals('Security Checkpoint'), R.always('nav.secure')],
|
|
91
|
-
[R.equals('Ground'), R.always('nav.primary')],
|
|
92
|
-
[R.T, R.always('')]
|
|
93
|
-
]);
|
|
94
|
-
|
|
95
|
-
export { enrichDebugNavGraph, orphanTest };
|
|
1
|
+
import*as a from"ramda";function e(e,s){const o=Object.values(e),n=function(a,e){const s=[e],o=new Set;for(;s.length;){const e=s.splice(0,1)[0];e&&!o.has(e)&&(o.add(e),e.edges.forEach((e=>{o.has(a[e.dst])||s.push(a[e.dst])})))}return o}(e,s||o[0]),r=o.filter((a=>!n.has(a)));return console.log(`${r.length} Orphaned nodes found from ${o.length} total`),{orphaned:r,orphanedByFloor:a.groupBy(a.prop("floorId"),r),connected:Array.from(n)}}const s=a=>({nodes:n(a),edges:r(a)}),o=e=>a.map(a.pipe(a.assoc("isOrphaned",e),a.dissoc("edges"))),n=a.pipe(e,a.pick(["connected","orphaned"]),a.evolve({connected:o(!1),orphaned:o(!0)}),a.values,a.flatten),r=a=>Object.values(a).flatMap((a=>a.edges)).map((e=>t(e,a))),t=({src:a,dst:e,type:s,isDriveway:o},n)=>({startCoordinates:[n[a].lng,n[a].lat],endCoordinates:[n[e].lng,n[e].lat],isDriveway:o,ordinal:n[a].ordinal,category:d(s),defaultStrokeColor:l(s)}),l=a.cond([[a.equals("Stairs"),a.always("#EFBC9B")],[a.equals("Elevator"),a.always("#A491D3")],[a.equals("Escalator"),a.always("#563F1B")],[a.equals("Ramp"),a.always("#DBD053")],[a.T,a.always("#FF0000")]]),d=a.cond([[a.equals("Train"),a.always("nav.train")],[a.equals("Bus"),a.always("nav.transit")],[a.equals("Security Checkpoint"),a.always("nav.secure")],[a.equals("Ground"),a.always("nav.primary")],[a.T,a.always("")]]);export{s as enrichDebugNavGraph,e as orphanTest};
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
START: 'wayfinding.start',
|
|
3
|
-
END: 'wayfinding.end',
|
|
4
|
-
WALKING_TO_SECURITY_CHECKPOINT: 'wayfinding.security',
|
|
5
|
-
ELEVATOR: 'wayfinding.elevator',
|
|
6
|
-
ELEVATOR_UP: 'wayfinding.elevator.up',
|
|
7
|
-
ELEVATOR_DOWN: 'wayfinding.elevator.down',
|
|
8
|
-
STAIRS: 'wayfinding.stairs',
|
|
9
|
-
STAIRS_UP: 'wayfinding.stairs.up',
|
|
10
|
-
STAIRS_DOWN: 'wayfinding.stairs.down',
|
|
11
|
-
ESCALATOR: 'wayfinding.escalator',
|
|
12
|
-
ESCALATOR_UP: 'wayfinding.escalator.up',
|
|
13
|
-
ESCALATOR_DOWN: 'wayfinding.escalator.down',
|
|
14
|
-
WALK: 'wayfinding.movingwalkway',
|
|
15
|
-
WALK_DOWN: 'walk.movingwalkway',
|
|
16
|
-
WALK_UP: 'walk.movingwalkway',
|
|
17
|
-
TRAIN: 'wayfinding.train',
|
|
18
|
-
TRAIN_UP: 'wayfinding.train.up',
|
|
19
|
-
TRAIN_DOWN: 'wayfinding.train.down',
|
|
20
|
-
BUS: 'wayfinding.bus',
|
|
21
|
-
BUS_UP: 'wayfinding.bus.up',
|
|
22
|
-
BUS_DOWN: 'wayfinding.bus.down',
|
|
23
|
-
SECURITY_CHECKPOINT: 'wayfinding.security',
|
|
24
|
-
RAMP: 'wayfinding.ramp',
|
|
25
|
-
RAMP_UP: 'wayfinding.ramp.up',
|
|
26
|
-
RAMP_DOWN: 'wayfinding.ramp.down'
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default segmentBadges;
|
|
1
|
+
const n={START:"wayfinding.start",END:"wayfinding.end",WALKING_TO_SECURITY_CHECKPOINT:"wayfinding.security",ELEVATOR:"wayfinding.elevator",ELEVATOR_UP:"wayfinding.elevator.up",ELEVATOR_DOWN:"wayfinding.elevator.down",STAIRS:"wayfinding.stairs",STAIRS_UP:"wayfinding.stairs.up",STAIRS_DOWN:"wayfinding.stairs.down",ESCALATOR:"wayfinding.escalator",ESCALATOR_UP:"wayfinding.escalator.up",ESCALATOR_DOWN:"wayfinding.escalator.down",WALK:"wayfinding.movingwalkway",WALK_DOWN:"walk.movingwalkway",WALK_UP:"walk.movingwalkway",TRAIN:"wayfinding.train",TRAIN_UP:"wayfinding.train.up",TRAIN_DOWN:"wayfinding.train.down",BUS:"wayfinding.bus",BUS_UP:"wayfinding.bus.up",BUS_DOWN:"wayfinding.bus.down",SECURITY_CHECKPOINT:"wayfinding.security",RAMP:"wayfinding.ramp",RAMP_UP:"wayfinding.ramp.up",RAMP_DOWN:"wayfinding.ramp.down"};export{n as default};
|
|
@@ -1,241 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { bezierCurveTo } from '../../../src/utils/geom.js';
|
|
3
|
-
import segmentCategories from './segmentCategories.js';
|
|
4
|
-
import getSteps from './stepBuilder.js';
|
|
5
|
-
|
|
6
|
-
const setSegmentCategory = (segments) => {
|
|
7
|
-
// Set the category of each segment based on the type of the current segment or the type of the next segment in case we are walking
|
|
8
|
-
// to a portal or to a security checkpoint
|
|
9
|
-
segments.forEach((segment, index) => {
|
|
10
|
-
if (index === 0)
|
|
11
|
-
segment.segmentCategory = segmentCategories.START;
|
|
12
|
-
else if (segment.waypoints[segment.waypoints.length - 1].isDestination)
|
|
13
|
-
segment.segmentCategory = segmentCategories.WALKING_TO_END;
|
|
14
|
-
else if (segment.type === 'Security Checkpoint')
|
|
15
|
-
segment.segmentCategory = segmentCategories.SECURITY_CHECKPOINT;
|
|
16
|
-
else if (segment.type === 'Bus')
|
|
17
|
-
segment.segmentCategory = segmentCategories.BUS;
|
|
18
|
-
else if (segment.type === 'Train')
|
|
19
|
-
segment.segmentCategory = segmentCategories.TRAIN;
|
|
20
|
-
else if (segment.type === 'Stairs') {
|
|
21
|
-
if (segment.levelDifference > 0)
|
|
22
|
-
segment.segmentCategory = segmentCategories.STAIRS_UP;
|
|
23
|
-
else if (segment.levelDifference < 0)
|
|
24
|
-
segment.segmentCategory = segmentCategories.STAIRS_DOWN;
|
|
25
|
-
else
|
|
26
|
-
segment.segmentCategory = segmentCategories.STAIRS;
|
|
27
|
-
} else if (segment.type === 'Elevator') {
|
|
28
|
-
if (segment.levelDifference > 0)
|
|
29
|
-
segment.segmentCategory = segmentCategories.ELEVATOR_UP;
|
|
30
|
-
else if (segment.levelDifference < 0)
|
|
31
|
-
segment.segmentCategory = segmentCategories.ELEVATOR_DOWN;
|
|
32
|
-
else
|
|
33
|
-
segment.segmentCategory = segmentCategories.ELEVATOR;
|
|
34
|
-
} else if (segment.type === 'Escalator') {
|
|
35
|
-
if (segment.levelDifference > 0)
|
|
36
|
-
segment.segmentCategory = segmentCategories.ESCALATOR_UP;
|
|
37
|
-
else if (segment.levelDifference < 0)
|
|
38
|
-
segment.segmentCategory = segmentCategories.ESCALATOR_DOWN;
|
|
39
|
-
else
|
|
40
|
-
segment.segmentCategory = segmentCategories.ESCALATOR;
|
|
41
|
-
} else if (segment.type === 'Ramp') {
|
|
42
|
-
if (segment.levelDifference > 0)
|
|
43
|
-
segment.segmentCategory = segmentCategories.RAMP_UP;
|
|
44
|
-
else if (segment.levelDifference < 0)
|
|
45
|
-
segment.segmentCategory = segmentCategories.RAMP_DOWN;
|
|
46
|
-
else
|
|
47
|
-
segment.segmentCategory = segmentCategories.RAMP;
|
|
48
|
-
} else if (segments[index + 1].type === 'Security Checkpoint')
|
|
49
|
-
segment.segmentCategory = segmentCategories.WALKING_TO_SECURITY_CHECKPOINT;
|
|
50
|
-
else if (segments[index + 1].type !== 'Walk')
|
|
51
|
-
segment.segmentCategory = segmentCategories.WALKING_TO_PORTAL;
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const existsEnd = (segments, lastWaypoint) => {
|
|
56
|
-
// if we have only one segment, add an extra segment with only the last point to simulate the end,
|
|
57
|
-
// that way we can draw separate markers for the start and the end of the navigation
|
|
58
|
-
if (segments.length === 1) {
|
|
59
|
-
const segment = { segmentCategory: undefined, waypoints: [] };
|
|
60
|
-
segment.segmentCategory = segmentCategories.WALKING_TO_END;
|
|
61
|
-
segment.type = 'Walk';
|
|
62
|
-
segment.waypoints = [lastWaypoint];
|
|
63
|
-
segments.push(segment);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// todo refactor to not affect step builder
|
|
68
|
-
const joinSegments = (segments) => {
|
|
69
|
-
segments.forEach((segment, index) => {
|
|
70
|
-
if (index > 1) {
|
|
71
|
-
const firstWaypointOfSegment = R.head(segment.waypoints);
|
|
72
|
-
if (firstWaypointOfSegment.levelDifference === 0) {
|
|
73
|
-
const lastWaypointOfPreviousSegment = R.last(segments[index - 1].waypoints);
|
|
74
|
-
segment.waypoints = R.prepend(lastWaypointOfPreviousSegment, segment.waypoints);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const calculateCurveLineCoordinates = segment =>
|
|
81
|
-
segment.waypoints.flatMap((waypoint, index) => {
|
|
82
|
-
// todo index > 0 is hacky fix
|
|
83
|
-
if (index > 0 && waypoint.curvedPathForward && waypoint.curvedPathForward.length > 0) {
|
|
84
|
-
return waypoint.curvedPathForward
|
|
85
|
-
.flatMap(p => bezierCurveTo(p.start.lng, p.start.lat, p.in.lng, p.in.lat, p.out.lng, p.out.lat, p.end.lng, p.end.lat))
|
|
86
|
-
.map(el => [el.x, el.y])
|
|
87
|
-
} else {
|
|
88
|
-
return [[waypoint.position.lng, waypoint.position.lat]]
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const addCurveLineCoordinates = R.map(
|
|
93
|
-
R.converge(R.assoc('coordinates'), [calculateCurveLineCoordinates, R.identity]));
|
|
94
|
-
|
|
95
|
-
// todo refactor
|
|
96
|
-
const createSegments = (waypoints) => {
|
|
97
|
-
const segments = [];
|
|
98
|
-
let segment = { segmentCategory: undefined, waypoints: [] };
|
|
99
|
-
let lastWaypoint = null;
|
|
100
|
-
let segmentWaypoints = [];
|
|
101
|
-
|
|
102
|
-
// Always add the first point to be the start of the route
|
|
103
|
-
segment.waypoints = [waypoints[0]];
|
|
104
|
-
segment.type = waypoints[0].isPortal ? waypoints[0].portalType : 'Walk';
|
|
105
|
-
segments.push(segment);
|
|
106
|
-
segment = { segmentCategory: undefined, waypoints: [] };
|
|
107
|
-
|
|
108
|
-
waypoints.forEach((waypoint) => {
|
|
109
|
-
segmentWaypoints.push(waypoint);
|
|
110
|
-
|
|
111
|
-
if (!lastWaypoint) {
|
|
112
|
-
segment.type = waypoint.isPortal ? waypoint.portalType : 'Walk';
|
|
113
|
-
lastWaypoint = waypoint;
|
|
114
|
-
} else {
|
|
115
|
-
if ((lastWaypoint.isPortal === waypoint.isPortal) &&
|
|
116
|
-
(lastWaypoint.isSecurityCheckpoint === waypoint.isSecurityCheckpoint)) { // todo not sure if this can happen
|
|
117
|
-
segment.levelDifference = waypoint.levelDifference;
|
|
118
|
-
} else {
|
|
119
|
-
segment.waypoints = segmentWaypoints;
|
|
120
|
-
|
|
121
|
-
if (waypoint.isPortal || lastWaypoint.isPortal) {
|
|
122
|
-
if (segmentWaypoints.length > 1)
|
|
123
|
-
segmentWaypoints.pop();
|
|
124
|
-
|
|
125
|
-
// if the portal is not train or bus, we only want it to be one point segment
|
|
126
|
-
if (waypoint.isPortal && (waypoint.portalType.toLowerCase() === 'train' || waypoint.portalType.toLowerCase() === 'bus'))
|
|
127
|
-
segmentWaypoints = [segmentWaypoints[segmentWaypoints.length - 1], waypoint];
|
|
128
|
-
else
|
|
129
|
-
segmentWaypoints = [waypoint];
|
|
130
|
-
} else
|
|
131
|
-
segmentWaypoints = [];
|
|
132
|
-
|
|
133
|
-
segments.push(segment);
|
|
134
|
-
|
|
135
|
-
segment = { segmentCategory: undefined, waypoints: [] };
|
|
136
|
-
|
|
137
|
-
segment.type = waypoint.isPortal ? waypoint.portalType : 'Walk';
|
|
138
|
-
segment.levelDifference = waypoint.levelDifference;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
lastWaypoint = waypoint;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
segment.waypoints = segmentWaypoints;
|
|
146
|
-
|
|
147
|
-
if (segmentWaypoints.length === 0)
|
|
148
|
-
segment.waypoints = [lastWaypoint];
|
|
149
|
-
|
|
150
|
-
segments.push(segment);
|
|
151
|
-
|
|
152
|
-
setSegmentCategory(segments);
|
|
153
|
-
|
|
154
|
-
existsEnd(segments, lastWaypoint);
|
|
155
|
-
|
|
156
|
-
joinSegments(segments);
|
|
157
|
-
|
|
158
|
-
return segments
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const getSegmentType = (segment) => {
|
|
162
|
-
if (segment.type === 'Train') {
|
|
163
|
-
return 'nav.train'
|
|
164
|
-
}
|
|
165
|
-
if (segment.type === 'Bus') {
|
|
166
|
-
return 'nav.transit'
|
|
167
|
-
}
|
|
168
|
-
if (segment.type === 'Security Checkpoint') {
|
|
169
|
-
return 'nav.secure'
|
|
170
|
-
}
|
|
171
|
-
return 'nav.primary'
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
*
|
|
176
|
-
* @typedef Badge
|
|
177
|
-
* @property {string} canonicalName
|
|
178
|
-
* @property {Coordinate} coordinates
|
|
179
|
-
*
|
|
180
|
-
* @typedef Segment
|
|
181
|
-
* @property {string} levelId
|
|
182
|
-
* @property {string} ordinalId
|
|
183
|
-
* @property {string} segmentType
|
|
184
|
-
* @property {Boolean} shouldDrawSegment - to not show edges like stairs or elevator
|
|
185
|
-
* @property {Array.<Coordinate>} coordinates - list of coordinate pairs [lng, lat]
|
|
186
|
-
* @property {Array<Badge>} badges
|
|
187
|
-
*
|
|
188
|
-
* @param {Waypoint} waypoints
|
|
189
|
-
* @param {Endpoint} fromEndpoint
|
|
190
|
-
* @param {Endpoint} toEndpoint
|
|
191
|
-
* @param {Object.<string, string>} floorIdToNameMap - dictionary of floor id to floor name
|
|
192
|
-
* @param T - i18n translations function
|
|
193
|
-
* @param {QueueTypes} queueTypes
|
|
194
|
-
* @return {{steps: Step[], segments: Segment[]}}
|
|
195
|
-
*/
|
|
196
|
-
const buildSegments = (waypoints, fromEndpoint, toEndpoint, floorIdToNameMap, T, queueTypes) => {
|
|
197
|
-
let rawSegments = createSegments(waypoints);
|
|
198
|
-
rawSegments = addCurveLineCoordinates(rawSegments);
|
|
199
|
-
|
|
200
|
-
// add start location (kiosk) as first coordinate to link it with the navline
|
|
201
|
-
if (fromEndpoint)
|
|
202
|
-
rawSegments[0].coordinates.unshift([fromEndpoint.lng, fromEndpoint.lat]);
|
|
203
|
-
|
|
204
|
-
if (toEndpoint)
|
|
205
|
-
R.last(rawSegments).coordinates.push([toEndpoint.lng, toEndpoint.lat]);
|
|
206
|
-
|
|
207
|
-
const segments = rawSegments.map((segment, index) => {
|
|
208
|
-
const startWaypoint = R.last(segment.waypoints);
|
|
209
|
-
const coordinates = segment.coordinates;
|
|
210
|
-
const shouldDrawSegment = !(segment.levelDifference && segment.waypoints.every(R.prop('isPortal')));
|
|
211
|
-
|
|
212
|
-
const badges = [];
|
|
213
|
-
if (segmentCategories.WALKING_TO_PORTAL === segment.segmentCategory) {
|
|
214
|
-
const nextSegment = rawSegments[index + 1];
|
|
215
|
-
badges.push({
|
|
216
|
-
canonicalName: `wayfinding.${nextSegment.segmentCategory}`,
|
|
217
|
-
coordinates: R.last(coordinates)
|
|
218
|
-
});
|
|
219
|
-
} else if (segmentCategories.START !== segment.segmentCategory) {
|
|
220
|
-
badges.push({
|
|
221
|
-
canonicalName: `wayfinding.${segment.segmentCategory}`,
|
|
222
|
-
coordinates: R.last(coordinates)
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
const segmentType = getSegmentType(segment);
|
|
226
|
-
return {
|
|
227
|
-
levelId: startWaypoint.position.structureId,
|
|
228
|
-
ordinalId: `ordinal: ${startWaypoint.position.ordinal}`,
|
|
229
|
-
coordinates,
|
|
230
|
-
segmentType,
|
|
231
|
-
badges,
|
|
232
|
-
shouldDrawSegment
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
const steps = getSteps(rawSegments, R.prop('title', fromEndpoint), R.prop('title', toEndpoint), floorIdToNameMap, T, queueTypes);
|
|
237
|
-
|
|
238
|
-
return { segments, steps }
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
export { buildSegments };
|
|
1
|
+
import*as e from"ramda";import{bezierCurveTo as t}from"../../../src/utils/geom.js";import o from"./segmentCategories.js";import a from"./stepBuilder.js";const n=e.map(e.converge(e.assoc("coordinates"),[e=>e.waypoints.flatMap(((e,o)=>o>0&&e.curvedPathForward&&e.curvedPathForward.length>0?e.curvedPathForward.flatMap((e=>t(e.start.lng,e.start.lat,e.in.lng,e.in.lat,e.out.lng,e.out.lat,e.end.lng,e.end.lat))).map((e=>[e.x,e.y])):[[e.position.lng,e.position.lat]])),e.identity])),r=t=>{const a=[];let n={segmentCategory:void 0,waypoints:[]},r=null,s=[];return n.waypoints=[t[0]],n.type=t[0].isPortal?t[0].portalType:"Walk",a.push(n),n={segmentCategory:void 0,waypoints:[]},t.forEach((e=>{s.push(e),r?(r.isPortal===e.isPortal&&r.isSecurityCheckpoint===e.isSecurityCheckpoint||(n.waypoints=s,e.isPortal||r.isPortal?(s.length>1&&s.pop(),s=!e.isPortal||"train"!==e.portalType.toLowerCase()&&"bus"!==e.portalType.toLowerCase()?[e]:[s[s.length-1],e]):s=[],r.poiId&&(n.poiId=r.poiId),a.push(n),n={segmentCategory:void 0,waypoints:[]},n.type=e.isPortal?e.portalType:"Walk"),n.levelDifference=e.levelDifference,r=e):(n.type=e.isPortal?e.portalType:"Walk",r=e)})),n.waypoints=s,0===s.length&&(n.waypoints=[r]),a.push(n),(e=>{e.forEach(((t,a)=>{0===a?t.segmentCategory=o.START:t.waypoints[t.waypoints.length-1].isDestination?t.segmentCategory=o.WALKING_TO_END:"Security Checkpoint"===t.type?t.segmentCategory=o.SECURITY_CHECKPOINT:"Bus"===t.type?t.segmentCategory=o.BUS:"Train"===t.type?t.segmentCategory=o.TRAIN:"Stairs"===t.type?t.levelDifference>0?t.segmentCategory=o.STAIRS_UP:t.levelDifference<0?t.segmentCategory=o.STAIRS_DOWN:t.segmentCategory=o.STAIRS:"Elevator"===t.type?t.levelDifference>0?t.segmentCategory=o.ELEVATOR_UP:t.levelDifference<0?t.segmentCategory=o.ELEVATOR_DOWN:t.segmentCategory=o.ELEVATOR:"Escalator"===t.type?t.levelDifference>0?t.segmentCategory=o.ESCALATOR_UP:t.levelDifference<0?t.segmentCategory=o.ESCALATOR_DOWN:t.segmentCategory=o.ESCALATOR:"Ramp"===t.type?t.levelDifference>0?t.segmentCategory=o.RAMP_UP:t.levelDifference<0?t.segmentCategory=o.RAMP_DOWN:t.segmentCategory=o.RAMP:"Security Checkpoint"===e[a+1].type?t.segmentCategory=o.WALKING_TO_SECURITY_CHECKPOINT:"Walk"!==e[a+1].type&&(t.segmentCategory=o.WALKING_TO_PORTAL)}))})(a),((e,t)=>{if(1===e.length){const a={segmentCategory:void 0,waypoints:[]};a.segmentCategory=o.WALKING_TO_END,a.type="Walk",a.waypoints=[t],e.push(a)}})(a,r),(t=>{t.forEach(((o,a)=>{if(a>1&&0===e.head(o.waypoints).levelDifference){const n=e.last(t[a-1].waypoints);o.waypoints=e.prepend(n,o.waypoints)}}))})(a),a},s=(t,s,i,p,l,g)=>{let y=r(t);y=n(y),s&&y[0].coordinates.unshift([s.lng,s.lat]),i&&e.last(y).coordinates.push([i.lng,i.lat]);return{segments:y.map(((t,a)=>{const n=e.last(t.waypoints),r=t.coordinates,s=!(t.levelDifference&&t.waypoints.every(e.prop("isPortal"))),i={levelId:n.position.structureId,ordinalId:`ordinal: ${n.position.ordinal}`,coordinates:r,shouldDrawSegment:s},p=[];if(o.WALKING_TO_PORTAL===t.segmentCategory){const t=y[a+1];p.push({canonicalName:`wayfinding.${t.segmentCategory}`,coordinates:e.last(r)})}else o.START!==t.segmentCategory&&p.push({canonicalName:`wayfinding.${t.segmentCategory}`,coordinates:e.last(r)});return i.badges=p,i.segmentType=(e=>"Train"===e.type?"nav.train":"Bus"===e.type?"nav.transit":"Security Checkpoint"===e.type?"nav.secure":"nav.primary")(t),t.poiId&&(i.poiId=t.poiId),i})),steps:a(y,e.prop("title",s),e.prop("title",i),p,l,g)}};export{s as buildSegments};
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
START: 'start',
|
|
3
|
-
WALKING_TO_SECURITY_CHECKPOINT: 'walking to security checkpoint',
|
|
4
|
-
WALKING_TO_PORTAL: 'walking to portal',
|
|
5
|
-
WALKING_TO_END: 'walking to end',
|
|
6
|
-
ELEVATOR: 'elevator',
|
|
7
|
-
ELEVATOR_UP: 'elevator.up',
|
|
8
|
-
ELEVATOR_DOWN: 'elevator.down',
|
|
9
|
-
STAIRS: 'stairs',
|
|
10
|
-
STAIRS_UP: 'stairs.up',
|
|
11
|
-
STAIRS_DOWN: 'stairs.down',
|
|
12
|
-
ESCALATOR: 'escalator',
|
|
13
|
-
ESCALATOR_UP: 'escalator.up',
|
|
14
|
-
ESCALATOR_DOWN: 'escalator.down',
|
|
15
|
-
WALK: 'walk',
|
|
16
|
-
WALK_DOWN: 'walk.down',
|
|
17
|
-
WALK_UP: 'walk.up',
|
|
18
|
-
TRAIN: 'train',
|
|
19
|
-
TRAIN_UP: 'train.up',
|
|
20
|
-
TRAIN_DOWN: 'train.down',
|
|
21
|
-
BUS: 'bus',
|
|
22
|
-
BUS_UP: 'bus.up',
|
|
23
|
-
BUS_DOWN: 'bus.down',
|
|
24
|
-
SECURITY_CHECKPOINT: 'enduring security checkpoint',
|
|
25
|
-
RAMP: 'ramp',
|
|
26
|
-
RAMP_UP: 'ramp.up',
|
|
27
|
-
RAMP_DOWN: 'ramp.down'
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default segmentCategories;
|
|
1
|
+
const a={START:"start",WALKING_TO_SECURITY_CHECKPOINT:"walking to security checkpoint",WALKING_TO_PORTAL:"walking to portal",WALKING_TO_END:"walking to end",ELEVATOR:"elevator",ELEVATOR_UP:"elevator.up",ELEVATOR_DOWN:"elevator.down",STAIRS:"stairs",STAIRS_UP:"stairs.up",STAIRS_DOWN:"stairs.down",ESCALATOR:"escalator",ESCALATOR_UP:"escalator.up",ESCALATOR_DOWN:"escalator.down",WALK:"walk",WALK_DOWN:"walk.down",WALK_UP:"walk.up",TRAIN:"train",TRAIN_UP:"train.up",TRAIN_DOWN:"train.down",BUS:"bus",BUS_UP:"bus.up",BUS_DOWN:"bus.down",SECURITY_CHECKPOINT:"enduring security checkpoint",RAMP:"ramp",RAMP_UP:"ramp.up",RAMP_DOWN:"ramp.down"};export{a as default};
|
|
@@ -1,236 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { findBoundsOfWaypoints } from '../../../src/utils/bounds.js';
|
|
3
|
-
import segmentBadges from './segmentBadges.js';
|
|
4
|
-
import segmentCategories from './segmentCategories.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef Step
|
|
8
|
-
* @property {string} primaryText
|
|
9
|
-
* @property {string} secondaryText
|
|
10
|
-
* @property {string} icon
|
|
11
|
-
* @property {Position} animationAnchor
|
|
12
|
-
* @property {number} eta
|
|
13
|
-
* @property {number} distance
|
|
14
|
-
* @property {boolean} isAccessible
|
|
15
|
-
* @property {Bounds} bounds
|
|
16
|
-
* @property {SecurityWaitTime} securityWaitTimes
|
|
17
|
-
*
|
|
18
|
-
* @typedef Position
|
|
19
|
-
* @property {number} lat
|
|
20
|
-
* @property {number} lng
|
|
21
|
-
* @property {string} floorId
|
|
22
|
-
* @property {number} ordinal
|
|
23
|
-
* @property {string} structureId
|
|
24
|
-
*
|
|
25
|
-
* @param {Segment[]} segments
|
|
26
|
-
* @param {string} startName
|
|
27
|
-
* @param {string} destinationName
|
|
28
|
-
* @param floorIdToNameMap
|
|
29
|
-
* @param {function} T - translate function
|
|
30
|
-
* @param {QueueTypes} queueTypes
|
|
31
|
-
* @return {Step[]} steps - list of navigation steps
|
|
32
|
-
*/
|
|
33
|
-
function getSteps (segments, startName = '', destinationName = '', floorIdToNameMap, T, queueTypes = {}) {
|
|
34
|
-
return segments.map((segment, index) => {
|
|
35
|
-
const securityWaitTimes = findPropWaypoints('securityWaitTimes')(segment.waypoints);
|
|
36
|
-
const eta = (securityWaitTimes && !securityWaitTimes.isTemporarilyClosed) // if there is dynamic wait time and checkpoint is open, then use it
|
|
37
|
-
? securityWaitTimes.queueTime
|
|
38
|
-
: Math.round(calculateSegmentEta(segment.waypoints));
|
|
39
|
-
const distance = Math.round(calculateSegmentDistance(segment.waypoints));
|
|
40
|
-
const icon = getIcon(segment.segmentCategory);
|
|
41
|
-
const animationAnchor = getAnimationAnchor(segment.segmentCategory, segment.waypoints);
|
|
42
|
-
const primaryText = getPrimaryText(segments, index, startName, destinationName, floorIdToNameMap, T);
|
|
43
|
-
const securityLaneName = getSecurityLaneName(queueTypes, segment.waypoints);
|
|
44
|
-
const secondaryText = getSecondaryText(segment, eta, securityLaneName, T);
|
|
45
|
-
const bounds = findBoundsOfWaypoints(segment.waypoints);
|
|
46
|
-
const isAccessible = checkIfAccessible(segment);
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
primaryText,
|
|
50
|
-
secondaryText,
|
|
51
|
-
icon,
|
|
52
|
-
animationAnchor,
|
|
53
|
-
eta,
|
|
54
|
-
distance,
|
|
55
|
-
bounds,
|
|
56
|
-
isAccessible,
|
|
57
|
-
securityWaitTimes
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function calculateSegmentEta (waypoints) {
|
|
63
|
-
if (waypoints.length === 1) return waypoints[0].eta // for stairs/elevator segments. should be removed once segment builder will be refactored to not append waypoint from previous semgnent
|
|
64
|
-
return waypoints
|
|
65
|
-
.map(prop('eta'))
|
|
66
|
-
.slice(1) // first waypoint is end of previous segment and is added only to connect segments for navline calculation
|
|
67
|
-
.reduce((segmentEta, eta) => segmentEta + eta, 0.0)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function calculateSegmentDistance (waypoints) {
|
|
71
|
-
if (waypoints.length === 1) return waypoints[0].distance // for stairs/elevator segments. should be removed once segment builder will be refactored to not append waypoint from previous semgnent
|
|
72
|
-
return waypoints
|
|
73
|
-
.map(waypoint => waypoint.distance)
|
|
74
|
-
.slice(1) // first waypoint is end of previous segment and is added only to connect segments for navline calculation
|
|
75
|
-
.reduce((segmentDistance, distance) => segmentDistance + distance, 0.0)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function getIcon (segmentCategory) {
|
|
79
|
-
switch (segmentCategory) {
|
|
80
|
-
case segmentCategories.START:
|
|
81
|
-
return segmentBadges.START
|
|
82
|
-
case segmentCategories.WALKING_TO_END:
|
|
83
|
-
return segmentBadges.END
|
|
84
|
-
case segmentCategories.ELEVATOR:
|
|
85
|
-
return segmentBadges.ELEVATOR
|
|
86
|
-
case segmentCategories.ELEVATOR_UP:
|
|
87
|
-
return segmentBadges.ELEVATOR_UP
|
|
88
|
-
case segmentCategories.ELEVATOR_DOWN:
|
|
89
|
-
return segmentBadges.ELEVATOR_DOWN
|
|
90
|
-
case segmentCategories.STAIRS:
|
|
91
|
-
return segmentBadges.STAIRS
|
|
92
|
-
case segmentCategories.STAIRS_UP:
|
|
93
|
-
return segmentBadges.STAIRS_UP
|
|
94
|
-
case segmentCategories.STAIRS_DOWN:
|
|
95
|
-
return segmentBadges.STAIRS_DOWN
|
|
96
|
-
case segmentCategories.ESCALATOR:
|
|
97
|
-
return segmentBadges.ESCALATOR
|
|
98
|
-
case segmentCategories.ESCALATOR_UP:
|
|
99
|
-
return segmentBadges.ESCALATOR_UP
|
|
100
|
-
case segmentCategories.ESCALATOR_DOWN:
|
|
101
|
-
return segmentBadges.ESCALATOR_DOWN
|
|
102
|
-
case segmentCategories.WALKING_TO_PORTAL:
|
|
103
|
-
case segmentCategories.WALK:
|
|
104
|
-
case segmentCategories.WALK_DOWN:
|
|
105
|
-
case segmentCategories.WALK_UP:
|
|
106
|
-
return segmentBadges.WALK
|
|
107
|
-
case segmentCategories.TRAIN:
|
|
108
|
-
return segmentBadges.TRAIN
|
|
109
|
-
case segmentCategories.TRAIN_UP:
|
|
110
|
-
return segmentBadges.TRAIN_UP
|
|
111
|
-
case segmentCategories.TRAIN_DOWN:
|
|
112
|
-
return segmentBadges.TRAIN_DOWN
|
|
113
|
-
case segmentCategories.BUS:
|
|
114
|
-
return segmentBadges.BUS
|
|
115
|
-
case segmentCategories.BUS_UP:
|
|
116
|
-
return segmentBadges.BUS_UP
|
|
117
|
-
case segmentCategories.BUS_DOWN:
|
|
118
|
-
return segmentBadges.BUS_DOWN
|
|
119
|
-
case segmentCategories.SECURITY_CHECKPOINT:
|
|
120
|
-
return segmentBadges.SECURITY_CHECKPOINT
|
|
121
|
-
case segmentCategories.RAMP:
|
|
122
|
-
return segmentBadges.RAMP
|
|
123
|
-
case segmentCategories.RAMP_UP:
|
|
124
|
-
return segmentBadges.RAMP_UP
|
|
125
|
-
case segmentCategories.RAMP_DOWN:
|
|
126
|
-
return segmentBadges.RAMP_DOWN
|
|
127
|
-
default:
|
|
128
|
-
return segmentBadges.WALK
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function getAnimationAnchor (segmentCategory, waypoints) {
|
|
133
|
-
let index;
|
|
134
|
-
switch (segmentCategory) {
|
|
135
|
-
case segmentCategories.START:
|
|
136
|
-
index = 0;
|
|
137
|
-
break
|
|
138
|
-
case segmentCategories.WALKING_TO_END:
|
|
139
|
-
index = waypoints.length - 1;
|
|
140
|
-
break
|
|
141
|
-
case segmentCategories.WALKING_TO_PORTAL:
|
|
142
|
-
index = Math.min(waypoints.length - 1, Math.ceil(waypoints.length / 2));
|
|
143
|
-
break
|
|
144
|
-
default:
|
|
145
|
-
index = waypoints.length - 1;
|
|
146
|
-
}
|
|
147
|
-
return waypoints[index].position
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function getPrimaryText (segments, index, startName, destinationName, floorIdToNameMap, T) {
|
|
151
|
-
const segment = segments[index];
|
|
152
|
-
switch (segment.segmentCategory) {
|
|
153
|
-
case segmentCategories.START:
|
|
154
|
-
return getPositionName(segment.waypoints[0].position, startName)
|
|
155
|
-
case segmentCategories.WALKING_TO_END:
|
|
156
|
-
return getPositionName(segment.waypoints[segment.waypoints.length - 1].position, destinationName)
|
|
157
|
-
case segmentCategories.WALKING_TO_SECURITY_CHECKPOINT:
|
|
158
|
-
case segmentCategories.WALKING_TO_PORTAL:
|
|
159
|
-
return T(`wayfinder:${segments[index + 1].type}`)
|
|
160
|
-
case segmentCategories.SECURITY_CHECKPOINT:
|
|
161
|
-
case segmentCategories.ELEVATOR:
|
|
162
|
-
case segmentCategories.ELEVATOR_DOWN:
|
|
163
|
-
case segmentCategories.ELEVATOR_UP:
|
|
164
|
-
case segmentCategories.ESCALATOR:
|
|
165
|
-
case segmentCategories.ESCALATOR_DOWN:
|
|
166
|
-
case segmentCategories.ESCALATOR_UP:
|
|
167
|
-
case segmentCategories.STAIRS:
|
|
168
|
-
case segmentCategories.STAIRS_DOWN:
|
|
169
|
-
case segmentCategories.STAIRS_UP:
|
|
170
|
-
return getLevelName(segment, floorIdToNameMap)
|
|
171
|
-
default: return T(`wayfinder:${segment.type}`)
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function getPositionName (position, poiName) {
|
|
176
|
-
if (position.name) { return position.name }
|
|
177
|
-
return poiName
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function getLevelName (segment, floorIdToNameMap) {
|
|
181
|
-
return floorIdToNameMap[last(segment.waypoints).position.floorId]
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function getSecondaryText (segment, minutes, securityLaneName, T) {
|
|
185
|
-
const zeroOrOtherKeys = translateZeroOrOther(minutes, T);
|
|
186
|
-
switch (segment.segmentCategory) {
|
|
187
|
-
case segmentCategories.START: return T('wayfinder:Begin route at')
|
|
188
|
-
case segmentCategories.ELEVATOR: return T('wayfinder:Take elevator to')
|
|
189
|
-
case segmentCategories.ELEVATOR_UP: return T('wayfinder:Take elevator up to')
|
|
190
|
-
case segmentCategories.ELEVATOR_DOWN: return T('wayfinder:Take elevator down to')
|
|
191
|
-
case segmentCategories.STAIRS: return T('wayfinder:Take stairs to')
|
|
192
|
-
case segmentCategories.STAIRS_UP: return T('wayfinder:Take stairs up to')
|
|
193
|
-
case segmentCategories.STAIRS_DOWN: return T('wayfinder:Take stairs down to')
|
|
194
|
-
case segmentCategories.ESCALATOR: return T('wayfinder:Take escalator to')
|
|
195
|
-
case segmentCategories.ESCALATOR_UP: return T('wayfinder:Take escalator up to')
|
|
196
|
-
case segmentCategories.ESCALATOR_DOWN: return T('wayfinder:Take escalator down to')
|
|
197
|
-
case segmentCategories.WALK:
|
|
198
|
-
case segmentCategories.WALKING_TO_SECURITY_CHECKPOINT:
|
|
199
|
-
case segmentCategories.WALKING_TO_PORTAL:
|
|
200
|
-
case segmentCategories.WALKING_TO_END: return zeroOrOtherKeys('Walk <1 minute to', 'Walk xx minute to')
|
|
201
|
-
case segmentCategories.WALK_DOWN: return zeroOrOtherKeys('Walk <1 minute down to', 'Walk xx minute down to')
|
|
202
|
-
case segmentCategories.WALK_UP: return zeroOrOtherKeys('Walk <1 minute up to', 'Walk xx minute up to')
|
|
203
|
-
// todo add stops for train and bus if needed
|
|
204
|
-
case segmentCategories.TRAIN: return zeroOrOtherKeys('Take train <1 minute', 'Take train xx minute')
|
|
205
|
-
case segmentCategories.BUS: return zeroOrOtherKeys('Take bus <1 minute', 'Take bus xx minute')
|
|
206
|
-
case segmentCategories.SECURITY_CHECKPOINT: return securityLaneName
|
|
207
|
-
? T('wayfinder:Through _security_ to', { name: securityLaneName })
|
|
208
|
-
: T('wayfinder:Through security to')
|
|
209
|
-
case segmentCategories.RAMP: return T('wayfinder:Take ramp to')
|
|
210
|
-
case segmentCategories.RAMP_UP: return T('wayfinder:Take ramp up to')
|
|
211
|
-
case segmentCategories.RAMP_DOWN: return T('wayfinder:Take ramp down to')
|
|
212
|
-
default: return ''
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const translateZeroOrOther = (count, T) => (zeroKey, otherKey) => count === 0
|
|
217
|
-
? T('wayfinder:' + zeroKey)
|
|
218
|
-
: T('wayfinder:' + otherKey, { count });
|
|
219
|
-
|
|
220
|
-
const checkIfAccessible = compose(
|
|
221
|
-
not, includes(__, ['escalator', 'stairs']), toLower, prop('type'));
|
|
222
|
-
|
|
223
|
-
const getSecurityLaneName = (queueTypes, waypoints) => {
|
|
224
|
-
const lane = findPropWaypoints('securityLane')(waypoints);
|
|
225
|
-
if (!lane) return
|
|
226
|
-
const types = prop(lane.type, queueTypes);
|
|
227
|
-
const laneType = find(propEq('id', lane.id), types);
|
|
228
|
-
return prop('displayText', laneType)
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
const findPropWaypoints = propName => compose(
|
|
232
|
-
prop(propName),
|
|
233
|
-
find(prop(propName)),
|
|
234
|
-
drop(1)); // because first waypoint is the end of previous segment and can be security checkpoint
|
|
235
|
-
|
|
236
|
-
export default getSteps;
|
|
1
|
+
import{compose as e,not as t,includes as r,__ as a,toLower as n,prop as s,find as c,drop as u,last as i,propEq as T}from"ramda";import{findBoundsOfWaypoints as o}from"../../../src/utils/bounds.js";import A from"./segmentBadges.js";import _ from"./segmentCategories.js";function R(e,t="",r="",a,n,c={}){return e.map(((u,T)=>{const R=N("securityWaitTimes")(u.waypoints),L=R&&!R.isTemporarilyClosed?R.queueTime:Math.round(1===(W=u.waypoints).length?W[0].eta:W.map(s("eta")).slice(1).reduce(((e,t)=>e+t),0));var W;const y=Math.round(function(e){return 1===e.length?e[0].distance:e.map((e=>e.distance)).slice(1).reduce(((e,t)=>e+t),0)}(u.waypoints)),I=function(e){switch(e){case _.START:return A.START;case _.WALKING_TO_END:return A.END;case _.ELEVATOR:return A.ELEVATOR;case _.ELEVATOR_UP:return A.ELEVATOR_UP;case _.ELEVATOR_DOWN:return A.ELEVATOR_DOWN;case _.STAIRS:return A.STAIRS;case _.STAIRS_UP:return A.STAIRS_UP;case _.STAIRS_DOWN:return A.STAIRS_DOWN;case _.ESCALATOR:return A.ESCALATOR;case _.ESCALATOR_UP:return A.ESCALATOR_UP;case _.ESCALATOR_DOWN:return A.ESCALATOR_DOWN;case _.WALKING_TO_PORTAL:case _.WALK:case _.WALK_DOWN:case _.WALK_UP:return A.WALK;case _.TRAIN:return A.TRAIN;case _.TRAIN_UP:return A.TRAIN_UP;case _.TRAIN_DOWN:return A.TRAIN_DOWN;case _.BUS:return A.BUS;case _.BUS_UP:return A.BUS_UP;case _.BUS_DOWN:return A.BUS_DOWN;case _.SECURITY_CHECKPOINT:return A.SECURITY_CHECKPOINT;case _.RAMP:return A.RAMP;case _.RAMP_UP:return A.RAMP_UP;case _.RAMP_DOWN:return A.RAMP_DOWN;default:return A.WALK}}(u.segmentCategory),m=function(e,t){let r;switch(e){case _.START:r=0;break;case _.WALKING_TO_END:r=t.length-1;break;case _.WALKING_TO_PORTAL:r=Math.min(t.length-1,Math.ceil(t.length/2));break;default:r=t.length-1}return t[r].position}(u.segmentCategory,u.waypoints),p={primaryText:function(e,t,r,a,n,s){const c=e[t];switch(c.segmentCategory){case _.START:return O(c.waypoints[0].position,r);case _.WALKING_TO_END:return O(c.waypoints[c.waypoints.length-1].position,a);case _.WALKING_TO_SECURITY_CHECKPOINT:case _.WALKING_TO_PORTAL:return s(`wayfinder:${e[t+1].type}`);case _.SECURITY_CHECKPOINT:case _.ELEVATOR:case _.ELEVATOR_DOWN:case _.ELEVATOR_UP:case _.ESCALATOR:case _.ESCALATOR_DOWN:case _.ESCALATOR_UP:case _.STAIRS:case _.STAIRS_DOWN:case _.STAIRS_UP:return function(e,t){return t[i(e.waypoints).position.floorId]}(c,n);default:return s(`wayfinder:${c.type}`)}}(e,T,t,r,a,n),secondaryText:function(e,t,r,a){const n=S(t,a);switch(e.segmentCategory){case _.START:return a("wayfinder:Begin route at");case _.ELEVATOR:return a("wayfinder:Take elevator to");case _.ELEVATOR_UP:return a("wayfinder:Take elevator up to");case _.ELEVATOR_DOWN:return a("wayfinder:Take elevator down to");case _.STAIRS:return a("wayfinder:Take stairs to");case _.STAIRS_UP:return a("wayfinder:Take stairs up to");case _.STAIRS_DOWN:return a("wayfinder:Take stairs down to");case _.ESCALATOR:return a("wayfinder:Take escalator to");case _.ESCALATOR_UP:return a("wayfinder:Take escalator up to");case _.ESCALATOR_DOWN:return a("wayfinder:Take escalator down to");case _.WALK:case _.WALKING_TO_SECURITY_CHECKPOINT:case _.WALKING_TO_PORTAL:case _.WALKING_TO_END:return n("Walk <1 minute to","Walk xx minute to");case _.WALK_DOWN:return n("Walk <1 minute down to","Walk xx minute down to");case _.WALK_UP:return n("Walk <1 minute up to","Walk xx minute up to");case _.TRAIN:return n("Take train <1 minute","Take train xx minute");case _.BUS:return n("Take bus <1 minute","Take bus xx minute");case _.SECURITY_CHECKPOINT:return r?a("wayfinder:Through _security_ to",{name:r}):a("wayfinder:Through security to");case _.RAMP:return a("wayfinder:Take ramp to");case _.RAMP_UP:return a("wayfinder:Take ramp up to");case _.RAMP_DOWN:return a("wayfinder:Take ramp down to");default:return""}}(u,L,d(c,u.waypoints),n),icon:I,animationAnchor:m,eta:L,distance:y,bounds:o(u.waypoints),isAccessible:E(u),securityWaitTimes:R};return u.poiId&&(p.poiId=u.poiId),p}))}function O(e,t){return e.name?e.name:t}const S=(e,t)=>(r,a)=>0===e?t("wayfinder:"+r):t("wayfinder:"+a,{count:e}),E=e(t,r(a,["escalator","stairs"]),n,s("type")),d=(e,t)=>{const r=N("securityLane")(t);if(!r)return;const a=s(r.type,e),n=c(T("id",r.id),a);return s("displayText",n)},N=t=>e(s(t),c(s(t)),u(1));export{R as default};
|