atriusmaps-node-sdk 3.3.31 → 3.3.225
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 +19 -1
- package/dist/cjs/_virtual/_empty_module_placeholder.js +2 -2
- package/dist/cjs/deploy/prepareSDKConfig.js +152 -2
- package/dist/cjs/nodesdk/nodeEntry.js +109 -0
- package/dist/cjs/package.json.js +190 -7
- package/dist/cjs/plugins/clientAPI/src/clientAPI.js +11 -2
- package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +218 -21
- package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +292 -21
- package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +99 -20
- package/dist/cjs/plugins/sdkServer/src/sdkServer.js +219 -2
- package/dist/cjs/plugins/sdkServer/src/util.js +16 -3
- package/dist/cjs/plugins/searchService/src/poiSearch.js +57 -19
- package/dist/cjs/plugins/searchService/src/searchService.js +246 -21
- package/dist/cjs/plugins/searchService/src/searchTypeahead.js +60 -3
- package/dist/cjs/plugins/searchService/src/utils.js +23 -4
- package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +472 -23
- package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +191 -23
- package/dist/cjs/plugins/wayfinder/src/findRoute.js +147 -19
- package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +88 -2
- package/dist/cjs/plugins/wayfinder/src/navGraph.js +393 -5
- package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +110 -20
- package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +28 -2
- package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +257 -19
- package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +29 -2
- package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +238 -3
- package/dist/cjs/plugins/wayfinder/src/wayfinder.js +597 -22
- package/dist/cjs/src/app.js +191 -25
- package/dist/cjs/src/configs/postproc-mol-url-parms.js +58 -2
- package/dist/cjs/src/configs/postproc-stateTracking.js +53 -19
- package/dist/cjs/src/controller.js +43 -4
- package/dist/cjs/src/debugTools.js +128 -23
- package/dist/cjs/src/env.js +17 -2
- package/dist/cjs/src/extModules/bustle.js +128 -4
- package/dist/cjs/src/extModules/flexapi/src/help.js +23 -4
- package/dist/cjs/src/extModules/flexapi/src/index.js +65 -4
- package/dist/cjs/src/extModules/flexapi/src/validate.js +133 -5
- package/dist/cjs/src/extModules/geohasher.js +90 -3
- package/dist/cjs/src/extModules/log.js +69 -2
- package/dist/cjs/src/historyManager.js +29 -2
- package/dist/cjs/src/utils/bounds.js +22 -4
- package/dist/cjs/src/utils/buildStructureLookup.js +31 -19
- package/dist/cjs/src/utils/configUtils.js +71 -3
- package/dist/cjs/src/utils/dom.js +48 -5
- package/dist/cjs/src/utils/funcs.js +30 -7
- package/dist/cjs/src/utils/geodesy.js +35 -3
- package/dist/cjs/src/utils/geom.js +212 -25
- package/dist/cjs/src/utils/i18n.js +69 -5
- package/dist/cjs/src/utils/observable.js +73 -2
- package/dist/cjs/src/utils/rand.js +82 -3
- package/dist/nodesdk/nodeEntry.js +1 -0
- package/dist/package.json.js +1 -0
- package/dist/plugins/dynamicPois/src/dynamicPois.js +1 -0
- package/dist/plugins/sdkServer/src/sdkHeadless.js +1 -0
- package/{lib → dist}/plugins/sdkServer/src/sdkServer.js +1 -1
- package/dist/plugins/searchService/src/poiSearch.js +1 -0
- package/dist/plugins/searchService/src/searchService.js +1 -0
- package/dist/plugins/venueDataLoader/src/venueDataLoader.js +1 -0
- package/dist/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -0
- package/dist/plugins/wayfinder/src/navGraph.js +1 -0
- package/{lib → dist}/plugins/wayfinder/src/segmentBuilder.js +1 -1
- package/dist/plugins/wayfinder/src/stepBuilder.js +1 -0
- package/dist/plugins/wayfinder/src/wayfinder.js +1 -0
- package/dist/src/app.js +1 -0
- package/dist/src/configs/postproc-mol-url-parms.js +1 -0
- package/{lib → dist}/src/configs/sdkHeadless.json.js +1 -1
- package/dist/src/extModules/bustle.js +1 -0
- package/dist/src/extModules/log.js +1 -0
- package/dist/src/utils/funcs.js +1 -0
- package/dist/src/utils/geom.js +1 -0
- package/dist/src/utils/i18n.js +1 -0
- package/package.json +17 -9
- package/config/rollup.config.cjs.js +0 -31
- package/dist/cjs/deploy/nodeEntry.js +0 -15
- package/dist/cjs/src/auth/Auth.js +0 -23
- package/lib/deploy/nodeEntry.js +0 -1
- package/lib/package.json.js +0 -1
- package/lib/plugins/dynamicPois/src/dynamicPois.js +0 -1
- package/lib/plugins/sdkServer/src/sdkHeadless.js +0 -1
- package/lib/plugins/searchService/src/poiSearch.js +0 -1
- package/lib/plugins/searchService/src/searchService.js +0 -1
- package/lib/plugins/venueDataLoader/src/venueDataLoader.js +0 -1
- package/lib/plugins/venueDataLoader/src/venueLoadingUtils.js +0 -1
- package/lib/plugins/wayfinder/src/navGraph.js +0 -1
- package/lib/plugins/wayfinder/src/stepBuilder.js +0 -1
- package/lib/plugins/wayfinder/src/wayfinder.js +0 -1
- package/lib/src/app.js +0 -1
- package/lib/src/auth/Auth.js +0 -1
- package/lib/src/configs/postproc-mol-url-parms.js +0 -1
- package/lib/src/configs/sdkHeadless.json +0 -28
- package/lib/src/extModules/bustle.js +0 -1
- package/lib/src/extModules/log.js +0 -1
- package/lib/src/utils/funcs.js +0 -1
- package/lib/src/utils/geom.js +0 -1
- package/lib/src/utils/i18n.js +0 -1
- /package/{lib → dist}/_virtual/_empty_module_placeholder.js +0 -0
- /package/{lib → dist}/deploy/prepareSDKConfig.js +0 -0
- /package/{lib → dist}/plugins/clientAPI/src/clientAPI.js +0 -0
- /package/{lib → dist}/plugins/poiDataManager/src/poiDataManager.js +0 -0
- /package/{lib → dist}/plugins/sdkServer/src/util.js +0 -0
- /package/{lib → dist}/plugins/searchService/src/searchTypeahead.js +0 -0
- /package/{lib → dist}/plugins/searchService/src/utils.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/findRoute.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/minPriorityQueue.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/navGraphDebug.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/segmentBadges.js +0 -0
- /package/{lib → dist}/plugins/wayfinder/src/segmentCategories.js +0 -0
- /package/{lib → dist}/src/configs/postproc-stateTracking.js +0 -0
- /package/{lib → dist}/src/controller.js +0 -0
- /package/{lib → dist}/src/debugTools.js +0 -0
- /package/{lib → dist}/src/env.js +0 -0
- /package/{lib → dist}/src/extModules/flexapi/src/help.js +0 -0
- /package/{lib → dist}/src/extModules/flexapi/src/index.js +0 -0
- /package/{lib → dist}/src/extModules/flexapi/src/validate.js +0 -0
- /package/{lib → dist}/src/extModules/geohasher.js +0 -0
- /package/{lib → dist}/src/historyManager.js +0 -0
- /package/{lib → dist}/src/utils/bounds.js +0 -0
- /package/{lib → dist}/src/utils/buildStructureLookup.js +0 -0
- /package/{lib → dist}/src/utils/configUtils.js +0 -0
- /package/{lib → dist}/src/utils/dom.js +0 -0
- /package/{lib → dist}/src/utils/geodesy.js +0 -0
- /package/{lib → dist}/src/utils/observable.js +0 -0
- /package/{lib → dist}/src/utils/rand.js +0 -0
|
@@ -2,31 +2,269 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var R = require('ramda');
|
|
6
6
|
var geom = require('../../../src/utils/geom.js');
|
|
7
7
|
var segmentCategories = require('./segmentCategories.js');
|
|
8
8
|
var stepBuilder = require('./stepBuilder.js');
|
|
9
9
|
|
|
10
10
|
function _interopNamespace(e) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n["default"] = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var R__namespace = /*#__PURE__*/_interopNamespace(R);
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const setSegmentCategory = (segments) => {
|
|
31
|
+
// 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
|
|
32
|
+
// to a portal or to a security checkpoint
|
|
33
|
+
segments.forEach((segment, index) => {
|
|
34
|
+
if (index === 0)
|
|
35
|
+
segment.segmentCategory = segmentCategories.START;
|
|
36
|
+
else if (segment.waypoints[segment.waypoints.length - 1].isDestination)
|
|
37
|
+
segment.segmentCategory = segmentCategories.WALKING_TO_END;
|
|
38
|
+
else if (segment.type === 'Security Checkpoint')
|
|
39
|
+
segment.segmentCategory = segmentCategories.SECURITY_CHECKPOINT;
|
|
40
|
+
else if (segment.type === 'Bus')
|
|
41
|
+
segment.segmentCategory = segmentCategories.BUS;
|
|
42
|
+
else if (segment.type === 'Train')
|
|
43
|
+
segment.segmentCategory = segmentCategories.TRAIN;
|
|
44
|
+
else if (segment.type === 'Stairs') {
|
|
45
|
+
if (segment.levelDifference > 0)
|
|
46
|
+
segment.segmentCategory = segmentCategories.STAIRS_UP;
|
|
47
|
+
else if (segment.levelDifference < 0)
|
|
48
|
+
segment.segmentCategory = segmentCategories.STAIRS_DOWN;
|
|
49
|
+
else
|
|
50
|
+
segment.segmentCategory = segmentCategories.STAIRS;
|
|
51
|
+
} else if (segment.type === 'Elevator') {
|
|
52
|
+
if (segment.levelDifference > 0)
|
|
53
|
+
segment.segmentCategory = segmentCategories.ELEVATOR_UP;
|
|
54
|
+
else if (segment.levelDifference < 0)
|
|
55
|
+
segment.segmentCategory = segmentCategories.ELEVATOR_DOWN;
|
|
56
|
+
else
|
|
57
|
+
segment.segmentCategory = segmentCategories.ELEVATOR;
|
|
58
|
+
} else if (segment.type === 'Escalator') {
|
|
59
|
+
if (segment.levelDifference > 0)
|
|
60
|
+
segment.segmentCategory = segmentCategories.ESCALATOR_UP;
|
|
61
|
+
else if (segment.levelDifference < 0)
|
|
62
|
+
segment.segmentCategory = segmentCategories.ESCALATOR_DOWN;
|
|
63
|
+
else
|
|
64
|
+
segment.segmentCategory = segmentCategories.ESCALATOR;
|
|
65
|
+
} else if (segment.type === 'Ramp') {
|
|
66
|
+
if (segment.levelDifference > 0)
|
|
67
|
+
segment.segmentCategory = segmentCategories.RAMP_UP;
|
|
68
|
+
else if (segment.levelDifference < 0)
|
|
69
|
+
segment.segmentCategory = segmentCategories.RAMP_DOWN;
|
|
70
|
+
else
|
|
71
|
+
segment.segmentCategory = segmentCategories.RAMP;
|
|
72
|
+
} else if (segments[index + 1].type === 'Security Checkpoint')
|
|
73
|
+
segment.segmentCategory = segmentCategories.WALKING_TO_SECURITY_CHECKPOINT;
|
|
74
|
+
else if (segments[index + 1].type !== 'Walk')
|
|
75
|
+
segment.segmentCategory = segmentCategories.WALKING_TO_PORTAL;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
31
78
|
|
|
32
|
-
|
|
79
|
+
const existsEnd = (segments, lastWaypoint) => {
|
|
80
|
+
// if we have only one segment, add an extra segment with only the last point to simulate the end,
|
|
81
|
+
// that way we can draw separate markers for the start and the end of the navigation
|
|
82
|
+
if (segments.length === 1) {
|
|
83
|
+
const segment = { segmentCategory: undefined, waypoints: [] };
|
|
84
|
+
segment.segmentCategory = segmentCategories.WALKING_TO_END;
|
|
85
|
+
segment.type = 'Walk';
|
|
86
|
+
segment.waypoints = [lastWaypoint];
|
|
87
|
+
segments.push(segment);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// todo refactor to not affect step builder
|
|
92
|
+
const joinSegments = (segments) => {
|
|
93
|
+
segments.forEach((segment, index) => {
|
|
94
|
+
if (index > 1) {
|
|
95
|
+
const firstWaypointOfSegment = R__namespace.head(segment.waypoints);
|
|
96
|
+
if (firstWaypointOfSegment.levelDifference === 0) {
|
|
97
|
+
const lastWaypointOfPreviousSegment = R__namespace.last(segments[index - 1].waypoints);
|
|
98
|
+
segment.waypoints = R__namespace.prepend(lastWaypointOfPreviousSegment, segment.waypoints);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const calculateCurveLineCoordinates = segment =>
|
|
105
|
+
segment.waypoints.flatMap((waypoint, index) => {
|
|
106
|
+
// todo index > 0 is hacky fix
|
|
107
|
+
if (index > 0 && waypoint.curvedPathForward && waypoint.curvedPathForward.length > 0) {
|
|
108
|
+
return waypoint.curvedPathForward
|
|
109
|
+
.flatMap(p => geom.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))
|
|
110
|
+
.map(el => [el.x, el.y])
|
|
111
|
+
} else {
|
|
112
|
+
return [[waypoint.position.lng, waypoint.position.lat]]
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const addCurveLineCoordinates = R__namespace.map(
|
|
117
|
+
R__namespace.converge(R__namespace.assoc('coordinates'), [calculateCurveLineCoordinates, R__namespace.identity]));
|
|
118
|
+
|
|
119
|
+
// todo refactor
|
|
120
|
+
const createSegments = (waypoints) => {
|
|
121
|
+
const segments = [];
|
|
122
|
+
let segment = { segmentCategory: undefined, waypoints: [] };
|
|
123
|
+
let lastWaypoint = null;
|
|
124
|
+
let segmentWaypoints = [];
|
|
125
|
+
|
|
126
|
+
// Always add the first point to be the start of the route
|
|
127
|
+
segment.waypoints = [waypoints[0]];
|
|
128
|
+
segment.type = waypoints[0].isPortal ? waypoints[0].portalType : 'Walk';
|
|
129
|
+
segments.push(segment);
|
|
130
|
+
segment = { segmentCategory: undefined, waypoints: [] };
|
|
131
|
+
|
|
132
|
+
waypoints.forEach(waypoint => {
|
|
133
|
+
segmentWaypoints.push(waypoint);
|
|
134
|
+
|
|
135
|
+
if (!lastWaypoint) { // true on first waypoint only
|
|
136
|
+
segment.type = waypoint.isPortal ? waypoint.portalType : 'Walk';
|
|
137
|
+
lastWaypoint = waypoint;
|
|
138
|
+
} else {
|
|
139
|
+
if ((lastWaypoint.isPortal === waypoint.isPortal) &&
|
|
140
|
+
(lastWaypoint.isSecurityCheckpoint === waypoint.isSecurityCheckpoint)) { // todo not sure if this can happen
|
|
141
|
+
segment.levelDifference = waypoint.levelDifference;
|
|
142
|
+
} else {
|
|
143
|
+
segment.waypoints = segmentWaypoints;
|
|
144
|
+
|
|
145
|
+
if (waypoint.isPortal || lastWaypoint.isPortal) {
|
|
146
|
+
if (segmentWaypoints.length > 1)
|
|
147
|
+
segmentWaypoints.pop();
|
|
148
|
+
|
|
149
|
+
// if the portal is not train or bus, we only want it to be one point segment
|
|
150
|
+
if (waypoint.isPortal && (waypoint.portalType.toLowerCase() === 'train' || waypoint.portalType.toLowerCase() === 'bus'))
|
|
151
|
+
segmentWaypoints = [segmentWaypoints[segmentWaypoints.length - 1], waypoint];
|
|
152
|
+
else
|
|
153
|
+
segmentWaypoints = [waypoint];
|
|
154
|
+
} else
|
|
155
|
+
segmentWaypoints = [];
|
|
156
|
+
|
|
157
|
+
if (lastWaypoint.poiId)
|
|
158
|
+
segment.poiId = lastWaypoint.poiId;
|
|
159
|
+
segments.push(segment);
|
|
160
|
+
|
|
161
|
+
segment = { segmentCategory: undefined, waypoints: [] };
|
|
162
|
+
|
|
163
|
+
segment.type = waypoint.isPortal ? waypoint.portalType : 'Walk';
|
|
164
|
+
segment.levelDifference = waypoint.levelDifference;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
lastWaypoint = waypoint;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
segment.waypoints = segmentWaypoints;
|
|
172
|
+
|
|
173
|
+
if (segmentWaypoints.length === 0)
|
|
174
|
+
segment.waypoints = [lastWaypoint];
|
|
175
|
+
|
|
176
|
+
segments.push(segment);
|
|
177
|
+
|
|
178
|
+
setSegmentCategory(segments);
|
|
179
|
+
|
|
180
|
+
existsEnd(segments, lastWaypoint);
|
|
181
|
+
|
|
182
|
+
joinSegments(segments);
|
|
183
|
+
|
|
184
|
+
return segments
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const getSegmentType = (segment) => {
|
|
188
|
+
if (segment.type === 'Train') {
|
|
189
|
+
return 'nav.train'
|
|
190
|
+
}
|
|
191
|
+
if (segment.type === 'Bus') {
|
|
192
|
+
return 'nav.transit'
|
|
193
|
+
}
|
|
194
|
+
if (segment.type === 'Security Checkpoint') {
|
|
195
|
+
return 'nav.secure'
|
|
196
|
+
}
|
|
197
|
+
return 'nav.primary'
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
*
|
|
202
|
+
* @typedef Badge
|
|
203
|
+
* @property {string} canonicalName
|
|
204
|
+
* @property {Coordinate} coordinates
|
|
205
|
+
*
|
|
206
|
+
* @typedef Segment
|
|
207
|
+
* @property {string} levelId
|
|
208
|
+
* @property {string} ordinalId
|
|
209
|
+
* @property {string} segmentType
|
|
210
|
+
* @property {Boolean} shouldDrawSegment - to not show edges like stairs or elevator
|
|
211
|
+
* @property {Array.<Coordinate>} coordinates - list of coordinate pairs [lng, lat]
|
|
212
|
+
* @property {Array<Badge>} badges
|
|
213
|
+
*
|
|
214
|
+
* @param {Waypoint} waypoints
|
|
215
|
+
* @param {Endpoint} fromEndpoint
|
|
216
|
+
* @param {Endpoint} toEndpoint
|
|
217
|
+
* @param {Object.<string, string>} floorIdToNameMap - dictionary of floor id to floor name
|
|
218
|
+
* @param T - i18n translations function
|
|
219
|
+
* @param {QueueTypes} queueTypes
|
|
220
|
+
* @param {boolean} requiresAccessibility
|
|
221
|
+
* @return {{steps: Step[], segments: Segment[]}}
|
|
222
|
+
*/
|
|
223
|
+
const buildSegments = (waypoints, fromEndpoint, toEndpoint, floorIdToNameMap, T, queueTypes, requiresAccessibility) => {
|
|
224
|
+
let rawSegments = createSegments(waypoints);
|
|
225
|
+
rawSegments = addCurveLineCoordinates(rawSegments);
|
|
226
|
+
|
|
227
|
+
// add start location (kiosk) as first coordinate to link it with the navline
|
|
228
|
+
if (fromEndpoint)
|
|
229
|
+
rawSegments[0].coordinates.unshift([fromEndpoint.lng, fromEndpoint.lat]);
|
|
230
|
+
|
|
231
|
+
if (toEndpoint)
|
|
232
|
+
R__namespace.last(rawSegments).coordinates.push([toEndpoint.lng, toEndpoint.lat]);
|
|
233
|
+
|
|
234
|
+
const segments = rawSegments.map((segment, index) => {
|
|
235
|
+
const startWaypoint = R__namespace.last(segment.waypoints);
|
|
236
|
+
const coordinates = segment.coordinates;
|
|
237
|
+
const shouldDrawSegment = !(segment.levelDifference && segment.waypoints.every(R__namespace.prop('isPortal')));
|
|
238
|
+
const cookedSegment = {
|
|
239
|
+
levelId: startWaypoint.position.structureId,
|
|
240
|
+
ordinalId: `ordinal: ${startWaypoint.position.ordinal}`,
|
|
241
|
+
coordinates,
|
|
242
|
+
shouldDrawSegment
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const badges = [];
|
|
246
|
+
if (segmentCategories.WALKING_TO_PORTAL === segment.segmentCategory) {
|
|
247
|
+
const nextSegment = rawSegments[index + 1];
|
|
248
|
+
badges.push({
|
|
249
|
+
canonicalName: `wayfinding.${nextSegment.segmentCategory}`,
|
|
250
|
+
coordinates: R__namespace.last(coordinates)
|
|
251
|
+
});
|
|
252
|
+
} else if (segmentCategories.START !== segment.segmentCategory) {
|
|
253
|
+
badges.push({
|
|
254
|
+
canonicalName: `wayfinding.${segment.segmentCategory}`,
|
|
255
|
+
coordinates: R__namespace.last(coordinates)
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
cookedSegment.badges = badges;
|
|
259
|
+
cookedSegment.segmentType = getSegmentType(segment);
|
|
260
|
+
if (segment.poiId)
|
|
261
|
+
cookedSegment.poiId = segment.poiId;
|
|
262
|
+
return cookedSegment
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const steps = stepBuilder(rawSegments, R__namespace.prop('title', fromEndpoint), R__namespace.prop('title', toEndpoint), floorIdToNameMap, T, queueTypes);
|
|
266
|
+
|
|
267
|
+
return { segments, steps }
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
exports.buildSegments = buildSegments;
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const segmentCategories = {
|
|
4
|
+
START: 'start',
|
|
5
|
+
WALKING_TO_SECURITY_CHECKPOINT: 'walking to security checkpoint',
|
|
6
|
+
WALKING_TO_PORTAL: 'walking to portal',
|
|
7
|
+
WALKING_TO_END: 'walking to end',
|
|
8
|
+
ELEVATOR: 'elevator',
|
|
9
|
+
ELEVATOR_UP: 'elevator.up',
|
|
10
|
+
ELEVATOR_DOWN: 'elevator.down',
|
|
11
|
+
STAIRS: 'stairs',
|
|
12
|
+
STAIRS_UP: 'stairs.up',
|
|
13
|
+
STAIRS_DOWN: 'stairs.down',
|
|
14
|
+
ESCALATOR: 'escalator',
|
|
15
|
+
ESCALATOR_UP: 'escalator.up',
|
|
16
|
+
ESCALATOR_DOWN: 'escalator.down',
|
|
17
|
+
WALK: 'walk',
|
|
18
|
+
WALK_DOWN: 'walk.down',
|
|
19
|
+
WALK_UP: 'walk.up',
|
|
20
|
+
TRAIN: 'train',
|
|
21
|
+
TRAIN_UP: 'train.up',
|
|
22
|
+
TRAIN_DOWN: 'train.down',
|
|
23
|
+
BUS: 'bus',
|
|
24
|
+
BUS_UP: 'bus.up',
|
|
25
|
+
BUS_DOWN: 'bus.down',
|
|
26
|
+
SECURITY_CHECKPOINT: 'enduring security checkpoint',
|
|
27
|
+
RAMP: 'ramp',
|
|
28
|
+
RAMP_UP: 'ramp.up',
|
|
29
|
+
RAMP_DOWN: 'ramp.down'
|
|
30
|
+
};
|
|
4
31
|
|
|
5
|
-
module.exports =
|
|
32
|
+
module.exports = segmentCategories;
|
|
@@ -1,10 +1,245 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var R = require('ramda');
|
|
4
4
|
var bounds = require('../../../src/utils/bounds.js');
|
|
5
5
|
var segmentBadges = require('./segmentBadges.js');
|
|
6
6
|
var segmentCategories = require('./segmentCategories.js');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @typedef Step
|
|
10
|
+
* @property {string} primaryText
|
|
11
|
+
* @property {string} secondaryText
|
|
12
|
+
* @property {string} icon
|
|
13
|
+
* @property {Position} animationAnchor
|
|
14
|
+
* @property {number} eta
|
|
15
|
+
* @property {number} distance
|
|
16
|
+
* @property {boolean} isAccessible
|
|
17
|
+
* @property {Bounds} bounds
|
|
18
|
+
* @property {SecurityWaitTime} securityWaitTimes
|
|
19
|
+
*
|
|
20
|
+
* @typedef Position
|
|
21
|
+
* @property {number} lat
|
|
22
|
+
* @property {number} lng
|
|
23
|
+
* @property {string} floorId
|
|
24
|
+
* @property {number} ordinal
|
|
25
|
+
* @property {string} structureId
|
|
26
|
+
*
|
|
27
|
+
* @param {Segment[]} segments
|
|
28
|
+
* @param {string} startName
|
|
29
|
+
* @param {string} destinationName
|
|
30
|
+
* @param floorIdToNameMap
|
|
31
|
+
* @param {function} T - translate function
|
|
32
|
+
* @param {QueueTypes} queueTypes
|
|
33
|
+
* @param {boolean} requiresAccessibility
|
|
34
|
+
* @return {Step[]} steps - list of navigation steps
|
|
35
|
+
*/
|
|
36
|
+
function getSteps (segments, startName = '', destinationName = '', floorIdToNameMap, T, queueTypes = {}, requiresAccessibility) {
|
|
37
|
+
return segments.map((segment, index) => {
|
|
38
|
+
const securityWaitTimes = findPropWaypoints('securityWaitTimes')(segment.waypoints);
|
|
39
|
+
const eta = (securityWaitTimes && !securityWaitTimes.isTemporarilyClosed) // if there is dynamic wait time and checkpoint is open, then use it
|
|
40
|
+
? securityWaitTimes.queueTime
|
|
41
|
+
: Math.round(calculateSegmentEta(segment.waypoints));
|
|
42
|
+
const distance = Math.round(calculateSegmentDistance(segment.waypoints));
|
|
43
|
+
const icon = getIcon(segment.segmentCategory);
|
|
44
|
+
const animationAnchor = getAnimationAnchor(segment.segmentCategory, segment.waypoints);
|
|
45
|
+
const primaryText = getPrimaryText(segments, index, startName, destinationName, floorIdToNameMap, T);
|
|
46
|
+
const securityLaneName = getSecurityLaneName(queueTypes, segment.waypoints);
|
|
47
|
+
const secondaryText = getSecondaryText(segment, eta, securityLaneName, T);
|
|
48
|
+
const bounds$1 = bounds.findBoundsOfWaypoints(segment.waypoints);
|
|
49
|
+
const isAccessible = checkIfAccessible(segment);
|
|
9
50
|
|
|
10
|
-
|
|
51
|
+
const step = {
|
|
52
|
+
primaryText,
|
|
53
|
+
secondaryText,
|
|
54
|
+
icon,
|
|
55
|
+
animationAnchor,
|
|
56
|
+
eta,
|
|
57
|
+
distance,
|
|
58
|
+
bounds: bounds$1,
|
|
59
|
+
isAccessible,
|
|
60
|
+
securityWaitTimes
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (segment.poiId)
|
|
64
|
+
step.poiId = segment.poiId;
|
|
65
|
+
|
|
66
|
+
return step
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function calculateSegmentEta (waypoints) {
|
|
71
|
+
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
|
|
72
|
+
return waypoints
|
|
73
|
+
.map(R.prop('eta'))
|
|
74
|
+
.slice(1) // first waypoint is end of previous segment and is added only to connect segments for navline calculation
|
|
75
|
+
.reduce((segmentEta, eta) => segmentEta + eta, 0.0)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function calculateSegmentDistance (waypoints) {
|
|
79
|
+
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
|
|
80
|
+
return waypoints
|
|
81
|
+
.map(waypoint => waypoint.distance)
|
|
82
|
+
.slice(1) // first waypoint is end of previous segment and is added only to connect segments for navline calculation
|
|
83
|
+
.reduce((segmentDistance, distance) => segmentDistance + distance, 0.0)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getIcon (segmentCategory) {
|
|
87
|
+
switch (segmentCategory) {
|
|
88
|
+
case segmentCategories.START:
|
|
89
|
+
return segmentBadges.START
|
|
90
|
+
case segmentCategories.WALKING_TO_END:
|
|
91
|
+
return segmentBadges.END
|
|
92
|
+
case segmentCategories.ELEVATOR:
|
|
93
|
+
return segmentBadges.ELEVATOR
|
|
94
|
+
case segmentCategories.ELEVATOR_UP:
|
|
95
|
+
return segmentBadges.ELEVATOR_UP
|
|
96
|
+
case segmentCategories.ELEVATOR_DOWN:
|
|
97
|
+
return segmentBadges.ELEVATOR_DOWN
|
|
98
|
+
case segmentCategories.STAIRS:
|
|
99
|
+
return segmentBadges.STAIRS
|
|
100
|
+
case segmentCategories.STAIRS_UP:
|
|
101
|
+
return segmentBadges.STAIRS_UP
|
|
102
|
+
case segmentCategories.STAIRS_DOWN:
|
|
103
|
+
return segmentBadges.STAIRS_DOWN
|
|
104
|
+
case segmentCategories.ESCALATOR:
|
|
105
|
+
return segmentBadges.ESCALATOR
|
|
106
|
+
case segmentCategories.ESCALATOR_UP:
|
|
107
|
+
return segmentBadges.ESCALATOR_UP
|
|
108
|
+
case segmentCategories.ESCALATOR_DOWN:
|
|
109
|
+
return segmentBadges.ESCALATOR_DOWN
|
|
110
|
+
case segmentCategories.WALKING_TO_PORTAL:
|
|
111
|
+
case segmentCategories.WALK:
|
|
112
|
+
case segmentCategories.WALK_DOWN:
|
|
113
|
+
case segmentCategories.WALK_UP:
|
|
114
|
+
return segmentBadges.WALK
|
|
115
|
+
case segmentCategories.TRAIN:
|
|
116
|
+
return segmentBadges.TRAIN
|
|
117
|
+
case segmentCategories.TRAIN_UP:
|
|
118
|
+
return segmentBadges.TRAIN_UP
|
|
119
|
+
case segmentCategories.TRAIN_DOWN:
|
|
120
|
+
return segmentBadges.TRAIN_DOWN
|
|
121
|
+
case segmentCategories.BUS:
|
|
122
|
+
return segmentBadges.BUS
|
|
123
|
+
case segmentCategories.BUS_UP:
|
|
124
|
+
return segmentBadges.BUS_UP
|
|
125
|
+
case segmentCategories.BUS_DOWN:
|
|
126
|
+
return segmentBadges.BUS_DOWN
|
|
127
|
+
case segmentCategories.SECURITY_CHECKPOINT:
|
|
128
|
+
return segmentBadges.SECURITY_CHECKPOINT
|
|
129
|
+
case segmentCategories.RAMP:
|
|
130
|
+
return segmentBadges.RAMP
|
|
131
|
+
case segmentCategories.RAMP_UP:
|
|
132
|
+
return segmentBadges.RAMP_UP
|
|
133
|
+
case segmentCategories.RAMP_DOWN:
|
|
134
|
+
return segmentBadges.RAMP_DOWN
|
|
135
|
+
default:
|
|
136
|
+
return segmentBadges.WALK
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function getAnimationAnchor (segmentCategory, waypoints) {
|
|
141
|
+
let index;
|
|
142
|
+
switch (segmentCategory) {
|
|
143
|
+
case segmentCategories.START:
|
|
144
|
+
index = 0;
|
|
145
|
+
break
|
|
146
|
+
case segmentCategories.WALKING_TO_END:
|
|
147
|
+
index = waypoints.length - 1;
|
|
148
|
+
break
|
|
149
|
+
case segmentCategories.WALKING_TO_PORTAL:
|
|
150
|
+
index = Math.min(waypoints.length - 1, Math.ceil(waypoints.length / 2));
|
|
151
|
+
break
|
|
152
|
+
default:
|
|
153
|
+
index = waypoints.length - 1;
|
|
154
|
+
}
|
|
155
|
+
return waypoints[index].position
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function getPrimaryText (segments, index, startName, destinationName, floorIdToNameMap, T) {
|
|
159
|
+
const segment = segments[index];
|
|
160
|
+
switch (segment.segmentCategory) {
|
|
161
|
+
case segmentCategories.START:
|
|
162
|
+
return getPositionName(segment.waypoints[0].position, startName)
|
|
163
|
+
case segmentCategories.WALKING_TO_END:
|
|
164
|
+
return getPositionName(segment.waypoints[segment.waypoints.length - 1].position, destinationName)
|
|
165
|
+
case segmentCategories.WALKING_TO_SECURITY_CHECKPOINT:
|
|
166
|
+
case segmentCategories.WALKING_TO_PORTAL:
|
|
167
|
+
return T(`wayfinder:${segments[index + 1].type}`)
|
|
168
|
+
case segmentCategories.SECURITY_CHECKPOINT:
|
|
169
|
+
case segmentCategories.ELEVATOR:
|
|
170
|
+
case segmentCategories.ELEVATOR_DOWN:
|
|
171
|
+
case segmentCategories.ELEVATOR_UP:
|
|
172
|
+
case segmentCategories.ESCALATOR:
|
|
173
|
+
case segmentCategories.ESCALATOR_DOWN:
|
|
174
|
+
case segmentCategories.ESCALATOR_UP:
|
|
175
|
+
case segmentCategories.STAIRS:
|
|
176
|
+
case segmentCategories.STAIRS_DOWN:
|
|
177
|
+
case segmentCategories.STAIRS_UP:
|
|
178
|
+
return getLevelName(segment, floorIdToNameMap)
|
|
179
|
+
default: return T(`wayfinder:${segment.type}`)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function getPositionName (position, poiName) {
|
|
184
|
+
if (position.name) { return position.name }
|
|
185
|
+
return poiName
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function getLevelName (segment, floorIdToNameMap) {
|
|
189
|
+
return floorIdToNameMap[R.last(segment.waypoints).position.floorId]
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function getSecondaryText (segment, minutes, securityLaneName, T, requiresAccessibility) {
|
|
193
|
+
const zeroOrOtherKeys = translateZeroOrOther(minutes, T);
|
|
194
|
+
const travelVerb = 'Proceed';
|
|
195
|
+
switch (segment.segmentCategory) {
|
|
196
|
+
case segmentCategories.START: return T('wayfinder:Begin route at')
|
|
197
|
+
case segmentCategories.ELEVATOR: return T('wayfinder:Take elevator to')
|
|
198
|
+
case segmentCategories.ELEVATOR_UP: return T('wayfinder:Take elevator up to')
|
|
199
|
+
case segmentCategories.ELEVATOR_DOWN: return T('wayfinder:Take elevator down to')
|
|
200
|
+
case segmentCategories.STAIRS: return T('wayfinder:Take stairs to')
|
|
201
|
+
case segmentCategories.STAIRS_UP: return T('wayfinder:Take stairs up to')
|
|
202
|
+
case segmentCategories.STAIRS_DOWN: return T('wayfinder:Take stairs down to')
|
|
203
|
+
case segmentCategories.ESCALATOR: return T('wayfinder:Take escalator to')
|
|
204
|
+
case segmentCategories.ESCALATOR_UP: return T('wayfinder:Take escalator up to')
|
|
205
|
+
case segmentCategories.ESCALATOR_DOWN: return T('wayfinder:Take escalator down to')
|
|
206
|
+
case segmentCategories.WALK:
|
|
207
|
+
case segmentCategories.WALKING_TO_SECURITY_CHECKPOINT:
|
|
208
|
+
case segmentCategories.WALKING_TO_PORTAL:
|
|
209
|
+
case segmentCategories.WALKING_TO_END: return zeroOrOtherKeys(`${travelVerb} <1 minute to`, `${travelVerb} xx minute to`)
|
|
210
|
+
case segmentCategories.WALK_DOWN: return zeroOrOtherKeys(`${travelVerb} <1 minute down to`, `${travelVerb} xx minute down to`)
|
|
211
|
+
case segmentCategories.WALK_UP: return zeroOrOtherKeys(`${travelVerb} <1 minute up to`, `${travelVerb} xx minute up to`)
|
|
212
|
+
// todo add stops for train and bus if needed
|
|
213
|
+
case segmentCategories.TRAIN: return zeroOrOtherKeys('Take train <1 minute', 'Take train xx minute')
|
|
214
|
+
case segmentCategories.BUS: return zeroOrOtherKeys('Take bus <1 minute', 'Take bus xx minute')
|
|
215
|
+
case segmentCategories.SECURITY_CHECKPOINT: return securityLaneName
|
|
216
|
+
? T('wayfinder:Through _security_ to', { name: securityLaneName })
|
|
217
|
+
: T('wayfinder:Through security to')
|
|
218
|
+
case segmentCategories.RAMP: return T('wayfinder:Take ramp to')
|
|
219
|
+
case segmentCategories.RAMP_UP: return T('wayfinder:Take ramp up to')
|
|
220
|
+
case segmentCategories.RAMP_DOWN: return T('wayfinder:Take ramp down to')
|
|
221
|
+
default: return ''
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const translateZeroOrOther = (count, T) => (zeroKey, otherKey) => count === 0
|
|
226
|
+
? T('wayfinder:' + zeroKey)
|
|
227
|
+
: T('wayfinder:' + otherKey, { count });
|
|
228
|
+
|
|
229
|
+
const checkIfAccessible = R.compose(
|
|
230
|
+
R.not, R.includes(R.__, ['escalator', 'stairs']), R.toLower, R.prop('type'));
|
|
231
|
+
|
|
232
|
+
const getSecurityLaneName = (queueTypes, waypoints) => {
|
|
233
|
+
const lane = findPropWaypoints('securityLane')(waypoints);
|
|
234
|
+
if (!lane) return
|
|
235
|
+
const types = R.prop(lane.type, queueTypes);
|
|
236
|
+
const laneType = R.find(R.propEq('id', lane.id), types);
|
|
237
|
+
return R.prop('displayText', laneType)
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const findPropWaypoints = propName => R.compose(
|
|
241
|
+
R.prop(propName),
|
|
242
|
+
R.find(R.prop(propName)),
|
|
243
|
+
R.drop(1)); // because first waypoint is the end of previous segment and can be security checkpoint
|
|
244
|
+
|
|
245
|
+
module.exports = getSteps;
|