venue-js 1.4.0-next.2 → 1.4.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data/index.d.mts +4 -0
- package/dist/data/index.d.ts +4 -0
- package/dist/data/index.js +2572 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/index.mjs +2523 -0
- package/dist/data/index.mjs.map +1 -0
- package/dist/index-CrxL_5B7.d.mts +1025 -0
- package/dist/index-CrxL_5B7.d.ts +1025 -0
- package/dist/index.d.mts +10 -791
- package/dist/index.d.ts +10 -791
- package/dist/index.js +2181 -1060
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2168 -1050
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -1
package/dist/index.mjs
CHANGED
|
@@ -27,6 +27,71 @@ var IMDF_FEATURE_TYPES = [
|
|
|
27
27
|
"unit",
|
|
28
28
|
"venue"
|
|
29
29
|
];
|
|
30
|
+
var IMDF_UNIT_CATEGORIES = [
|
|
31
|
+
"auditorium",
|
|
32
|
+
"brick",
|
|
33
|
+
"classroom",
|
|
34
|
+
"column",
|
|
35
|
+
"concrete",
|
|
36
|
+
"conferenceroom",
|
|
37
|
+
"drywall",
|
|
38
|
+
"elevator",
|
|
39
|
+
"escalator",
|
|
40
|
+
"fieldofplay",
|
|
41
|
+
"firstaid",
|
|
42
|
+
"fitnessroom",
|
|
43
|
+
"foodservice",
|
|
44
|
+
"footbridge",
|
|
45
|
+
"glass",
|
|
46
|
+
"huddleroom",
|
|
47
|
+
"kitchen",
|
|
48
|
+
"laboratory",
|
|
49
|
+
"library",
|
|
50
|
+
"lobby",
|
|
51
|
+
"lounge",
|
|
52
|
+
"mailroom",
|
|
53
|
+
"mothersroom",
|
|
54
|
+
"movietheater",
|
|
55
|
+
"movingwalkway",
|
|
56
|
+
"nonpublic",
|
|
57
|
+
"office",
|
|
58
|
+
"opentobelow",
|
|
59
|
+
"parking",
|
|
60
|
+
"phoneroom",
|
|
61
|
+
"platform",
|
|
62
|
+
"privatelounge",
|
|
63
|
+
"ramp",
|
|
64
|
+
"recreation",
|
|
65
|
+
"restroom",
|
|
66
|
+
"restroom.family",
|
|
67
|
+
"restroom.female",
|
|
68
|
+
"restroom.female.wheelchair",
|
|
69
|
+
"restroom.male",
|
|
70
|
+
"restroom.male.wheelchair",
|
|
71
|
+
"restroom.transgender",
|
|
72
|
+
"restroom.transgender.wheelchair",
|
|
73
|
+
"restroom.unisex",
|
|
74
|
+
"restroom.unisex.wheelchair",
|
|
75
|
+
"restroom.wheelchair",
|
|
76
|
+
"road",
|
|
77
|
+
"room",
|
|
78
|
+
"serverroom",
|
|
79
|
+
"shower",
|
|
80
|
+
"smokingarea",
|
|
81
|
+
"stairs",
|
|
82
|
+
"steps",
|
|
83
|
+
"storage",
|
|
84
|
+
"structure",
|
|
85
|
+
"terrace",
|
|
86
|
+
"theater",
|
|
87
|
+
"unenclosedarea",
|
|
88
|
+
"unspecified",
|
|
89
|
+
"vegetation",
|
|
90
|
+
"waitingroom",
|
|
91
|
+
"walkway",
|
|
92
|
+
"walkway.island",
|
|
93
|
+
"wood"
|
|
94
|
+
];
|
|
30
95
|
var NONIMDF_FEATURE_TYPES = [
|
|
31
96
|
"taxonomy",
|
|
32
97
|
"event",
|
|
@@ -85,6 +150,119 @@ var defaultFeatureQueryOptionsMap = {
|
|
|
85
150
|
model3d: {}
|
|
86
151
|
};
|
|
87
152
|
|
|
153
|
+
// src/data/utils/geometry-validator.ts
|
|
154
|
+
var isValidCoordinate = (point2) => {
|
|
155
|
+
return point2.length === 2 && point2.every((coord) => typeof coord === "number");
|
|
156
|
+
};
|
|
157
|
+
function isValidLinearRingCoordinates(ring) {
|
|
158
|
+
if (ring.length < 4) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
|
|
162
|
+
}
|
|
163
|
+
var isValidPolygonCoordinates = (polygon2) => {
|
|
164
|
+
if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
|
|
165
|
+
return isValidLinearRingCoordinates(polygon2);
|
|
166
|
+
}
|
|
167
|
+
if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
|
|
168
|
+
if (!isValidLinearRingCoordinates(polygon2[0])) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
for (let i = 1; i < polygon2.length; i++) {
|
|
172
|
+
if (!isValidLinearRingCoordinates(polygon2[i])) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
};
|
|
180
|
+
var isValidMultiPolygonCoordinates = (multipolygon) => {
|
|
181
|
+
return multipolygon.every(isValidPolygonCoordinates);
|
|
182
|
+
};
|
|
183
|
+
var isValidLineStringCoordinates = (lineString2) => {
|
|
184
|
+
if (!Array.isArray(lineString2) || lineString2.length < 2) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
const firstPoint = lineString2[0];
|
|
188
|
+
const lastPoint = lineString2[lineString2.length - 1];
|
|
189
|
+
if (firstPoint[0] === lastPoint[0] && firstPoint[1] === lastPoint[1]) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
return lineString2.every(isValidCoordinate);
|
|
193
|
+
};
|
|
194
|
+
var isValidMultiPolygon = (geometry) => {
|
|
195
|
+
const { type, coordinates } = geometry;
|
|
196
|
+
return type === "MultiPolygon" && isValidMultiPolygonCoordinates(coordinates);
|
|
197
|
+
};
|
|
198
|
+
var isValidPolygon = (geometry) => {
|
|
199
|
+
const { type, coordinates } = geometry;
|
|
200
|
+
return type === "Polygon" && isValidPolygonCoordinates(coordinates);
|
|
201
|
+
};
|
|
202
|
+
var isValidLineString = (geometry) => {
|
|
203
|
+
const { type, coordinates } = geometry;
|
|
204
|
+
return type === "LineString" && isValidLineStringCoordinates(coordinates);
|
|
205
|
+
};
|
|
206
|
+
var isValidPoint = (geometry) => {
|
|
207
|
+
const { type, coordinates } = geometry;
|
|
208
|
+
return type === "Point" && isValidCoordinate(coordinates);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/data/utils/match-filters.ts
|
|
212
|
+
function isInFilter(filter) {
|
|
213
|
+
return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
|
|
214
|
+
}
|
|
215
|
+
var someIntersect = (a, b) => a.some((v) => b.includes(v));
|
|
216
|
+
function matchFilter(value, filter) {
|
|
217
|
+
if (Array.isArray(value)) {
|
|
218
|
+
if (isInFilter(filter)) return someIntersect(value, filter.$in);
|
|
219
|
+
return value.includes(filter);
|
|
220
|
+
} else {
|
|
221
|
+
if (isInFilter(filter)) return filter.$in.includes(value);
|
|
222
|
+
return value === filter;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function matchFilters(item, filters) {
|
|
226
|
+
return Object.entries(filters).every(([key, filter]) => {
|
|
227
|
+
return matchFilter(item.properties[key], filter);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/data/utils/occupant-helper.ts
|
|
232
|
+
var occupant_helper_exports = {};
|
|
233
|
+
__export(occupant_helper_exports, {
|
|
234
|
+
getOccupantCorrelatedLocations: () => getOccupantCorrelatedLocations,
|
|
235
|
+
getOccupantMainLocation: () => getOccupantMainLocation,
|
|
236
|
+
getOccupantMarkerLocations: () => getOccupantMarkerLocations
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// src/data/utils/lodash/compact.ts
|
|
240
|
+
var compact = (arr) => arr.filter((item) => Boolean(item));
|
|
241
|
+
|
|
242
|
+
// src/data/utils/occupant-helper.ts
|
|
243
|
+
var getOccupantMainLocation = (occupant) => {
|
|
244
|
+
return occupant.properties.kiosk || occupant.properties.unit;
|
|
245
|
+
};
|
|
246
|
+
var getOccupantCorrelatedLocations = (occupant) => {
|
|
247
|
+
const allCorrelatedLocations = [
|
|
248
|
+
...occupant.properties.units,
|
|
249
|
+
...occupant.properties.kiosks
|
|
250
|
+
];
|
|
251
|
+
return compact(allCorrelatedLocations);
|
|
252
|
+
};
|
|
253
|
+
var getOccupantMarkerLocations = (occupant, options) => {
|
|
254
|
+
const placementType = options?.type ? options.type : occupant.properties.show_name_on_all_units ? "ALL_LOCATIONS" : "ONCE_PER_LEVEL";
|
|
255
|
+
const mainLocation = getOccupantMainLocation(occupant);
|
|
256
|
+
const mainLocationLevel = mainLocation?.properties?.level_id;
|
|
257
|
+
const allCorrelatedLocations = getOccupantCorrelatedLocations(occupant);
|
|
258
|
+
if (placementType === "ALL_LOCATIONS") {
|
|
259
|
+
return compact([mainLocation, ...allCorrelatedLocations]);
|
|
260
|
+
}
|
|
261
|
+
const otherLevelLocations = allCorrelatedLocations.filter((f) => f.properties.level_id !== mainLocationLevel);
|
|
262
|
+
const onePerLevelLocations = [...new Map(otherLevelLocations.map((loc) => [loc.properties.level_id, loc])).values()];
|
|
263
|
+
return compact([mainLocation, ...onePerLevelLocations]);
|
|
264
|
+
};
|
|
265
|
+
|
|
88
266
|
// src/data/api/delivery-project.ts
|
|
89
267
|
async function fetchDeliveryApi(projectId, apiKey, featureType, baseUrl = DEFAULT_BASE_URL) {
|
|
90
268
|
switch (featureType) {
|
|
@@ -206,115 +384,6 @@ var safeFetchFeature = async (featureType, params) => {
|
|
|
206
384
|
}
|
|
207
385
|
};
|
|
208
386
|
|
|
209
|
-
// src/data/utils/geometry-validator.ts
|
|
210
|
-
var isValidCoordinate = (point2) => {
|
|
211
|
-
return point2.length === 2 && point2.every((coord) => typeof coord === "number");
|
|
212
|
-
};
|
|
213
|
-
function isValidLinearRingCoordinates(ring) {
|
|
214
|
-
if (ring.length < 4) {
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
|
|
218
|
-
}
|
|
219
|
-
var isValidPolygonCoordinates = (polygon2) => {
|
|
220
|
-
if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
|
|
221
|
-
return isValidLinearRingCoordinates(polygon2);
|
|
222
|
-
}
|
|
223
|
-
if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
|
|
224
|
-
if (!isValidLinearRingCoordinates(polygon2[0])) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
for (let i = 1; i < polygon2.length; i++) {
|
|
228
|
-
if (!isValidLinearRingCoordinates(polygon2[i])) {
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return true;
|
|
233
|
-
}
|
|
234
|
-
return false;
|
|
235
|
-
};
|
|
236
|
-
var isValidMultiPolygonCoordinates = (multipolygon) => {
|
|
237
|
-
return multipolygon.every(isValidPolygonCoordinates);
|
|
238
|
-
};
|
|
239
|
-
var isValidLineStringCoordinates = (lineString2) => {
|
|
240
|
-
if (!Array.isArray(lineString2) || lineString2.length < 2) {
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
const firstPoint = lineString2[0];
|
|
244
|
-
const lastPoint = lineString2[lineString2.length - 1];
|
|
245
|
-
if (firstPoint[0] === lastPoint[0] && firstPoint[1] === lastPoint[1]) {
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
return lineString2.every(isValidCoordinate);
|
|
249
|
-
};
|
|
250
|
-
var isValidMultiPolygon = (geometry) => {
|
|
251
|
-
const { type, coordinates } = geometry;
|
|
252
|
-
return type === "MultiPolygon" && isValidMultiPolygonCoordinates(coordinates);
|
|
253
|
-
};
|
|
254
|
-
var isValidPolygon = (geometry) => {
|
|
255
|
-
const { type, coordinates } = geometry;
|
|
256
|
-
return type === "Polygon" && isValidPolygonCoordinates(coordinates);
|
|
257
|
-
};
|
|
258
|
-
var isValidLineString = (geometry) => {
|
|
259
|
-
const { type, coordinates } = geometry;
|
|
260
|
-
return type === "LineString" && isValidLineStringCoordinates(coordinates);
|
|
261
|
-
};
|
|
262
|
-
var isValidPoint = (geometry) => {
|
|
263
|
-
const { type, coordinates } = geometry;
|
|
264
|
-
return type === "Point" && isValidCoordinate(coordinates);
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
// src/data/utils/match-filters.ts
|
|
268
|
-
function isInFilter(filter) {
|
|
269
|
-
return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
|
|
270
|
-
}
|
|
271
|
-
var someIntersect = (a, b) => a.some((v2) => b.includes(v2));
|
|
272
|
-
function matchFilter(value, filter) {
|
|
273
|
-
if (Array.isArray(value)) {
|
|
274
|
-
if (isInFilter(filter)) return someIntersect(value, filter.$in);
|
|
275
|
-
return value.includes(filter);
|
|
276
|
-
} else {
|
|
277
|
-
if (isInFilter(filter)) return filter.$in.includes(value);
|
|
278
|
-
return value === filter;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
function matchFilters(item, filters) {
|
|
282
|
-
return Object.entries(filters).every(([key, filter]) => {
|
|
283
|
-
return matchFilter(item.properties[key], filter);
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// src/data/utils/occupant-helper.ts
|
|
288
|
-
var occupant_helper_exports = {};
|
|
289
|
-
__export(occupant_helper_exports, {
|
|
290
|
-
getOccupantCorrelatedLocations: () => getOccupantCorrelatedLocations,
|
|
291
|
-
getOccupantMainLocation: () => getOccupantMainLocation,
|
|
292
|
-
getOccupantMarkerLocations: () => getOccupantMarkerLocations
|
|
293
|
-
});
|
|
294
|
-
import { compact } from "lodash-es";
|
|
295
|
-
var getOccupantMainLocation = (occupant) => {
|
|
296
|
-
return occupant.properties.kiosk || occupant.properties.unit;
|
|
297
|
-
};
|
|
298
|
-
var getOccupantCorrelatedLocations = (occupant) => {
|
|
299
|
-
const allCorrelatedLocations = [
|
|
300
|
-
...occupant.properties.units,
|
|
301
|
-
...occupant.properties.kiosks
|
|
302
|
-
];
|
|
303
|
-
return compact(allCorrelatedLocations);
|
|
304
|
-
};
|
|
305
|
-
var getOccupantMarkerLocations = (occupant, options) => {
|
|
306
|
-
const placementType = options?.type ? options.type : occupant.properties.show_name_on_all_units ? "ALL_LOCATIONS" : "ONCE_PER_LEVEL";
|
|
307
|
-
const mainLocation = getOccupantMainLocation(occupant);
|
|
308
|
-
const mainLocationLevel = mainLocation?.properties?.level_id;
|
|
309
|
-
const allCorrelatedLocations = getOccupantCorrelatedLocations(occupant);
|
|
310
|
-
if (placementType === "ALL_LOCATIONS") {
|
|
311
|
-
return compact([mainLocation, ...allCorrelatedLocations]);
|
|
312
|
-
}
|
|
313
|
-
const otherLevelLocations = allCorrelatedLocations.filter((f) => f.properties.level_id !== mainLocationLevel);
|
|
314
|
-
const onePerLevelLocations = [...new Map(otherLevelLocations.map((loc) => [loc.properties.level_id, loc])).values()];
|
|
315
|
-
return compact([mainLocation, ...onePerLevelLocations]);
|
|
316
|
-
};
|
|
317
|
-
|
|
318
387
|
// src/data/getDataClient.ts
|
|
319
388
|
import {
|
|
320
389
|
QueryClient,
|
|
@@ -322,8 +391,40 @@ import {
|
|
|
322
391
|
} from "@tanstack/query-core";
|
|
323
392
|
|
|
324
393
|
// src/data/populator/index.ts
|
|
325
|
-
import {
|
|
326
|
-
import {
|
|
394
|
+
import { center as center2 } from "@turf/center";
|
|
395
|
+
import { booleanPointInPolygon as booleanPointInPolygon2 } from "@turf/boolean-point-in-polygon";
|
|
396
|
+
|
|
397
|
+
// src/data/utils/findContaining.ts
|
|
398
|
+
import { center } from "@turf/center";
|
|
399
|
+
import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
|
|
400
|
+
var findContainingUnit = (poi, units) => {
|
|
401
|
+
const unit = units.find(
|
|
402
|
+
(unit2) => {
|
|
403
|
+
try {
|
|
404
|
+
return unit2.properties.level_id === poi.properties.level_id && booleanPointInPolygon(center(poi), unit2);
|
|
405
|
+
} catch (e) {
|
|
406
|
+
console.log(`Cannot find containing unit of (${poi.id}):`, e.message);
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
return unit;
|
|
412
|
+
};
|
|
413
|
+
var findContainingUnitAtPoint = (point2, levelId, units) => {
|
|
414
|
+
const unit = units.find(
|
|
415
|
+
(unit2) => {
|
|
416
|
+
try {
|
|
417
|
+
return unit2.properties.level_id === levelId && booleanPointInPolygon(point2, unit2);
|
|
418
|
+
} catch (e) {
|
|
419
|
+
console.log(`Cannot find containing unit of (point: ${point2}, levelId: ${levelId}):`, e.message);
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
return unit;
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
// src/data/populator/index.ts
|
|
327
428
|
var createPopulator = ({
|
|
328
429
|
internalFindById,
|
|
329
430
|
internalFilterByType
|
|
@@ -333,7 +434,6 @@ var createPopulator = ({
|
|
|
333
434
|
const populateDetail = (detail) => Promise.resolve(detail);
|
|
334
435
|
const populateFootprint = (footprint) => Promise.resolve(footprint);
|
|
335
436
|
const populateGeofence = (geofence) => Promise.resolve(geofence);
|
|
336
|
-
const populateRelationship = (relationship) => Promise.resolve(relationship);
|
|
337
437
|
const populatePrivilege = (privilege) => Promise.resolve(privilege);
|
|
338
438
|
const populateEvent = (event) => Promise.resolve(event);
|
|
339
439
|
const populatePromotion = async (promotion) => {
|
|
@@ -357,13 +457,14 @@ var createPopulator = ({
|
|
|
357
457
|
const ordinalKiosks = kiosks.filter(
|
|
358
458
|
(kiosk2) => kiosk2.properties.level_id === defaultLevel.id
|
|
359
459
|
);
|
|
360
|
-
const kiosk = ordinalKiosks.find((kiosk2) =>
|
|
460
|
+
const kiosk = ordinalKiosks.find((kiosk2) => booleanPointInPolygon2(amenity, kiosk2));
|
|
361
461
|
return {
|
|
362
462
|
...amenity,
|
|
363
463
|
properties: {
|
|
364
464
|
...amenity.properties,
|
|
365
465
|
ordinal: defaultLevel.properties.ordinal,
|
|
366
466
|
level_name: defaultLevel.properties.name.en,
|
|
467
|
+
level: defaultLevel,
|
|
367
468
|
units: populatedUnits,
|
|
368
469
|
venue,
|
|
369
470
|
_experimental_kiosk: kiosk ? await populateKiosk(kiosk) : null
|
|
@@ -375,7 +476,7 @@ var createPopulator = ({
|
|
|
375
476
|
const venue = await internalFindById(unit.properties.venue_id);
|
|
376
477
|
const level = await internalFindById(unit.properties.level_id);
|
|
377
478
|
const sections = await internalFilterByType("section");
|
|
378
|
-
const section = sections.find((section2) =>
|
|
479
|
+
const section = sections.find((section2) => booleanPointInPolygon2(anchor, section2));
|
|
379
480
|
return {
|
|
380
481
|
...anchor,
|
|
381
482
|
properties: {
|
|
@@ -408,20 +509,11 @@ var createPopulator = ({
|
|
|
408
509
|
const venue = await internalFindById(kiosk.properties.venue_id);
|
|
409
510
|
const anchor = await internalFindById(kiosk.properties.anchor_id);
|
|
410
511
|
const units = await internalFilterByType("unit");
|
|
411
|
-
const unit = units.
|
|
412
|
-
(unit2) => {
|
|
413
|
-
try {
|
|
414
|
-
return unit2.properties.category === "walkway" && unit2.properties.level_id === kiosk.properties.level_id && booleanWithin(kiosk, unit2);
|
|
415
|
-
} catch (e) {
|
|
416
|
-
console.log(`Cannot find kiosk(${kiosk.id})'s units:`, e.message);
|
|
417
|
-
return false;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
);
|
|
512
|
+
const unit = findContainingUnit(kiosk, units.filter((unit2) => unit2.properties.category === "walkway"));
|
|
421
513
|
let section = null;
|
|
422
514
|
if (anchor) {
|
|
423
515
|
const sections = await internalFilterByType("section");
|
|
424
|
-
section = sections.find((section2) =>
|
|
516
|
+
section = sections.find((section2) => booleanPointInPolygon2(anchor, section2));
|
|
425
517
|
}
|
|
426
518
|
return {
|
|
427
519
|
...kiosk,
|
|
@@ -451,8 +543,8 @@ var createPopulator = ({
|
|
|
451
543
|
anchor_id,
|
|
452
544
|
venue_id,
|
|
453
545
|
local_category_ids,
|
|
454
|
-
promotion_ids,
|
|
455
|
-
privilege_ids,
|
|
546
|
+
promotion_ids = [],
|
|
547
|
+
privilege_ids = [],
|
|
456
548
|
kiosk_id,
|
|
457
549
|
unit_id,
|
|
458
550
|
kiosk_ids = [],
|
|
@@ -479,7 +571,7 @@ var createPopulator = ({
|
|
|
479
571
|
...occupant.properties,
|
|
480
572
|
anchor: anchor ? await populateAnchor(anchor) : null,
|
|
481
573
|
local_categories: await Promise.all(
|
|
482
|
-
|
|
574
|
+
compact(localCategories).map(populateTaxonomy)
|
|
483
575
|
),
|
|
484
576
|
venue,
|
|
485
577
|
promotions,
|
|
@@ -516,12 +608,29 @@ var createPopulator = ({
|
|
|
516
608
|
}
|
|
517
609
|
};
|
|
518
610
|
};
|
|
611
|
+
const populateRelationship = async (relationship) => {
|
|
612
|
+
const originId = relationship.properties.origin?.id;
|
|
613
|
+
const destinationId = relationship.properties.destination?.id;
|
|
614
|
+
const origin = originId ? await internalFindById(originId) : null;
|
|
615
|
+
const destination = destinationId ? await internalFindById(destinationId) : null;
|
|
616
|
+
const intermediary_ids = (relationship.properties.intermediary || []).map(({ id }) => id);
|
|
617
|
+
const intermediary = await Promise.all(intermediary_ids.map(internalFindById));
|
|
618
|
+
return {
|
|
619
|
+
...relationship,
|
|
620
|
+
properties: {
|
|
621
|
+
...relationship.properties,
|
|
622
|
+
origin,
|
|
623
|
+
destination,
|
|
624
|
+
intermediary
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
};
|
|
519
628
|
const populateUnit = async (unit) => {
|
|
520
629
|
const venue = await internalFindById(unit.properties.venue_id);
|
|
521
630
|
const level = await internalFindById(unit.properties.level_id);
|
|
522
631
|
const sections = await internalFilterByType("section");
|
|
523
632
|
try {
|
|
524
|
-
const section = unit.geometry.type !== "MultiPolygon" ? sections.find((section2) =>
|
|
633
|
+
const section = unit.geometry.type !== "MultiPolygon" ? sections.find((section2) => booleanPointInPolygon2(center2(unit), section2)) : null;
|
|
525
634
|
return {
|
|
526
635
|
...unit,
|
|
527
636
|
properties: {
|
|
@@ -549,6 +658,20 @@ var createPopulator = ({
|
|
|
549
658
|
}
|
|
550
659
|
};
|
|
551
660
|
};
|
|
661
|
+
const populateModel3D = async (model3d) => {
|
|
662
|
+
const level = await internalFindById(model3d.properties.level_id);
|
|
663
|
+
try {
|
|
664
|
+
return {
|
|
665
|
+
...model3d,
|
|
666
|
+
properties: {
|
|
667
|
+
...model3d.properties,
|
|
668
|
+
level: await populateLevel(level)
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
} catch (err) {
|
|
672
|
+
console.log(`error finding level`, { model3d, level });
|
|
673
|
+
}
|
|
674
|
+
};
|
|
552
675
|
const populateFeature = (feature2) => Promise.resolve(feature2);
|
|
553
676
|
return {
|
|
554
677
|
address: populateAddress,
|
|
@@ -573,150 +696,570 @@ var createPopulator = ({
|
|
|
573
696
|
section: populateSection,
|
|
574
697
|
unit: populateUnit,
|
|
575
698
|
venue: populateVenue,
|
|
576
|
-
taxonomy: populateTaxonomy
|
|
699
|
+
taxonomy: populateTaxonomy,
|
|
700
|
+
model3d: populateModel3D
|
|
577
701
|
};
|
|
578
702
|
};
|
|
579
703
|
|
|
580
|
-
// src/data/
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
throw new Error(
|
|
595
|
-
"Cannot create VenueDataClient. Reason: `previewToken` is missing"
|
|
596
|
-
);
|
|
597
|
-
const createDeliveryApiQueryOptions = (featureType) => ({
|
|
598
|
-
queryKey: ["_deliveryapi", featureType],
|
|
599
|
-
queryFn: () => safeFetchFeature(featureType, { mode, projectId, apiKey, previewToken, baseUrl })
|
|
704
|
+
// src/data/search/getSearchClient.ts
|
|
705
|
+
import Fuse from "fuse.js";
|
|
706
|
+
|
|
707
|
+
// src/data/search/utils/sanitizeInput.ts
|
|
708
|
+
var sanitizeInput = (str) => str.replace(/[\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, "").replace(/[\-–—_./()]+/g, "").normalize("NFC").trim();
|
|
709
|
+
|
|
710
|
+
// src/data/search/getSearchClient.ts
|
|
711
|
+
var getSearchClient = ({ occupants, amenities }) => {
|
|
712
|
+
const fuseAmenities = new Fuse(amenities, {
|
|
713
|
+
threshold: 0.2,
|
|
714
|
+
keys: [
|
|
715
|
+
{ name: "properties.name", "weight": 1, getFn: (obj) => Object.values(obj.properties.name || {}) },
|
|
716
|
+
{ name: "properties.category", "weight": 1 }
|
|
717
|
+
]
|
|
600
718
|
});
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
719
|
+
const fuseOccupants = new Fuse(occupants, {
|
|
720
|
+
threshold: 0.25,
|
|
721
|
+
// 0.2 is too strict (can't find Mo-Mo Paradise with "momo" search string)
|
|
722
|
+
includeScore: true,
|
|
723
|
+
shouldSort: true,
|
|
724
|
+
keys: [
|
|
725
|
+
{ name: "properties.name", "weight": 4, getFn: (obj) => Object.values(obj.properties.name || {}) },
|
|
726
|
+
{ name: "properties.keywords", "weight": 0.5 },
|
|
727
|
+
{ name: "properties.category", "weight": 0.25 },
|
|
728
|
+
{ name: "properties.local_category_names", "weight": 0.25 },
|
|
729
|
+
{ name: "properties.description", "weight": 0.25, getFn: (occ) => Object.values(occ.properties.description || {}) },
|
|
730
|
+
{ name: "properties.unit_name", "weight": 0.25 },
|
|
731
|
+
{ name: "properties.kiosk_name", "weight": 0.25 }
|
|
732
|
+
]
|
|
733
|
+
});
|
|
734
|
+
const search = (value) => {
|
|
735
|
+
const sanitizedValue = sanitizeInput(value);
|
|
736
|
+
const matchedAmenities = fuseAmenities.search(sanitizedValue);
|
|
737
|
+
const matchedOccupants = fuseOccupants.search(sanitizedValue);
|
|
738
|
+
return [...matchedAmenities, ...matchedOccupants];
|
|
608
739
|
};
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
const featureType = id.slice(0, id.lastIndexOf("-"));
|
|
612
|
-
const feature2 = await queryClient.ensureQueryData({
|
|
613
|
-
queryKey: ["_deliveryapi", featureType, id],
|
|
614
|
-
queryFn: async () => {
|
|
615
|
-
const features = await internalFilterByType(featureType);
|
|
616
|
-
const feature3 = features.find(
|
|
617
|
-
(f) => f.id === id
|
|
618
|
-
);
|
|
619
|
-
return feature3 ?? null;
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
return feature2;
|
|
740
|
+
return {
|
|
741
|
+
search
|
|
623
742
|
};
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
// src/data/navigate/getNavigateClient.ts
|
|
746
|
+
import { booleanPointInPolygon as booleanPointInPolygon4 } from "@turf/boolean-point-in-polygon";
|
|
747
|
+
|
|
748
|
+
// src/data/navigate/graph/prepare.ts
|
|
749
|
+
import _6 from "lodash";
|
|
750
|
+
import DijstraGraph from "node-dijkstra";
|
|
751
|
+
import { distance as distance2 } from "@turf/distance";
|
|
752
|
+
import { center as turfCenter3 } from "@turf/center";
|
|
753
|
+
|
|
754
|
+
// src/data/navigate/graph/nodemap/createTraversalNodeMap.ts
|
|
755
|
+
import { distance as turfDistance } from "@turf/distance";
|
|
756
|
+
import { center as turfCenter } from "@turf/center";
|
|
757
|
+
import _ from "lodash";
|
|
758
|
+
|
|
759
|
+
// src/data/navigate/graph/constants.ts
|
|
760
|
+
var ROOM_BASEDISTANCE = 1e3;
|
|
761
|
+
var TERRACE_BASEDISTANCE = 1e3;
|
|
762
|
+
var ESCALATOR_BASEDISTANCE = 200;
|
|
763
|
+
var RAMP_BASEDISTANCE = 200;
|
|
764
|
+
var ELEVATOR_BASEDISTANCE = 500;
|
|
765
|
+
var STAIR_BASEDISTANCE = 1e5;
|
|
766
|
+
var BASE_POI_BASEDISTANCE = 9999999;
|
|
767
|
+
var DEFAULT_UNIT_BASEDISTANCE_OPTIONS = {
|
|
768
|
+
default: { baseDistance: 0 },
|
|
769
|
+
byCategory: {
|
|
770
|
+
room: { baseDistance: ROOM_BASEDISTANCE },
|
|
771
|
+
terrace: { baseDistance: TERRACE_BASEDISTANCE },
|
|
772
|
+
escalator: { baseDistance: ESCALATOR_BASEDISTANCE, scaleDistanceByLevel: false },
|
|
773
|
+
ramp: { baseDistance: RAMP_BASEDISTANCE, scaleDistanceByLevel: false },
|
|
774
|
+
elevator: { baseDistance: ELEVATOR_BASEDISTANCE, scaleDistanceByLevel: false },
|
|
775
|
+
stairs: {
|
|
776
|
+
baseDistance: STAIR_BASEDISTANCE,
|
|
777
|
+
scaleDistanceByLevel: true
|
|
778
|
+
},
|
|
779
|
+
"stairs.emergencyexit": {
|
|
780
|
+
baseDistance: STAIR_BASEDISTANCE,
|
|
781
|
+
scaleDistanceByLevel: true
|
|
630
782
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
// src/data/navigate/graph/utils/getDistanceOption.ts
|
|
787
|
+
var getDistanceOptions = (options, category) => {
|
|
788
|
+
if (!options) return DEFAULT_UNIT_BASEDISTANCE_OPTIONS.byCategory[category];
|
|
789
|
+
return (category && options.byCategory?.[category]) ?? DEFAULT_UNIT_BASEDISTANCE_OPTIONS.byCategory[category] ?? options?.default ?? DEFAULT_UNIT_BASEDISTANCE_OPTIONS.default;
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
// src/data/utils/trace.ts
|
|
793
|
+
var trace = (namespace, text, ms, color) => {
|
|
794
|
+
if (process.env.NODE_ENV !== "test") console.log(`[${namespace}] %c${text.padEnd(90)} ${ms !== void 0 ? `${ms.toFixed(1).padStart(6)} ms` : ``}`, color ? `color: ${color}` : void 0);
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// src/data/navigate/graph/nodemap/createTraversalNodeMap.ts
|
|
798
|
+
var createTraversalNodeMap = (unitOpenings, options) => {
|
|
799
|
+
const { units } = options.data;
|
|
800
|
+
let counter = 0;
|
|
801
|
+
const calculateFeatureDistanceWithinUnit = (features, distanceOptions) => {
|
|
802
|
+
let relationshipGraph = {};
|
|
803
|
+
for (let currentIndex = 0; currentIndex < features.length; currentIndex++) {
|
|
804
|
+
const isLastItem = currentIndex + 1 === features.length;
|
|
805
|
+
if (isLastItem) break;
|
|
806
|
+
for (let j = currentIndex + 1; j < features.length; j++) {
|
|
807
|
+
const opening = features[currentIndex];
|
|
808
|
+
const feature2 = features[j];
|
|
809
|
+
try {
|
|
810
|
+
const distance5 = turfDistance(
|
|
811
|
+
turfCenter(opening.geometry),
|
|
812
|
+
turfCenter(feature2.geometry),
|
|
813
|
+
{ units: "meters" }
|
|
814
|
+
) + (distanceOptions?.baseDistance ?? 0);
|
|
815
|
+
if (opening.id === feature2.id) continue;
|
|
816
|
+
_.set(relationshipGraph, `${opening.id}.${feature2.id}`, distance5);
|
|
817
|
+
_.set(relationshipGraph, `${feature2.id}.${opening.id}`, distance5);
|
|
818
|
+
counter++;
|
|
819
|
+
} catch (error) {
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
663
822
|
}
|
|
664
|
-
|
|
823
|
+
}
|
|
824
|
+
return relationshipGraph;
|
|
825
|
+
};
|
|
826
|
+
const t0 = performance.now();
|
|
827
|
+
const nodeMap = _.reduce(
|
|
828
|
+
unitOpenings,
|
|
829
|
+
(acc, openings, unitId) => {
|
|
830
|
+
const unit = units.find((unit2) => unit2.id === unitId);
|
|
831
|
+
const unitDistanceOption = getDistanceOptions(options.unitDistanceOptions, unit.properties.category);
|
|
832
|
+
return _.merge(
|
|
833
|
+
acc,
|
|
834
|
+
calculateFeatureDistanceWithinUnit(openings, unitDistanceOption)
|
|
835
|
+
);
|
|
665
836
|
},
|
|
666
|
-
|
|
837
|
+
{}
|
|
838
|
+
);
|
|
839
|
+
const t1 = performance.now();
|
|
840
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} traversal relationships`, t1 - t0);
|
|
841
|
+
return nodeMap;
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
// src/data/navigate/graph/nodemap/createElevatorNodeMap.ts
|
|
845
|
+
import _2 from "lodash";
|
|
846
|
+
var createElevatorNodeMap = (elevatorLikeRelationships, unitOpenings, options) => {
|
|
847
|
+
const t0 = performance.now();
|
|
848
|
+
const { levels, units } = options.data;
|
|
849
|
+
const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "elevator");
|
|
850
|
+
const {
|
|
851
|
+
baseDistance = ELEVATOR_BASEDISTANCE,
|
|
852
|
+
scaleDistanceByLevel = false
|
|
853
|
+
} = distanceOptions;
|
|
854
|
+
let elevatorNodeMap = {};
|
|
855
|
+
let counter = 0;
|
|
856
|
+
for (const relationship of elevatorLikeRelationships) {
|
|
857
|
+
try {
|
|
858
|
+
const {
|
|
859
|
+
origin: originTypeAndId,
|
|
860
|
+
intermediary,
|
|
861
|
+
destination: destinationTypeAndId
|
|
862
|
+
} = relationship.properties;
|
|
863
|
+
const origin = units.find((unit) => unit.id === originTypeAndId.id);
|
|
864
|
+
if (!origin) return;
|
|
865
|
+
const originOpenings = compact(unitOpenings[origin.id]);
|
|
866
|
+
const originLevel = levels.find((level) => level.id === origin.properties.level_id);
|
|
867
|
+
const destination = units.find((unit) => unit.id === destinationTypeAndId.id);
|
|
868
|
+
const destinationOpenings = unitOpenings[destination.id];
|
|
869
|
+
const destinationOpeningAndLevels = destinationOpenings.map((opening) => {
|
|
870
|
+
const level = levels.find((level2) => level2.id === destination.properties.level_id);
|
|
871
|
+
return { opening, level };
|
|
872
|
+
});
|
|
873
|
+
const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
|
|
874
|
+
const openings = unitOpenings[unitTypeAndId.id];
|
|
875
|
+
const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
|
|
876
|
+
const level = levels.find((level2) => level2.id === unit.properties.level_id);
|
|
877
|
+
return openings.map((opening) => ({ opening, level }));
|
|
878
|
+
}).flat();
|
|
879
|
+
const connections = compact([...intermediaryOpeningAndLevels, ...destinationOpeningAndLevels]);
|
|
880
|
+
if (!originOpenings || originOpenings.length === 0) return;
|
|
881
|
+
for (const originOpening of originOpenings) {
|
|
882
|
+
for (const connection of connections) {
|
|
883
|
+
const { opening, level } = connection;
|
|
884
|
+
let distance5 = baseDistance;
|
|
885
|
+
if (scaleDistanceByLevel) {
|
|
886
|
+
const originOrdinal = originLevel.properties.ordinal;
|
|
887
|
+
const connectionOrdinal = level.properties.ordinal;
|
|
888
|
+
const levelDifference = Math.abs(originOrdinal - connectionOrdinal);
|
|
889
|
+
if (levelDifference > 0) distance5 *= levelDifference;
|
|
890
|
+
}
|
|
891
|
+
_2.set(elevatorNodeMap, `${originOpening.id}.${opening.id}`, distance5);
|
|
892
|
+
_2.set(elevatorNodeMap, `${opening.id}.${originOpening.id}`, distance5);
|
|
893
|
+
counter++;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
} catch (err) {
|
|
897
|
+
console.log(err);
|
|
898
|
+
console.log("cannot create elevatorNodeMap for ", { relationship });
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
const t1 = performance.now();
|
|
902
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
|
|
903
|
+
return elevatorNodeMap;
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
// src/data/navigate/graph/nodemap/createEscalatorNodeMap.ts
|
|
907
|
+
import set from "lodash/set";
|
|
908
|
+
var createEscalatorNodeMap = (relationships, options) => {
|
|
909
|
+
const t0 = performance.now();
|
|
910
|
+
const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "escalator");
|
|
911
|
+
let counter = 0;
|
|
912
|
+
let nodeMap = {};
|
|
913
|
+
for (const relationship of relationships) {
|
|
914
|
+
const {
|
|
915
|
+
properties: { direction, origin, destination }
|
|
916
|
+
} = relationship;
|
|
917
|
+
set(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
|
|
918
|
+
if (direction === "undirected") {
|
|
919
|
+
set(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
|
|
920
|
+
}
|
|
921
|
+
counter++;
|
|
922
|
+
}
|
|
923
|
+
const t1 = performance.now();
|
|
924
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
|
|
925
|
+
return nodeMap;
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
// src/data/navigate/graph/nodemap/createRampNodeMap.ts
|
|
929
|
+
import set2 from "lodash/set";
|
|
930
|
+
var createRampNodeMap = (relationships, options) => {
|
|
931
|
+
const t0 = performance.now();
|
|
932
|
+
const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "ramp");
|
|
933
|
+
let counter = 0;
|
|
934
|
+
let nodeMap = {};
|
|
935
|
+
relationships.forEach((relationship) => {
|
|
936
|
+
const {
|
|
937
|
+
properties: { origin, destination }
|
|
938
|
+
} = relationship;
|
|
939
|
+
set2(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
|
|
940
|
+
set2(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
|
|
941
|
+
counter++;
|
|
667
942
|
});
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
943
|
+
const t1 = performance.now();
|
|
944
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} ramp relationships`, t1 - t0);
|
|
945
|
+
return nodeMap;
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
// src/data/navigate/graph/nodemap/createStairNodeMap.ts
|
|
949
|
+
import _3 from "lodash";
|
|
950
|
+
var createStairNodeMap = (elevatorLikeRelationships, unitOpenings, options) => {
|
|
951
|
+
const t0 = performance.now();
|
|
952
|
+
const { levels = [], openings = [], units = [] } = options.data;
|
|
953
|
+
const { baseDistance, scaleDistanceByLevel } = getDistanceOptions(options.unitDistanceOptions, "stairs");
|
|
954
|
+
let elevatorNodeMap = {};
|
|
955
|
+
let counter = 0;
|
|
956
|
+
for (const relationship of elevatorLikeRelationships) {
|
|
957
|
+
try {
|
|
958
|
+
const {
|
|
959
|
+
origin: { id: originId },
|
|
960
|
+
intermediary,
|
|
961
|
+
destination: { id: destinationId }
|
|
962
|
+
} = relationship.properties;
|
|
963
|
+
const origin = openings.find((opening) => opening.id === originId);
|
|
964
|
+
if (!origin) return;
|
|
965
|
+
const originLevel = levels.find((level) => level.id === origin.properties.level_id);
|
|
966
|
+
const destination = openings.find((opening) => opening.id === destinationId);
|
|
967
|
+
const destinationOpeningAndLevel = {
|
|
968
|
+
opening: destination,
|
|
969
|
+
level: levels.find((level) => level.id === destination.properties.level_id)
|
|
970
|
+
};
|
|
971
|
+
const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
|
|
972
|
+
const openings2 = unitOpenings[unitTypeAndId.id];
|
|
973
|
+
const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
|
|
974
|
+
const level = levels.find((level2) => level2.id === unit.properties.level_id);
|
|
975
|
+
return openings2.map((opening) => ({ opening, level }));
|
|
976
|
+
}).flat();
|
|
977
|
+
const connections = [...intermediaryOpeningAndLevels, destinationOpeningAndLevel];
|
|
978
|
+
if (!origin) return;
|
|
979
|
+
for (const connection of connections) {
|
|
980
|
+
const { opening, level } = connection;
|
|
981
|
+
let distance5 = baseDistance;
|
|
982
|
+
if (scaleDistanceByLevel) {
|
|
983
|
+
const originOrdinal = originLevel.properties.ordinal;
|
|
984
|
+
const connectionOrdinal = level.properties.ordinal;
|
|
985
|
+
const levelDifference = Math.abs(originOrdinal - connectionOrdinal);
|
|
986
|
+
if (levelDifference > 0) distance5 *= levelDifference;
|
|
987
|
+
}
|
|
988
|
+
_3.set(elevatorNodeMap, `${origin.id}.${opening.id}`, distance5);
|
|
989
|
+
_3.set(elevatorNodeMap, `${opening.id}.${origin.id}`, distance5);
|
|
990
|
+
counter++;
|
|
991
|
+
}
|
|
992
|
+
} catch (err) {
|
|
993
|
+
console.warn(
|
|
994
|
+
"Failed to create stairNodeMap",
|
|
995
|
+
{
|
|
996
|
+
relationshipId: relationship.id,
|
|
997
|
+
featureType: relationship.feature_type,
|
|
998
|
+
error: err instanceof Error ? err.message : err,
|
|
999
|
+
stack: err instanceof Error ? err.stack : void 0
|
|
1000
|
+
}
|
|
1001
|
+
);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
const t1 = performance.now();
|
|
1005
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} stairs relationships`, t1 - t0);
|
|
1006
|
+
return elevatorNodeMap;
|
|
1007
|
+
};
|
|
1008
|
+
|
|
1009
|
+
// src/data/navigate/graph/nodemap/createOccupantNodeMap.ts
|
|
1010
|
+
import _4 from "lodash";
|
|
1011
|
+
var createOccupantNodeMap = (occupants) => {
|
|
1012
|
+
const t0 = performance.now();
|
|
1013
|
+
let nodeMap = {};
|
|
1014
|
+
let counter = 0;
|
|
1015
|
+
occupants.forEach((occupant) => {
|
|
1016
|
+
const { unit_id, unit_ids = [], kiosk_id, kiosk_ids = [] } = occupant.properties;
|
|
1017
|
+
const occupantRoomIds = compact([unit_id, ...unit_ids]);
|
|
1018
|
+
const occupantKioskIds = compact([kiosk_id, ...kiosk_ids]);
|
|
1019
|
+
for (const roomId of occupantRoomIds) {
|
|
1020
|
+
_4.set(nodeMap, `${roomId}.${occupant.id}`, 1e-3);
|
|
1021
|
+
_4.set(nodeMap, `${occupant.id}.${roomId}`, 1e-3);
|
|
1022
|
+
counter++;
|
|
1023
|
+
}
|
|
1024
|
+
for (const kioskId of occupantKioskIds) {
|
|
1025
|
+
_4.set(nodeMap, `${kioskId}.${occupant.id}`, 1e-3);
|
|
1026
|
+
_4.set(nodeMap, `${occupant.id}.${kioskId}`, 1e-3);
|
|
1027
|
+
counter++;
|
|
1028
|
+
}
|
|
675
1029
|
});
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
1030
|
+
const t1 = performance.now();
|
|
1031
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} occupants relationships`, t1 - t0);
|
|
1032
|
+
return nodeMap;
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
// src/data/navigate/graph/nodemap/createPOINodeMaps.ts
|
|
1036
|
+
import { center as turfCenter2 } from "@turf/center";
|
|
1037
|
+
import { distance } from "@turf/distance";
|
|
1038
|
+
import _5 from "lodash";
|
|
1039
|
+
var createPOINodeMap = (features, getFeatureUnit, unitOpenings) => {
|
|
1040
|
+
const t0 = performance.now();
|
|
1041
|
+
let nodeMap = {};
|
|
1042
|
+
let counter = 0;
|
|
1043
|
+
features.forEach((feat) => {
|
|
1044
|
+
try {
|
|
1045
|
+
const locatedOnUnitId = getFeatureUnit(feat);
|
|
1046
|
+
const openings = unitOpenings[locatedOnUnitId];
|
|
1047
|
+
const center8 = turfCenter2(feat);
|
|
1048
|
+
for (const opening of openings) {
|
|
1049
|
+
try {
|
|
1050
|
+
const openingCenter = turfCenter2(opening);
|
|
1051
|
+
const dis = distance(center8, openingCenter, { units: "meters" }) + BASE_POI_BASEDISTANCE;
|
|
1052
|
+
_5.set(nodeMap, `${opening.id}.${feat.id}`, dis);
|
|
1053
|
+
_5.set(nodeMap, `${feat.id}.${opening.id}`, dis);
|
|
1054
|
+
counter++;
|
|
1055
|
+
} catch (err) {
|
|
1056
|
+
console.log(err, opening);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
} catch (err) {
|
|
1060
|
+
console.log(err);
|
|
1061
|
+
console.log(`cannot connect poi to openings`, err.message, { feat });
|
|
1062
|
+
}
|
|
1063
|
+
});
|
|
1064
|
+
const type = features.length > 0 ? features[0].feature_type : "-";
|
|
1065
|
+
const t1 = performance.now();
|
|
1066
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} ${type} relationships`, t1 - t0);
|
|
1067
|
+
return nodeMap;
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
// src/data/navigate/graph/utils/mergeNodeMap.ts
|
|
1071
|
+
var mergeNodeMap = (nodeMaps) => {
|
|
1072
|
+
const out = {};
|
|
1073
|
+
for (const nodeMap of nodeMaps) {
|
|
1074
|
+
for (const from in nodeMap) {
|
|
1075
|
+
out[from] = {
|
|
1076
|
+
...out[from] ?? {},
|
|
1077
|
+
...nodeMap[from]
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
683
1080
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
1081
|
+
return out;
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
// src/data/navigate/graph/utils/createUnitOpenings.ts
|
|
1085
|
+
import uniqBy from "lodash/uniqBy";
|
|
1086
|
+
var createUnitOpenings = (relationships, units, openings) => {
|
|
1087
|
+
const openingConnections = {};
|
|
1088
|
+
const relationshipMap = /* @__PURE__ */ new Map();
|
|
1089
|
+
relationships.forEach((relationship) => {
|
|
1090
|
+
const originId = relationship.properties.origin?.id || null;
|
|
1091
|
+
const destinationId = relationship.properties.destination?.id || null;
|
|
1092
|
+
if (!relationshipMap.has(originId)) {
|
|
1093
|
+
relationshipMap.set(originId, []);
|
|
1094
|
+
}
|
|
1095
|
+
if (!relationshipMap.has(destinationId)) {
|
|
1096
|
+
relationshipMap.set(destinationId, []);
|
|
1097
|
+
}
|
|
1098
|
+
relationshipMap.get(originId).push(relationship);
|
|
1099
|
+
relationshipMap.get(destinationId).push(relationship);
|
|
1100
|
+
});
|
|
1101
|
+
units.forEach((unit) => {
|
|
1102
|
+
const unitId = unit.id;
|
|
1103
|
+
const connectedRelationship = relationshipMap.get(unitId) || [];
|
|
1104
|
+
const relationshipIntermediaryTypeAndId = compact(connectedRelationship.map(
|
|
1105
|
+
(relationship) => relationship.properties.intermediary?.[0]
|
|
1106
|
+
// Assuming intermediary is always an array
|
|
1107
|
+
));
|
|
1108
|
+
const relationshipIntermediary = relationshipIntermediaryTypeAndId.map(({ id }) => {
|
|
1109
|
+
return openings.find((opening) => !!opening && opening.id === id);
|
|
1110
|
+
});
|
|
1111
|
+
openingConnections[unitId] = uniqBy(
|
|
1112
|
+
[...openingConnections[unitId] || [], ...relationshipIntermediary],
|
|
1113
|
+
"id"
|
|
689
1114
|
);
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
1115
|
+
});
|
|
1116
|
+
return openingConnections;
|
|
1117
|
+
};
|
|
1118
|
+
|
|
1119
|
+
// src/data/navigate/parsers.ts
|
|
1120
|
+
var parseOrdinalCoordinate = (id) => {
|
|
1121
|
+
return id.slice(0, -1).split(",").map(Number);
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
// src/data/navigate/graph/prepare.ts
|
|
1125
|
+
var prepareGraph = (options) => {
|
|
1126
|
+
const {
|
|
1127
|
+
data: {
|
|
1128
|
+
amenities = [],
|
|
1129
|
+
anchors = [],
|
|
1130
|
+
occupants = [],
|
|
1131
|
+
relationships = [],
|
|
1132
|
+
openings = [],
|
|
1133
|
+
units = [],
|
|
1134
|
+
kiosks = []
|
|
1135
|
+
}
|
|
1136
|
+
} = options;
|
|
1137
|
+
const {
|
|
1138
|
+
traversal: traversalRelationships = [],
|
|
1139
|
+
escalator: escalatorRelationships = [],
|
|
1140
|
+
ramp: rampRelationships = [],
|
|
1141
|
+
elevator: elevatorRelationships = [],
|
|
1142
|
+
stairs: stairsRelationships = []
|
|
1143
|
+
} = _6.groupBy(relationships, "properties.category");
|
|
1144
|
+
const unitOpenings = createUnitOpenings(traversalRelationships, units, openings);
|
|
1145
|
+
const traversalNodeMap = createTraversalNodeMap(unitOpenings, options);
|
|
1146
|
+
const escalatorNodeMap = createEscalatorNodeMap(escalatorRelationships, options);
|
|
1147
|
+
const rampNodeMap = createRampNodeMap(rampRelationships, options);
|
|
1148
|
+
const elevatorNodeMap = createElevatorNodeMap(
|
|
1149
|
+
elevatorRelationships,
|
|
1150
|
+
unitOpenings,
|
|
1151
|
+
options
|
|
1152
|
+
);
|
|
1153
|
+
const stairNodeMap = createStairNodeMap(
|
|
1154
|
+
stairsRelationships,
|
|
1155
|
+
unitOpenings,
|
|
1156
|
+
options
|
|
1157
|
+
);
|
|
1158
|
+
const amenityNodeMap = createPOINodeMap(amenities, (amenity) => amenity.properties.unit_ids[0], unitOpenings);
|
|
1159
|
+
const anchorsNodeMap = createPOINodeMap(anchors, (anchor) => anchor.properties.unit_id, unitOpenings);
|
|
1160
|
+
const walkwayUnits = units.filter((unit) => unit.properties.category === "walkway");
|
|
1161
|
+
const kioskNodeMap = createPOINodeMap(kiosks, (kiosk) => findContainingUnit(kiosk, walkwayUnits)?.id, unitOpenings);
|
|
1162
|
+
const unitNodeMap = createPOINodeMap(units, (unit) => unit.id, unitOpenings);
|
|
1163
|
+
const occupantNodeMap = createOccupantNodeMap(occupants);
|
|
1164
|
+
const defaultGraph = new DijstraGraph(mergeNodeMap([
|
|
1165
|
+
traversalNodeMap,
|
|
1166
|
+
escalatorNodeMap,
|
|
1167
|
+
rampNodeMap,
|
|
1168
|
+
elevatorNodeMap,
|
|
1169
|
+
stairNodeMap,
|
|
1170
|
+
amenityNodeMap,
|
|
1171
|
+
anchorsNodeMap,
|
|
1172
|
+
kioskNodeMap,
|
|
1173
|
+
unitNodeMap,
|
|
1174
|
+
occupantNodeMap
|
|
1175
|
+
]));
|
|
1176
|
+
const accessibleGraph = new DijstraGraph(mergeNodeMap([
|
|
1177
|
+
traversalNodeMap,
|
|
1178
|
+
rampNodeMap,
|
|
1179
|
+
elevatorNodeMap,
|
|
1180
|
+
amenityNodeMap,
|
|
1181
|
+
anchorsNodeMap,
|
|
1182
|
+
kioskNodeMap,
|
|
1183
|
+
unitNodeMap,
|
|
1184
|
+
occupantNodeMap
|
|
1185
|
+
]));
|
|
1186
|
+
const addCoordinateOrdinalNode = (params, locatedOnUnit) => {
|
|
1187
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(params);
|
|
1188
|
+
if (locatedOnUnit) {
|
|
1189
|
+
const openings2 = unitOpenings[locatedOnUnit.id];
|
|
1190
|
+
for (const opening of openings2) {
|
|
1191
|
+
const openingCenter = turfCenter3(opening);
|
|
1192
|
+
const dis = distance2([lat, lng], openingCenter, { units: "meters" });
|
|
1193
|
+
defaultGraph.addNode(params, { [opening.id]: dis }).addNode(opening.id, { [params]: dis });
|
|
1194
|
+
accessibleGraph.addNode(params, { [opening.id]: dis }).addNode(opening.id, { [params]: dis });
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
return { defaultGraph, accessibleGraph, unitOpenings, addCoordinateOrdinalNode };
|
|
1199
|
+
};
|
|
1200
|
+
|
|
1201
|
+
// src/data/navigate/steps/createStepUtils.ts
|
|
1202
|
+
import { capitalize } from "lodash";
|
|
1203
|
+
import _intersectionBy from "lodash/intersectionBy";
|
|
1204
|
+
|
|
1205
|
+
// src/data/navigate/description/describe.ts
|
|
1206
|
+
var t = (template, locale, options) => {
|
|
1207
|
+
return template.replace(`{{intermediary}}`, options.intermediary ?? "").replace(`{{toward}}`, options.toward?.[locale] ?? "").replace(`{{landmark}}`, options.landmark?.[locale] ?? "");
|
|
1208
|
+
};
|
|
1209
|
+
var describeVerticalStep = (fromLevel, toLevel, intermediary) => {
|
|
1210
|
+
const dir = fromLevel.properties.ordinal < toLevel.properties.ordinal ? "up" : "down";
|
|
1211
|
+
const template = `Take the {{intermediary}} ${dir} to {{toward}}`;
|
|
693
1212
|
return {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
1213
|
+
template,
|
|
1214
|
+
text: t(template, "en", { intermediary, toward: toLevel.properties.name })
|
|
1215
|
+
};
|
|
1216
|
+
};
|
|
1217
|
+
var describeHorizontalStep = (intermediary, toward, landmark) => {
|
|
1218
|
+
const template = `Follow the path ${intermediary === "walkway" ? `along the walkway` : `through {{intermediary}}`} ${toward ? `toward {{toward}}` : ``} ${landmark ? `near {{landmark}}` : ``}`.trim();
|
|
1219
|
+
return {
|
|
1220
|
+
text: t(template, "en", { intermediary, toward, landmark }),
|
|
1221
|
+
template
|
|
703
1222
|
};
|
|
704
1223
|
};
|
|
705
1224
|
|
|
706
|
-
// src/
|
|
707
|
-
import
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
1225
|
+
// src/data/navigate/steps/path/index.ts
|
|
1226
|
+
import _7 from "lodash";
|
|
1227
|
+
|
|
1228
|
+
// src/data/navigate/constants.ts
|
|
1229
|
+
var OBSTACLE_FEATURE_TYPES = [
|
|
1230
|
+
"kiosk"
|
|
1231
|
+
/* , "fixture" */
|
|
1232
|
+
];
|
|
1233
|
+
var OBSTACLE_CATEGORIES = [
|
|
1234
|
+
"fixture.water",
|
|
1235
|
+
"fixture.stage",
|
|
1236
|
+
"nonpublic",
|
|
1237
|
+
"opentobelow",
|
|
1238
|
+
"elevator",
|
|
1239
|
+
"escalator",
|
|
1240
|
+
"stairs",
|
|
1241
|
+
"stairs.emergencyexit",
|
|
1242
|
+
"room",
|
|
1243
|
+
"unspecified",
|
|
1244
|
+
"structure",
|
|
1245
|
+
"brick",
|
|
1246
|
+
"concrete",
|
|
1247
|
+
"drywall",
|
|
1248
|
+
"glass",
|
|
1249
|
+
"wood",
|
|
1250
|
+
"column"
|
|
1251
|
+
];
|
|
1252
|
+
var WALKABLE_CATEGORY = [
|
|
1253
|
+
"walkway",
|
|
1254
|
+
"parking",
|
|
1255
|
+
"room",
|
|
1256
|
+
"terrace",
|
|
1257
|
+
"unenclosedarea",
|
|
1258
|
+
"vegetation",
|
|
1259
|
+
"unspecified"
|
|
1260
|
+
];
|
|
718
1261
|
|
|
719
|
-
//
|
|
1262
|
+
// node_modules/@turf/helpers/dist/esm/index.js
|
|
720
1263
|
var earthRadius = 63710088e-1;
|
|
721
1264
|
var factors = {
|
|
722
1265
|
centimeters: earthRadius * 100,
|
|
@@ -803,26 +1346,1175 @@ function featureCollection(features, options = {}) {
|
|
|
803
1346
|
if (options.id) {
|
|
804
1347
|
fc.id = options.id;
|
|
805
1348
|
}
|
|
806
|
-
if (options.bbox) {
|
|
807
|
-
fc.bbox = options.bbox;
|
|
1349
|
+
if (options.bbox) {
|
|
1350
|
+
fc.bbox = options.bbox;
|
|
1351
|
+
}
|
|
1352
|
+
fc.features = features;
|
|
1353
|
+
return fc;
|
|
1354
|
+
}
|
|
1355
|
+
function multiPoint(coordinates, properties, options = {}) {
|
|
1356
|
+
const geom = {
|
|
1357
|
+
type: "MultiPoint",
|
|
1358
|
+
coordinates
|
|
1359
|
+
};
|
|
1360
|
+
return feature(geom, properties, options);
|
|
1361
|
+
}
|
|
1362
|
+
function isNumber(num) {
|
|
1363
|
+
return !isNaN(num) && num !== null && !Array.isArray(num);
|
|
1364
|
+
}
|
|
1365
|
+
function isObject(input) {
|
|
1366
|
+
return input !== null && typeof input === "object" && !Array.isArray(input);
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
// node_modules/@turf/invariant/dist/esm/index.js
|
|
1370
|
+
function getCoord(coord) {
|
|
1371
|
+
if (!coord) {
|
|
1372
|
+
throw new Error("coord is required");
|
|
1373
|
+
}
|
|
1374
|
+
if (!Array.isArray(coord)) {
|
|
1375
|
+
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
1376
|
+
return [...coord.geometry.coordinates];
|
|
1377
|
+
}
|
|
1378
|
+
if (coord.type === "Point") {
|
|
1379
|
+
return [...coord.coordinates];
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
1383
|
+
return [...coord];
|
|
1384
|
+
}
|
|
1385
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
1386
|
+
}
|
|
1387
|
+
function getGeom(geojson) {
|
|
1388
|
+
if (geojson.type === "Feature") {
|
|
1389
|
+
return geojson.geometry;
|
|
1390
|
+
}
|
|
1391
|
+
return geojson;
|
|
1392
|
+
}
|
|
1393
|
+
function getType(geojson, _name) {
|
|
1394
|
+
if (geojson.type === "FeatureCollection") {
|
|
1395
|
+
return "FeatureCollection";
|
|
1396
|
+
}
|
|
1397
|
+
if (geojson.type === "GeometryCollection") {
|
|
1398
|
+
return "GeometryCollection";
|
|
1399
|
+
}
|
|
1400
|
+
if (geojson.type === "Feature" && geojson.geometry !== null) {
|
|
1401
|
+
return geojson.geometry.type;
|
|
1402
|
+
}
|
|
1403
|
+
return geojson.type;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// src/data/navigate/steps/path/index.ts
|
|
1407
|
+
import difference from "@turf/difference";
|
|
1408
|
+
import envelope from "@turf/envelope";
|
|
1409
|
+
import booleanOverlap from "@turf/boolean-overlap";
|
|
1410
|
+
import booleanIntersects from "@turf/boolean-intersects";
|
|
1411
|
+
|
|
1412
|
+
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
1413
|
+
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
1414
|
+
if (geojson === null) return;
|
|
1415
|
+
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
1416
|
+
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
1417
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
1418
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
1419
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
1420
|
+
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
1421
|
+
var multiFeatureIndex = 0;
|
|
1422
|
+
var geometryIndex = 0;
|
|
1423
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
1424
|
+
if (geometry === null) continue;
|
|
1425
|
+
coords = geometry.coordinates;
|
|
1426
|
+
var geomType = geometry.type;
|
|
1427
|
+
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
1428
|
+
switch (geomType) {
|
|
1429
|
+
case null:
|
|
1430
|
+
break;
|
|
1431
|
+
case "Point":
|
|
1432
|
+
if (callback(
|
|
1433
|
+
coords,
|
|
1434
|
+
coordIndex,
|
|
1435
|
+
featureIndex,
|
|
1436
|
+
multiFeatureIndex,
|
|
1437
|
+
geometryIndex
|
|
1438
|
+
) === false)
|
|
1439
|
+
return false;
|
|
1440
|
+
coordIndex++;
|
|
1441
|
+
multiFeatureIndex++;
|
|
1442
|
+
break;
|
|
1443
|
+
case "LineString":
|
|
1444
|
+
case "MultiPoint":
|
|
1445
|
+
for (j = 0; j < coords.length; j++) {
|
|
1446
|
+
if (callback(
|
|
1447
|
+
coords[j],
|
|
1448
|
+
coordIndex,
|
|
1449
|
+
featureIndex,
|
|
1450
|
+
multiFeatureIndex,
|
|
1451
|
+
geometryIndex
|
|
1452
|
+
) === false)
|
|
1453
|
+
return false;
|
|
1454
|
+
coordIndex++;
|
|
1455
|
+
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
1456
|
+
}
|
|
1457
|
+
if (geomType === "LineString") multiFeatureIndex++;
|
|
1458
|
+
break;
|
|
1459
|
+
case "Polygon":
|
|
1460
|
+
case "MultiLineString":
|
|
1461
|
+
for (j = 0; j < coords.length; j++) {
|
|
1462
|
+
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
1463
|
+
if (callback(
|
|
1464
|
+
coords[j][k],
|
|
1465
|
+
coordIndex,
|
|
1466
|
+
featureIndex,
|
|
1467
|
+
multiFeatureIndex,
|
|
1468
|
+
geometryIndex
|
|
1469
|
+
) === false)
|
|
1470
|
+
return false;
|
|
1471
|
+
coordIndex++;
|
|
1472
|
+
}
|
|
1473
|
+
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
1474
|
+
if (geomType === "Polygon") geometryIndex++;
|
|
1475
|
+
}
|
|
1476
|
+
if (geomType === "Polygon") multiFeatureIndex++;
|
|
1477
|
+
break;
|
|
1478
|
+
case "MultiPolygon":
|
|
1479
|
+
for (j = 0; j < coords.length; j++) {
|
|
1480
|
+
geometryIndex = 0;
|
|
1481
|
+
for (k = 0; k < coords[j].length; k++) {
|
|
1482
|
+
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
1483
|
+
if (callback(
|
|
1484
|
+
coords[j][k][l],
|
|
1485
|
+
coordIndex,
|
|
1486
|
+
featureIndex,
|
|
1487
|
+
multiFeatureIndex,
|
|
1488
|
+
geometryIndex
|
|
1489
|
+
) === false)
|
|
1490
|
+
return false;
|
|
1491
|
+
coordIndex++;
|
|
1492
|
+
}
|
|
1493
|
+
geometryIndex++;
|
|
1494
|
+
}
|
|
1495
|
+
multiFeatureIndex++;
|
|
1496
|
+
}
|
|
1497
|
+
break;
|
|
1498
|
+
case "GeometryCollection":
|
|
1499
|
+
for (j = 0; j < geometry.geometries.length; j++)
|
|
1500
|
+
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
1501
|
+
return false;
|
|
1502
|
+
break;
|
|
1503
|
+
default:
|
|
1504
|
+
throw new Error("Unknown Geometry Type");
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
1511
|
+
function bbox(geojson, options = {}) {
|
|
1512
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
1513
|
+
return geojson.bbox;
|
|
1514
|
+
}
|
|
1515
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
1516
|
+
coordEach(geojson, (coord) => {
|
|
1517
|
+
if (result[0] > coord[0]) {
|
|
1518
|
+
result[0] = coord[0];
|
|
1519
|
+
}
|
|
1520
|
+
if (result[1] > coord[1]) {
|
|
1521
|
+
result[1] = coord[1];
|
|
1522
|
+
}
|
|
1523
|
+
if (result[2] < coord[0]) {
|
|
1524
|
+
result[2] = coord[0];
|
|
1525
|
+
}
|
|
1526
|
+
if (result[3] < coord[1]) {
|
|
1527
|
+
result[3] = coord[1];
|
|
1528
|
+
}
|
|
1529
|
+
});
|
|
1530
|
+
return result;
|
|
1531
|
+
}
|
|
1532
|
+
var index_default = bbox;
|
|
1533
|
+
|
|
1534
|
+
// src/data/navigate/steps/path/turf/shortestPath.ts
|
|
1535
|
+
import booleanPointInPolygon3 from "@turf/boolean-point-in-polygon";
|
|
1536
|
+
import distance3 from "@turf/distance";
|
|
1537
|
+
import scale from "@turf/transform-scale";
|
|
1538
|
+
import union from "@turf/union";
|
|
1539
|
+
import bboxPolygon from "@turf/bbox-polygon";
|
|
1540
|
+
import { cleanCoords } from "@turf/clean-coords";
|
|
1541
|
+
import PF from "pathfinding";
|
|
1542
|
+
import set3 from "lodash/set";
|
|
1543
|
+
|
|
1544
|
+
// src/data/navigate/steps/path/turf/stringPull.ts
|
|
1545
|
+
function stringPull(grid, path) {
|
|
1546
|
+
const isWalkable = (x, y) => grid.isInside(x, y) && grid.isWalkableAt(x, y);
|
|
1547
|
+
function hasLOS(a, b) {
|
|
1548
|
+
let x0 = a[0], y0 = a[1];
|
|
1549
|
+
const x1 = b[0], y1 = b[1];
|
|
1550
|
+
if (!isWalkable(x0, y0) || !isWalkable(x1, y1)) return false;
|
|
1551
|
+
const dx = Math.abs(x1 - x0);
|
|
1552
|
+
const dy = Math.abs(y1 - y0);
|
|
1553
|
+
const sx = x0 < x1 ? 1 : -1;
|
|
1554
|
+
const sy = y0 < y1 ? 1 : -1;
|
|
1555
|
+
let err = dx - dy;
|
|
1556
|
+
while (true) {
|
|
1557
|
+
if (!isWalkable(x0, y0)) return false;
|
|
1558
|
+
if (x0 === x1 && y0 === y1) break;
|
|
1559
|
+
const e2 = err * 2;
|
|
1560
|
+
let nx = x0;
|
|
1561
|
+
let ny = y0;
|
|
1562
|
+
let movedX = false;
|
|
1563
|
+
let movedY = false;
|
|
1564
|
+
if (e2 > -dy) {
|
|
1565
|
+
err -= dy;
|
|
1566
|
+
nx += sx;
|
|
1567
|
+
movedX = true;
|
|
1568
|
+
}
|
|
1569
|
+
if (e2 < dx) {
|
|
1570
|
+
err += dx;
|
|
1571
|
+
ny += sy;
|
|
1572
|
+
movedY = true;
|
|
1573
|
+
}
|
|
1574
|
+
if (movedX && movedY) {
|
|
1575
|
+
if (!isWalkable(nx, y0) || !isWalkable(x0, ny)) return false;
|
|
1576
|
+
}
|
|
1577
|
+
x0 = nx;
|
|
1578
|
+
y0 = ny;
|
|
1579
|
+
}
|
|
1580
|
+
return true;
|
|
1581
|
+
}
|
|
1582
|
+
if (path.length <= 2) return path;
|
|
1583
|
+
const out = [path[0]];
|
|
1584
|
+
let i = 0;
|
|
1585
|
+
while (i < path.length - 1) {
|
|
1586
|
+
let best = i + 1;
|
|
1587
|
+
for (let j = i + 2; j < path.length; j++) {
|
|
1588
|
+
if (hasLOS(path[i], path[j])) best = j;
|
|
1589
|
+
else break;
|
|
1590
|
+
}
|
|
1591
|
+
out.push(path[best]);
|
|
1592
|
+
i = best;
|
|
1593
|
+
}
|
|
1594
|
+
return out;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// src/data/navigate/steps/path/turf/pruneSmallAngle.ts
|
|
1598
|
+
function pruneSmallAngles(path, minDeg = 10) {
|
|
1599
|
+
if (path.length <= 2) return path;
|
|
1600
|
+
const out = [path[0]];
|
|
1601
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
1602
|
+
const a = out.at(-1);
|
|
1603
|
+
const b = path[i];
|
|
1604
|
+
const c = path[i + 1];
|
|
1605
|
+
const abx = b[0] - a[0], aby = b[1] - a[1];
|
|
1606
|
+
const bcx = c[0] - b[0], bcy = c[1] - b[1];
|
|
1607
|
+
const dot = abx * bcx + aby * bcy;
|
|
1608
|
+
const ab = Math.hypot(abx, aby);
|
|
1609
|
+
const bc = Math.hypot(bcx, bcy);
|
|
1610
|
+
const angle = Math.acos(dot / (ab * bc)) * 180 / Math.PI;
|
|
1611
|
+
if (angle > minDeg) out.push(b);
|
|
1612
|
+
}
|
|
1613
|
+
out.push(path.at(-1));
|
|
1614
|
+
return out;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
// src/data/navigate/steps/path/turf/pruneShortSegments.ts
|
|
1618
|
+
function pruneShortSegments(path, minLen = 5) {
|
|
1619
|
+
const out = [path[0]];
|
|
1620
|
+
for (let i = 1; i < path.length; i++) {
|
|
1621
|
+
const [x0, y0] = out.at(-1);
|
|
1622
|
+
const [x1, y1] = path[i];
|
|
1623
|
+
if (Math.hypot(x1 - x0, y1 - y0) >= minLen) {
|
|
1624
|
+
out.push(path[i]);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
return out;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
// src/data/navigate/steps/path/turf/clearance.ts
|
|
1631
|
+
function buildClearanceGrid(matrix) {
|
|
1632
|
+
const h = matrix.length;
|
|
1633
|
+
const w = matrix[0].length;
|
|
1634
|
+
const INF = 1e9;
|
|
1635
|
+
const dist = Array.from({ length: h }, () => Array(w).fill(INF));
|
|
1636
|
+
const q = [];
|
|
1637
|
+
for (let y = 0; y < h; y++) {
|
|
1638
|
+
for (let x = 0; x < w; x++) {
|
|
1639
|
+
if (matrix[y][x] === 1) {
|
|
1640
|
+
dist[y][x] = 0;
|
|
1641
|
+
q.push([x, y]);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
const dirs = [
|
|
1646
|
+
[1, 0],
|
|
1647
|
+
[-1, 0],
|
|
1648
|
+
[0, 1],
|
|
1649
|
+
[0, -1],
|
|
1650
|
+
[1, 1],
|
|
1651
|
+
[1, -1],
|
|
1652
|
+
[-1, 1],
|
|
1653
|
+
[-1, -1]
|
|
1654
|
+
];
|
|
1655
|
+
let qi = 0;
|
|
1656
|
+
while (qi < q.length) {
|
|
1657
|
+
const [x, y] = q[qi++];
|
|
1658
|
+
const d0 = dist[y][x];
|
|
1659
|
+
for (const [dx, dy] of dirs) {
|
|
1660
|
+
const nx = x + dx, ny = y + dy;
|
|
1661
|
+
if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
|
|
1662
|
+
const nd = d0 + 1;
|
|
1663
|
+
if (nd < dist[ny][nx]) {
|
|
1664
|
+
dist[ny][nx] = nd;
|
|
1665
|
+
q.push([nx, ny]);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
return dist;
|
|
1670
|
+
}
|
|
1671
|
+
function snapPointToClearancePeak(p, clearance, isWalkableCell, radius = 4) {
|
|
1672
|
+
const [px, py] = p;
|
|
1673
|
+
let best = p;
|
|
1674
|
+
let bestScore = clearance[py]?.[px] ?? -Infinity;
|
|
1675
|
+
for (let dy = -radius; dy <= radius; dy++) {
|
|
1676
|
+
for (let dx = -radius; dx <= radius; dx++) {
|
|
1677
|
+
const x = px + dx;
|
|
1678
|
+
const y = py + dy;
|
|
1679
|
+
if (!isWalkableCell(x, y)) continue;
|
|
1680
|
+
const score = clearance[y][x];
|
|
1681
|
+
const penalty = Math.hypot(dx, dy) * 5e-3;
|
|
1682
|
+
const finalScore = score - penalty;
|
|
1683
|
+
if (finalScore > bestScore) {
|
|
1684
|
+
bestScore = finalScore;
|
|
1685
|
+
best = [x, y];
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
return best;
|
|
1690
|
+
}
|
|
1691
|
+
function centerlineSnapPath(path, clearance, isWalkableCell, radius = 4) {
|
|
1692
|
+
const snapped = path.map((p) => snapPointToClearancePeak(p, clearance, isWalkableCell, radius));
|
|
1693
|
+
return snapped;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
// src/data/navigate/steps/path/turf/shortestPath.ts
|
|
1697
|
+
function shortestPath(start, end, options) {
|
|
1698
|
+
options = options || {};
|
|
1699
|
+
if (!isObject(options)) throw new Error("options is invalid");
|
|
1700
|
+
let resolution = options.resolution;
|
|
1701
|
+
const smoothenPath = options.smoothenPath;
|
|
1702
|
+
let obstacles = options.obstacles || featureCollection([]);
|
|
1703
|
+
if (!start) throw new Error("start is required");
|
|
1704
|
+
if (!end) throw new Error("end is required");
|
|
1705
|
+
if (resolution && !isNumber(resolution) || resolution <= 0)
|
|
1706
|
+
throw new Error("options.resolution must be a number, greater than 0");
|
|
1707
|
+
const startCoord = getCoord(start);
|
|
1708
|
+
const endCoord = getCoord(end);
|
|
1709
|
+
start = point(startCoord);
|
|
1710
|
+
end = point(endCoord);
|
|
1711
|
+
switch (getType(obstacles)) {
|
|
1712
|
+
case "FeatureCollection":
|
|
1713
|
+
if (obstacles.features.length === 0)
|
|
1714
|
+
return lineString([startCoord, endCoord]);
|
|
1715
|
+
break;
|
|
1716
|
+
case "Polygon":
|
|
1717
|
+
obstacles = featureCollection([feature(getGeom(obstacles))]);
|
|
1718
|
+
break;
|
|
1719
|
+
default:
|
|
1720
|
+
throw new Error("invalid obstacles");
|
|
1721
|
+
}
|
|
1722
|
+
const collection = obstacles;
|
|
1723
|
+
collection.features.push(start, end);
|
|
1724
|
+
const box = index_default(scale(bboxPolygon(index_default(collection)), 1.15));
|
|
1725
|
+
if (!resolution) {
|
|
1726
|
+
const width = distance3([box[0], box[1]], [box[2], box[1]], options);
|
|
1727
|
+
resolution = width / 100;
|
|
1728
|
+
}
|
|
1729
|
+
collection.features.pop();
|
|
1730
|
+
collection.features.pop();
|
|
1731
|
+
const [west, south, east, north] = box;
|
|
1732
|
+
const xFraction = resolution / distance3([west, south], [east, south], options);
|
|
1733
|
+
const cellWidth = xFraction * (east - west);
|
|
1734
|
+
const yFraction = resolution / distance3([west, south], [west, north], options);
|
|
1735
|
+
const cellHeight = yFraction * (north - south);
|
|
1736
|
+
const bboxHorizontalSide = east - west;
|
|
1737
|
+
const bboxVerticalSide = north - south;
|
|
1738
|
+
const columns = Math.floor(bboxHorizontalSide / cellWidth);
|
|
1739
|
+
const rows = Math.floor(bboxVerticalSide / cellHeight);
|
|
1740
|
+
const deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;
|
|
1741
|
+
const deltaY = (bboxVerticalSide - rows * cellHeight) / 2;
|
|
1742
|
+
let closestToStart = null, closestToEnd = null, minDistStart = Infinity, minDistEnd = Infinity, currentY = north - deltaY, currentX = west + deltaX, row = 0, column = 0, distStart, distEnd, pt, isInsideObstacle;
|
|
1743
|
+
const roundLoopY = Math.ceil((currentY - south) / cellHeight);
|
|
1744
|
+
const roundLoopX = Math.ceil((east - currentX) / cellWidth);
|
|
1745
|
+
let totalRounds = roundLoopX * roundLoopY;
|
|
1746
|
+
const pointMatrix = [];
|
|
1747
|
+
const matrix = [];
|
|
1748
|
+
const obstacleTotal = collection.features.length;
|
|
1749
|
+
const obstacleFeatures = collection.features;
|
|
1750
|
+
let combinedObstacle = obstacleFeatures[0];
|
|
1751
|
+
let obstacleIndex = 0;
|
|
1752
|
+
for (obstacleIndex = 0; obstacleIndex < obstacleTotal; obstacleIndex++) {
|
|
1753
|
+
const nextObstacleFeature = obstacleFeatures[obstacleIndex + 1];
|
|
1754
|
+
if (!nextObstacleFeature) continue;
|
|
1755
|
+
try {
|
|
1756
|
+
combinedObstacle = union(
|
|
1757
|
+
featureCollection([combinedObstacle, nextObstacleFeature])
|
|
1758
|
+
);
|
|
1759
|
+
} catch (e) {
|
|
1760
|
+
console.log(e);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
while (totalRounds--) {
|
|
1764
|
+
pt = point([currentX, currentY]);
|
|
1765
|
+
isInsideObstacle = booleanPointInPolygon3(pt, combinedObstacle);
|
|
1766
|
+
set3(matrix, `[${row}][${column}]`, isInsideObstacle ? 1 : 0);
|
|
1767
|
+
set3(pointMatrix, `[${row}][${column}]`, `${currentX}|${currentY}`);
|
|
1768
|
+
distStart = distance3(pt, start);
|
|
1769
|
+
if (!isInsideObstacle && distStart < minDistStart) {
|
|
1770
|
+
minDistStart = distStart;
|
|
1771
|
+
closestToStart = { x: column, y: row };
|
|
1772
|
+
}
|
|
1773
|
+
distEnd = distance3(pt, end);
|
|
1774
|
+
if (!isInsideObstacle && distEnd < minDistEnd) {
|
|
1775
|
+
minDistEnd = distEnd;
|
|
1776
|
+
closestToEnd = { x: column, y: row };
|
|
1777
|
+
}
|
|
1778
|
+
if (column < roundLoopX) {
|
|
1779
|
+
currentX += cellWidth;
|
|
1780
|
+
column++;
|
|
1781
|
+
continue;
|
|
1782
|
+
}
|
|
1783
|
+
if (row < roundLoopY) {
|
|
1784
|
+
currentY -= cellHeight;
|
|
1785
|
+
currentX = west + deltaX;
|
|
1786
|
+
column = 0;
|
|
1787
|
+
row++;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
const finder = new PF.AStarFinder({
|
|
1791
|
+
allowDiagonal: true,
|
|
1792
|
+
dontCrossCorners: true,
|
|
1793
|
+
heuristic: PF.Heuristic.euclidean
|
|
1794
|
+
});
|
|
1795
|
+
const grid = new PF.Grid(matrix);
|
|
1796
|
+
const startOnMatrix = [closestToStart.x, closestToStart.y];
|
|
1797
|
+
const endOnMatrix = [closestToEnd.x, closestToEnd.y];
|
|
1798
|
+
let result = finder.findPath(...startOnMatrix, ...endOnMatrix, grid);
|
|
1799
|
+
if (result.length > 0) {
|
|
1800
|
+
result = stringPull(grid, result);
|
|
1801
|
+
const clearanceGrid = buildClearanceGrid(matrix);
|
|
1802
|
+
const isWalkable = (x, y) => grid.isInside(x, y) && grid.isWalkableAt(x, y);
|
|
1803
|
+
result = centerlineSnapPath(result, clearanceGrid, isWalkable);
|
|
1804
|
+
result = stringPull(grid, result);
|
|
1805
|
+
result = pruneSmallAngles(result);
|
|
1806
|
+
result = pruneShortSegments(result);
|
|
1807
|
+
}
|
|
1808
|
+
result.pop();
|
|
1809
|
+
result.shift();
|
|
1810
|
+
const path = [startCoord];
|
|
1811
|
+
result.forEach((coord) => {
|
|
1812
|
+
const coords = pointMatrix[coord[1]][coord[0]].split("|");
|
|
1813
|
+
path.push([+coords[0], +coords[1]]);
|
|
1814
|
+
});
|
|
1815
|
+
path.push(endCoord);
|
|
1816
|
+
return cleanCoords(lineString(path));
|
|
1817
|
+
}
|
|
1818
|
+
var shortestPath_default = shortestPath;
|
|
1819
|
+
|
|
1820
|
+
// src/data/navigate/steps/path/index.ts
|
|
1821
|
+
var createStepPathUtils = (options) => {
|
|
1822
|
+
const resolution = options.resolution ?? 88e-5;
|
|
1823
|
+
const { units = [], kiosks = [], fixtures = [] } = options.data;
|
|
1824
|
+
const possibleObstacleFeatures = [...units, ...kiosks, ...fixtures];
|
|
1825
|
+
const filterObstaclesByOrdinal = (levelId) => {
|
|
1826
|
+
return possibleObstacleFeatures.filter(({ feature_type, properties, geometry }) => {
|
|
1827
|
+
return properties.level_id === levelId && ["Polygon", "MultiPolygon"].includes(geometry.type) && (OBSTACLE_FEATURE_TYPES.includes(feature_type) || "category" in properties && OBSTACLE_CATEGORIES.includes(properties.category));
|
|
1828
|
+
});
|
|
1829
|
+
};
|
|
1830
|
+
const findObstaclesFromWalkway = (intermediaryUnit, exceptionIds = []) => {
|
|
1831
|
+
const result = featureCollection([]);
|
|
1832
|
+
if (!intermediaryUnit) return result;
|
|
1833
|
+
const walkwayLevelId = intermediaryUnit.properties.level_id;
|
|
1834
|
+
const obstacleOnLevel = filterObstaclesByOrdinal(walkwayLevelId).filter(
|
|
1835
|
+
(obstacle) => !exceptionIds.includes(obstacle.id)
|
|
1836
|
+
);
|
|
1837
|
+
const relatedObstacleWithIntermediary = obstacleOnLevel.reduce(
|
|
1838
|
+
(obstacles, feature2) => {
|
|
1839
|
+
if (
|
|
1840
|
+
// Prevent detecting itself as an obstacle
|
|
1841
|
+
// Ex. Unable to draw a line to amenity located with in a room as room is also consider as obstacle
|
|
1842
|
+
feature2.id !== intermediaryUnit.id && (booleanOverlap(intermediaryUnit, feature2) || booleanIntersects(intermediaryUnit, feature2))
|
|
1843
|
+
) {
|
|
1844
|
+
const polygons = getType(feature2) === "Polygon" ? [polygon(feature2.geometry.coordinates, { id: feature2.id })] : feature2.geometry.coordinates.map((ring) => polygon(ring, { id: feature2.id }));
|
|
1845
|
+
obstacles.push(...polygons);
|
|
1846
|
+
}
|
|
1847
|
+
return obstacles;
|
|
1848
|
+
},
|
|
1849
|
+
[]
|
|
1850
|
+
);
|
|
1851
|
+
const intermediaryExtends = envelope(intermediaryUnit);
|
|
1852
|
+
const walkwayPerimeter = difference(
|
|
1853
|
+
featureCollection([intermediaryExtends, intermediaryUnit])
|
|
1854
|
+
);
|
|
1855
|
+
result.features.push(...relatedObstacleWithIntermediary, walkwayPerimeter);
|
|
1856
|
+
return result;
|
|
1857
|
+
};
|
|
1858
|
+
const findPathOnArea = (originPoint, destinationPoint, options2) => {
|
|
1859
|
+
const { obstacles = featureCollection([]), resolution: resolution2, properties } = options2 || {};
|
|
1860
|
+
const stepPath = shortestPath_default(originPoint, destinationPoint, {
|
|
1861
|
+
obstacles,
|
|
1862
|
+
smoothenPath: false,
|
|
1863
|
+
resolution: resolution2
|
|
1864
|
+
});
|
|
1865
|
+
stepPath.properties = properties;
|
|
1866
|
+
return stepPath;
|
|
1867
|
+
};
|
|
1868
|
+
const findStepPath = (from, to, intermediaries) => {
|
|
1869
|
+
const t0 = performance.now();
|
|
1870
|
+
const relatedWalkablePlatform = intermediaries.find(
|
|
1871
|
+
(feature2) => WALKABLE_CATEGORY.includes(feature2.properties.category)
|
|
1872
|
+
);
|
|
1873
|
+
const exceptionFeatureIds = [];
|
|
1874
|
+
const obstacles = findObstaclesFromWalkway(
|
|
1875
|
+
relatedWalkablePlatform,
|
|
1876
|
+
_7.compact(exceptionFeatureIds)
|
|
1877
|
+
);
|
|
1878
|
+
const line = findPathOnArea(from, to, {
|
|
1879
|
+
resolution,
|
|
1880
|
+
obstacles
|
|
1881
|
+
});
|
|
1882
|
+
return line.geometry.coordinates;
|
|
1883
|
+
};
|
|
1884
|
+
return {
|
|
1885
|
+
findStepPath
|
|
1886
|
+
};
|
|
1887
|
+
};
|
|
1888
|
+
|
|
1889
|
+
// src/data/navigate/steps/utils/combineWalkwaySteps.ts
|
|
1890
|
+
import uniq from "lodash/uniq";
|
|
1891
|
+
var combineWalkwaySteps = (steps) => {
|
|
1892
|
+
let result = [];
|
|
1893
|
+
for (let i = 0; i < steps.length; i++) {
|
|
1894
|
+
const thisStep = steps[i];
|
|
1895
|
+
if (i === steps.length - 1) {
|
|
1896
|
+
result.push(thisStep);
|
|
1897
|
+
continue;
|
|
1898
|
+
}
|
|
1899
|
+
const nextStep = steps[i + 1];
|
|
1900
|
+
if (thisStep.intermediaryCategory === "walkway" && nextStep.intermediaryCategory === "walkway" && thisStep.from.source.type === "opening" && nextStep.from.source.type === "opening") {
|
|
1901
|
+
result.push({
|
|
1902
|
+
from: thisStep.from,
|
|
1903
|
+
to: nextStep.to,
|
|
1904
|
+
levelIds: uniq([...thisStep.levelIds, ...nextStep.levelIds]),
|
|
1905
|
+
ordinals: uniq([...thisStep.ordinals, ...nextStep.ordinals]),
|
|
1906
|
+
intermediaryCategory: "walkway",
|
|
1907
|
+
description: nextStep.description,
|
|
1908
|
+
path: [
|
|
1909
|
+
...thisStep.path,
|
|
1910
|
+
...nextStep.path
|
|
1911
|
+
]
|
|
1912
|
+
});
|
|
1913
|
+
i++;
|
|
1914
|
+
} else {
|
|
1915
|
+
result.push(thisStep);
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
return result;
|
|
1919
|
+
};
|
|
1920
|
+
|
|
1921
|
+
// src/data/navigate/steps/createStepUtils.ts
|
|
1922
|
+
var createStepUtils = (options) => {
|
|
1923
|
+
const { data: { units, relationships }, findByIdSync } = options;
|
|
1924
|
+
const stepPathUtils = createStepPathUtils({ ...options, resolution: 88e-5 });
|
|
1925
|
+
const findUnitBetweenOpenings = (originId, destinationId) => {
|
|
1926
|
+
const origin = findByIdSync(originId);
|
|
1927
|
+
const destination = findByIdSync(destinationId);
|
|
1928
|
+
const matchedOne = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(origin.id));
|
|
1929
|
+
const matchOneUnits = matchedOne ? [matchedOne.properties.origin, matchedOne.properties.destination] : [];
|
|
1930
|
+
const matchedTwo = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(destination.id));
|
|
1931
|
+
const matchTwoUnits = matchedTwo ? [matchedTwo.properties.origin, matchedTwo.properties.destination] : [];
|
|
1932
|
+
const unitIds = _intersectionBy(matchOneUnits, matchTwoUnits, "id");
|
|
1933
|
+
return unitIds.map(({ id }) => findByIdSync(id));
|
|
1934
|
+
};
|
|
1935
|
+
const findHorizontalIntermediary = (from, to) => {
|
|
1936
|
+
if (from.source.type !== "opening") {
|
|
1937
|
+
const unit = findContainingUnitAtPoint(from.point, from.levelId, units);
|
|
1938
|
+
return unit ? [unit] : [];
|
|
1939
|
+
}
|
|
1940
|
+
if (to.source.type !== "opening") {
|
|
1941
|
+
const unit = findContainingUnitAtPoint(to.point, to.levelId, units);
|
|
1942
|
+
return unit ? [unit] : [];
|
|
1943
|
+
}
|
|
1944
|
+
return findUnitBetweenOpenings(from.source.id, to.source.id);
|
|
1945
|
+
};
|
|
1946
|
+
const findVerticalIntermediary = (from, to) => {
|
|
1947
|
+
const firstOpeningId = from.source.id;
|
|
1948
|
+
const secondOpeningId = to.source.id;
|
|
1949
|
+
const relationship = relationships.find((rel) => {
|
|
1950
|
+
return rel.properties.origin?.id === firstOpeningId && rel.properties.destination?.id === secondOpeningId || rel.properties.origin?.id === secondOpeningId && rel.properties.destination?.id === firstOpeningId;
|
|
1951
|
+
});
|
|
1952
|
+
const intermediaryTypeAndId = relationship.properties.intermediary;
|
|
1953
|
+
return intermediaryTypeAndId.map(({ id }) => findByIdSync(id));
|
|
1954
|
+
};
|
|
1955
|
+
const formatCategoryLabel = (category) => {
|
|
1956
|
+
return capitalize(category);
|
|
1957
|
+
};
|
|
1958
|
+
const getNextStepIntermediary = (from, to, intermediary) => {
|
|
1959
|
+
if (to.type === "end") return to.name;
|
|
1960
|
+
const intermediaryIds = intermediary.map((int) => int.id);
|
|
1961
|
+
const relationship = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(to.source.id));
|
|
1962
|
+
if (!relationship) return to.name;
|
|
1963
|
+
const candidates = [relationship.properties.origin.id, relationship.properties.destination.id];
|
|
1964
|
+
const nextUnitId = candidates.filter((id) => !intermediaryIds.includes(id))[0];
|
|
1965
|
+
if (!nextUnitId) return to.name;
|
|
1966
|
+
const nextUnit = findByIdSync(nextUnitId);
|
|
1967
|
+
return { en: formatCategoryLabel(`${nextUnit.properties.category}`) };
|
|
1968
|
+
};
|
|
1969
|
+
const createHorizontalStep = (from, to) => {
|
|
1970
|
+
const intermediary = findHorizontalIntermediary(from, to);
|
|
1971
|
+
const intermediaryCategories = intermediary.map((unit) => unit.properties.category);
|
|
1972
|
+
const intermediaryCategory = intermediaryCategories.length > 0 ? intermediaryCategories[0] : "unspecified";
|
|
1973
|
+
const toward = getNextStepIntermediary(from, to, intermediary);
|
|
1974
|
+
const landmark = to.hint?.kind === "landmark" ? to.hint.name : null;
|
|
1975
|
+
const path = stepPathUtils.findStepPath(from.point, to.point, intermediary);
|
|
1976
|
+
const step = {
|
|
1977
|
+
from,
|
|
1978
|
+
to,
|
|
1979
|
+
levelIds: [from.levelId],
|
|
1980
|
+
ordinals: [from.ordinal],
|
|
1981
|
+
intermediaryCategory,
|
|
1982
|
+
description: describeHorizontalStep(intermediaryCategory, toward, landmark),
|
|
1983
|
+
path: path.map((coord) => [...coord, from.ordinal * 9])
|
|
1984
|
+
};
|
|
1985
|
+
return step;
|
|
1986
|
+
};
|
|
1987
|
+
const createVerticalStep = (from, to) => {
|
|
1988
|
+
const intermediary = findVerticalIntermediary(from, to);
|
|
1989
|
+
const intermediaryCategories = intermediary.map((unit) => unit.properties.category);
|
|
1990
|
+
const intermediaryCategory = intermediaryCategories.length > 0 ? intermediaryCategories[0] : "unspecified";
|
|
1991
|
+
const fromLevel = findByIdSync(from.levelId);
|
|
1992
|
+
const toLevel = findByIdSync(to.levelId);
|
|
1993
|
+
return {
|
|
1994
|
+
from,
|
|
1995
|
+
to,
|
|
1996
|
+
levelIds: [from.levelId, to.levelId],
|
|
1997
|
+
ordinals: [from.ordinal, to.ordinal],
|
|
1998
|
+
intermediaryCategory,
|
|
1999
|
+
description: describeVerticalStep(fromLevel, toLevel, intermediaryCategory),
|
|
2000
|
+
path: [
|
|
2001
|
+
[...from.point, from.ordinal * 9],
|
|
2002
|
+
[...to.point, to.ordinal * 9]
|
|
2003
|
+
]
|
|
2004
|
+
};
|
|
2005
|
+
};
|
|
2006
|
+
const isVertical = (from, to) => {
|
|
2007
|
+
const fromLevel = findByIdSync(from.levelId);
|
|
2008
|
+
const toLevel = findByIdSync(to.levelId);
|
|
2009
|
+
return !!fromLevel && !!toLevel && fromLevel.properties.ordinal !== toLevel.properties.ordinal;
|
|
2010
|
+
};
|
|
2011
|
+
const toSteps = (waypoints) => {
|
|
2012
|
+
let steps = [];
|
|
2013
|
+
const t0_allSteps = performance.now();
|
|
2014
|
+
for (let i = 0; i < waypoints.length - 1; i++) {
|
|
2015
|
+
const from = waypoints[i];
|
|
2016
|
+
const to = waypoints[i + 1];
|
|
2017
|
+
const t0 = performance.now();
|
|
2018
|
+
const step = isVertical(from, to) ? createVerticalStep(from, to) : createHorizontalStep(from, to);
|
|
2019
|
+
steps.push(step);
|
|
2020
|
+
const t1 = performance.now();
|
|
2021
|
+
trace("nav", ` \u2502 \u251C\u2500 #${i} ${from.id.padEnd(25)} \u2192 ${`(${step.intermediaryCategory})`.padEnd(12)} \u2192 ${to.id}`, t1 - t0);
|
|
2022
|
+
trace("nav", ` \u2502 \u2502 ${step.description.text}`, void 0, "#bada55");
|
|
2023
|
+
}
|
|
2024
|
+
const simplifySteps = combineWalkwaySteps(steps);
|
|
2025
|
+
const t1_allSteps = performance.now();
|
|
2026
|
+
trace("nav", " \u2502 \u2514\u2500 Total ", t1_allSteps - t0_allSteps);
|
|
2027
|
+
return simplifySteps;
|
|
2028
|
+
};
|
|
2029
|
+
return {
|
|
2030
|
+
toSteps
|
|
2031
|
+
};
|
|
2032
|
+
};
|
|
2033
|
+
|
|
2034
|
+
// src/data/navigate/utils/timeDistance.ts
|
|
2035
|
+
import calculateLength from "@turf/length";
|
|
2036
|
+
var WALKING_SPEED = 1.4;
|
|
2037
|
+
var calculatePathLength = (feature2) => calculateLength(feature2, { units: "kilometers" }) * 1e3;
|
|
2038
|
+
var calculateTravelingDuration = (distance5) => {
|
|
2039
|
+
const duration = distance5 / WALKING_SPEED;
|
|
2040
|
+
const minutes = Math.round(duration / 60);
|
|
2041
|
+
return minutes > 0 ? minutes : 1;
|
|
2042
|
+
};
|
|
2043
|
+
var calculateTotalDistance = (steps = []) => {
|
|
2044
|
+
return steps.reduce((acc, { path }) => acc + calculatePathLength(lineString(path)), 0);
|
|
2045
|
+
};
|
|
2046
|
+
var calculateRoundedDistance = (distance5) => {
|
|
2047
|
+
return Math.round(distance5 - distance5 % 25);
|
|
2048
|
+
};
|
|
2049
|
+
|
|
2050
|
+
// src/data/navigate/type-guard.ts
|
|
2051
|
+
function isCoordinateOrdinalString(id) {
|
|
2052
|
+
return /^-?\d+(\.\d+)?,-?\d+(\.\d+)?,-?\d+(\.\d+)?o$/.test(id);
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
// src/data/navigate/utils/createFindByIdSync.ts
|
|
2056
|
+
var createFindByIdSync = (data) => {
|
|
2057
|
+
const { amenities = [], anchors = [], fixtures = [], levels = [], kiosks = [], relationships = [], occupants = [], openings = [], units } = data;
|
|
2058
|
+
const featureById = /* @__PURE__ */ new Map();
|
|
2059
|
+
const entries = [
|
|
2060
|
+
...amenities,
|
|
2061
|
+
...anchors,
|
|
2062
|
+
...fixtures,
|
|
2063
|
+
...levels,
|
|
2064
|
+
...kiosks,
|
|
2065
|
+
...relationships,
|
|
2066
|
+
...occupants,
|
|
2067
|
+
...openings,
|
|
2068
|
+
...units
|
|
2069
|
+
];
|
|
2070
|
+
for (const f of entries) featureById.set(f.id, f);
|
|
2071
|
+
const findByIdSync = (id) => {
|
|
2072
|
+
return featureById.get(id);
|
|
2073
|
+
};
|
|
2074
|
+
return { findByIdSync };
|
|
2075
|
+
};
|
|
2076
|
+
|
|
2077
|
+
// src/data/navigate/waypoint/createWaypointUtils.ts
|
|
2078
|
+
import { center as center6 } from "@turf/center";
|
|
2079
|
+
|
|
2080
|
+
// src/data/navigate/waypoint/extractEndWaypoint.ts
|
|
2081
|
+
import { center as center3 } from "@turf/center";
|
|
2082
|
+
|
|
2083
|
+
// src/data/navigate/waypoint/featureIdGuard.ts
|
|
2084
|
+
var isOccupant = (id) => !!id && id.startsWith("occupant-");
|
|
2085
|
+
var isUnit = (id) => !!id && id.startsWith("unit-");
|
|
2086
|
+
var isKiosk = (id) => !!id && id.startsWith("kiosk-");
|
|
2087
|
+
var isOpening = (id) => !!id && id.startsWith("opening-");
|
|
2088
|
+
|
|
2089
|
+
// src/data/navigate/waypoint/extractEndWaypoint.ts
|
|
2090
|
+
var extractEndPoint = (path, options) => {
|
|
2091
|
+
const { findByIdSync } = options;
|
|
2092
|
+
const [c, b, a] = path.slice(-3);
|
|
2093
|
+
if (isOccupant(a) && isUnit(b) && isOpening(c)) {
|
|
2094
|
+
const occ = findByIdSync(a);
|
|
2095
|
+
const opening = findByIdSync(c);
|
|
2096
|
+
const level = findByIdSync(opening.properties.level_id);
|
|
2097
|
+
return [
|
|
2098
|
+
{
|
|
2099
|
+
id: occ.id,
|
|
2100
|
+
type: "end",
|
|
2101
|
+
name: occ.properties.name,
|
|
2102
|
+
point: center3(opening).geometry.coordinates,
|
|
2103
|
+
levelId: opening.properties.level_id,
|
|
2104
|
+
ordinal: level.properties.ordinal,
|
|
2105
|
+
source: { type: "opening", id: opening.id }
|
|
2106
|
+
},
|
|
2107
|
+
path.slice(0, -3)
|
|
2108
|
+
];
|
|
2109
|
+
}
|
|
2110
|
+
if (isOccupant(a) && isKiosk(b)) {
|
|
2111
|
+
const occ = findByIdSync(a);
|
|
2112
|
+
const kiosk = findByIdSync(b);
|
|
2113
|
+
const level = findByIdSync(kiosk.properties.level_id);
|
|
2114
|
+
return [
|
|
2115
|
+
{
|
|
2116
|
+
id: occ.id,
|
|
2117
|
+
type: "end",
|
|
2118
|
+
name: occ.properties.name,
|
|
2119
|
+
point: center3(kiosk).geometry.coordinates,
|
|
2120
|
+
levelId: kiosk.properties.level_id,
|
|
2121
|
+
ordinal: level.properties.ordinal,
|
|
2122
|
+
source: { type: "kiosk", id: kiosk.id }
|
|
2123
|
+
},
|
|
2124
|
+
path.slice(0, -2)
|
|
2125
|
+
];
|
|
2126
|
+
}
|
|
2127
|
+
if (isCoordinateOrdinalString(a) && isOpening(b)) {
|
|
2128
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(a);
|
|
2129
|
+
const opening = findByIdSync(b);
|
|
2130
|
+
return [
|
|
2131
|
+
{
|
|
2132
|
+
id: a,
|
|
2133
|
+
type: "end",
|
|
2134
|
+
name: { en: a },
|
|
2135
|
+
point: [lng, lat],
|
|
2136
|
+
levelId: opening.properties.level_id,
|
|
2137
|
+
ordinal,
|
|
2138
|
+
source: { type: "coordinate", raw: a }
|
|
2139
|
+
},
|
|
2140
|
+
path.slice(0, -1)
|
|
2141
|
+
];
|
|
2142
|
+
}
|
|
2143
|
+
return [null, path];
|
|
2144
|
+
};
|
|
2145
|
+
|
|
2146
|
+
// src/data/navigate/waypoint/extractStartWaypoint.ts
|
|
2147
|
+
import { center as center4 } from "@turf/center";
|
|
2148
|
+
var extractStartPoint = (path, options) => {
|
|
2149
|
+
const { findByIdSync } = options;
|
|
2150
|
+
const [a, b, c] = path;
|
|
2151
|
+
if (isOccupant(a) && isUnit(b) && isOpening(c)) {
|
|
2152
|
+
const occ = findByIdSync(a);
|
|
2153
|
+
const opening = findByIdSync(c);
|
|
2154
|
+
const level = findByIdSync(opening.properties.level_id);
|
|
2155
|
+
return [
|
|
2156
|
+
{
|
|
2157
|
+
id: occ.id,
|
|
2158
|
+
type: "start",
|
|
2159
|
+
name: occ.properties.name,
|
|
2160
|
+
point: center4(opening).geometry.coordinates,
|
|
2161
|
+
levelId: opening.properties.level_id,
|
|
2162
|
+
ordinal: level.properties.ordinal,
|
|
2163
|
+
source: { type: "opening", id: opening.id }
|
|
2164
|
+
},
|
|
2165
|
+
path.slice(3)
|
|
2166
|
+
];
|
|
2167
|
+
}
|
|
2168
|
+
if (isOccupant(a) && isKiosk(b)) {
|
|
2169
|
+
const occ = findByIdSync(a);
|
|
2170
|
+
const kiosk = findByIdSync(b);
|
|
2171
|
+
const level = findByIdSync(kiosk.properties.level_id);
|
|
2172
|
+
return [
|
|
2173
|
+
{
|
|
2174
|
+
id: occ.id,
|
|
2175
|
+
type: "start",
|
|
2176
|
+
name: occ.properties.name,
|
|
2177
|
+
point: center4(kiosk).geometry.coordinates,
|
|
2178
|
+
levelId: kiosk.properties.level_id,
|
|
2179
|
+
ordinal: level.properties.ordinal,
|
|
2180
|
+
source: { type: "kiosk", id: kiosk.id }
|
|
2181
|
+
},
|
|
2182
|
+
path.slice(2)
|
|
2183
|
+
];
|
|
2184
|
+
}
|
|
2185
|
+
if (isCoordinateOrdinalString(a) && isOpening(b)) {
|
|
2186
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(a);
|
|
2187
|
+
const opening = findByIdSync(b);
|
|
2188
|
+
return [
|
|
2189
|
+
{
|
|
2190
|
+
id: a,
|
|
2191
|
+
type: "start",
|
|
2192
|
+
name: { en: a },
|
|
2193
|
+
point: [lng, lat],
|
|
2194
|
+
levelId: opening.properties.level_id,
|
|
2195
|
+
ordinal,
|
|
2196
|
+
source: { type: "coordinate", raw: a }
|
|
2197
|
+
},
|
|
2198
|
+
path.slice(1)
|
|
2199
|
+
];
|
|
2200
|
+
}
|
|
2201
|
+
return [null, path];
|
|
2202
|
+
};
|
|
2203
|
+
|
|
2204
|
+
// src/data/navigate/landmark/createLandmarkUtils.ts
|
|
2205
|
+
import { center as center5 } from "@turf/center";
|
|
2206
|
+
import distance4 from "@turf/distance";
|
|
2207
|
+
var NEARBY_DISTANCE = 30;
|
|
2208
|
+
var createLandmarkUtils = (options) => {
|
|
2209
|
+
const { data, findByIdSync } = options;
|
|
2210
|
+
const { occupants = [] } = data;
|
|
2211
|
+
const occupantToLandmark = (occupant) => {
|
|
2212
|
+
const locationType = occupant.properties.unit_id ? "unit" : "kiosk";
|
|
2213
|
+
const locationId = locationType === "unit" ? occupant.properties.unit_id : occupant.properties.kiosk_id;
|
|
2214
|
+
const location = locationType === "unit" ? findByIdSync(locationId) : findByIdSync(locationId);
|
|
2215
|
+
const level = findByIdSync(location.properties.level_id);
|
|
2216
|
+
return {
|
|
2217
|
+
name: occupant.properties.name,
|
|
2218
|
+
point: center5(location.geometry).geometry.coordinates,
|
|
2219
|
+
level_id: location.properties.level_id,
|
|
2220
|
+
is_priority: occupant.properties.is_landmark,
|
|
2221
|
+
ordinal: level.properties.ordinal
|
|
2222
|
+
};
|
|
2223
|
+
};
|
|
2224
|
+
const landmarks = [
|
|
2225
|
+
...occupants.map(occupantToLandmark)
|
|
2226
|
+
];
|
|
2227
|
+
const findNearbyLandmarks = (point2, levelId) => {
|
|
2228
|
+
if (point2 === null || levelId === null) return [];
|
|
2229
|
+
return landmarks.map((landmark) => {
|
|
2230
|
+
const landmarkAndDistance = {
|
|
2231
|
+
landmark,
|
|
2232
|
+
d: distance4(point2, landmark.point, { units: "meters" })
|
|
2233
|
+
};
|
|
2234
|
+
return landmarkAndDistance;
|
|
2235
|
+
}).filter(({ landmark, d }) => d <= NEARBY_DISTANCE && landmark.level_id === levelId).sort((a, b) => {
|
|
2236
|
+
const aPriority = a.landmark.is_priority ? 0 : 1;
|
|
2237
|
+
const bPriority = b.landmark.is_priority ? 0 : 1;
|
|
2238
|
+
if (aPriority !== bPriority) return aPriority - bPriority;
|
|
2239
|
+
return a.d - b.d;
|
|
2240
|
+
}).map(({ landmark }) => landmark);
|
|
2241
|
+
};
|
|
2242
|
+
const findNearestLandmark = (point2, levelId) => {
|
|
2243
|
+
const nearbyLandmarks = findNearbyLandmarks(point2, levelId);
|
|
2244
|
+
const nearestLandmark = nearbyLandmarks.length > 0 ? nearbyLandmarks[0] : null;
|
|
2245
|
+
return nearestLandmark;
|
|
2246
|
+
};
|
|
2247
|
+
return { findNearbyLandmarks, findNearestLandmark };
|
|
2248
|
+
};
|
|
2249
|
+
|
|
2250
|
+
// src/data/navigate/waypoint/createWaypointUtils.ts
|
|
2251
|
+
var createWaypointUtils = (options) => {
|
|
2252
|
+
const { findByIdSync } = options;
|
|
2253
|
+
const landmarkUtils = createLandmarkUtils(options);
|
|
2254
|
+
const toWaypoints = (path) => {
|
|
2255
|
+
const [startPoint, middleAndEndPoints] = extractStartPoint(path, options);
|
|
2256
|
+
const [endPoint, middlePoints] = extractEndPoint(middleAndEndPoints, options);
|
|
2257
|
+
const waypoints = middlePoints.map((openingId) => {
|
|
2258
|
+
const opening = findByIdSync(openingId);
|
|
2259
|
+
const level = findByIdSync(opening.properties.level_id);
|
|
2260
|
+
const coordinates = center6(opening).geometry.coordinates;
|
|
2261
|
+
const landmark = landmarkUtils.findNearestLandmark(coordinates, opening.properties.level_id);
|
|
2262
|
+
return {
|
|
2263
|
+
id: `${opening.properties.level_id}:${openingId}`,
|
|
2264
|
+
type: "between",
|
|
2265
|
+
point: coordinates,
|
|
2266
|
+
name: null,
|
|
2267
|
+
levelId: opening.properties.level_id,
|
|
2268
|
+
ordinal: level.properties.ordinal,
|
|
2269
|
+
hint: landmark ? { kind: "landmark", name: landmark.name } : void 0,
|
|
2270
|
+
source: { type: "opening", id: opening.id }
|
|
2271
|
+
};
|
|
2272
|
+
});
|
|
2273
|
+
return [startPoint, ...waypoints, endPoint];
|
|
2274
|
+
};
|
|
2275
|
+
return { toWaypoints };
|
|
2276
|
+
};
|
|
2277
|
+
|
|
2278
|
+
// src/data/navigate/getNavigateClient.ts
|
|
2279
|
+
var getNavigateClient = (options) => {
|
|
2280
|
+
const { data } = options;
|
|
2281
|
+
const { levels, units } = data;
|
|
2282
|
+
trace("nav", "\u2713 prepare");
|
|
2283
|
+
const t0 = performance.now();
|
|
2284
|
+
trace("nav", " \u251C\u2500 createGraph (dijkstra)");
|
|
2285
|
+
const { defaultGraph, accessibleGraph, addCoordinateOrdinalNode } = prepareGraph({ data });
|
|
2286
|
+
const t1 = performance.now();
|
|
2287
|
+
trace("nav", " \u2502 \u2514\u2500 Total ", t1 - t0);
|
|
2288
|
+
const t2 = performance.now();
|
|
2289
|
+
const { findByIdSync } = createFindByIdSync(data);
|
|
2290
|
+
const t3 = performance.now();
|
|
2291
|
+
trace("nav", " \u2514\u2500 findByIdSync", t3 - t2);
|
|
2292
|
+
const findCoordinateOrdinalUnit = (params) => {
|
|
2293
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(params);
|
|
2294
|
+
const levelIdsWithOrdinal = levels.filter((level) => level.properties.ordinal === ordinal).map((level) => level.id);
|
|
2295
|
+
const unit = units.find((unit2) => levelIdsWithOrdinal.includes(unit2.properties.level_id) && booleanPointInPolygon4([lat, lng], unit2));
|
|
2296
|
+
return unit;
|
|
2297
|
+
};
|
|
2298
|
+
const stepUtils = createStepUtils({ ...options, findByIdSync });
|
|
2299
|
+
const waypointUtils = createWaypointUtils({ ...options, findByIdSync });
|
|
2300
|
+
const findRoute = async (routeOriginParam, routeDestinationParam, options2) => {
|
|
2301
|
+
if (!routeOriginParam || !routeDestinationParam) return null;
|
|
2302
|
+
const graph = options2?.mode === "accessible" ? accessibleGraph : defaultGraph;
|
|
2303
|
+
if (isCoordinateOrdinalString(routeOriginParam)) {
|
|
2304
|
+
const walkwayUnit = findCoordinateOrdinalUnit(routeOriginParam);
|
|
2305
|
+
addCoordinateOrdinalNode(routeOriginParam, walkwayUnit);
|
|
2306
|
+
}
|
|
2307
|
+
if (isCoordinateOrdinalString(routeDestinationParam)) {
|
|
2308
|
+
const walkwayUnit = findCoordinateOrdinalUnit(routeDestinationParam);
|
|
2309
|
+
addCoordinateOrdinalNode(routeDestinationParam, walkwayUnit);
|
|
2310
|
+
}
|
|
2311
|
+
try {
|
|
2312
|
+
trace("nav", "\u2713 findRoute", 0);
|
|
2313
|
+
const t02 = performance.now();
|
|
2314
|
+
const path = graph.path(routeOriginParam, routeDestinationParam);
|
|
2315
|
+
const t12 = performance.now();
|
|
2316
|
+
trace("nav", " \u251C\u2500 path (dijkstra)", t12 - t02);
|
|
2317
|
+
const waypoints = waypointUtils.toWaypoints(path);
|
|
2318
|
+
const t22 = performance.now();
|
|
2319
|
+
trace("nav", " \u251C\u2500 toWaypoints", t22 - t12);
|
|
2320
|
+
trace("nav", " \u251C\u2500 toSteps", 0);
|
|
2321
|
+
const steps = stepUtils.toSteps(waypoints);
|
|
2322
|
+
const t32 = performance.now();
|
|
2323
|
+
const totalDistance = calculateTotalDistance(steps);
|
|
2324
|
+
const roundedDistance = calculateRoundedDistance(totalDistance);
|
|
2325
|
+
const duration = calculateTravelingDuration(totalDistance);
|
|
2326
|
+
const t4 = performance.now();
|
|
2327
|
+
trace("nav", " \u2514\u2500 postProcess", t4 - t32);
|
|
2328
|
+
return {
|
|
2329
|
+
distance: roundedDistance,
|
|
2330
|
+
duration,
|
|
2331
|
+
steps
|
|
2332
|
+
};
|
|
2333
|
+
} catch (error) {
|
|
2334
|
+
console.log(error);
|
|
2335
|
+
throw error;
|
|
2336
|
+
}
|
|
2337
|
+
};
|
|
2338
|
+
return {
|
|
2339
|
+
findRoute,
|
|
2340
|
+
findByIdSync
|
|
2341
|
+
};
|
|
2342
|
+
};
|
|
2343
|
+
|
|
2344
|
+
// src/data/getDataClient.ts
|
|
2345
|
+
var getDataClient = (options) => {
|
|
2346
|
+
let searchClient;
|
|
2347
|
+
let navigateClient;
|
|
2348
|
+
const observers = /* @__PURE__ */ new Map();
|
|
2349
|
+
const queryClient = options.queryClient ?? new QueryClient();
|
|
2350
|
+
const { mode = "delivery", projectId, apiKey, baseUrl, previewToken } = options;
|
|
2351
|
+
if (!projectId)
|
|
2352
|
+
throw new Error(
|
|
2353
|
+
"Cannot create VenueDataClient. Reason: `projectId` is missing"
|
|
2354
|
+
);
|
|
2355
|
+
if (mode === "delivery" && !apiKey)
|
|
2356
|
+
throw new Error(
|
|
2357
|
+
"Cannot create VenueDataClient. Reason: `apiKey` is missing"
|
|
2358
|
+
);
|
|
2359
|
+
if (mode === "preview" && !previewToken)
|
|
2360
|
+
throw new Error(
|
|
2361
|
+
"Cannot create VenueDataClient. Reason: `previewToken` is missing"
|
|
2362
|
+
);
|
|
2363
|
+
const createDeliveryApiQueryOptions = (featureType) => ({
|
|
2364
|
+
queryKey: ["_deliveryapi", featureType],
|
|
2365
|
+
queryFn: () => safeFetchFeature(featureType, { mode, projectId, apiKey, previewToken, baseUrl })
|
|
2366
|
+
});
|
|
2367
|
+
const internalFilterByType = async (featureType) => {
|
|
2368
|
+
try {
|
|
2369
|
+
const features = await queryClient.ensureQueryData(createDeliveryApiQueryOptions(featureType));
|
|
2370
|
+
return features;
|
|
2371
|
+
} catch (error) {
|
|
2372
|
+
throw error;
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
|
+
const internalFindById = async (id) => {
|
|
2376
|
+
if (id === null || id === void 0) return null;
|
|
2377
|
+
const featureType = id.slice(0, id.lastIndexOf("-"));
|
|
2378
|
+
const feature2 = await queryClient.ensureQueryData({
|
|
2379
|
+
queryKey: ["_deliveryapi", featureType, id],
|
|
2380
|
+
queryFn: async () => {
|
|
2381
|
+
const features = await internalFilterByType(featureType);
|
|
2382
|
+
const feature3 = features.find(
|
|
2383
|
+
(f) => f.id === id
|
|
2384
|
+
);
|
|
2385
|
+
return feature3 ?? null;
|
|
2386
|
+
}
|
|
2387
|
+
});
|
|
2388
|
+
return feature2;
|
|
2389
|
+
};
|
|
2390
|
+
const populator = createPopulator({ internalFindById, internalFilterByType });
|
|
2391
|
+
const registerObserver = (featureType, refetchInterval) => {
|
|
2392
|
+
if (observers.has(featureType)) {
|
|
2393
|
+
console.warn(`Observer for ${featureType} already exists`);
|
|
2394
|
+
const record = observers.get(featureType);
|
|
2395
|
+
return record.observer;
|
|
2396
|
+
}
|
|
2397
|
+
const options2 = createDeliveryApiQueryOptions(featureType);
|
|
2398
|
+
const observer = new QueryObserver(queryClient, {
|
|
2399
|
+
...options2,
|
|
2400
|
+
refetchInterval
|
|
2401
|
+
});
|
|
2402
|
+
const unsubscribe = observer.subscribe(() => {
|
|
2403
|
+
console.log(`[venue-js] Listening to ${featureType} changes (interval = ${refetchInterval}ms)`);
|
|
2404
|
+
});
|
|
2405
|
+
observers.set(featureType, { observer, unsubscribe });
|
|
2406
|
+
return observer;
|
|
2407
|
+
};
|
|
2408
|
+
const destroyObserver = (featureType) => {
|
|
2409
|
+
const record = observers.get(featureType);
|
|
2410
|
+
if (!record) return;
|
|
2411
|
+
record.unsubscribe();
|
|
2412
|
+
observers.delete(featureType);
|
|
2413
|
+
};
|
|
2414
|
+
const destroyObservers = () => {
|
|
2415
|
+
observers.forEach(({ observer, unsubscribe }) => {
|
|
2416
|
+
unsubscribe();
|
|
2417
|
+
observer.destroy();
|
|
2418
|
+
});
|
|
2419
|
+
observers.clear();
|
|
2420
|
+
};
|
|
2421
|
+
const createFilterByTypeQueryOptions = (featureType, params = {}, options2 = {}) => ({
|
|
2422
|
+
queryKey: [featureType, "list", params],
|
|
2423
|
+
queryFn: async () => {
|
|
2424
|
+
const features = await internalFilterByType(featureType);
|
|
2425
|
+
const filters = params.filters ?? {};
|
|
2426
|
+
let result = features;
|
|
2427
|
+
if (params.filters) {
|
|
2428
|
+
result = features.filter((f) => matchFilters(f, filters));
|
|
2429
|
+
}
|
|
2430
|
+
return params.populate === true ? await Promise.all(result.map((f) => populator[featureType](f))) : result;
|
|
2431
|
+
},
|
|
2432
|
+
...options2 ?? {}
|
|
2433
|
+
});
|
|
2434
|
+
const createFindByIdQueryOptions = (featureType, id, params = {}, options2 = {}) => ({
|
|
2435
|
+
queryKey: [featureType, "detail", id, params],
|
|
2436
|
+
queryFn: async () => {
|
|
2437
|
+
const feature2 = await internalFindById(id);
|
|
2438
|
+
return params.populate === true ? await populator[featureType](feature2) : Promise.resolve(feature2);
|
|
2439
|
+
},
|
|
2440
|
+
...options2 ?? {}
|
|
2441
|
+
});
|
|
2442
|
+
async function filterByType(featureType, params) {
|
|
2443
|
+
const filterQueryOptions = createFilterByTypeQueryOptions(
|
|
2444
|
+
featureType,
|
|
2445
|
+
params
|
|
2446
|
+
);
|
|
2447
|
+
const features = await queryClient.ensureQueryData(filterQueryOptions);
|
|
2448
|
+
return params?.populate === true ? features : features;
|
|
2449
|
+
}
|
|
2450
|
+
async function findById(featureType, id, params) {
|
|
2451
|
+
const findQueryOptions = createFindByIdQueryOptions(
|
|
2452
|
+
featureType,
|
|
2453
|
+
id,
|
|
2454
|
+
params
|
|
2455
|
+
);
|
|
2456
|
+
const feature2 = await queryClient.ensureQueryData(findQueryOptions);
|
|
2457
|
+
return feature2;
|
|
808
2458
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
2459
|
+
const searchFn = async (txt) => {
|
|
2460
|
+
if (!searchClient) {
|
|
2461
|
+
const [occupants, amenities] = await Promise.all([
|
|
2462
|
+
filterByType("occupant"),
|
|
2463
|
+
filterByType("amenity")
|
|
2464
|
+
]);
|
|
2465
|
+
const haystack = { occupants, amenities };
|
|
2466
|
+
searchClient = getSearchClient(haystack);
|
|
2467
|
+
}
|
|
2468
|
+
return searchClient.search(txt);
|
|
816
2469
|
};
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
2470
|
+
const navigateFn = async (origin, destination) => {
|
|
2471
|
+
if (!navigateClient) {
|
|
2472
|
+
const [levels, occupants, openings, relationships, units, fixtures, kiosks, amenities, anchors] = await Promise.all([
|
|
2473
|
+
filterByType("level"),
|
|
2474
|
+
filterByType("occupant"),
|
|
2475
|
+
filterByType("opening"),
|
|
2476
|
+
filterByType("relationship"),
|
|
2477
|
+
filterByType("unit"),
|
|
2478
|
+
filterByType("fixture"),
|
|
2479
|
+
filterByType("kiosk"),
|
|
2480
|
+
filterByType("amenity"),
|
|
2481
|
+
filterByType("anchor")
|
|
2482
|
+
]);
|
|
2483
|
+
const haystack = { levels, occupants, openings, relationships, units, fixtures, kiosks, amenities, anchors };
|
|
2484
|
+
navigateClient = getNavigateClient({ data: haystack });
|
|
2485
|
+
}
|
|
2486
|
+
return navigateClient.findRoute(origin, destination);
|
|
2487
|
+
};
|
|
2488
|
+
return {
|
|
2489
|
+
projectId,
|
|
2490
|
+
queryClient,
|
|
2491
|
+
registerObserver,
|
|
2492
|
+
destroyObserver,
|
|
2493
|
+
destroyObservers,
|
|
2494
|
+
createFilterByTypeQueryOptions,
|
|
2495
|
+
createFindByIdQueryOptions,
|
|
2496
|
+
_internalFindById: internalFindById,
|
|
2497
|
+
filterByType,
|
|
2498
|
+
findById,
|
|
2499
|
+
search: searchFn,
|
|
2500
|
+
navigate: navigateFn
|
|
2501
|
+
};
|
|
2502
|
+
};
|
|
822
2503
|
|
|
823
2504
|
// src/IndoorMap/IndoorMap.ts
|
|
824
|
-
import
|
|
825
|
-
|
|
2505
|
+
import {
|
|
2506
|
+
Map as Map2,
|
|
2507
|
+
TileLayer,
|
|
2508
|
+
LineString as LineString3,
|
|
2509
|
+
Coordinate as Coordinate4,
|
|
2510
|
+
GroupGLLayer,
|
|
2511
|
+
GLTFLayer
|
|
2512
|
+
} from "maptalks-gl";
|
|
2513
|
+
import "@maptalks/transcoders.draco";
|
|
2514
|
+
import TWEEN from "@tweenjs/tween.js";
|
|
2515
|
+
import _13 from "lodash";
|
|
2516
|
+
import turfDistance2 from "@turf/distance";
|
|
2517
|
+
import turfCenter6 from "@turf/center";
|
|
826
2518
|
import { PerspectiveCamera } from "three";
|
|
827
2519
|
import { ThreeLayer as ThreeLayer5 } from "maptalks.three";
|
|
828
2520
|
|
|
@@ -901,7 +2593,7 @@ var VENUE_EVENTS = {
|
|
|
901
2593
|
};
|
|
902
2594
|
|
|
903
2595
|
// src/IndoorMap/utils/createElements.js
|
|
904
|
-
import
|
|
2596
|
+
import _12 from "lodash";
|
|
905
2597
|
import {
|
|
906
2598
|
Polygon,
|
|
907
2599
|
MultiPolygon,
|
|
@@ -911,7 +2603,7 @@ import {
|
|
|
911
2603
|
MultiLineString,
|
|
912
2604
|
ui
|
|
913
2605
|
} from "maptalks";
|
|
914
|
-
import
|
|
2606
|
+
import turfCenter4 from "@turf/center";
|
|
915
2607
|
import turfBuffer from "@turf/buffer";
|
|
916
2608
|
import {
|
|
917
2609
|
TextureLoader as TextureLoader2,
|
|
@@ -931,7 +2623,7 @@ import {
|
|
|
931
2623
|
SpriteMaterial,
|
|
932
2624
|
Sprite
|
|
933
2625
|
} from "three";
|
|
934
|
-
import
|
|
2626
|
+
import _9 from "lodash";
|
|
935
2627
|
var OPTIONS = {
|
|
936
2628
|
altitude: 25,
|
|
937
2629
|
scale: 15e-5,
|
|
@@ -964,7 +2656,7 @@ var Billboard = class extends BaseObject {
|
|
|
964
2656
|
} = options;
|
|
965
2657
|
this.properties = { ...properties };
|
|
966
2658
|
this._createGroup();
|
|
967
|
-
const divider =
|
|
2659
|
+
const divider = _9.clamp(window.innerWidth / 375 / 1.75, 1, 1.7);
|
|
968
2660
|
if (showLeg) {
|
|
969
2661
|
const lineMaterial = new LineBasicMaterial({
|
|
970
2662
|
color: legColor,
|
|
@@ -999,9 +2691,9 @@ var Billboard = class extends BaseObject {
|
|
|
999
2691
|
});
|
|
1000
2692
|
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
1001
2693
|
const position = layer.coordinateToVector3(coordinate, z);
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
2694
|
+
_9.set(this.properties, "default.position", position);
|
|
2695
|
+
_9.set(this.properties, "default.altitude", altitude);
|
|
2696
|
+
_9.set(this.properties, "default.scale", scale3);
|
|
1005
2697
|
this.getObject3d().position.copy(position);
|
|
1006
2698
|
}
|
|
1007
2699
|
setLineHeight(altitude) {
|
|
@@ -1017,7 +2709,7 @@ var Billboard = class extends BaseObject {
|
|
|
1017
2709
|
// src/IndoorMap/object3d/SpriteMarker.ts
|
|
1018
2710
|
import { BaseObject as BaseObject2 } from "maptalks.three";
|
|
1019
2711
|
import { Sprite as Sprite2, SpriteMaterial as SpriteMaterial2 } from "three";
|
|
1020
|
-
import
|
|
2712
|
+
import _10 from "lodash";
|
|
1021
2713
|
var DEFAULT_SCALE = 0.05;
|
|
1022
2714
|
var DEFAULT_ALTITUDE = 0;
|
|
1023
2715
|
var DEFAULT_ALPHATEST = 0.3;
|
|
@@ -1048,7 +2740,7 @@ var SpriteMarker = class extends BaseObject2 {
|
|
|
1048
2740
|
this.properties = { ...properties };
|
|
1049
2741
|
const modifiedAltitude = altitude + 2;
|
|
1050
2742
|
this.#default = { options: { scale: scale3, altitude: modifiedAltitude }, material };
|
|
1051
|
-
this.#highlight =
|
|
2743
|
+
this.#highlight = _10.merge({}, DEFAULT_OPTIONS.highlight, highlight);
|
|
1052
2744
|
if (material && material instanceof SpriteMaterial2)
|
|
1053
2745
|
material.alphaTest = alphaTest;
|
|
1054
2746
|
const sprite = new Sprite2(material);
|
|
@@ -1057,7 +2749,7 @@ var SpriteMarker = class extends BaseObject2 {
|
|
|
1057
2749
|
obj3d.add(sprite);
|
|
1058
2750
|
const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
|
|
1059
2751
|
const position = layer.coordinateToVector3(coordinate, z);
|
|
1060
|
-
|
|
2752
|
+
_10.set(this.properties, "default.position", position);
|
|
1061
2753
|
this.getObject3d().position.copy(position);
|
|
1062
2754
|
}
|
|
1063
2755
|
// Different objects need to implement their own methods
|
|
@@ -1198,15 +2890,15 @@ var NavigationPath = class extends BaseObject3 {
|
|
|
1198
2890
|
};
|
|
1199
2891
|
|
|
1200
2892
|
// src/IndoorMap/utils/geometry.ts
|
|
1201
|
-
import
|
|
1202
|
-
import
|
|
2893
|
+
import center7 from "@turf/center";
|
|
2894
|
+
import _11 from "lodash";
|
|
1203
2895
|
import turfLineOffset from "@turf/line-offset";
|
|
1204
2896
|
var getCenterFromGeometry = (geometry) => {
|
|
1205
2897
|
try {
|
|
1206
2898
|
const { type = null, coordinates = null } = geometry;
|
|
1207
2899
|
if (!type || !coordinates) return null;
|
|
1208
|
-
const centerPoint =
|
|
1209
|
-
return
|
|
2900
|
+
const centerPoint = center7(geometry);
|
|
2901
|
+
return _11.get(centerPoint, "geometry.coordinates");
|
|
1210
2902
|
} catch (error) {
|
|
1211
2903
|
return null;
|
|
1212
2904
|
}
|
|
@@ -1357,7 +3049,7 @@ var createWaterFixture = (feature2, style, options = {}) => {
|
|
|
1357
3049
|
const { geometry, properties } = feature2;
|
|
1358
3050
|
const { allowOverride, inheritFillColorToLine, zIndex } = options;
|
|
1359
3051
|
const symbolStyle = { ...style };
|
|
1360
|
-
if (allowOverride)
|
|
3052
|
+
if (allowOverride) _12.merge(symbolStyle, properties.style);
|
|
1361
3053
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
1362
3054
|
return new GeometryType[geometry.type](geometry.coordinates, {
|
|
1363
3055
|
properties: {
|
|
@@ -1373,7 +3065,7 @@ var createVegetationFixture = (feature2, style, options = {}) => {
|
|
|
1373
3065
|
const { geometry, properties } = feature2;
|
|
1374
3066
|
const { allowOverride, inheritFillColorToLine, zIndex } = options;
|
|
1375
3067
|
const symbolStyle = { ...style };
|
|
1376
|
-
if (allowOverride)
|
|
3068
|
+
if (allowOverride) _12.merge(symbolStyle, properties.style);
|
|
1377
3069
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
1378
3070
|
return new GeometryType[geometry.type](geometry.coordinates, {
|
|
1379
3071
|
properties: {
|
|
@@ -1390,8 +3082,8 @@ var createObstructionalFixture = (feature2, style = {}, options = {}) => {
|
|
|
1390
3082
|
const { model3d } = properties;
|
|
1391
3083
|
const { allowOverride, inheritFillColorToLine, zIndex } = options;
|
|
1392
3084
|
const symbolStyle = { ...style };
|
|
1393
|
-
if (!
|
|
1394
|
-
if (allowOverride)
|
|
3085
|
+
if (!_12.isEmpty(model3d)) return;
|
|
3086
|
+
if (allowOverride) _12.merge(symbolStyle, properties.style);
|
|
1395
3087
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
1396
3088
|
if (geometry.type === "LineString") {
|
|
1397
3089
|
const polygon2 = createPolygonFromLineString(geometry);
|
|
@@ -1461,7 +3153,7 @@ var createPrincipalOpening = (feature2, style, options = {}) => {
|
|
|
1461
3153
|
const { geometry, properties } = feature2;
|
|
1462
3154
|
const { allowOverride, zIndex } = options;
|
|
1463
3155
|
const symbolStyle = { ...style };
|
|
1464
|
-
if (allowOverride)
|
|
3156
|
+
if (allowOverride) _12.merge(symbolStyle, properties.style);
|
|
1465
3157
|
try {
|
|
1466
3158
|
return new LineString(geometry.coordinates, {
|
|
1467
3159
|
properties: {
|
|
@@ -1478,7 +3170,7 @@ var createEmergencyExitOpening = (feature2, style, options = {}) => {
|
|
|
1478
3170
|
const { geometry, properties } = feature2;
|
|
1479
3171
|
const { allowOverride, zIndex } = options;
|
|
1480
3172
|
const symbolStyle = { ...style };
|
|
1481
|
-
if (allowOverride)
|
|
3173
|
+
if (allowOverride) _12.merge(symbolStyle, properties.style);
|
|
1482
3174
|
try {
|
|
1483
3175
|
return new LineString(geometry.coordinates, {
|
|
1484
3176
|
properties: {
|
|
@@ -1495,7 +3187,7 @@ var createPedestrianOpening = (feature2, style, options = {}) => {
|
|
|
1495
3187
|
const { geometry, properties, id } = feature2;
|
|
1496
3188
|
const { allowOverride, zIndex } = options;
|
|
1497
3189
|
const symbolStyle = { ...style };
|
|
1498
|
-
if (allowOverride)
|
|
3190
|
+
if (allowOverride) _12.merge(symbolStyle, properties.style);
|
|
1499
3191
|
try {
|
|
1500
3192
|
return new LineString(geometry.coordinates, {
|
|
1501
3193
|
properties: {
|
|
@@ -1533,9 +3225,9 @@ var create3DMarker = (coordinates, options, material, threeLayer, markerProperti
|
|
|
1533
3225
|
};
|
|
1534
3226
|
var getExtrudeConfigByFeature = (baseExtrudeConfig, feature2 = {}) => {
|
|
1535
3227
|
const { feature_type: featureType } = feature2;
|
|
1536
|
-
const featureExtrudeConfig =
|
|
1537
|
-
const featureCategory =
|
|
1538
|
-
const baseFeatureExtrudeConfig =
|
|
3228
|
+
const featureExtrudeConfig = _12.get(feature2, "properties.extrude");
|
|
3229
|
+
const featureCategory = _12.get(feature2, "properties.category");
|
|
3230
|
+
const baseFeatureExtrudeConfig = _12.get(
|
|
1539
3231
|
baseExtrudeConfig,
|
|
1540
3232
|
`${featureType}.${featureCategory || featureType}`
|
|
1541
3233
|
);
|
|
@@ -1593,50 +3285,50 @@ var createStyledUIMarkerElement = ({
|
|
|
1593
3285
|
var styledFeatureGenerator = (mapTheme) => {
|
|
1594
3286
|
const getElementSymbol = (key) => {
|
|
1595
3287
|
const [featureType] = key.split(".");
|
|
1596
|
-
const featureTypeTheme =
|
|
3288
|
+
const featureTypeTheme = _12.get(mapTheme, `${featureType}.geometry.symbol`);
|
|
1597
3289
|
if (featureType === key) return featureTypeTheme;
|
|
1598
|
-
const categoryTheme =
|
|
1599
|
-
return
|
|
3290
|
+
const categoryTheme = _12.get(mapTheme, `${key}.geometry.symbol`);
|
|
3291
|
+
return _12.merge({}, featureTypeTheme, categoryTheme);
|
|
1600
3292
|
};
|
|
1601
3293
|
const getLabelSymbol = (key) => {
|
|
1602
3294
|
const [featureType] = key.split(".");
|
|
1603
|
-
const featureTypeTheme =
|
|
1604
|
-
const categoryTheme =
|
|
1605
|
-
const mergedSymbol =
|
|
1606
|
-
let symbols =
|
|
3295
|
+
const featureTypeTheme = _12.get(mapTheme, `${featureType}.label`);
|
|
3296
|
+
const categoryTheme = _12.get(mapTheme, `${key}.label`);
|
|
3297
|
+
const mergedSymbol = _12.merge({}, featureTypeTheme, categoryTheme);
|
|
3298
|
+
let symbols = _12.values(_12.map(mergedSymbol, "symbol"));
|
|
1607
3299
|
const markerIndexToMove = symbols.findIndex(
|
|
1608
3300
|
({ elementType }) => elementType === "label.marker"
|
|
1609
3301
|
);
|
|
1610
3302
|
if (markerIndexToMove >= 0) {
|
|
1611
|
-
const markerSymbolToMove =
|
|
3303
|
+
const markerSymbolToMove = _12.pullAt(symbols, markerIndexToMove)[0];
|
|
1612
3304
|
symbols.push(markerSymbolToMove);
|
|
1613
3305
|
}
|
|
1614
3306
|
return symbols;
|
|
1615
3307
|
};
|
|
1616
3308
|
const getUIMarkerSymbol = (key) => {
|
|
1617
3309
|
const [featureType] = key.split(".");
|
|
1618
|
-
const featureTypeTheme =
|
|
1619
|
-
const categoryTheme =
|
|
1620
|
-
const mergedSymbol =
|
|
1621
|
-
const symbol =
|
|
3310
|
+
const featureTypeTheme = _12.get(mapTheme, `${featureType}.ui.marker`);
|
|
3311
|
+
const categoryTheme = _12.get(mapTheme, `${key}.ui.marker`);
|
|
3312
|
+
const mergedSymbol = _12.merge({}, featureTypeTheme, categoryTheme);
|
|
3313
|
+
const symbol = _12.get(mergedSymbol, "symbol");
|
|
1622
3314
|
return symbol;
|
|
1623
3315
|
};
|
|
1624
3316
|
const getUIMarkerOptions = (key) => {
|
|
1625
3317
|
const [featureType] = key.split(".");
|
|
1626
|
-
const featureTypeTheme =
|
|
1627
|
-
const categoryTheme =
|
|
1628
|
-
const mergedSymbol =
|
|
1629
|
-
const options =
|
|
3318
|
+
const featureTypeTheme = _12.get(mapTheme, `${featureType}.ui.marker`);
|
|
3319
|
+
const categoryTheme = _12.get(mapTheme, `${key}.ui.marker`);
|
|
3320
|
+
const mergedSymbol = _12.merge({}, featureTypeTheme, categoryTheme);
|
|
3321
|
+
const options = _12.get(mergedSymbol, "options");
|
|
1630
3322
|
return options;
|
|
1631
3323
|
};
|
|
1632
3324
|
const getLabelOptions = (key) => {
|
|
1633
3325
|
const [featureType] = key.split(".");
|
|
1634
|
-
const featureTypeSymbol =
|
|
1635
|
-
const categorySymbol =
|
|
1636
|
-
const mergedSymbol =
|
|
1637
|
-
return
|
|
3326
|
+
const featureTypeSymbol = _12.get(mapTheme, `${featureType}.label`);
|
|
3327
|
+
const categorySymbol = _12.get(mapTheme, `${key}.label`);
|
|
3328
|
+
const mergedSymbol = _12.merge({}, featureTypeSymbol, categorySymbol);
|
|
3329
|
+
return _12.reduce(
|
|
1638
3330
|
mergedSymbol,
|
|
1639
|
-
(acc, symbol) => ({ ...acc, ...
|
|
3331
|
+
(acc, symbol) => ({ ...acc, ..._12.get(symbol, "options", {}) }),
|
|
1640
3332
|
{}
|
|
1641
3333
|
);
|
|
1642
3334
|
};
|
|
@@ -1651,13 +3343,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1651
3343
|
};
|
|
1652
3344
|
const generateSpriteHighlightMarkerOption = () => {
|
|
1653
3345
|
return SPRITE_HIGHLIGHT_MARKER_FEATURE.reduce((acc, featCate) => {
|
|
1654
|
-
const categoryKey =
|
|
3346
|
+
const categoryKey = _12.last(featCate.split("-"));
|
|
1655
3347
|
const defaultLabelSymbol = getLabelSymbol(categoryKey);
|
|
1656
3348
|
const highlightLabelSymbol = getLabelSymbol(featCate);
|
|
1657
3349
|
const [defaultBase, defaultIcon] = defaultLabelSymbol;
|
|
1658
3350
|
const [highlightBase, highlightIcon] = highlightLabelSymbol;
|
|
1659
|
-
const base =
|
|
1660
|
-
const icon =
|
|
3351
|
+
const base = _12.merge({}, defaultBase, highlightBase);
|
|
3352
|
+
const icon = _12.merge({}, defaultIcon, highlightIcon);
|
|
1661
3353
|
const material = createSpriteMaterialByLabelSymbol([base, icon]);
|
|
1662
3354
|
const options = getLabelOptions(featCate);
|
|
1663
3355
|
return { ...acc, [featCate]: { material, options } };
|
|
@@ -1667,32 +3359,32 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1667
3359
|
const spriteHighlightMarkerOptionObj = generateSpriteHighlightMarkerOption();
|
|
1668
3360
|
const getElementOptions = (key) => {
|
|
1669
3361
|
const [featureType] = key.split(".");
|
|
1670
|
-
const featureTypeOptions =
|
|
3362
|
+
const featureTypeOptions = _12.get(
|
|
1671
3363
|
mapTheme,
|
|
1672
3364
|
`${featureType}.geometry.options`
|
|
1673
3365
|
);
|
|
1674
|
-
const categoryOptions =
|
|
1675
|
-
return
|
|
3366
|
+
const categoryOptions = _12.get(mapTheme, `${key}.geometry.options`);
|
|
3367
|
+
return _12.merge({}, featureTypeOptions, categoryOptions);
|
|
1676
3368
|
};
|
|
1677
3369
|
const createOccupantMarker = (feature2, locatedFeature, mapConfig) => {
|
|
1678
3370
|
const { textMarkerType, featureExtrudeConfig } = getFeatureMarkerConfig(
|
|
1679
3371
|
feature2,
|
|
1680
3372
|
mapConfig
|
|
1681
3373
|
);
|
|
1682
|
-
const markerHeight =
|
|
3374
|
+
const markerHeight = _12.get(featureExtrudeConfig, "height", 0);
|
|
1683
3375
|
const { properties, id, feature_type } = feature2;
|
|
1684
3376
|
if (!properties.anchor) return;
|
|
1685
|
-
const mainLocationId =
|
|
3377
|
+
const mainLocationId = _12.get(properties, "unit.id") || _12.get(properties, "kiosk.id");
|
|
1686
3378
|
const isMainLocationFeature = mainLocationId === locatedFeature?.id;
|
|
1687
3379
|
const { geometry: mainLocationGeometry } = properties?.anchor;
|
|
1688
|
-
const geometry = isMainLocationFeature ? mainLocationGeometry :
|
|
3380
|
+
const geometry = isMainLocationFeature ? mainLocationGeometry : turfCenter4(locatedFeature)?.geometry;
|
|
1689
3381
|
const baseProperties = {
|
|
1690
3382
|
id,
|
|
1691
3383
|
feature_type,
|
|
1692
3384
|
category: properties.category,
|
|
1693
3385
|
altitude: getAltitude(properties)
|
|
1694
3386
|
};
|
|
1695
|
-
const occupantName =
|
|
3387
|
+
const occupantName = _12.isEmpty(properties.short_name) ? properties.name : properties.short_name;
|
|
1696
3388
|
if (locatedFeature) {
|
|
1697
3389
|
const { feature_type: feature_type2, properties: properties2 } = locatedFeature;
|
|
1698
3390
|
const { category } = properties2;
|
|
@@ -1706,21 +3398,21 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1706
3398
|
}
|
|
1707
3399
|
return requestedType;
|
|
1708
3400
|
};
|
|
1709
|
-
const logoUrl =
|
|
1710
|
-
const requestedRenderType =
|
|
3401
|
+
const logoUrl = _12.get(properties, "logo.url");
|
|
3402
|
+
const requestedRenderType = _12.get(properties, "render_type", "Name");
|
|
1711
3403
|
const renderType = getValidatedRenderType(requestedRenderType, logoUrl);
|
|
1712
3404
|
if (renderType === "Label") return null;
|
|
1713
3405
|
const renderPriority = properties.render_priority || 3;
|
|
1714
|
-
const labelSymbol = getLabelSymbol(`occupant-${
|
|
1715
|
-
const markerSymbol =
|
|
1716
|
-
const coordinates =
|
|
3406
|
+
const labelSymbol = getLabelSymbol(`occupant-${_12.toLower(renderType)}`);
|
|
3407
|
+
const markerSymbol = _12.last(labelSymbol);
|
|
3408
|
+
const coordinates = _12.get(geometry, "coordinates");
|
|
1717
3409
|
const priorityLabelSymbol = getLabelSymbol(
|
|
1718
|
-
`occupant-${
|
|
3410
|
+
`occupant-${_12.toLower(renderType)}-${renderPriority}`
|
|
1719
3411
|
);
|
|
1720
|
-
const priorityMarkerSymbol =
|
|
3412
|
+
const priorityMarkerSymbol = _12.last(priorityLabelSymbol) || {};
|
|
1721
3413
|
switch (renderType) {
|
|
1722
3414
|
case "Logo":
|
|
1723
|
-
|
|
3415
|
+
_12.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
1724
3416
|
return new Marker(coordinates, {
|
|
1725
3417
|
properties: {
|
|
1726
3418
|
altitude: getAltitude(properties) + markerHeight,
|
|
@@ -1781,13 +3473,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1781
3473
|
});
|
|
1782
3474
|
}
|
|
1783
3475
|
const uiMarkerSymbol = getUIMarkerSymbol(
|
|
1784
|
-
`occupant-${
|
|
3476
|
+
`occupant-${_12.toLower(renderType)}`
|
|
1785
3477
|
);
|
|
1786
3478
|
const uiMarkerPrioritySymbol = getUIMarkerSymbol(
|
|
1787
|
-
`occupant-${
|
|
3479
|
+
`occupant-${_12.toLower(renderType)}-${renderPriority}`
|
|
1788
3480
|
);
|
|
1789
3481
|
const uiMarkerPriorityOptions = getUIMarkerOptions(
|
|
1790
|
-
`occupant-${
|
|
3482
|
+
`occupant-${_12.toLower(renderType)}-${renderPriority}`
|
|
1791
3483
|
);
|
|
1792
3484
|
const style = { ...uiMarkerSymbol, ...uiMarkerPrioritySymbol };
|
|
1793
3485
|
return new ui.UIMarker(coordinates, {
|
|
@@ -1809,7 +3501,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1809
3501
|
const { category, ordinal, style = {} } = properties;
|
|
1810
3502
|
const elementStyle = getElementSymbol(`${feature_type}.${category}`);
|
|
1811
3503
|
const { allowOverride } = getElementOptions(`${feature_type}.${category}`);
|
|
1812
|
-
if (allowOverride)
|
|
3504
|
+
if (allowOverride) _12.merge(elementStyle, style);
|
|
1813
3505
|
const { polygonFill: color } = elementStyle;
|
|
1814
3506
|
const featureProperty = {
|
|
1815
3507
|
id,
|
|
@@ -1898,9 +3590,9 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1898
3590
|
feature2,
|
|
1899
3591
|
mapConfig
|
|
1900
3592
|
);
|
|
1901
|
-
const markerHeight =
|
|
3593
|
+
const markerHeight = _12.get(featureExtrudeConfig, "height");
|
|
1902
3594
|
const { id, properties } = feature2;
|
|
1903
|
-
const geometry =
|
|
3595
|
+
const geometry = _12.get(feature2, "geometry") || _12.get(feature2, "properties.anchor.geometry");
|
|
1904
3596
|
const coordinates = getCenterFromGeometry(geometry);
|
|
1905
3597
|
const symbol = getElementSymbol("pin-marker");
|
|
1906
3598
|
try {
|
|
@@ -1920,10 +3612,10 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1920
3612
|
feature2,
|
|
1921
3613
|
mapConfig
|
|
1922
3614
|
);
|
|
1923
|
-
const markerHeight =
|
|
3615
|
+
const markerHeight = _12.get(featureExtrudeConfig, "height", 0);
|
|
1924
3616
|
const { properties, id } = feature2;
|
|
1925
3617
|
const { geometry } = properties.anchor;
|
|
1926
|
-
const logoUrl =
|
|
3618
|
+
const logoUrl = _12.get(properties, "logo.url");
|
|
1927
3619
|
const coordinates = getCenterFromGeometry(geometry);
|
|
1928
3620
|
const [markerBase, markerLabel] = getLabelSymbol(
|
|
1929
3621
|
"highlighted-logo-marker"
|
|
@@ -1993,7 +3685,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1993
3685
|
feature2,
|
|
1994
3686
|
mapConfig
|
|
1995
3687
|
);
|
|
1996
|
-
const markerHeight =
|
|
3688
|
+
const markerHeight = _12.get(featureExtrudeConfig, "height");
|
|
1997
3689
|
const { id, feature_type, properties } = feature2;
|
|
1998
3690
|
if (!properties.anchor) return;
|
|
1999
3691
|
const markerProperties = {
|
|
@@ -2003,8 +3695,8 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2003
3695
|
altitude: getAltitude(properties) + markerHeight
|
|
2004
3696
|
};
|
|
2005
3697
|
const { geometry } = properties?.anchor;
|
|
2006
|
-
const coordinates =
|
|
2007
|
-
const logoUrl =
|
|
3698
|
+
const coordinates = _12.get(geometry, "coordinates");
|
|
3699
|
+
const logoUrl = _12.get(properties, "logo.url");
|
|
2008
3700
|
if (markerSymbol) {
|
|
2009
3701
|
return new Marker(coordinates, {
|
|
2010
3702
|
properties: markerProperties,
|
|
@@ -2019,8 +3711,8 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2019
3711
|
});
|
|
2020
3712
|
}
|
|
2021
3713
|
const labelSymbol = getLabelSymbol("highlight-occupant-logo");
|
|
2022
|
-
const priorityMarkerSymbol =
|
|
2023
|
-
|
|
3714
|
+
const priorityMarkerSymbol = _12.last(labelSymbol) || {};
|
|
3715
|
+
_12.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
2024
3716
|
return new Marker(coordinates, {
|
|
2025
3717
|
properties: markerProperties,
|
|
2026
3718
|
symbol: labelSymbol
|
|
@@ -2028,14 +3720,14 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2028
3720
|
},
|
|
2029
3721
|
createHighlight2DAmenityMarkerFrom3DMarker: (feature2, mapConfig) => {
|
|
2030
3722
|
const { coordinates, units, kiosk } = feature2;
|
|
2031
|
-
const amenityLocatedUnit =
|
|
3723
|
+
const amenityLocatedUnit = _12.first(units);
|
|
2032
3724
|
const unitConfig = getExtrudeConfigByFeature(
|
|
2033
3725
|
mapConfig,
|
|
2034
3726
|
amenityLocatedUnit
|
|
2035
3727
|
);
|
|
2036
|
-
const unitHeight =
|
|
3728
|
+
const unitHeight = _12.get(unitConfig, "height", 0);
|
|
2037
3729
|
const kioskConfig = getExtrudeConfigByFeature(mapConfig, kiosk);
|
|
2038
|
-
const kioskHeight =
|
|
3730
|
+
const kioskHeight = _12.get(kioskConfig, "height", 0);
|
|
2039
3731
|
const markerHeight = unitHeight + kioskHeight;
|
|
2040
3732
|
const symbol = getElementSymbol("highlight-amenity-marker");
|
|
2041
3733
|
return new Marker(coordinates, {
|
|
@@ -2111,7 +3803,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2111
3803
|
}
|
|
2112
3804
|
},
|
|
2113
3805
|
createLineStringFromGeometries: (geometries) => {
|
|
2114
|
-
const mergedCoordinates =
|
|
3806
|
+
const mergedCoordinates = _12(geometries).map((geometry) => {
|
|
2115
3807
|
switch (geometry.type) {
|
|
2116
3808
|
case "Point":
|
|
2117
3809
|
return [
|
|
@@ -2220,29 +3912,29 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2220
3912
|
create3DAmenityMarker: (feature2, threeLayer, config) => {
|
|
2221
3913
|
const { geometry, properties, feature_type, id } = feature2;
|
|
2222
3914
|
const { category, units, kiosk, is_clickable } = properties;
|
|
2223
|
-
const amenityLocatedUnit =
|
|
2224
|
-
const isLocatedUnitModel3dAvailable = !
|
|
3915
|
+
const amenityLocatedUnit = _12.first(units);
|
|
3916
|
+
const isLocatedUnitModel3dAvailable = !_12.isEmpty(
|
|
2225
3917
|
amenityLocatedUnit?.properties?.model3d
|
|
2226
3918
|
);
|
|
2227
|
-
const isLocatedKioskModel3dAvailable = !
|
|
3919
|
+
const isLocatedKioskModel3dAvailable = !_12.isEmpty(
|
|
2228
3920
|
kiosk?.properties?.model3d
|
|
2229
3921
|
);
|
|
2230
3922
|
const unitConfig = getExtrudeConfigByFeature(config, amenityLocatedUnit);
|
|
2231
|
-
const unitHeight = isLocatedUnitModel3dAvailable ? 0 :
|
|
3923
|
+
const unitHeight = isLocatedUnitModel3dAvailable ? 0 : _12.get(unitConfig, "height", 0);
|
|
2232
3924
|
const kioskConfig = getExtrudeConfigByFeature(config, kiosk);
|
|
2233
|
-
const kioskHeight = isLocatedKioskModel3dAvailable ? 0 :
|
|
2234
|
-
const coordinates =
|
|
3925
|
+
const kioskHeight = isLocatedKioskModel3dAvailable ? 0 : _12.get(kioskConfig, "height", 0);
|
|
3926
|
+
const coordinates = _12.get(geometry, "coordinates");
|
|
2235
3927
|
const markerProperties = {
|
|
2236
3928
|
...properties,
|
|
2237
3929
|
coordinates,
|
|
2238
3930
|
id,
|
|
2239
3931
|
feature_type
|
|
2240
3932
|
};
|
|
2241
|
-
const material =
|
|
3933
|
+
const material = _12.get(
|
|
2242
3934
|
spriteMarkerMaterialObj,
|
|
2243
3935
|
`${feature_type}.${category}`
|
|
2244
3936
|
);
|
|
2245
|
-
const highlightOptions =
|
|
3937
|
+
const highlightOptions = _12.get(
|
|
2246
3938
|
spriteHighlightMarkerOptionObj,
|
|
2247
3939
|
`${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
|
|
2248
3940
|
);
|
|
@@ -2265,24 +3957,24 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2265
3957
|
const { category, unit, kiosk } = properties;
|
|
2266
3958
|
const amenityLocation = kiosk || unit;
|
|
2267
3959
|
const locationConfig = getExtrudeConfigByFeature(config, amenityLocation);
|
|
2268
|
-
const coordinates =
|
|
3960
|
+
const coordinates = _12.get(geometry, "coordinates");
|
|
2269
3961
|
const markerProperties = {
|
|
2270
3962
|
...properties,
|
|
2271
3963
|
coordinates,
|
|
2272
3964
|
id,
|
|
2273
3965
|
feature_type
|
|
2274
3966
|
};
|
|
2275
|
-
const material =
|
|
3967
|
+
const material = _12.get(
|
|
2276
3968
|
spriteMarkerMaterialObj,
|
|
2277
3969
|
`${feature_type}.${category}`
|
|
2278
3970
|
);
|
|
2279
|
-
const highlightOptions =
|
|
3971
|
+
const highlightOptions = _12.get(
|
|
2280
3972
|
spriteHighlightMarkerOptionObj,
|
|
2281
3973
|
`${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
|
|
2282
3974
|
);
|
|
2283
3975
|
const options = {
|
|
2284
3976
|
scale: 0.05,
|
|
2285
|
-
altitude:
|
|
3977
|
+
altitude: _12.get(locationConfig, "height", 0),
|
|
2286
3978
|
highlight: highlightOptions
|
|
2287
3979
|
};
|
|
2288
3980
|
return create3DMarker(
|
|
@@ -2298,24 +3990,24 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2298
3990
|
const { category, unit, kiosk } = properties;
|
|
2299
3991
|
const amenityLocation = kiosk || unit;
|
|
2300
3992
|
const locationConfig = getExtrudeConfigByFeature(config, amenityLocation);
|
|
2301
|
-
const coordinates =
|
|
3993
|
+
const coordinates = _12.get(geometry, "coordinates");
|
|
2302
3994
|
const markerProperties = {
|
|
2303
3995
|
...properties,
|
|
2304
3996
|
coordinates,
|
|
2305
3997
|
id,
|
|
2306
3998
|
feature_type
|
|
2307
3999
|
};
|
|
2308
|
-
const material =
|
|
4000
|
+
const material = _12.get(
|
|
2309
4001
|
spriteMarkerMaterialObj,
|
|
2310
4002
|
`${feature_type}.${category}`
|
|
2311
4003
|
);
|
|
2312
|
-
const highlightOptions =
|
|
4004
|
+
const highlightOptions = _12.get(
|
|
2313
4005
|
spriteHighlightMarkerOptionObj,
|
|
2314
4006
|
`${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
|
|
2315
4007
|
);
|
|
2316
4008
|
const options = {
|
|
2317
4009
|
scale: 0.05,
|
|
2318
|
-
altitude:
|
|
4010
|
+
altitude: _12.get(locationConfig, "height", 0),
|
|
2319
4011
|
highlight: highlightOptions
|
|
2320
4012
|
};
|
|
2321
4013
|
return create3DMarker(
|
|
@@ -2327,13 +4019,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2327
4019
|
);
|
|
2328
4020
|
},
|
|
2329
4021
|
createExtrudedUnit: (unit, threeLayer, options) => {
|
|
2330
|
-
const extrudeHeight =
|
|
4022
|
+
const extrudeHeight = _12.get(options, "height");
|
|
2331
4023
|
if (!extrudeHeight) return;
|
|
2332
4024
|
const unitProperty = getFeatureProperties(unit);
|
|
2333
4025
|
const options3d = {
|
|
2334
4026
|
// TODO: Move to extrude config later
|
|
2335
4027
|
offset: -0.1,
|
|
2336
|
-
altitude:
|
|
4028
|
+
altitude: _12.get(options, "altitude", 0)
|
|
2337
4029
|
};
|
|
2338
4030
|
const color = unitProperty.defaultColor;
|
|
2339
4031
|
if (color === "transparent") return;
|
|
@@ -2376,14 +4068,14 @@ var EXCEPT_AMENITY_LOCATION_CATEGORIES = [
|
|
|
2376
4068
|
"unspecified"
|
|
2377
4069
|
];
|
|
2378
4070
|
var getLocationByAmenity = (feature2) => {
|
|
2379
|
-
const unit =
|
|
2380
|
-
const unitCategory =
|
|
4071
|
+
const unit = _12.get(feature2, "properties.units[0]", null);
|
|
4072
|
+
const unitCategory = _12.get(unit, "properties.category");
|
|
2381
4073
|
if (!unit) return feature2.id;
|
|
2382
4074
|
return EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory) ? feature2 : unit;
|
|
2383
4075
|
};
|
|
2384
4076
|
var getLocationByOccupant = (feature2) => {
|
|
2385
|
-
const kiosk =
|
|
2386
|
-
const unit =
|
|
4077
|
+
const kiosk = _12.get(feature2, "properties.kiosk", null);
|
|
4078
|
+
const unit = _12.get(feature2, "properties.anchor.properties.unit", null);
|
|
2387
4079
|
return kiosk || unit;
|
|
2388
4080
|
};
|
|
2389
4081
|
var getLocationIdByFeature = (feature2) => {
|
|
@@ -2411,10 +4103,10 @@ var getFeatureByLocationId = (id, features = []) => {
|
|
|
2411
4103
|
});
|
|
2412
4104
|
};
|
|
2413
4105
|
var isClickableFeature = (feature2) => {
|
|
2414
|
-
const isClickable =
|
|
4106
|
+
const isClickable = _12.get(feature2, "properties.is_clickable");
|
|
2415
4107
|
switch (feature2?.feature_type) {
|
|
2416
4108
|
case "amenity":
|
|
2417
|
-
return
|
|
4109
|
+
return _12.isNull(isClickable) ? true : isClickable;
|
|
2418
4110
|
case "occupant":
|
|
2419
4111
|
return true;
|
|
2420
4112
|
default:
|
|
@@ -2432,24 +4124,24 @@ var getLocationByFeature = (feature2) => {
|
|
|
2432
4124
|
}
|
|
2433
4125
|
};
|
|
2434
4126
|
var getRelatedLocationsByOccupant = (feature2) => {
|
|
2435
|
-
const kiosks =
|
|
2436
|
-
const units =
|
|
4127
|
+
const kiosks = _12.get(feature2, "properties.kiosks", []);
|
|
4128
|
+
const units = _12.get(feature2, "properties.units", []);
|
|
2437
4129
|
return [...kiosks, ...units];
|
|
2438
4130
|
};
|
|
2439
4131
|
var getRelatedLocationsByAmenity = (feature2) => {
|
|
2440
|
-
const units =
|
|
4132
|
+
const units = _12.get(feature2, "properties.units", []);
|
|
2441
4133
|
if (units.length === 0) return [feature2];
|
|
2442
4134
|
return units.filter((unit) => {
|
|
2443
|
-
const unitCategory =
|
|
4135
|
+
const unitCategory = _12.get(unit, "properties.category");
|
|
2444
4136
|
return !EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory);
|
|
2445
4137
|
});
|
|
2446
4138
|
};
|
|
2447
4139
|
var getRelatedLocationIdsByFeature = (feature2) => {
|
|
2448
4140
|
switch (feature2?.feature_type) {
|
|
2449
4141
|
case "amenity":
|
|
2450
|
-
return getRelatedLocationsByAmenity(feature2).map((
|
|
4142
|
+
return getRelatedLocationsByAmenity(feature2).map((v) => v?.id);
|
|
2451
4143
|
case "occupant":
|
|
2452
|
-
return getRelatedLocationsByOccupant(feature2).map((
|
|
4144
|
+
return getRelatedLocationsByOccupant(feature2).map((v) => v?.id);
|
|
2453
4145
|
default:
|
|
2454
4146
|
return [];
|
|
2455
4147
|
}
|
|
@@ -2466,8 +4158,8 @@ var getRelatedLocationsByFeature = (feature2) => {
|
|
|
2466
4158
|
};
|
|
2467
4159
|
var getOrdinalByLocationId = (locationId, feature2) => {
|
|
2468
4160
|
if (!feature2) return null;
|
|
2469
|
-
const mainUnit =
|
|
2470
|
-
const mainKiosk =
|
|
4161
|
+
const mainUnit = _12.get(feature2, "properties.unit");
|
|
4162
|
+
const mainKiosk = _12.get(feature2, "properties.kiosk");
|
|
2471
4163
|
const relatedLocations = getRelatedLocationsByFeature(feature2);
|
|
2472
4164
|
const allLocations = [mainUnit, mainKiosk, ...relatedLocations].filter(
|
|
2473
4165
|
Boolean
|
|
@@ -2475,7 +4167,7 @@ var getOrdinalByLocationId = (locationId, feature2) => {
|
|
|
2475
4167
|
const targetLocation = allLocations.find(
|
|
2476
4168
|
(location) => location.id === locationId
|
|
2477
4169
|
);
|
|
2478
|
-
return targetLocation ?
|
|
4170
|
+
return targetLocation ? _12.get(targetLocation, "properties.level.properties.ordinal") || _12.get(targetLocation, "properties.ordinal") : null;
|
|
2479
4171
|
};
|
|
2480
4172
|
|
|
2481
4173
|
// src/IndoorMap/utils/math.ts
|
|
@@ -2488,140 +4180,16 @@ var getBearingBetweenPoints = (origin, destination) => {
|
|
|
2488
4180
|
return Math.floor(radToDegree(theta));
|
|
2489
4181
|
};
|
|
2490
4182
|
var getSuitablyValueBetweenBearings = (newBearing, currentBearing) => {
|
|
2491
|
-
const
|
|
2492
|
-
if (
|
|
4183
|
+
const difference2 = Math.abs(newBearing - currentBearing);
|
|
4184
|
+
if (difference2 > 180)
|
|
2493
4185
|
return newBearing > 0 ? newBearing - 360 : newBearing + 360;
|
|
2494
4186
|
return newBearing;
|
|
2495
4187
|
};
|
|
2496
4188
|
|
|
2497
4189
|
// src/IndoorMap/camera/CameraManager.ts
|
|
2498
4190
|
import { Extent } from "maptalks";
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
2502
|
-
if (geojson === null) return;
|
|
2503
|
-
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
2504
|
-
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
2505
|
-
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
2506
|
-
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
2507
|
-
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
2508
|
-
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
2509
|
-
var multiFeatureIndex = 0;
|
|
2510
|
-
var geometryIndex = 0;
|
|
2511
|
-
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
2512
|
-
if (geometry === null) continue;
|
|
2513
|
-
coords = geometry.coordinates;
|
|
2514
|
-
var geomType = geometry.type;
|
|
2515
|
-
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
2516
|
-
switch (geomType) {
|
|
2517
|
-
case null:
|
|
2518
|
-
break;
|
|
2519
|
-
case "Point":
|
|
2520
|
-
if (callback(
|
|
2521
|
-
coords,
|
|
2522
|
-
coordIndex,
|
|
2523
|
-
featureIndex,
|
|
2524
|
-
multiFeatureIndex,
|
|
2525
|
-
geometryIndex
|
|
2526
|
-
) === false)
|
|
2527
|
-
return false;
|
|
2528
|
-
coordIndex++;
|
|
2529
|
-
multiFeatureIndex++;
|
|
2530
|
-
break;
|
|
2531
|
-
case "LineString":
|
|
2532
|
-
case "MultiPoint":
|
|
2533
|
-
for (j = 0; j < coords.length; j++) {
|
|
2534
|
-
if (callback(
|
|
2535
|
-
coords[j],
|
|
2536
|
-
coordIndex,
|
|
2537
|
-
featureIndex,
|
|
2538
|
-
multiFeatureIndex,
|
|
2539
|
-
geometryIndex
|
|
2540
|
-
) === false)
|
|
2541
|
-
return false;
|
|
2542
|
-
coordIndex++;
|
|
2543
|
-
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
2544
|
-
}
|
|
2545
|
-
if (geomType === "LineString") multiFeatureIndex++;
|
|
2546
|
-
break;
|
|
2547
|
-
case "Polygon":
|
|
2548
|
-
case "MultiLineString":
|
|
2549
|
-
for (j = 0; j < coords.length; j++) {
|
|
2550
|
-
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
2551
|
-
if (callback(
|
|
2552
|
-
coords[j][k],
|
|
2553
|
-
coordIndex,
|
|
2554
|
-
featureIndex,
|
|
2555
|
-
multiFeatureIndex,
|
|
2556
|
-
geometryIndex
|
|
2557
|
-
) === false)
|
|
2558
|
-
return false;
|
|
2559
|
-
coordIndex++;
|
|
2560
|
-
}
|
|
2561
|
-
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
2562
|
-
if (geomType === "Polygon") geometryIndex++;
|
|
2563
|
-
}
|
|
2564
|
-
if (geomType === "Polygon") multiFeatureIndex++;
|
|
2565
|
-
break;
|
|
2566
|
-
case "MultiPolygon":
|
|
2567
|
-
for (j = 0; j < coords.length; j++) {
|
|
2568
|
-
geometryIndex = 0;
|
|
2569
|
-
for (k = 0; k < coords[j].length; k++) {
|
|
2570
|
-
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
2571
|
-
if (callback(
|
|
2572
|
-
coords[j][k][l],
|
|
2573
|
-
coordIndex,
|
|
2574
|
-
featureIndex,
|
|
2575
|
-
multiFeatureIndex,
|
|
2576
|
-
geometryIndex
|
|
2577
|
-
) === false)
|
|
2578
|
-
return false;
|
|
2579
|
-
coordIndex++;
|
|
2580
|
-
}
|
|
2581
|
-
geometryIndex++;
|
|
2582
|
-
}
|
|
2583
|
-
multiFeatureIndex++;
|
|
2584
|
-
}
|
|
2585
|
-
break;
|
|
2586
|
-
case "GeometryCollection":
|
|
2587
|
-
for (j = 0; j < geometry.geometries.length; j++)
|
|
2588
|
-
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
2589
|
-
return false;
|
|
2590
|
-
break;
|
|
2591
|
-
default:
|
|
2592
|
-
throw new Error("Unknown Geometry Type");
|
|
2593
|
-
}
|
|
2594
|
-
}
|
|
2595
|
-
}
|
|
2596
|
-
}
|
|
2597
|
-
|
|
2598
|
-
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
2599
|
-
function bbox(geojson, options = {}) {
|
|
2600
|
-
if (geojson.bbox != null && true !== options.recompute) {
|
|
2601
|
-
return geojson.bbox;
|
|
2602
|
-
}
|
|
2603
|
-
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
2604
|
-
coordEach(geojson, (coord) => {
|
|
2605
|
-
if (result[0] > coord[0]) {
|
|
2606
|
-
result[0] = coord[0];
|
|
2607
|
-
}
|
|
2608
|
-
if (result[1] > coord[1]) {
|
|
2609
|
-
result[1] = coord[1];
|
|
2610
|
-
}
|
|
2611
|
-
if (result[2] < coord[0]) {
|
|
2612
|
-
result[2] = coord[0];
|
|
2613
|
-
}
|
|
2614
|
-
if (result[3] < coord[1]) {
|
|
2615
|
-
result[3] = coord[1];
|
|
2616
|
-
}
|
|
2617
|
-
});
|
|
2618
|
-
return result;
|
|
2619
|
-
}
|
|
2620
|
-
var index_default = bbox;
|
|
2621
|
-
|
|
2622
|
-
// src/IndoorMap/camera/CameraManager.ts
|
|
2623
|
-
import scale from "@turf/transform-scale";
|
|
2624
|
-
import bboxPolygon from "@turf/bbox-polygon";
|
|
4191
|
+
import scale2 from "@turf/transform-scale";
|
|
4192
|
+
import bboxPolygon2 from "@turf/bbox-polygon";
|
|
2625
4193
|
var CameraManager = class {
|
|
2626
4194
|
map;
|
|
2627
4195
|
constructor(map, options) {
|
|
@@ -2647,7 +4215,7 @@ var CameraManager = class {
|
|
|
2647
4215
|
}
|
|
2648
4216
|
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
2649
4217
|
const [minX, minY, maxX, maxY] = index_default(
|
|
2650
|
-
|
|
4218
|
+
scale2(bboxPolygon2(index_default(feature2)), scaleFactor)
|
|
2651
4219
|
);
|
|
2652
4220
|
return new Extent(minX, minY, maxX, maxY);
|
|
2653
4221
|
};
|
|
@@ -2684,8 +4252,8 @@ var CameraManager = class {
|
|
|
2684
4252
|
};
|
|
2685
4253
|
|
|
2686
4254
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
2687
|
-
import { min, compact as
|
|
2688
|
-
import { center as
|
|
4255
|
+
import { min, compact as compact2, isFunction } from "lodash";
|
|
4256
|
+
import { center as turfCenter5 } from "@turf/center";
|
|
2689
4257
|
import * as THREE4 from "three";
|
|
2690
4258
|
|
|
2691
4259
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
@@ -2693,7 +4261,7 @@ import * as maptalks4 from "maptalks-gl";
|
|
|
2693
4261
|
import * as THREE from "three";
|
|
2694
4262
|
import { BaseObject as BaseObject5 } from "maptalks.three";
|
|
2695
4263
|
import turfBuffer2 from "@turf/buffer";
|
|
2696
|
-
import { cleanCoords } from "@turf/clean-coords";
|
|
4264
|
+
import { cleanCoords as cleanCoords2 } from "@turf/clean-coords";
|
|
2697
4265
|
import { polygonToLine } from "@turf/polygon-to-line";
|
|
2698
4266
|
import { nearestPointOnLine } from "@turf/nearest-point-on-line";
|
|
2699
4267
|
import { length } from "@turf/length";
|
|
@@ -2709,7 +4277,7 @@ import {
|
|
|
2709
4277
|
PlaneGeometry
|
|
2710
4278
|
} from "three";
|
|
2711
4279
|
import { largestRect } from "d3plus-shape";
|
|
2712
|
-
import { max, merge, isNumber as isNumber2, isArray, range } from "lodash
|
|
4280
|
+
import { max, merge, isNumber as isNumber2, isArray, range } from "lodash";
|
|
2713
4281
|
var OPTIONS3 = {
|
|
2714
4282
|
// Allowing click through and prevent interaction
|
|
2715
4283
|
interactive: false,
|
|
@@ -2789,16 +4357,16 @@ var getMaterial = (text, flatLabelOptions) => {
|
|
|
2789
4357
|
ctx.font = `${fontWeight} ${scale3 * fontSize}px "${fontFamily}", Arial`;
|
|
2790
4358
|
textWidth = max(texts.map((text2) => ctx.measureText(text2).width));
|
|
2791
4359
|
}
|
|
2792
|
-
const
|
|
4360
|
+
const center8 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
|
|
2793
4361
|
if (scale3 > scaleMin) {
|
|
2794
4362
|
const totalHeight = texts.length * (fontSize * scale3 * lineHeight);
|
|
2795
|
-
const startY =
|
|
4363
|
+
const startY = center8.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
|
|
2796
4364
|
texts.forEach((text2, index) => {
|
|
2797
4365
|
const yOffset = startY + index * (fontSize * scale3 * lineHeight);
|
|
2798
4366
|
if (strokeStyle && lineWidth) {
|
|
2799
|
-
ctx.strokeText(text2,
|
|
4367
|
+
ctx.strokeText(text2, center8.x, yOffset);
|
|
2800
4368
|
}
|
|
2801
|
-
ctx.fillText(text2,
|
|
4369
|
+
ctx.fillText(text2, center8.x, yOffset);
|
|
2802
4370
|
});
|
|
2803
4371
|
}
|
|
2804
4372
|
const texture = new Texture(canvas);
|
|
@@ -3055,6 +4623,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3055
4623
|
threeLayer;
|
|
3056
4624
|
scene;
|
|
3057
4625
|
lineMaterial;
|
|
4626
|
+
navigationLineMaterial;
|
|
3058
4627
|
materialByColorMap;
|
|
3059
4628
|
// Renderer is Ready
|
|
3060
4629
|
isReady = false;
|
|
@@ -3066,6 +4635,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3066
4635
|
this.threeLayer = groupLayer.getLayer("three");
|
|
3067
4636
|
this.gltfLayer = groupLayer.getLayer("gltf");
|
|
3068
4637
|
this.lineMaterial = new THREE.LineBasicMaterial({ color: "#000" });
|
|
4638
|
+
this.navigationLineMaterial = new THREE.LineBasicMaterial({ color: "#f00" });
|
|
3069
4639
|
this.render();
|
|
3070
4640
|
}
|
|
3071
4641
|
animation() {
|
|
@@ -3181,7 +4751,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3181
4751
|
const polygons = unit.geometry.type === "Polygon" ? [unit.geometry.coordinates] : unit.geometry.coordinates;
|
|
3182
4752
|
return polygons.map((plg) => {
|
|
3183
4753
|
return plg.map((ring) => {
|
|
3184
|
-
const roomWall =
|
|
4754
|
+
const roomWall = cleanCoords2(polygonToLine(polygon([ring])));
|
|
3185
4755
|
if (openings.length === 0) {
|
|
3186
4756
|
const color = "#ababab";
|
|
3187
4757
|
const material = this.getOrCreateMaterialByColor(color);
|
|
@@ -3268,10 +4838,10 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3268
4838
|
this.threeLayer.addMesh(groundLabel);
|
|
3269
4839
|
return groundLabel;
|
|
3270
4840
|
}
|
|
3271
|
-
async createModel3d(
|
|
3272
|
-
const marker = new maptalks4.GLTFMarker(
|
|
4841
|
+
async createModel3d(center8, url) {
|
|
4842
|
+
const marker = new maptalks4.GLTFMarker(center8, {
|
|
3273
4843
|
symbol: {
|
|
3274
|
-
url
|
|
4844
|
+
url
|
|
3275
4845
|
}
|
|
3276
4846
|
});
|
|
3277
4847
|
marker.addTo(this.gltfLayer);
|
|
@@ -3330,11 +4900,23 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3330
4900
|
}
|
|
3331
4901
|
}
|
|
3332
4902
|
}
|
|
4903
|
+
drawNavigation = (route) => {
|
|
4904
|
+
const lines = [];
|
|
4905
|
+
route.steps.map((step) => {
|
|
4906
|
+
const lineString2 = new maptalks4.LineString(step.path);
|
|
4907
|
+
const line = this.threeLayer.toPath(lineString2, { altitude: 0.2, cornerRadius: 1, width: 1, asynchronous: true }, this.navigationLineMaterial);
|
|
4908
|
+
lines.push(line);
|
|
4909
|
+
});
|
|
4910
|
+
this.threeLayer.addMesh(lines);
|
|
4911
|
+
};
|
|
3333
4912
|
render() {
|
|
3334
4913
|
this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
|
|
3335
4914
|
if (this.threeLayer._needsUpdate) {
|
|
3336
4915
|
this.threeLayer.redraw();
|
|
3337
4916
|
}
|
|
4917
|
+
if (this.navigationLineMaterial?.map?.offset) {
|
|
4918
|
+
this.navigationLineMaterial.map.offset.x -= 2e-3;
|
|
4919
|
+
}
|
|
3338
4920
|
requestAnimationFrame(this.render.bind(this));
|
|
3339
4921
|
}
|
|
3340
4922
|
};
|
|
@@ -3474,6 +5056,8 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3474
5056
|
}
|
|
3475
5057
|
};
|
|
3476
5058
|
}
|
|
5059
|
+
drawNavigation(route) {
|
|
5060
|
+
}
|
|
3477
5061
|
};
|
|
3478
5062
|
|
|
3479
5063
|
// src/IndoorMap/renderer/2d/Marker2DRenderer.ts
|
|
@@ -3519,7 +5103,7 @@ import * as THREE3 from "three";
|
|
|
3519
5103
|
import { Coordinate as Coordinate2, Util as Util4 } from "maptalks";
|
|
3520
5104
|
import * as THREE2 from "three";
|
|
3521
5105
|
import { BaseObject as BaseObject6 } from "maptalks.three";
|
|
3522
|
-
import { isNil, set } from "lodash";
|
|
5106
|
+
import { isNil, set as set4 } from "lodash";
|
|
3523
5107
|
|
|
3524
5108
|
// src/IndoorMap/renderer/utils/interpolateStops.ts
|
|
3525
5109
|
var interpolateStops = ({ stops }, zoom) => {
|
|
@@ -3529,8 +5113,8 @@ var interpolateStops = ({ stops }, zoom) => {
|
|
|
3529
5113
|
const [z1, v1] = stops[i];
|
|
3530
5114
|
const [z2, v2] = stops[i + 1];
|
|
3531
5115
|
if (zoom >= z1 && zoom <= z2) {
|
|
3532
|
-
const
|
|
3533
|
-
return v1 +
|
|
5116
|
+
const t2 = (zoom - z1) / (z2 - z1);
|
|
5117
|
+
return v1 + t2 * (v2 - v1);
|
|
3534
5118
|
}
|
|
3535
5119
|
}
|
|
3536
5120
|
};
|
|
@@ -3675,7 +5259,7 @@ var TextSpriteMarker = class extends BaseObject6 {
|
|
|
3675
5259
|
const altitude = (options.altitude || 0) + this.#altitudeOffset;
|
|
3676
5260
|
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
3677
5261
|
const position = layer.coordinateToVector3(this._coordinate, z);
|
|
3678
|
-
|
|
5262
|
+
set4(this.properties, "default.position", position);
|
|
3679
5263
|
this.getObject3d().position.copy(position);
|
|
3680
5264
|
}
|
|
3681
5265
|
_animation() {
|
|
@@ -3849,478 +5433,11 @@ var angleBetweenLineStrings = (line1, line2) => {
|
|
|
3849
5433
|
return Math.atan2(dy, dx);
|
|
3850
5434
|
};
|
|
3851
5435
|
|
|
3852
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/util.js
|
|
3853
|
-
var epsilon = 11102230246251565e-32;
|
|
3854
|
-
var splitter = 134217729;
|
|
3855
|
-
var resulterrbound = (3 + 8 * epsilon) * epsilon;
|
|
3856
|
-
function sum(elen, e, flen, f, h) {
|
|
3857
|
-
let Q, Qnew, hh, bvirt;
|
|
3858
|
-
let enow = e[0];
|
|
3859
|
-
let fnow = f[0];
|
|
3860
|
-
let eindex = 0;
|
|
3861
|
-
let findex = 0;
|
|
3862
|
-
if (fnow > enow === fnow > -enow) {
|
|
3863
|
-
Q = enow;
|
|
3864
|
-
enow = e[++eindex];
|
|
3865
|
-
} else {
|
|
3866
|
-
Q = fnow;
|
|
3867
|
-
fnow = f[++findex];
|
|
3868
|
-
}
|
|
3869
|
-
let hindex = 0;
|
|
3870
|
-
if (eindex < elen && findex < flen) {
|
|
3871
|
-
if (fnow > enow === fnow > -enow) {
|
|
3872
|
-
Qnew = enow + Q;
|
|
3873
|
-
hh = Q - (Qnew - enow);
|
|
3874
|
-
enow = e[++eindex];
|
|
3875
|
-
} else {
|
|
3876
|
-
Qnew = fnow + Q;
|
|
3877
|
-
hh = Q - (Qnew - fnow);
|
|
3878
|
-
fnow = f[++findex];
|
|
3879
|
-
}
|
|
3880
|
-
Q = Qnew;
|
|
3881
|
-
if (hh !== 0) {
|
|
3882
|
-
h[hindex++] = hh;
|
|
3883
|
-
}
|
|
3884
|
-
while (eindex < elen && findex < flen) {
|
|
3885
|
-
if (fnow > enow === fnow > -enow) {
|
|
3886
|
-
Qnew = Q + enow;
|
|
3887
|
-
bvirt = Qnew - Q;
|
|
3888
|
-
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3889
|
-
enow = e[++eindex];
|
|
3890
|
-
} else {
|
|
3891
|
-
Qnew = Q + fnow;
|
|
3892
|
-
bvirt = Qnew - Q;
|
|
3893
|
-
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3894
|
-
fnow = f[++findex];
|
|
3895
|
-
}
|
|
3896
|
-
Q = Qnew;
|
|
3897
|
-
if (hh !== 0) {
|
|
3898
|
-
h[hindex++] = hh;
|
|
3899
|
-
}
|
|
3900
|
-
}
|
|
3901
|
-
}
|
|
3902
|
-
while (eindex < elen) {
|
|
3903
|
-
Qnew = Q + enow;
|
|
3904
|
-
bvirt = Qnew - Q;
|
|
3905
|
-
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3906
|
-
enow = e[++eindex];
|
|
3907
|
-
Q = Qnew;
|
|
3908
|
-
if (hh !== 0) {
|
|
3909
|
-
h[hindex++] = hh;
|
|
3910
|
-
}
|
|
3911
|
-
}
|
|
3912
|
-
while (findex < flen) {
|
|
3913
|
-
Qnew = Q + fnow;
|
|
3914
|
-
bvirt = Qnew - Q;
|
|
3915
|
-
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3916
|
-
fnow = f[++findex];
|
|
3917
|
-
Q = Qnew;
|
|
3918
|
-
if (hh !== 0) {
|
|
3919
|
-
h[hindex++] = hh;
|
|
3920
|
-
}
|
|
3921
|
-
}
|
|
3922
|
-
if (Q !== 0 || hindex === 0) {
|
|
3923
|
-
h[hindex++] = Q;
|
|
3924
|
-
}
|
|
3925
|
-
return hindex;
|
|
3926
|
-
}
|
|
3927
|
-
function estimate(elen, e) {
|
|
3928
|
-
let Q = e[0];
|
|
3929
|
-
for (let i = 1; i < elen; i++) Q += e[i];
|
|
3930
|
-
return Q;
|
|
3931
|
-
}
|
|
3932
|
-
function vec(n) {
|
|
3933
|
-
return new Float64Array(n);
|
|
3934
|
-
}
|
|
3935
|
-
|
|
3936
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient2d.js
|
|
3937
|
-
var ccwerrboundA = (3 + 16 * epsilon) * epsilon;
|
|
3938
|
-
var ccwerrboundB = (2 + 12 * epsilon) * epsilon;
|
|
3939
|
-
var ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
|
|
3940
|
-
var B = vec(4);
|
|
3941
|
-
var C1 = vec(8);
|
|
3942
|
-
var C2 = vec(12);
|
|
3943
|
-
var D = vec(16);
|
|
3944
|
-
var u = vec(4);
|
|
3945
|
-
function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
|
|
3946
|
-
let acxtail, acytail, bcxtail, bcytail;
|
|
3947
|
-
let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u32;
|
|
3948
|
-
const acx = ax - cx;
|
|
3949
|
-
const bcx = bx - cx;
|
|
3950
|
-
const acy = ay - cy;
|
|
3951
|
-
const bcy = by - cy;
|
|
3952
|
-
s1 = acx * bcy;
|
|
3953
|
-
c = splitter * acx;
|
|
3954
|
-
ahi = c - (c - acx);
|
|
3955
|
-
alo = acx - ahi;
|
|
3956
|
-
c = splitter * bcy;
|
|
3957
|
-
bhi = c - (c - bcy);
|
|
3958
|
-
blo = bcy - bhi;
|
|
3959
|
-
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3960
|
-
t1 = acy * bcx;
|
|
3961
|
-
c = splitter * acy;
|
|
3962
|
-
ahi = c - (c - acy);
|
|
3963
|
-
alo = acy - ahi;
|
|
3964
|
-
c = splitter * bcx;
|
|
3965
|
-
bhi = c - (c - bcx);
|
|
3966
|
-
blo = bcx - bhi;
|
|
3967
|
-
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
3968
|
-
_i = s0 - t0;
|
|
3969
|
-
bvirt = s0 - _i;
|
|
3970
|
-
B[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
3971
|
-
_j = s1 + _i;
|
|
3972
|
-
bvirt = _j - s1;
|
|
3973
|
-
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
3974
|
-
_i = _0 - t1;
|
|
3975
|
-
bvirt = _0 - _i;
|
|
3976
|
-
B[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
3977
|
-
u32 = _j + _i;
|
|
3978
|
-
bvirt = u32 - _j;
|
|
3979
|
-
B[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
3980
|
-
B[3] = u32;
|
|
3981
|
-
let det = estimate(4, B);
|
|
3982
|
-
let errbound = ccwerrboundB * detsum;
|
|
3983
|
-
if (det >= errbound || -det >= errbound) {
|
|
3984
|
-
return det;
|
|
3985
|
-
}
|
|
3986
|
-
bvirt = ax - acx;
|
|
3987
|
-
acxtail = ax - (acx + bvirt) + (bvirt - cx);
|
|
3988
|
-
bvirt = bx - bcx;
|
|
3989
|
-
bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
|
|
3990
|
-
bvirt = ay - acy;
|
|
3991
|
-
acytail = ay - (acy + bvirt) + (bvirt - cy);
|
|
3992
|
-
bvirt = by - bcy;
|
|
3993
|
-
bcytail = by - (bcy + bvirt) + (bvirt - cy);
|
|
3994
|
-
if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
|
|
3995
|
-
return det;
|
|
3996
|
-
}
|
|
3997
|
-
errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
|
|
3998
|
-
det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
|
|
3999
|
-
if (det >= errbound || -det >= errbound) return det;
|
|
4000
|
-
s1 = acxtail * bcy;
|
|
4001
|
-
c = splitter * acxtail;
|
|
4002
|
-
ahi = c - (c - acxtail);
|
|
4003
|
-
alo = acxtail - ahi;
|
|
4004
|
-
c = splitter * bcy;
|
|
4005
|
-
bhi = c - (c - bcy);
|
|
4006
|
-
blo = bcy - bhi;
|
|
4007
|
-
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4008
|
-
t1 = acytail * bcx;
|
|
4009
|
-
c = splitter * acytail;
|
|
4010
|
-
ahi = c - (c - acytail);
|
|
4011
|
-
alo = acytail - ahi;
|
|
4012
|
-
c = splitter * bcx;
|
|
4013
|
-
bhi = c - (c - bcx);
|
|
4014
|
-
blo = bcx - bhi;
|
|
4015
|
-
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4016
|
-
_i = s0 - t0;
|
|
4017
|
-
bvirt = s0 - _i;
|
|
4018
|
-
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4019
|
-
_j = s1 + _i;
|
|
4020
|
-
bvirt = _j - s1;
|
|
4021
|
-
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4022
|
-
_i = _0 - t1;
|
|
4023
|
-
bvirt = _0 - _i;
|
|
4024
|
-
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4025
|
-
u32 = _j + _i;
|
|
4026
|
-
bvirt = u32 - _j;
|
|
4027
|
-
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4028
|
-
u[3] = u32;
|
|
4029
|
-
const C1len = sum(4, B, 4, u, C1);
|
|
4030
|
-
s1 = acx * bcytail;
|
|
4031
|
-
c = splitter * acx;
|
|
4032
|
-
ahi = c - (c - acx);
|
|
4033
|
-
alo = acx - ahi;
|
|
4034
|
-
c = splitter * bcytail;
|
|
4035
|
-
bhi = c - (c - bcytail);
|
|
4036
|
-
blo = bcytail - bhi;
|
|
4037
|
-
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4038
|
-
t1 = acy * bcxtail;
|
|
4039
|
-
c = splitter * acy;
|
|
4040
|
-
ahi = c - (c - acy);
|
|
4041
|
-
alo = acy - ahi;
|
|
4042
|
-
c = splitter * bcxtail;
|
|
4043
|
-
bhi = c - (c - bcxtail);
|
|
4044
|
-
blo = bcxtail - bhi;
|
|
4045
|
-
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4046
|
-
_i = s0 - t0;
|
|
4047
|
-
bvirt = s0 - _i;
|
|
4048
|
-
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4049
|
-
_j = s1 + _i;
|
|
4050
|
-
bvirt = _j - s1;
|
|
4051
|
-
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4052
|
-
_i = _0 - t1;
|
|
4053
|
-
bvirt = _0 - _i;
|
|
4054
|
-
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4055
|
-
u32 = _j + _i;
|
|
4056
|
-
bvirt = u32 - _j;
|
|
4057
|
-
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4058
|
-
u[3] = u32;
|
|
4059
|
-
const C2len = sum(C1len, C1, 4, u, C2);
|
|
4060
|
-
s1 = acxtail * bcytail;
|
|
4061
|
-
c = splitter * acxtail;
|
|
4062
|
-
ahi = c - (c - acxtail);
|
|
4063
|
-
alo = acxtail - ahi;
|
|
4064
|
-
c = splitter * bcytail;
|
|
4065
|
-
bhi = c - (c - bcytail);
|
|
4066
|
-
blo = bcytail - bhi;
|
|
4067
|
-
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4068
|
-
t1 = acytail * bcxtail;
|
|
4069
|
-
c = splitter * acytail;
|
|
4070
|
-
ahi = c - (c - acytail);
|
|
4071
|
-
alo = acytail - ahi;
|
|
4072
|
-
c = splitter * bcxtail;
|
|
4073
|
-
bhi = c - (c - bcxtail);
|
|
4074
|
-
blo = bcxtail - bhi;
|
|
4075
|
-
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4076
|
-
_i = s0 - t0;
|
|
4077
|
-
bvirt = s0 - _i;
|
|
4078
|
-
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4079
|
-
_j = s1 + _i;
|
|
4080
|
-
bvirt = _j - s1;
|
|
4081
|
-
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4082
|
-
_i = _0 - t1;
|
|
4083
|
-
bvirt = _0 - _i;
|
|
4084
|
-
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4085
|
-
u32 = _j + _i;
|
|
4086
|
-
bvirt = u32 - _j;
|
|
4087
|
-
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4088
|
-
u[3] = u32;
|
|
4089
|
-
const Dlen = sum(C2len, C2, 4, u, D);
|
|
4090
|
-
return D[Dlen - 1];
|
|
4091
|
-
}
|
|
4092
|
-
function orient2d(ax, ay, bx, by, cx, cy) {
|
|
4093
|
-
const detleft = (ay - cy) * (bx - cx);
|
|
4094
|
-
const detright = (ax - cx) * (by - cy);
|
|
4095
|
-
const det = detleft - detright;
|
|
4096
|
-
const detsum = Math.abs(detleft + detright);
|
|
4097
|
-
if (Math.abs(det) >= ccwerrboundA * detsum) return det;
|
|
4098
|
-
return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
|
|
4099
|
-
}
|
|
4100
|
-
|
|
4101
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient3d.js
|
|
4102
|
-
var o3derrboundA = (7 + 56 * epsilon) * epsilon;
|
|
4103
|
-
var o3derrboundB = (3 + 28 * epsilon) * epsilon;
|
|
4104
|
-
var o3derrboundC = (26 + 288 * epsilon) * epsilon * epsilon;
|
|
4105
|
-
var bc = vec(4);
|
|
4106
|
-
var ca = vec(4);
|
|
4107
|
-
var ab = vec(4);
|
|
4108
|
-
var at_b = vec(4);
|
|
4109
|
-
var at_c = vec(4);
|
|
4110
|
-
var bt_c = vec(4);
|
|
4111
|
-
var bt_a = vec(4);
|
|
4112
|
-
var ct_a = vec(4);
|
|
4113
|
-
var ct_b = vec(4);
|
|
4114
|
-
var bct = vec(8);
|
|
4115
|
-
var cat = vec(8);
|
|
4116
|
-
var abt = vec(8);
|
|
4117
|
-
var u2 = vec(4);
|
|
4118
|
-
var _8 = vec(8);
|
|
4119
|
-
var _8b = vec(8);
|
|
4120
|
-
var _16 = vec(8);
|
|
4121
|
-
var _12 = vec(12);
|
|
4122
|
-
var fin = vec(192);
|
|
4123
|
-
var fin2 = vec(192);
|
|
4124
|
-
|
|
4125
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/incircle.js
|
|
4126
|
-
var iccerrboundA = (10 + 96 * epsilon) * epsilon;
|
|
4127
|
-
var iccerrboundB = (4 + 48 * epsilon) * epsilon;
|
|
4128
|
-
var iccerrboundC = (44 + 576 * epsilon) * epsilon * epsilon;
|
|
4129
|
-
var bc2 = vec(4);
|
|
4130
|
-
var ca2 = vec(4);
|
|
4131
|
-
var ab2 = vec(4);
|
|
4132
|
-
var aa = vec(4);
|
|
4133
|
-
var bb = vec(4);
|
|
4134
|
-
var cc = vec(4);
|
|
4135
|
-
var u3 = vec(4);
|
|
4136
|
-
var v = vec(4);
|
|
4137
|
-
var axtbc = vec(8);
|
|
4138
|
-
var aytbc = vec(8);
|
|
4139
|
-
var bxtca = vec(8);
|
|
4140
|
-
var bytca = vec(8);
|
|
4141
|
-
var cxtab = vec(8);
|
|
4142
|
-
var cytab = vec(8);
|
|
4143
|
-
var abt2 = vec(8);
|
|
4144
|
-
var bct2 = vec(8);
|
|
4145
|
-
var cat2 = vec(8);
|
|
4146
|
-
var abtt = vec(4);
|
|
4147
|
-
var bctt = vec(4);
|
|
4148
|
-
var catt = vec(4);
|
|
4149
|
-
var _82 = vec(8);
|
|
4150
|
-
var _162 = vec(16);
|
|
4151
|
-
var _16b = vec(16);
|
|
4152
|
-
var _16c = vec(16);
|
|
4153
|
-
var _32 = vec(32);
|
|
4154
|
-
var _32b = vec(32);
|
|
4155
|
-
var _48 = vec(48);
|
|
4156
|
-
var _64 = vec(64);
|
|
4157
|
-
var fin3 = vec(1152);
|
|
4158
|
-
var fin22 = vec(1152);
|
|
4159
|
-
|
|
4160
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/insphere.js
|
|
4161
|
-
var isperrboundA = (16 + 224 * epsilon) * epsilon;
|
|
4162
|
-
var isperrboundB = (5 + 72 * epsilon) * epsilon;
|
|
4163
|
-
var isperrboundC = (71 + 1408 * epsilon) * epsilon * epsilon;
|
|
4164
|
-
var ab3 = vec(4);
|
|
4165
|
-
var bc3 = vec(4);
|
|
4166
|
-
var cd = vec(4);
|
|
4167
|
-
var de = vec(4);
|
|
4168
|
-
var ea = vec(4);
|
|
4169
|
-
var ac = vec(4);
|
|
4170
|
-
var bd = vec(4);
|
|
4171
|
-
var ce = vec(4);
|
|
4172
|
-
var da = vec(4);
|
|
4173
|
-
var eb = vec(4);
|
|
4174
|
-
var abc = vec(24);
|
|
4175
|
-
var bcd = vec(24);
|
|
4176
|
-
var cde = vec(24);
|
|
4177
|
-
var dea = vec(24);
|
|
4178
|
-
var eab = vec(24);
|
|
4179
|
-
var abd = vec(24);
|
|
4180
|
-
var bce = vec(24);
|
|
4181
|
-
var cda = vec(24);
|
|
4182
|
-
var deb = vec(24);
|
|
4183
|
-
var eac = vec(24);
|
|
4184
|
-
var adet = vec(1152);
|
|
4185
|
-
var bdet = vec(1152);
|
|
4186
|
-
var cdet = vec(1152);
|
|
4187
|
-
var ddet = vec(1152);
|
|
4188
|
-
var edet = vec(1152);
|
|
4189
|
-
var abdet = vec(2304);
|
|
4190
|
-
var cddet = vec(2304);
|
|
4191
|
-
var cdedet = vec(3456);
|
|
4192
|
-
var deter = vec(5760);
|
|
4193
|
-
var _83 = vec(8);
|
|
4194
|
-
var _8b2 = vec(8);
|
|
4195
|
-
var _8c = vec(8);
|
|
4196
|
-
var _163 = vec(16);
|
|
4197
|
-
var _24 = vec(24);
|
|
4198
|
-
var _482 = vec(48);
|
|
4199
|
-
var _48b = vec(48);
|
|
4200
|
-
var _96 = vec(96);
|
|
4201
|
-
var _192 = vec(192);
|
|
4202
|
-
var _384x = vec(384);
|
|
4203
|
-
var _384y = vec(384);
|
|
4204
|
-
var _384z = vec(384);
|
|
4205
|
-
var _768 = vec(768);
|
|
4206
|
-
var xdet = vec(96);
|
|
4207
|
-
var ydet = vec(96);
|
|
4208
|
-
var zdet = vec(96);
|
|
4209
|
-
var fin4 = vec(1152);
|
|
4210
|
-
|
|
4211
|
-
// ../../node_modules/point-in-polygon-hao/dist/esm/index.js
|
|
4212
|
-
function pointInPolygon(p, polygon2) {
|
|
4213
|
-
var i;
|
|
4214
|
-
var ii;
|
|
4215
|
-
var k = 0;
|
|
4216
|
-
var f;
|
|
4217
|
-
var u1;
|
|
4218
|
-
var v1;
|
|
4219
|
-
var u22;
|
|
4220
|
-
var v2;
|
|
4221
|
-
var currentP;
|
|
4222
|
-
var nextP;
|
|
4223
|
-
var x = p[0];
|
|
4224
|
-
var y = p[1];
|
|
4225
|
-
var numContours = polygon2.length;
|
|
4226
|
-
for (i = 0; i < numContours; i++) {
|
|
4227
|
-
ii = 0;
|
|
4228
|
-
var contour = polygon2[i];
|
|
4229
|
-
var contourLen = contour.length - 1;
|
|
4230
|
-
currentP = contour[0];
|
|
4231
|
-
if (currentP[0] !== contour[contourLen][0] && currentP[1] !== contour[contourLen][1]) {
|
|
4232
|
-
throw new Error("First and last coordinates in a ring must be the same");
|
|
4233
|
-
}
|
|
4234
|
-
u1 = currentP[0] - x;
|
|
4235
|
-
v1 = currentP[1] - y;
|
|
4236
|
-
for (ii; ii < contourLen; ii++) {
|
|
4237
|
-
nextP = contour[ii + 1];
|
|
4238
|
-
u22 = nextP[0] - x;
|
|
4239
|
-
v2 = nextP[1] - y;
|
|
4240
|
-
if (v1 === 0 && v2 === 0) {
|
|
4241
|
-
if (u22 <= 0 && u1 >= 0 || u1 <= 0 && u22 >= 0) {
|
|
4242
|
-
return 0;
|
|
4243
|
-
}
|
|
4244
|
-
} else if (v2 >= 0 && v1 <= 0 || v2 <= 0 && v1 >= 0) {
|
|
4245
|
-
f = orient2d(u1, u22, v1, v2, 0, 0);
|
|
4246
|
-
if (f === 0) {
|
|
4247
|
-
return 0;
|
|
4248
|
-
}
|
|
4249
|
-
if (f > 0 && v2 > 0 && v1 <= 0 || f < 0 && v2 <= 0 && v1 > 0) {
|
|
4250
|
-
k++;
|
|
4251
|
-
}
|
|
4252
|
-
}
|
|
4253
|
-
currentP = nextP;
|
|
4254
|
-
v1 = v2;
|
|
4255
|
-
u1 = u22;
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
|
-
if (k % 2 === 0) {
|
|
4259
|
-
return false;
|
|
4260
|
-
}
|
|
4261
|
-
return true;
|
|
4262
|
-
}
|
|
4263
|
-
|
|
4264
|
-
// ../../node_modules/@turf/invariant/dist/esm/index.js
|
|
4265
|
-
function getCoord(coord) {
|
|
4266
|
-
if (!coord) {
|
|
4267
|
-
throw new Error("coord is required");
|
|
4268
|
-
}
|
|
4269
|
-
if (!Array.isArray(coord)) {
|
|
4270
|
-
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
4271
|
-
return [...coord.geometry.coordinates];
|
|
4272
|
-
}
|
|
4273
|
-
if (coord.type === "Point") {
|
|
4274
|
-
return [...coord.coordinates];
|
|
4275
|
-
}
|
|
4276
|
-
}
|
|
4277
|
-
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
4278
|
-
return [...coord];
|
|
4279
|
-
}
|
|
4280
|
-
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
4281
|
-
}
|
|
4282
|
-
function getGeom(geojson) {
|
|
4283
|
-
if (geojson.type === "Feature") {
|
|
4284
|
-
return geojson.geometry;
|
|
4285
|
-
}
|
|
4286
|
-
return geojson;
|
|
4287
|
-
}
|
|
4288
|
-
|
|
4289
|
-
// ../../node_modules/@turf/boolean-point-in-polygon/dist/esm/index.js
|
|
4290
|
-
function booleanPointInPolygon(point2, polygon2, options = {}) {
|
|
4291
|
-
if (!point2) {
|
|
4292
|
-
throw new Error("point is required");
|
|
4293
|
-
}
|
|
4294
|
-
if (!polygon2) {
|
|
4295
|
-
throw new Error("polygon is required");
|
|
4296
|
-
}
|
|
4297
|
-
const pt = getCoord(point2);
|
|
4298
|
-
const geom = getGeom(polygon2);
|
|
4299
|
-
const type = geom.type;
|
|
4300
|
-
const bbox2 = polygon2.bbox;
|
|
4301
|
-
let polys = geom.coordinates;
|
|
4302
|
-
if (bbox2 && inBBox(pt, bbox2) === false) {
|
|
4303
|
-
return false;
|
|
4304
|
-
}
|
|
4305
|
-
if (type === "Polygon") {
|
|
4306
|
-
polys = [polys];
|
|
4307
|
-
}
|
|
4308
|
-
let result = false;
|
|
4309
|
-
for (var i = 0; i < polys.length; ++i) {
|
|
4310
|
-
const polyResult = pointInPolygon(pt, polys[i]);
|
|
4311
|
-
if (polyResult === 0) return options.ignoreBoundary ? false : true;
|
|
4312
|
-
else if (polyResult) result = true;
|
|
4313
|
-
}
|
|
4314
|
-
return result;
|
|
4315
|
-
}
|
|
4316
|
-
function inBBox(pt, bbox2) {
|
|
4317
|
-
return bbox2[0] <= pt[0] && bbox2[1] <= pt[1] && bbox2[2] >= pt[0] && bbox2[3] >= pt[1];
|
|
4318
|
-
}
|
|
4319
|
-
|
|
4320
5436
|
// src/IndoorMap/renderer/utils/findUnitOnPoint.ts
|
|
5437
|
+
import { booleanPointInPolygon as booleanPointInPolygon5 } from "@turf/boolean-point-in-polygon";
|
|
4321
5438
|
var findUnitOnPoint = (units, point2) => {
|
|
4322
5439
|
try {
|
|
4323
|
-
return units.find((unit) =>
|
|
5440
|
+
return units.find((unit) => booleanPointInPolygon5(point2, polygon(unit.geometry.coordinates)));
|
|
4324
5441
|
} catch (err) {
|
|
4325
5442
|
return null;
|
|
4326
5443
|
}
|
|
@@ -4369,9 +5486,9 @@ var RendererManager = class extends EventTarget {
|
|
|
4369
5486
|
const pos = geom?.attributes?.position?.array;
|
|
4370
5487
|
if (!pos || pos.length === 0) return;
|
|
4371
5488
|
for (let i = 0; i < pos.length; i++) {
|
|
4372
|
-
const
|
|
4373
|
-
if (!Number.isFinite(
|
|
4374
|
-
bad.push({ mesh: obj, index: i, value:
|
|
5489
|
+
const v = pos[i];
|
|
5490
|
+
if (!Number.isFinite(v)) {
|
|
5491
|
+
bad.push({ mesh: obj, index: i, value: v });
|
|
4375
5492
|
break;
|
|
4376
5493
|
}
|
|
4377
5494
|
}
|
|
@@ -4407,6 +5524,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4407
5524
|
options.onRendererReady();
|
|
4408
5525
|
}
|
|
4409
5526
|
_this.#createElements();
|
|
5527
|
+
_this.elementRenderer.createModel3d([100.54724407, 13.72699081], "https://s3.venue.in.th/all_park_f95ac5be3c.gltf");
|
|
4410
5528
|
setTimeout(() => {
|
|
4411
5529
|
findBadMeshes(scene);
|
|
4412
5530
|
}, 3e3);
|
|
@@ -4467,7 +5585,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4467
5585
|
populate: true
|
|
4468
5586
|
});
|
|
4469
5587
|
units.filter(
|
|
4470
|
-
(
|
|
5588
|
+
(u) => !["opentobelow", "escalator", "room"].includes(u.properties.category)
|
|
4471
5589
|
).forEach((unit) => {
|
|
4472
5590
|
const element = this.elementRenderer.createGeometry(unit);
|
|
4473
5591
|
if (element) {
|
|
@@ -4475,9 +5593,9 @@ var RendererManager = class extends EventTarget {
|
|
|
4475
5593
|
this.addElementsToManager(unit.id, _elements, unit.properties.level.properties.ordinal);
|
|
4476
5594
|
}
|
|
4477
5595
|
});
|
|
4478
|
-
units.filter((
|
|
5596
|
+
units.filter((u) => u.properties.category === "room").forEach((unit) => {
|
|
4479
5597
|
const openingRelationships = relationships.filter((r) => r.properties.origin?.id === unit.id || r.properties.destination?.id === unit.id);
|
|
4480
|
-
const roomOpenings =
|
|
5598
|
+
const roomOpenings = compact2(openingRelationships.map((rel) => {
|
|
4481
5599
|
const openingId = rel?.properties.intermediary[0].id;
|
|
4482
5600
|
return openings.find((o) => o.id === openingId);
|
|
4483
5601
|
}));
|
|
@@ -4501,7 +5619,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4501
5619
|
this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal);
|
|
4502
5620
|
}
|
|
4503
5621
|
});
|
|
4504
|
-
const escalators = units.filter((
|
|
5622
|
+
const escalators = units.filter((u) => u.properties.category === "escalator");
|
|
4505
5623
|
for (const escalator of escalators) {
|
|
4506
5624
|
try {
|
|
4507
5625
|
const escalatorRelationships = relationships.filter((r) => (r.properties?.intermediary || []).some((inter) => inter.id === escalator.id));
|
|
@@ -4523,7 +5641,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4523
5641
|
const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
|
|
4524
5642
|
const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
4525
5643
|
const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
|
|
4526
|
-
const escalatorEntryPoint =
|
|
5644
|
+
const escalatorEntryPoint = turfCenter5(thisLevelOpening).geometry.coordinates;
|
|
4527
5645
|
const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
|
|
4528
5646
|
if (element) {
|
|
4529
5647
|
const _elements = Array.isArray(element) ? element : [element];
|
|
@@ -4535,8 +5653,8 @@ var RendererManager = class extends EventTarget {
|
|
|
4535
5653
|
}
|
|
4536
5654
|
const groundLabels = await this.#dataClient.filterByType("label");
|
|
4537
5655
|
for (const label of groundLabels) {
|
|
4538
|
-
const
|
|
4539
|
-
const unit = findUnitOnPoint(units,
|
|
5656
|
+
const center8 = turfCenter5(polygon(label.geometry.coordinates)).geometry.coordinates;
|
|
5657
|
+
const unit = findUnitOnPoint(units, center8);
|
|
4540
5658
|
if (unit) {
|
|
4541
5659
|
const element = this.elementRenderer.createGroundLabel(label, unit);
|
|
4542
5660
|
if (element) {
|
|
@@ -4545,12 +5663,6 @@ var RendererManager = class extends EventTarget {
|
|
|
4545
5663
|
}
|
|
4546
5664
|
}
|
|
4547
5665
|
}
|
|
4548
|
-
if (this.options.type === "3D") {
|
|
4549
|
-
const model3ds = await this.#dataClient.filterByType("model3d");
|
|
4550
|
-
for (const model3d of model3ds) {
|
|
4551
|
-
this.elementRenderer.createModel3d(model3d);
|
|
4552
|
-
}
|
|
4553
|
-
}
|
|
4554
5666
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
4555
5667
|
this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
|
|
4556
5668
|
}
|
|
@@ -4635,6 +5747,9 @@ var RendererManager = class extends EventTarget {
|
|
|
4635
5747
|
this.markerRenderer.removeMarker(marker);
|
|
4636
5748
|
}
|
|
4637
5749
|
}
|
|
5750
|
+
drawNavigation(route) {
|
|
5751
|
+
this.elementRenderer.drawNavigation(route);
|
|
5752
|
+
}
|
|
4638
5753
|
};
|
|
4639
5754
|
|
|
4640
5755
|
// src/IndoorMap/IndoorMap.ts
|
|
@@ -4712,7 +5827,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4712
5827
|
};
|
|
4713
5828
|
constructor(elementId, options) {
|
|
4714
5829
|
super();
|
|
4715
|
-
const combinedOptions =
|
|
5830
|
+
const combinedOptions = _13.merge({}, defaultOptions, options);
|
|
4716
5831
|
this.options = combinedOptions;
|
|
4717
5832
|
const {
|
|
4718
5833
|
onMapReady,
|
|
@@ -4759,7 +5874,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4759
5874
|
this.dataClient = options.dataClient;
|
|
4760
5875
|
}
|
|
4761
5876
|
setOptions(options) {
|
|
4762
|
-
const combinedOptions =
|
|
5877
|
+
const combinedOptions = _13.merge({}, defaultOptions, options);
|
|
4763
5878
|
this.options = combinedOptions;
|
|
4764
5879
|
const maptalksOptions = parseMaptalksOptions(combinedOptions);
|
|
4765
5880
|
this.map.setOptions(maptalksOptions);
|
|
@@ -4769,10 +5884,10 @@ var IndoorMap = class extends EventTarget {
|
|
|
4769
5884
|
if (!this.options.camera?.defaultView?.center) {
|
|
4770
5885
|
this.#dataClient.filterByType("venue").then((venues) => {
|
|
4771
5886
|
this.#venues = venues;
|
|
4772
|
-
const venueCenters =
|
|
5887
|
+
const venueCenters = turfCenter6(featureCollection(venues));
|
|
4773
5888
|
const [x, y] = venueCenters.geometry.coordinates;
|
|
4774
|
-
const
|
|
4775
|
-
this.camera.setView({ center:
|
|
5889
|
+
const center8 = new Coordinate4(x, y);
|
|
5890
|
+
this.camera.setView({ center: center8, pitch: 60, zoom: 19 });
|
|
4776
5891
|
});
|
|
4777
5892
|
}
|
|
4778
5893
|
}
|
|
@@ -4785,7 +5900,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4785
5900
|
handleMapClick = ({ coordinate }) => {
|
|
4786
5901
|
const { x, y } = coordinate;
|
|
4787
5902
|
console.log(
|
|
4788
|
-
`[Coordinates]: x: ${
|
|
5903
|
+
`[Coordinates]: x: ${_13.round(x, 8)} y: ${_13.round(
|
|
4789
5904
|
y,
|
|
4790
5905
|
8
|
|
4791
5906
|
)}, [Bearing]: ${this.map.getBearing()}, [Pitch]: ${this.map.getPitch()}`
|
|
@@ -4871,7 +5986,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4871
5986
|
if (this.#isClicked) return;
|
|
4872
5987
|
this.#isClicked = true;
|
|
4873
5988
|
const onClickElement = this.#onClickElement;
|
|
4874
|
-
if (!
|
|
5989
|
+
if (!_13.isFunction(onClickElement)) return;
|
|
4875
5990
|
this.#onClickElement(e);
|
|
4876
5991
|
this.#isClicked = false;
|
|
4877
5992
|
};
|
|
@@ -4891,16 +6006,16 @@ var IndoorMap = class extends EventTarget {
|
|
|
4891
6006
|
for (const feature2 of this.#features) {
|
|
4892
6007
|
try {
|
|
4893
6008
|
const { feature_type: featureType, properties, id } = feature2;
|
|
4894
|
-
const layerName =
|
|
6009
|
+
const layerName = _13.get(
|
|
4895
6010
|
LAYER_FEATURE_TYPE_OBJ,
|
|
4896
6011
|
featureType,
|
|
4897
6012
|
featureType
|
|
4898
6013
|
);
|
|
4899
6014
|
const layer = this.map.getLayer(layerName);
|
|
4900
6015
|
let geometry;
|
|
4901
|
-
const category =
|
|
4902
|
-
const extrudeConfig =
|
|
4903
|
-
const textMarkerType =
|
|
6016
|
+
const category = _13.get(feature2, "properties.category");
|
|
6017
|
+
const extrudeConfig = _13.get(this.#mapConfig, "extrude");
|
|
6018
|
+
const textMarkerType = _13.get(
|
|
4904
6019
|
this.#mapConfig,
|
|
4905
6020
|
"text_marker_type",
|
|
4906
6021
|
"ui-marker"
|
|
@@ -4932,7 +6047,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4932
6047
|
case "opening": {
|
|
4933
6048
|
switch (category) {
|
|
4934
6049
|
case "emergencyexit":
|
|
4935
|
-
const { geometry: geometry2 } =
|
|
6050
|
+
const { geometry: geometry2 } = turfCenter6(feature2);
|
|
4936
6051
|
const markerFeature = {
|
|
4937
6052
|
...feature2,
|
|
4938
6053
|
geometry: geometry2
|
|
@@ -5015,9 +6130,9 @@ var IndoorMap = class extends EventTarget {
|
|
|
5015
6130
|
const mapCenter = this.map.getCenter();
|
|
5016
6131
|
const result = this.#venues.reduce((closest, venue) => {
|
|
5017
6132
|
const { display_point: displayPoint } = venue.properties;
|
|
5018
|
-
const
|
|
5019
|
-
if (!closest ||
|
|
5020
|
-
return { venueId: venue.id, distance };
|
|
6133
|
+
const distance5 = turfDistance2(displayPoint, [mapCenter.x, mapCenter.y]);
|
|
6134
|
+
if (!closest || distance5 < closest.distance) {
|
|
6135
|
+
return { venueId: venue.id, distance: distance5 };
|
|
5021
6136
|
}
|
|
5022
6137
|
return closest;
|
|
5023
6138
|
}, null);
|
|
@@ -5067,15 +6182,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
5067
6182
|
}
|
|
5068
6183
|
}
|
|
5069
6184
|
updateUserLocationSymbolByLocale(locale) {
|
|
5070
|
-
const userLocationGeometry =
|
|
6185
|
+
const userLocationGeometry = _13.get(
|
|
5071
6186
|
this.#elements,
|
|
5072
6187
|
`${USER_LOCATION_ELEMENT_ID}.geometry`
|
|
5073
6188
|
);
|
|
5074
6189
|
if (!userLocationGeometry) return;
|
|
5075
6190
|
const currentSymbol = userLocationGeometry.getSymbol();
|
|
5076
6191
|
const localeSymbolToUpdate = currentSymbol.map((symbol) => {
|
|
5077
|
-
const localeSymbol =
|
|
5078
|
-
if (!
|
|
6192
|
+
const localeSymbol = _13.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) || _13.get(symbol, `${LOCALE_SYMBOL_KEY}.default`);
|
|
6193
|
+
if (!_13.isPlainObject(localeSymbol)) return symbol;
|
|
5079
6194
|
return {
|
|
5080
6195
|
...symbol,
|
|
5081
6196
|
...localeSymbol
|
|
@@ -5149,14 +6264,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
5149
6264
|
* END of User Location
|
|
5150
6265
|
****************************/
|
|
5151
6266
|
showGeometryByElementId = (elementId) => {
|
|
5152
|
-
const geometry =
|
|
6267
|
+
const geometry = _13.get(
|
|
5153
6268
|
this.#elements,
|
|
5154
6269
|
`${elementId}.geometry`
|
|
5155
6270
|
);
|
|
5156
6271
|
if (geometry) geometry.show();
|
|
5157
6272
|
};
|
|
5158
6273
|
hideGeometryByElementId = (elementId) => {
|
|
5159
|
-
const geometry =
|
|
6274
|
+
const geometry = _13.get(this.#elements, `${elementId}.geometry`);
|
|
5160
6275
|
if (geometry) geometry.hide();
|
|
5161
6276
|
};
|
|
5162
6277
|
setSpriteMarkersOpacity = (opacity = 1) => {
|
|
@@ -5195,7 +6310,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5195
6310
|
* Navigation
|
|
5196
6311
|
****************************/
|
|
5197
6312
|
combineNearbyLineStrings(lineStrings, options = { properties: {}, distance: 3e-4 }) {
|
|
5198
|
-
const { properties = {}, distance = 3e-4 } = options || {};
|
|
6313
|
+
const { properties = {}, distance: distance5 = 3e-4 } = options || {};
|
|
5199
6314
|
const combinedLineStrings = [];
|
|
5200
6315
|
const accLine = [];
|
|
5201
6316
|
if (lineStrings.length === 1) return lineStrings;
|
|
@@ -5203,14 +6318,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
5203
6318
|
const line = lineStrings[i];
|
|
5204
6319
|
const coords = line.geometry.coordinates;
|
|
5205
6320
|
const prevLine = lineStrings[i - 1];
|
|
5206
|
-
const firstCoord =
|
|
6321
|
+
const firstCoord = _13.first(coords);
|
|
5207
6322
|
const isFirstLine = i === 0;
|
|
5208
6323
|
if (isFirstLine) {
|
|
5209
6324
|
accLine.push(...coords);
|
|
5210
6325
|
continue;
|
|
5211
6326
|
}
|
|
5212
|
-
const prevLastCoord =
|
|
5213
|
-
const isNearby =
|
|
6327
|
+
const prevLastCoord = _13.last(prevLine.geometry.coordinates);
|
|
6328
|
+
const isNearby = turfDistance2(point(firstCoord), point(prevLastCoord)) < distance5;
|
|
5214
6329
|
if (!isNearby) {
|
|
5215
6330
|
const remainingLines = lineStrings.slice(i);
|
|
5216
6331
|
const res = this.combineNearbyLineStrings(remainingLines, properties);
|
|
@@ -5230,8 +6345,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
5230
6345
|
create3DStepPath
|
|
5231
6346
|
} = this.#styler;
|
|
5232
6347
|
const routeMarkerLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
|
|
5233
|
-
const linesByOrdinal =
|
|
5234
|
-
const joinedLines =
|
|
6348
|
+
const linesByOrdinal = _13(stepGeometries).filter(({ geometry }) => geometry.type === "LineString").groupBy("properties.ordinal").value();
|
|
6349
|
+
const joinedLines = _13(linesByOrdinal).reduce((acc, lines, key) => {
|
|
5235
6350
|
const joined = this.combineNearbyLineStrings(lines, {
|
|
5236
6351
|
properties: { ordinal: +key }
|
|
5237
6352
|
});
|
|
@@ -5259,14 +6374,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
5259
6374
|
stepElement = createOriginMarker(stepGeometry).addTo(routeMarkerLayer);
|
|
5260
6375
|
break;
|
|
5261
6376
|
case "destination-marker":
|
|
5262
|
-
const extrudeConfig =
|
|
6377
|
+
const extrudeConfig = _13.get(this.#mapConfig, "extrude");
|
|
5263
6378
|
if (destinationFeature.feature_type === "occupant") {
|
|
5264
|
-
const stepId =
|
|
6379
|
+
const stepId = _13.get(stepGeometry, "id");
|
|
5265
6380
|
const normalizedDestinationFeature = {
|
|
5266
6381
|
...destinationFeature,
|
|
5267
6382
|
id: stepId
|
|
5268
6383
|
};
|
|
5269
|
-
const logoUrl =
|
|
6384
|
+
const logoUrl = _13.get(
|
|
5270
6385
|
normalizedDestinationFeature,
|
|
5271
6386
|
"properties.logo.url"
|
|
5272
6387
|
);
|
|
@@ -5311,15 +6426,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
5311
6426
|
const routeMarkerLayer = this.map.getLayer(
|
|
5312
6427
|
HIGHLIGHT_LAYER_NAME
|
|
5313
6428
|
);
|
|
5314
|
-
const originMarkerGeometry =
|
|
6429
|
+
const originMarkerGeometry = _13.get(
|
|
5315
6430
|
this.#elements,
|
|
5316
6431
|
`${ORIGIN_MARKER_ID}.geometry`
|
|
5317
6432
|
);
|
|
5318
|
-
const destinationMarkerGeometry =
|
|
6433
|
+
const destinationMarkerGeometry = _13.get(
|
|
5319
6434
|
this.#elements,
|
|
5320
6435
|
`${DESTINATION_MARKER_ID}.geometry`
|
|
5321
6436
|
);
|
|
5322
|
-
const geometriesToRemove =
|
|
6437
|
+
const geometriesToRemove = _13.compact([
|
|
5323
6438
|
originMarkerGeometry,
|
|
5324
6439
|
destinationMarkerGeometry
|
|
5325
6440
|
]);
|
|
@@ -5330,7 +6445,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5330
6445
|
(obj) => !(obj instanceof NavigationPath)
|
|
5331
6446
|
);
|
|
5332
6447
|
const objects = this.#navigationGeometries || {};
|
|
5333
|
-
|
|
6448
|
+
_13.forEach(objects, (obj) => {
|
|
5334
6449
|
if (!obj) return;
|
|
5335
6450
|
this.#navigationGeometries[obj.properties.id] = null;
|
|
5336
6451
|
obj.remove();
|
|
@@ -5367,7 +6482,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5367
6482
|
}
|
|
5368
6483
|
if (this.threeLayer) {
|
|
5369
6484
|
const currentView = this.camera.getView();
|
|
5370
|
-
const objectOpacity =
|
|
6485
|
+
const objectOpacity = _13.clamp(38 - 2 * currentView.zoom, 0, 1);
|
|
5371
6486
|
this.#objects.forEach((object) => {
|
|
5372
6487
|
object.getObject3d().traverse((child) => {
|
|
5373
6488
|
if (child.isMesh) child.material.opacity = objectOpacity;
|
|
@@ -5377,7 +6492,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5377
6492
|
});
|
|
5378
6493
|
if (this.#billboardObjects) {
|
|
5379
6494
|
this.#billboardObjects.forEach((object) => {
|
|
5380
|
-
const objectScale =
|
|
6495
|
+
const objectScale = _13.clamp(
|
|
5381
6496
|
20 - 1 * currentView.zoom,
|
|
5382
6497
|
1,
|
|
5383
6498
|
1.05
|
|
@@ -5386,7 +6501,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5386
6501
|
});
|
|
5387
6502
|
}
|
|
5388
6503
|
if (this.#isLayersFadingOnZoom) {
|
|
5389
|
-
const layerOpacity =
|
|
6504
|
+
const layerOpacity = _13.clamp(1 - objectOpacity, 0, 1);
|
|
5390
6505
|
LAYERS.forEach((layerKey) => {
|
|
5391
6506
|
const layer = this.map.getLayer(layerKey);
|
|
5392
6507
|
if (layer) layer.setOpacity(layerOpacity);
|
|
@@ -5415,6 +6530,7 @@ export {
|
|
|
5415
6530
|
GEOJSON_FEATURE_TYPES,
|
|
5416
6531
|
HIGHLIGHT_LAYER_NAME,
|
|
5417
6532
|
IMDF_FEATURE_TYPES,
|
|
6533
|
+
IMDF_UNIT_CATEGORIES,
|
|
5418
6534
|
IndoorMap,
|
|
5419
6535
|
LAST_USER_LOCATION_ELEMENT_ID_PREFIX,
|
|
5420
6536
|
LAYERS,
|
|
@@ -5446,11 +6562,13 @@ export {
|
|
|
5446
6562
|
getLocationByFeature,
|
|
5447
6563
|
getLocationByOccupant,
|
|
5448
6564
|
getLocationIdByFeature,
|
|
6565
|
+
getNavigateClient,
|
|
5449
6566
|
getOrdinalByLocationId,
|
|
5450
6567
|
getRelatedLocationIdsByFeature,
|
|
5451
6568
|
getRelatedLocationsByAmenity,
|
|
5452
6569
|
getRelatedLocationsByFeature,
|
|
5453
6570
|
getRelatedLocationsByOccupant,
|
|
6571
|
+
getSearchClient,
|
|
5454
6572
|
getSuitablyValueBetweenBearings,
|
|
5455
6573
|
isClickableFeature,
|
|
5456
6574
|
isValidCoordinate,
|