venue-js 1.4.0-next.2 → 1.4.0-next.20
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 +2573 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/index.mjs +2524 -0
- package/dist/data/index.mjs.map +1 -0
- package/dist/index-X4qpYAhF.d.mts +1025 -0
- package/dist/index-X4qpYAhF.d.ts +1025 -0
- package/dist/index.d.mts +10 -791
- package/dist/index.d.ts +10 -791
- package/dist/index.js +2182 -1060
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2169 -1050
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -1
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
GEOJSON_FEATURE_TYPES: () => GEOJSON_FEATURE_TYPES,
|
|
38
38
|
HIGHLIGHT_LAYER_NAME: () => HIGHLIGHT_LAYER_NAME,
|
|
39
39
|
IMDF_FEATURE_TYPES: () => IMDF_FEATURE_TYPES,
|
|
40
|
+
IMDF_UNIT_CATEGORIES: () => IMDF_UNIT_CATEGORIES,
|
|
40
41
|
IndoorMap: () => IndoorMap,
|
|
41
42
|
LAST_USER_LOCATION_ELEMENT_ID_PREFIX: () => LAST_USER_LOCATION_ELEMENT_ID_PREFIX,
|
|
42
43
|
LAYERS: () => LAYERS,
|
|
@@ -68,11 +69,13 @@ __export(index_exports, {
|
|
|
68
69
|
getLocationByFeature: () => getLocationByFeature,
|
|
69
70
|
getLocationByOccupant: () => getLocationByOccupant,
|
|
70
71
|
getLocationIdByFeature: () => getLocationIdByFeature,
|
|
72
|
+
getNavigateClient: () => getNavigateClient,
|
|
71
73
|
getOrdinalByLocationId: () => getOrdinalByLocationId,
|
|
72
74
|
getRelatedLocationIdsByFeature: () => getRelatedLocationIdsByFeature,
|
|
73
75
|
getRelatedLocationsByAmenity: () => getRelatedLocationsByAmenity,
|
|
74
76
|
getRelatedLocationsByFeature: () => getRelatedLocationsByFeature,
|
|
75
77
|
getRelatedLocationsByOccupant: () => getRelatedLocationsByOccupant,
|
|
78
|
+
getSearchClient: () => getSearchClient,
|
|
76
79
|
getSuitablyValueBetweenBearings: () => getSuitablyValueBetweenBearings,
|
|
77
80
|
isClickableFeature: () => isClickableFeature,
|
|
78
81
|
isValidCoordinate: () => isValidCoordinate,
|
|
@@ -113,6 +116,71 @@ var IMDF_FEATURE_TYPES = [
|
|
|
113
116
|
"unit",
|
|
114
117
|
"venue"
|
|
115
118
|
];
|
|
119
|
+
var IMDF_UNIT_CATEGORIES = [
|
|
120
|
+
"auditorium",
|
|
121
|
+
"brick",
|
|
122
|
+
"classroom",
|
|
123
|
+
"column",
|
|
124
|
+
"concrete",
|
|
125
|
+
"conferenceroom",
|
|
126
|
+
"drywall",
|
|
127
|
+
"elevator",
|
|
128
|
+
"escalator",
|
|
129
|
+
"fieldofplay",
|
|
130
|
+
"firstaid",
|
|
131
|
+
"fitnessroom",
|
|
132
|
+
"foodservice",
|
|
133
|
+
"footbridge",
|
|
134
|
+
"glass",
|
|
135
|
+
"huddleroom",
|
|
136
|
+
"kitchen",
|
|
137
|
+
"laboratory",
|
|
138
|
+
"library",
|
|
139
|
+
"lobby",
|
|
140
|
+
"lounge",
|
|
141
|
+
"mailroom",
|
|
142
|
+
"mothersroom",
|
|
143
|
+
"movietheater",
|
|
144
|
+
"movingwalkway",
|
|
145
|
+
"nonpublic",
|
|
146
|
+
"office",
|
|
147
|
+
"opentobelow",
|
|
148
|
+
"parking",
|
|
149
|
+
"phoneroom",
|
|
150
|
+
"platform",
|
|
151
|
+
"privatelounge",
|
|
152
|
+
"ramp",
|
|
153
|
+
"recreation",
|
|
154
|
+
"restroom",
|
|
155
|
+
"restroom.family",
|
|
156
|
+
"restroom.female",
|
|
157
|
+
"restroom.female.wheelchair",
|
|
158
|
+
"restroom.male",
|
|
159
|
+
"restroom.male.wheelchair",
|
|
160
|
+
"restroom.transgender",
|
|
161
|
+
"restroom.transgender.wheelchair",
|
|
162
|
+
"restroom.unisex",
|
|
163
|
+
"restroom.unisex.wheelchair",
|
|
164
|
+
"restroom.wheelchair",
|
|
165
|
+
"road",
|
|
166
|
+
"room",
|
|
167
|
+
"serverroom",
|
|
168
|
+
"shower",
|
|
169
|
+
"smokingarea",
|
|
170
|
+
"stairs",
|
|
171
|
+
"steps",
|
|
172
|
+
"storage",
|
|
173
|
+
"structure",
|
|
174
|
+
"terrace",
|
|
175
|
+
"theater",
|
|
176
|
+
"unenclosedarea",
|
|
177
|
+
"unspecified",
|
|
178
|
+
"vegetation",
|
|
179
|
+
"waitingroom",
|
|
180
|
+
"walkway",
|
|
181
|
+
"walkway.island",
|
|
182
|
+
"wood"
|
|
183
|
+
];
|
|
116
184
|
var NONIMDF_FEATURE_TYPES = [
|
|
117
185
|
"taxonomy",
|
|
118
186
|
"event",
|
|
@@ -171,6 +239,119 @@ var defaultFeatureQueryOptionsMap = {
|
|
|
171
239
|
model3d: {}
|
|
172
240
|
};
|
|
173
241
|
|
|
242
|
+
// src/data/utils/geometry-validator.ts
|
|
243
|
+
var isValidCoordinate = (point2) => {
|
|
244
|
+
return point2.length === 2 && point2.every((coord) => typeof coord === "number");
|
|
245
|
+
};
|
|
246
|
+
function isValidLinearRingCoordinates(ring) {
|
|
247
|
+
if (ring.length < 4) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
return ring.every(isValidCoordinate) && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1];
|
|
251
|
+
}
|
|
252
|
+
var isValidPolygonCoordinates = (polygon2) => {
|
|
253
|
+
if (Array.isArray(polygon2[0]) && (polygon2[0].length === 0 || typeof polygon2[0][0] === "number")) {
|
|
254
|
+
return isValidLinearRingCoordinates(polygon2);
|
|
255
|
+
}
|
|
256
|
+
if (Array.isArray(polygon2) && polygon2.length > 0 && Array.isArray(polygon2[0])) {
|
|
257
|
+
if (!isValidLinearRingCoordinates(polygon2[0])) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
for (let i = 1; i < polygon2.length; i++) {
|
|
261
|
+
if (!isValidLinearRingCoordinates(polygon2[i])) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
};
|
|
269
|
+
var isValidMultiPolygonCoordinates = (multipolygon) => {
|
|
270
|
+
return multipolygon.every(isValidPolygonCoordinates);
|
|
271
|
+
};
|
|
272
|
+
var isValidLineStringCoordinates = (lineString2) => {
|
|
273
|
+
if (!Array.isArray(lineString2) || lineString2.length < 2) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
const firstPoint = lineString2[0];
|
|
277
|
+
const lastPoint = lineString2[lineString2.length - 1];
|
|
278
|
+
if (firstPoint[0] === lastPoint[0] && firstPoint[1] === lastPoint[1]) {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
return lineString2.every(isValidCoordinate);
|
|
282
|
+
};
|
|
283
|
+
var isValidMultiPolygon = (geometry) => {
|
|
284
|
+
const { type, coordinates } = geometry;
|
|
285
|
+
return type === "MultiPolygon" && isValidMultiPolygonCoordinates(coordinates);
|
|
286
|
+
};
|
|
287
|
+
var isValidPolygon = (geometry) => {
|
|
288
|
+
const { type, coordinates } = geometry;
|
|
289
|
+
return type === "Polygon" && isValidPolygonCoordinates(coordinates);
|
|
290
|
+
};
|
|
291
|
+
var isValidLineString = (geometry) => {
|
|
292
|
+
const { type, coordinates } = geometry;
|
|
293
|
+
return type === "LineString" && isValidLineStringCoordinates(coordinates);
|
|
294
|
+
};
|
|
295
|
+
var isValidPoint = (geometry) => {
|
|
296
|
+
const { type, coordinates } = geometry;
|
|
297
|
+
return type === "Point" && isValidCoordinate(coordinates);
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// src/data/utils/match-filters.ts
|
|
301
|
+
function isInFilter(filter) {
|
|
302
|
+
return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
|
|
303
|
+
}
|
|
304
|
+
var someIntersect = (a, b) => a.some((v) => b.includes(v));
|
|
305
|
+
function matchFilter(value, filter) {
|
|
306
|
+
if (Array.isArray(value)) {
|
|
307
|
+
if (isInFilter(filter)) return someIntersect(value, filter.$in);
|
|
308
|
+
return value.includes(filter);
|
|
309
|
+
} else {
|
|
310
|
+
if (isInFilter(filter)) return filter.$in.includes(value);
|
|
311
|
+
return value === filter;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function matchFilters(item, filters) {
|
|
315
|
+
return Object.entries(filters).every(([key, filter]) => {
|
|
316
|
+
return matchFilter(item.properties[key], filter);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/data/utils/occupant-helper.ts
|
|
321
|
+
var occupant_helper_exports = {};
|
|
322
|
+
__export(occupant_helper_exports, {
|
|
323
|
+
getOccupantCorrelatedLocations: () => getOccupantCorrelatedLocations,
|
|
324
|
+
getOccupantMainLocation: () => getOccupantMainLocation,
|
|
325
|
+
getOccupantMarkerLocations: () => getOccupantMarkerLocations
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// src/data/utils/lodash/compact.ts
|
|
329
|
+
var compact = (arr) => arr.filter((item) => Boolean(item));
|
|
330
|
+
|
|
331
|
+
// src/data/utils/occupant-helper.ts
|
|
332
|
+
var getOccupantMainLocation = (occupant) => {
|
|
333
|
+
return occupant.properties.kiosk || occupant.properties.unit;
|
|
334
|
+
};
|
|
335
|
+
var getOccupantCorrelatedLocations = (occupant) => {
|
|
336
|
+
const allCorrelatedLocations = [
|
|
337
|
+
...occupant.properties.units,
|
|
338
|
+
...occupant.properties.kiosks
|
|
339
|
+
];
|
|
340
|
+
return compact(allCorrelatedLocations);
|
|
341
|
+
};
|
|
342
|
+
var getOccupantMarkerLocations = (occupant, options) => {
|
|
343
|
+
const placementType = options?.type ? options.type : occupant.properties.show_name_on_all_units ? "ALL_LOCATIONS" : "ONCE_PER_LEVEL";
|
|
344
|
+
const mainLocation = getOccupantMainLocation(occupant);
|
|
345
|
+
const mainLocationLevel = mainLocation?.properties?.level_id;
|
|
346
|
+
const allCorrelatedLocations = getOccupantCorrelatedLocations(occupant);
|
|
347
|
+
if (placementType === "ALL_LOCATIONS") {
|
|
348
|
+
return compact([mainLocation, ...allCorrelatedLocations]);
|
|
349
|
+
}
|
|
350
|
+
const otherLevelLocations = allCorrelatedLocations.filter((f) => f.properties.level_id !== mainLocationLevel);
|
|
351
|
+
const onePerLevelLocations = [...new Map(otherLevelLocations.map((loc) => [loc.properties.level_id, loc])).values()];
|
|
352
|
+
return compact([mainLocation, ...onePerLevelLocations]);
|
|
353
|
+
};
|
|
354
|
+
|
|
174
355
|
// src/data/api/delivery-project.ts
|
|
175
356
|
async function fetchDeliveryApi(projectId, apiKey, featureType, baseUrl = DEFAULT_BASE_URL) {
|
|
176
357
|
switch (featureType) {
|
|
@@ -292,121 +473,44 @@ var safeFetchFeature = async (featureType, params) => {
|
|
|
292
473
|
}
|
|
293
474
|
};
|
|
294
475
|
|
|
295
|
-
// src/data/
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
var
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
for (let i = 1; i < polygon2.length; i++) {
|
|
314
|
-
if (!isValidLinearRingCoordinates(polygon2[i])) {
|
|
476
|
+
// src/data/getDataClient.ts
|
|
477
|
+
var import_query_core = require("@tanstack/query-core");
|
|
478
|
+
|
|
479
|
+
// src/data/populator/index.ts
|
|
480
|
+
var import_center2 = require("@turf/center");
|
|
481
|
+
var import_boolean_point_in_polygon2 = require("@turf/boolean-point-in-polygon");
|
|
482
|
+
|
|
483
|
+
// src/data/utils/findContaining.ts
|
|
484
|
+
var import_center = require("@turf/center");
|
|
485
|
+
var import_boolean_point_in_polygon = require("@turf/boolean-point-in-polygon");
|
|
486
|
+
var findContainingUnit = (poi, units) => {
|
|
487
|
+
const unit = units.find(
|
|
488
|
+
(unit2) => {
|
|
489
|
+
try {
|
|
490
|
+
return unit2.properties.level_id === poi.properties.level_id && (0, import_boolean_point_in_polygon.booleanPointInPolygon)((0, import_center.center)(poi), unit2);
|
|
491
|
+
} catch (e) {
|
|
492
|
+
console.log(`Cannot find containing unit of (${poi.id}):`, e.message);
|
|
315
493
|
return false;
|
|
316
494
|
}
|
|
317
495
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return false;
|
|
321
|
-
};
|
|
322
|
-
var isValidMultiPolygonCoordinates = (multipolygon) => {
|
|
323
|
-
return multipolygon.every(isValidPolygonCoordinates);
|
|
324
|
-
};
|
|
325
|
-
var isValidLineStringCoordinates = (lineString2) => {
|
|
326
|
-
if (!Array.isArray(lineString2) || lineString2.length < 2) {
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
const firstPoint = lineString2[0];
|
|
330
|
-
const lastPoint = lineString2[lineString2.length - 1];
|
|
331
|
-
if (firstPoint[0] === lastPoint[0] && firstPoint[1] === lastPoint[1]) {
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
return lineString2.every(isValidCoordinate);
|
|
335
|
-
};
|
|
336
|
-
var isValidMultiPolygon = (geometry) => {
|
|
337
|
-
const { type, coordinates } = geometry;
|
|
338
|
-
return type === "MultiPolygon" && isValidMultiPolygonCoordinates(coordinates);
|
|
339
|
-
};
|
|
340
|
-
var isValidPolygon = (geometry) => {
|
|
341
|
-
const { type, coordinates } = geometry;
|
|
342
|
-
return type === "Polygon" && isValidPolygonCoordinates(coordinates);
|
|
343
|
-
};
|
|
344
|
-
var isValidLineString = (geometry) => {
|
|
345
|
-
const { type, coordinates } = geometry;
|
|
346
|
-
return type === "LineString" && isValidLineStringCoordinates(coordinates);
|
|
347
|
-
};
|
|
348
|
-
var isValidPoint = (geometry) => {
|
|
349
|
-
const { type, coordinates } = geometry;
|
|
350
|
-
return type === "Point" && isValidCoordinate(coordinates);
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
// src/data/utils/match-filters.ts
|
|
354
|
-
function isInFilter(filter) {
|
|
355
|
-
return typeof filter === "object" && filter !== null && "$in" in filter && Array.isArray(filter.$in);
|
|
356
|
-
}
|
|
357
|
-
var someIntersect = (a, b) => a.some((v2) => b.includes(v2));
|
|
358
|
-
function matchFilter(value, filter) {
|
|
359
|
-
if (Array.isArray(value)) {
|
|
360
|
-
if (isInFilter(filter)) return someIntersect(value, filter.$in);
|
|
361
|
-
return value.includes(filter);
|
|
362
|
-
} else {
|
|
363
|
-
if (isInFilter(filter)) return filter.$in.includes(value);
|
|
364
|
-
return value === filter;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
function matchFilters(item, filters) {
|
|
368
|
-
return Object.entries(filters).every(([key, filter]) => {
|
|
369
|
-
return matchFilter(item.properties[key], filter);
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// src/data/utils/occupant-helper.ts
|
|
374
|
-
var occupant_helper_exports = {};
|
|
375
|
-
__export(occupant_helper_exports, {
|
|
376
|
-
getOccupantCorrelatedLocations: () => getOccupantCorrelatedLocations,
|
|
377
|
-
getOccupantMainLocation: () => getOccupantMainLocation,
|
|
378
|
-
getOccupantMarkerLocations: () => getOccupantMarkerLocations
|
|
379
|
-
});
|
|
380
|
-
var import_lodash_es = require("lodash-es");
|
|
381
|
-
var getOccupantMainLocation = (occupant) => {
|
|
382
|
-
return occupant.properties.kiosk || occupant.properties.unit;
|
|
383
|
-
};
|
|
384
|
-
var getOccupantCorrelatedLocations = (occupant) => {
|
|
385
|
-
const allCorrelatedLocations = [
|
|
386
|
-
...occupant.properties.units,
|
|
387
|
-
...occupant.properties.kiosks
|
|
388
|
-
];
|
|
389
|
-
return (0, import_lodash_es.compact)(allCorrelatedLocations);
|
|
496
|
+
);
|
|
497
|
+
return unit;
|
|
390
498
|
};
|
|
391
|
-
var
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
499
|
+
var findContainingUnitAtPoint = (point2, levelId, units) => {
|
|
500
|
+
const unit = units.find(
|
|
501
|
+
(unit2) => {
|
|
502
|
+
try {
|
|
503
|
+
return unit2.properties.level_id === levelId && (0, import_boolean_point_in_polygon.booleanPointInPolygon)(point2, unit2);
|
|
504
|
+
} catch (e) {
|
|
505
|
+
console.log(`Cannot find containing unit of (point: ${point2}, levelId: ${levelId}):`, e.message);
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
);
|
|
510
|
+
return unit;
|
|
402
511
|
};
|
|
403
512
|
|
|
404
|
-
// src/data/getDataClient.ts
|
|
405
|
-
var import_query_core = require("@tanstack/query-core");
|
|
406
|
-
|
|
407
513
|
// src/data/populator/index.ts
|
|
408
|
-
var import_lodash_es2 = require("lodash-es");
|
|
409
|
-
var import_boolean_within = require("@turf/boolean-within");
|
|
410
514
|
var createPopulator = ({
|
|
411
515
|
internalFindById,
|
|
412
516
|
internalFilterByType
|
|
@@ -416,7 +520,6 @@ var createPopulator = ({
|
|
|
416
520
|
const populateDetail = (detail) => Promise.resolve(detail);
|
|
417
521
|
const populateFootprint = (footprint) => Promise.resolve(footprint);
|
|
418
522
|
const populateGeofence = (geofence) => Promise.resolve(geofence);
|
|
419
|
-
const populateRelationship = (relationship) => Promise.resolve(relationship);
|
|
420
523
|
const populatePrivilege = (privilege) => Promise.resolve(privilege);
|
|
421
524
|
const populateEvent = (event) => Promise.resolve(event);
|
|
422
525
|
const populatePromotion = async (promotion) => {
|
|
@@ -440,13 +543,14 @@ var createPopulator = ({
|
|
|
440
543
|
const ordinalKiosks = kiosks.filter(
|
|
441
544
|
(kiosk2) => kiosk2.properties.level_id === defaultLevel.id
|
|
442
545
|
);
|
|
443
|
-
const kiosk = ordinalKiosks.find((kiosk2) => (0,
|
|
546
|
+
const kiosk = ordinalKiosks.find((kiosk2) => (0, import_boolean_point_in_polygon2.booleanPointInPolygon)(amenity, kiosk2));
|
|
444
547
|
return {
|
|
445
548
|
...amenity,
|
|
446
549
|
properties: {
|
|
447
550
|
...amenity.properties,
|
|
448
551
|
ordinal: defaultLevel.properties.ordinal,
|
|
449
552
|
level_name: defaultLevel.properties.name.en,
|
|
553
|
+
level: defaultLevel,
|
|
450
554
|
units: populatedUnits,
|
|
451
555
|
venue,
|
|
452
556
|
_experimental_kiosk: kiosk ? await populateKiosk(kiosk) : null
|
|
@@ -458,7 +562,7 @@ var createPopulator = ({
|
|
|
458
562
|
const venue = await internalFindById(unit.properties.venue_id);
|
|
459
563
|
const level = await internalFindById(unit.properties.level_id);
|
|
460
564
|
const sections = await internalFilterByType("section");
|
|
461
|
-
const section = sections.find((section2) => (0,
|
|
565
|
+
const section = sections.find((section2) => (0, import_boolean_point_in_polygon2.booleanPointInPolygon)(anchor, section2));
|
|
462
566
|
return {
|
|
463
567
|
...anchor,
|
|
464
568
|
properties: {
|
|
@@ -491,20 +595,11 @@ var createPopulator = ({
|
|
|
491
595
|
const venue = await internalFindById(kiosk.properties.venue_id);
|
|
492
596
|
const anchor = await internalFindById(kiosk.properties.anchor_id);
|
|
493
597
|
const units = await internalFilterByType("unit");
|
|
494
|
-
const unit = units.
|
|
495
|
-
(unit2) => {
|
|
496
|
-
try {
|
|
497
|
-
return unit2.properties.category === "walkway" && unit2.properties.level_id === kiosk.properties.level_id && (0, import_boolean_within.booleanWithin)(kiosk, unit2);
|
|
498
|
-
} catch (e) {
|
|
499
|
-
console.log(`Cannot find kiosk(${kiosk.id})'s units:`, e.message);
|
|
500
|
-
return false;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
);
|
|
598
|
+
const unit = findContainingUnit(kiosk, units.filter((unit2) => unit2.properties.category === "walkway"));
|
|
504
599
|
let section = null;
|
|
505
600
|
if (anchor) {
|
|
506
601
|
const sections = await internalFilterByType("section");
|
|
507
|
-
section = sections.find((section2) => (0,
|
|
602
|
+
section = sections.find((section2) => (0, import_boolean_point_in_polygon2.booleanPointInPolygon)(anchor, section2));
|
|
508
603
|
}
|
|
509
604
|
return {
|
|
510
605
|
...kiosk,
|
|
@@ -534,8 +629,8 @@ var createPopulator = ({
|
|
|
534
629
|
anchor_id,
|
|
535
630
|
venue_id,
|
|
536
631
|
local_category_ids,
|
|
537
|
-
promotion_ids,
|
|
538
|
-
privilege_ids,
|
|
632
|
+
promotion_ids = [],
|
|
633
|
+
privilege_ids = [],
|
|
539
634
|
kiosk_id,
|
|
540
635
|
unit_id,
|
|
541
636
|
kiosk_ids = [],
|
|
@@ -562,7 +657,7 @@ var createPopulator = ({
|
|
|
562
657
|
...occupant.properties,
|
|
563
658
|
anchor: anchor ? await populateAnchor(anchor) : null,
|
|
564
659
|
local_categories: await Promise.all(
|
|
565
|
-
|
|
660
|
+
compact(localCategories).map(populateTaxonomy)
|
|
566
661
|
),
|
|
567
662
|
venue,
|
|
568
663
|
promotions,
|
|
@@ -599,12 +694,29 @@ var createPopulator = ({
|
|
|
599
694
|
}
|
|
600
695
|
};
|
|
601
696
|
};
|
|
697
|
+
const populateRelationship = async (relationship) => {
|
|
698
|
+
const originId = relationship.properties.origin?.id;
|
|
699
|
+
const destinationId = relationship.properties.destination?.id;
|
|
700
|
+
const origin = originId ? await internalFindById(originId) : null;
|
|
701
|
+
const destination = destinationId ? await internalFindById(destinationId) : null;
|
|
702
|
+
const intermediary_ids = (relationship.properties.intermediary || []).map(({ id }) => id);
|
|
703
|
+
const intermediary = await Promise.all(intermediary_ids.map(internalFindById));
|
|
704
|
+
return {
|
|
705
|
+
...relationship,
|
|
706
|
+
properties: {
|
|
707
|
+
...relationship.properties,
|
|
708
|
+
origin,
|
|
709
|
+
destination,
|
|
710
|
+
intermediary
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
};
|
|
602
714
|
const populateUnit = async (unit) => {
|
|
603
715
|
const venue = await internalFindById(unit.properties.venue_id);
|
|
604
716
|
const level = await internalFindById(unit.properties.level_id);
|
|
605
717
|
const sections = await internalFilterByType("section");
|
|
606
718
|
try {
|
|
607
|
-
const section = unit.geometry.type !== "MultiPolygon" ? sections.find((section2) => (0,
|
|
719
|
+
const section = unit.geometry.type !== "MultiPolygon" ? sections.find((section2) => (0, import_boolean_point_in_polygon2.booleanPointInPolygon)((0, import_center2.center)(unit), section2)) : null;
|
|
608
720
|
return {
|
|
609
721
|
...unit,
|
|
610
722
|
properties: {
|
|
@@ -632,6 +744,20 @@ var createPopulator = ({
|
|
|
632
744
|
}
|
|
633
745
|
};
|
|
634
746
|
};
|
|
747
|
+
const populateModel3D = async (model3d) => {
|
|
748
|
+
const level = await internalFindById(model3d.properties.level_id);
|
|
749
|
+
try {
|
|
750
|
+
return {
|
|
751
|
+
...model3d,
|
|
752
|
+
properties: {
|
|
753
|
+
...model3d.properties,
|
|
754
|
+
level: await populateLevel(level)
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
} catch (err) {
|
|
758
|
+
console.log(`error finding level`, { model3d, level });
|
|
759
|
+
}
|
|
760
|
+
};
|
|
635
761
|
const populateFeature = (feature2) => Promise.resolve(feature2);
|
|
636
762
|
return {
|
|
637
763
|
address: populateAddress,
|
|
@@ -656,23 +782,1667 @@ var createPopulator = ({
|
|
|
656
782
|
section: populateSection,
|
|
657
783
|
unit: populateUnit,
|
|
658
784
|
venue: populateVenue,
|
|
659
|
-
taxonomy: populateTaxonomy
|
|
785
|
+
taxonomy: populateTaxonomy,
|
|
786
|
+
model3d: populateModel3D
|
|
660
787
|
};
|
|
661
788
|
};
|
|
662
789
|
|
|
663
|
-
// src/data/
|
|
664
|
-
var
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
790
|
+
// src/data/search/getSearchClient.ts
|
|
791
|
+
var import_fuse = __toESM(require("fuse.js"));
|
|
792
|
+
|
|
793
|
+
// src/data/search/utils/sanitizeInput.ts
|
|
794
|
+
var sanitizeInput = (str) => str.replace(/[\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, "").replace(/[\-–—_./()]+/g, "").normalize("NFC").trim();
|
|
795
|
+
|
|
796
|
+
// src/data/search/getSearchClient.ts
|
|
797
|
+
var getSearchClient = ({ occupants, amenities }) => {
|
|
798
|
+
const fuseAmenities = new import_fuse.default(amenities, {
|
|
799
|
+
threshold: 0.2,
|
|
800
|
+
keys: [
|
|
801
|
+
{ name: "properties.name", "weight": 1, getFn: (obj) => Object.values(obj.properties.name || {}) },
|
|
802
|
+
{ name: "properties.category", "weight": 1 }
|
|
803
|
+
]
|
|
804
|
+
});
|
|
805
|
+
const fuseOccupants = new import_fuse.default(occupants, {
|
|
806
|
+
threshold: 0.25,
|
|
807
|
+
// 0.2 is too strict (can't find Mo-Mo Paradise with "momo" search string)
|
|
808
|
+
includeScore: true,
|
|
809
|
+
shouldSort: true,
|
|
810
|
+
keys: [
|
|
811
|
+
{ name: "properties.name", "weight": 4, getFn: (obj) => Object.values(obj.properties.name || {}) },
|
|
812
|
+
{ name: "properties.keywords", "weight": 0.5 },
|
|
813
|
+
{ name: "properties.category", "weight": 0.25 },
|
|
814
|
+
{ name: "properties.local_category_names", "weight": 0.25 },
|
|
815
|
+
{ name: "properties.description", "weight": 0.25, getFn: (occ) => Object.values(occ.properties.description || {}) },
|
|
816
|
+
{ name: "properties.unit_name", "weight": 0.25 },
|
|
817
|
+
{ name: "properties.kiosk_name", "weight": 0.25 }
|
|
818
|
+
]
|
|
819
|
+
});
|
|
820
|
+
const search = (value) => {
|
|
821
|
+
const sanitizedValue = sanitizeInput(value);
|
|
822
|
+
const matchedAmenities = fuseAmenities.search(sanitizedValue);
|
|
823
|
+
const matchedOccupants = fuseOccupants.search(sanitizedValue);
|
|
824
|
+
return [...matchedAmenities, ...matchedOccupants];
|
|
825
|
+
};
|
|
826
|
+
return {
|
|
827
|
+
search
|
|
828
|
+
};
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
// src/data/navigate/getNavigateClient.ts
|
|
832
|
+
var import_boolean_point_in_polygon4 = require("@turf/boolean-point-in-polygon");
|
|
833
|
+
|
|
834
|
+
// src/data/navigate/graph/prepare.ts
|
|
835
|
+
var import_lodash10 = __toESM(require("lodash"));
|
|
836
|
+
var import_node_dijkstra = __toESM(require("node-dijkstra"));
|
|
837
|
+
var import_distance3 = require("@turf/distance");
|
|
838
|
+
var import_center5 = require("@turf/center");
|
|
839
|
+
|
|
840
|
+
// src/data/navigate/graph/nodemap/createTraversalNodeMap.ts
|
|
841
|
+
var import_distance = require("@turf/distance");
|
|
842
|
+
var import_center3 = require("@turf/center");
|
|
843
|
+
var import_lodash3 = __toESM(require("lodash"));
|
|
844
|
+
|
|
845
|
+
// src/data/navigate/graph/constants.ts
|
|
846
|
+
var ROOM_BASEDISTANCE = 1e3;
|
|
847
|
+
var TERRACE_BASEDISTANCE = 1e3;
|
|
848
|
+
var ESCALATOR_BASEDISTANCE = 200;
|
|
849
|
+
var RAMP_BASEDISTANCE = 200;
|
|
850
|
+
var ELEVATOR_BASEDISTANCE = 500;
|
|
851
|
+
var STAIR_BASEDISTANCE = 1e5;
|
|
852
|
+
var BASE_POI_BASEDISTANCE = 9999999;
|
|
853
|
+
var DEFAULT_UNIT_BASEDISTANCE_OPTIONS = {
|
|
854
|
+
default: { baseDistance: 0 },
|
|
855
|
+
byCategory: {
|
|
856
|
+
room: { baseDistance: ROOM_BASEDISTANCE },
|
|
857
|
+
terrace: { baseDistance: TERRACE_BASEDISTANCE },
|
|
858
|
+
escalator: { baseDistance: ESCALATOR_BASEDISTANCE, scaleDistanceByLevel: false },
|
|
859
|
+
ramp: { baseDistance: RAMP_BASEDISTANCE, scaleDistanceByLevel: false },
|
|
860
|
+
elevator: { baseDistance: ELEVATOR_BASEDISTANCE, scaleDistanceByLevel: false },
|
|
861
|
+
stairs: {
|
|
862
|
+
baseDistance: STAIR_BASEDISTANCE,
|
|
863
|
+
scaleDistanceByLevel: true
|
|
864
|
+
},
|
|
865
|
+
"stairs.emergencyexit": {
|
|
866
|
+
baseDistance: STAIR_BASEDISTANCE,
|
|
867
|
+
scaleDistanceByLevel: true
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
// src/data/navigate/graph/utils/getDistanceOption.ts
|
|
873
|
+
var getDistanceOptions = (options, category) => {
|
|
874
|
+
if (!options) return DEFAULT_UNIT_BASEDISTANCE_OPTIONS.byCategory[category];
|
|
875
|
+
return (category && options.byCategory?.[category]) ?? DEFAULT_UNIT_BASEDISTANCE_OPTIONS.byCategory[category] ?? options?.default ?? DEFAULT_UNIT_BASEDISTANCE_OPTIONS.default;
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
// src/data/utils/trace.ts
|
|
879
|
+
var trace = (namespace, text, ms, color) => {
|
|
880
|
+
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);
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// src/data/navigate/graph/nodemap/createTraversalNodeMap.ts
|
|
884
|
+
var createTraversalNodeMap = (unitOpenings, options) => {
|
|
885
|
+
const { units } = options.data;
|
|
886
|
+
let counter = 0;
|
|
887
|
+
const calculateFeatureDistanceWithinUnit = (features, distanceOptions) => {
|
|
888
|
+
let relationshipGraph = {};
|
|
889
|
+
for (let currentIndex = 0; currentIndex < features.length; currentIndex++) {
|
|
890
|
+
const isLastItem = currentIndex + 1 === features.length;
|
|
891
|
+
if (isLastItem) break;
|
|
892
|
+
for (let j = currentIndex + 1; j < features.length; j++) {
|
|
893
|
+
const opening = features[currentIndex];
|
|
894
|
+
const feature2 = features[j];
|
|
895
|
+
try {
|
|
896
|
+
const distance5 = (0, import_distance.distance)(
|
|
897
|
+
(0, import_center3.center)(opening.geometry),
|
|
898
|
+
(0, import_center3.center)(feature2.geometry),
|
|
899
|
+
{ units: "meters" }
|
|
900
|
+
) + (distanceOptions?.baseDistance ?? 0);
|
|
901
|
+
if (opening.id === feature2.id) continue;
|
|
902
|
+
import_lodash3.default.set(relationshipGraph, `${opening.id}.${feature2.id}`, distance5);
|
|
903
|
+
import_lodash3.default.set(relationshipGraph, `${feature2.id}.${opening.id}`, distance5);
|
|
904
|
+
counter++;
|
|
905
|
+
} catch (error) {
|
|
906
|
+
continue;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
return relationshipGraph;
|
|
911
|
+
};
|
|
912
|
+
const t0 = performance.now();
|
|
913
|
+
const nodeMap = import_lodash3.default.reduce(
|
|
914
|
+
unitOpenings,
|
|
915
|
+
(acc, openings, unitId) => {
|
|
916
|
+
const unit = units.find((unit2) => unit2.id === unitId);
|
|
917
|
+
const unitDistanceOption = getDistanceOptions(options.unitDistanceOptions, unit.properties.category);
|
|
918
|
+
return import_lodash3.default.merge(
|
|
919
|
+
acc,
|
|
920
|
+
calculateFeatureDistanceWithinUnit(openings, unitDistanceOption)
|
|
921
|
+
);
|
|
922
|
+
},
|
|
923
|
+
{}
|
|
924
|
+
);
|
|
925
|
+
const t1 = performance.now();
|
|
926
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} traversal relationships`, t1 - t0);
|
|
927
|
+
return nodeMap;
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
// src/data/navigate/graph/nodemap/createElevatorNodeMap.ts
|
|
931
|
+
var import_lodash4 = __toESM(require("lodash"));
|
|
932
|
+
var createElevatorNodeMap = (elevatorLikeRelationships, unitOpenings, options) => {
|
|
933
|
+
const t0 = performance.now();
|
|
934
|
+
const { levels, units } = options.data;
|
|
935
|
+
const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "elevator");
|
|
936
|
+
const {
|
|
937
|
+
baseDistance = ELEVATOR_BASEDISTANCE,
|
|
938
|
+
scaleDistanceByLevel = false
|
|
939
|
+
} = distanceOptions;
|
|
940
|
+
let elevatorNodeMap = {};
|
|
941
|
+
let counter = 0;
|
|
942
|
+
for (const relationship of elevatorLikeRelationships) {
|
|
943
|
+
try {
|
|
944
|
+
const {
|
|
945
|
+
origin: originTypeAndId,
|
|
946
|
+
intermediary,
|
|
947
|
+
destination: destinationTypeAndId
|
|
948
|
+
} = relationship.properties;
|
|
949
|
+
const origin = units.find((unit) => unit.id === originTypeAndId.id);
|
|
950
|
+
if (!origin) return;
|
|
951
|
+
const originOpenings = compact(unitOpenings[origin.id]);
|
|
952
|
+
const originLevel = levels.find((level) => level.id === origin.properties.level_id);
|
|
953
|
+
const destination = units.find((unit) => unit.id === destinationTypeAndId.id);
|
|
954
|
+
const destinationOpenings = unitOpenings[destination.id];
|
|
955
|
+
const destinationOpeningAndLevels = destinationOpenings.map((opening) => {
|
|
956
|
+
const level = levels.find((level2) => level2.id === destination.properties.level_id);
|
|
957
|
+
return { opening, level };
|
|
958
|
+
});
|
|
959
|
+
const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
|
|
960
|
+
const openings = unitOpenings[unitTypeAndId.id];
|
|
961
|
+
const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
|
|
962
|
+
const level = levels.find((level2) => level2.id === unit.properties.level_id);
|
|
963
|
+
return openings.map((opening) => ({ opening, level }));
|
|
964
|
+
}).flat();
|
|
965
|
+
const connections = compact([...intermediaryOpeningAndLevels, ...destinationOpeningAndLevels]);
|
|
966
|
+
if (!originOpenings || originOpenings.length === 0) return;
|
|
967
|
+
for (const originOpening of originOpenings) {
|
|
968
|
+
for (const connection of connections) {
|
|
969
|
+
const { opening, level } = connection;
|
|
970
|
+
let distance5 = baseDistance;
|
|
971
|
+
if (scaleDistanceByLevel) {
|
|
972
|
+
const originOrdinal = originLevel.properties.ordinal;
|
|
973
|
+
const connectionOrdinal = level.properties.ordinal;
|
|
974
|
+
const levelDifference = Math.abs(originOrdinal - connectionOrdinal);
|
|
975
|
+
if (levelDifference > 0) distance5 *= levelDifference;
|
|
976
|
+
}
|
|
977
|
+
import_lodash4.default.set(elevatorNodeMap, `${originOpening.id}.${opening.id}`, distance5);
|
|
978
|
+
import_lodash4.default.set(elevatorNodeMap, `${opening.id}.${originOpening.id}`, distance5);
|
|
979
|
+
counter++;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
} catch (err) {
|
|
983
|
+
console.log(err);
|
|
984
|
+
console.log("cannot create elevatorNodeMap for ", { relationship });
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
const t1 = performance.now();
|
|
988
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
|
|
989
|
+
return elevatorNodeMap;
|
|
990
|
+
};
|
|
991
|
+
|
|
992
|
+
// src/data/navigate/graph/nodemap/createEscalatorNodeMap.ts
|
|
993
|
+
var import_set = __toESM(require("lodash/set"));
|
|
994
|
+
var createEscalatorNodeMap = (relationships, options) => {
|
|
995
|
+
const t0 = performance.now();
|
|
996
|
+
const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "escalator");
|
|
997
|
+
let counter = 0;
|
|
998
|
+
let nodeMap = {};
|
|
999
|
+
for (const relationship of relationships) {
|
|
1000
|
+
const {
|
|
1001
|
+
properties: { direction, origin, destination }
|
|
1002
|
+
} = relationship;
|
|
1003
|
+
(0, import_set.default)(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
|
|
1004
|
+
if (direction === "undirected") {
|
|
1005
|
+
(0, import_set.default)(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
|
|
1006
|
+
}
|
|
1007
|
+
counter++;
|
|
1008
|
+
}
|
|
1009
|
+
const t1 = performance.now();
|
|
1010
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
|
|
1011
|
+
return nodeMap;
|
|
1012
|
+
};
|
|
1013
|
+
|
|
1014
|
+
// src/data/navigate/graph/nodemap/createRampNodeMap.ts
|
|
1015
|
+
var import_set2 = __toESM(require("lodash/set"));
|
|
1016
|
+
var createRampNodeMap = (relationships, options) => {
|
|
1017
|
+
const t0 = performance.now();
|
|
1018
|
+
const distanceOptions = getDistanceOptions(options.unitDistanceOptions, "ramp");
|
|
1019
|
+
let counter = 0;
|
|
1020
|
+
let nodeMap = {};
|
|
1021
|
+
relationships.forEach((relationship) => {
|
|
1022
|
+
const {
|
|
1023
|
+
properties: { origin, destination }
|
|
1024
|
+
} = relationship;
|
|
1025
|
+
(0, import_set2.default)(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
|
|
1026
|
+
(0, import_set2.default)(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
|
|
1027
|
+
counter++;
|
|
1028
|
+
});
|
|
1029
|
+
const t1 = performance.now();
|
|
1030
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} ramp relationships`, t1 - t0);
|
|
1031
|
+
return nodeMap;
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
// src/data/navigate/graph/nodemap/createStairNodeMap.ts
|
|
1035
|
+
var import_lodash6 = __toESM(require("lodash"));
|
|
1036
|
+
var createStairNodeMap = (elevatorLikeRelationships, unitOpenings, options) => {
|
|
1037
|
+
const t0 = performance.now();
|
|
1038
|
+
const { levels = [], openings = [], units = [] } = options.data;
|
|
1039
|
+
const { baseDistance, scaleDistanceByLevel } = getDistanceOptions(options.unitDistanceOptions, "stairs");
|
|
1040
|
+
let elevatorNodeMap = {};
|
|
1041
|
+
let counter = 0;
|
|
1042
|
+
for (const relationship of elevatorLikeRelationships) {
|
|
1043
|
+
try {
|
|
1044
|
+
const {
|
|
1045
|
+
origin: { id: originId },
|
|
1046
|
+
intermediary,
|
|
1047
|
+
destination: { id: destinationId }
|
|
1048
|
+
} = relationship.properties;
|
|
1049
|
+
const origin = openings.find((opening) => opening.id === originId);
|
|
1050
|
+
if (!origin) return;
|
|
1051
|
+
const originLevel = levels.find((level) => level.id === origin.properties.level_id);
|
|
1052
|
+
const destination = openings.find((opening) => opening.id === destinationId);
|
|
1053
|
+
const destinationOpeningAndLevel = {
|
|
1054
|
+
opening: destination,
|
|
1055
|
+
level: levels.find((level) => level.id === destination.properties.level_id)
|
|
1056
|
+
};
|
|
1057
|
+
const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
|
|
1058
|
+
const openings2 = unitOpenings[unitTypeAndId.id];
|
|
1059
|
+
const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
|
|
1060
|
+
const level = levels.find((level2) => level2.id === unit.properties.level_id);
|
|
1061
|
+
return openings2.map((opening) => ({ opening, level }));
|
|
1062
|
+
}).flat();
|
|
1063
|
+
const connections = [...intermediaryOpeningAndLevels, destinationOpeningAndLevel];
|
|
1064
|
+
if (!origin) return;
|
|
1065
|
+
for (const connection of connections) {
|
|
1066
|
+
const { opening, level } = connection;
|
|
1067
|
+
let distance5 = baseDistance;
|
|
1068
|
+
if (scaleDistanceByLevel) {
|
|
1069
|
+
const originOrdinal = originLevel.properties.ordinal;
|
|
1070
|
+
const connectionOrdinal = level.properties.ordinal;
|
|
1071
|
+
const levelDifference = Math.abs(originOrdinal - connectionOrdinal);
|
|
1072
|
+
if (levelDifference > 0) distance5 *= levelDifference;
|
|
1073
|
+
}
|
|
1074
|
+
import_lodash6.default.set(elevatorNodeMap, `${origin.id}.${opening.id}`, distance5);
|
|
1075
|
+
import_lodash6.default.set(elevatorNodeMap, `${opening.id}.${origin.id}`, distance5);
|
|
1076
|
+
counter++;
|
|
1077
|
+
}
|
|
1078
|
+
} catch (err) {
|
|
1079
|
+
console.warn(
|
|
1080
|
+
"Failed to create stairNodeMap",
|
|
1081
|
+
{
|
|
1082
|
+
relationshipId: relationship.id,
|
|
1083
|
+
featureType: relationship.feature_type,
|
|
1084
|
+
error: err instanceof Error ? err.message : err,
|
|
1085
|
+
stack: err instanceof Error ? err.stack : void 0
|
|
1086
|
+
}
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
const t1 = performance.now();
|
|
1091
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} stairs relationships`, t1 - t0);
|
|
1092
|
+
return elevatorNodeMap;
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
// src/data/navigate/graph/nodemap/createOccupantNodeMap.ts
|
|
1096
|
+
var import_lodash7 = __toESM(require("lodash"));
|
|
1097
|
+
var createOccupantNodeMap = (occupants) => {
|
|
1098
|
+
const t0 = performance.now();
|
|
1099
|
+
let nodeMap = {};
|
|
1100
|
+
let counter = 0;
|
|
1101
|
+
occupants.forEach((occupant) => {
|
|
1102
|
+
const { unit_id, unit_ids = [], kiosk_id, kiosk_ids = [] } = occupant.properties;
|
|
1103
|
+
const occupantRoomIds = compact([unit_id, ...unit_ids]);
|
|
1104
|
+
const occupantKioskIds = compact([kiosk_id, ...kiosk_ids]);
|
|
1105
|
+
for (const roomId of occupantRoomIds) {
|
|
1106
|
+
import_lodash7.default.set(nodeMap, `${roomId}.${occupant.id}`, 1e-3);
|
|
1107
|
+
import_lodash7.default.set(nodeMap, `${occupant.id}.${roomId}`, 1e-3);
|
|
1108
|
+
counter++;
|
|
1109
|
+
}
|
|
1110
|
+
for (const kioskId of occupantKioskIds) {
|
|
1111
|
+
import_lodash7.default.set(nodeMap, `${kioskId}.${occupant.id}`, 1e-3);
|
|
1112
|
+
import_lodash7.default.set(nodeMap, `${occupant.id}.${kioskId}`, 1e-3);
|
|
1113
|
+
counter++;
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
const t1 = performance.now();
|
|
1117
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} occupants relationships`, t1 - t0);
|
|
1118
|
+
return nodeMap;
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
// src/data/navigate/graph/nodemap/createPOINodeMaps.ts
|
|
1122
|
+
var import_center4 = require("@turf/center");
|
|
1123
|
+
var import_distance2 = require("@turf/distance");
|
|
1124
|
+
var import_lodash9 = __toESM(require("lodash"));
|
|
1125
|
+
var createPOINodeMap = (features, getFeatureUnit, unitOpenings) => {
|
|
1126
|
+
const t0 = performance.now();
|
|
1127
|
+
let nodeMap = {};
|
|
1128
|
+
let counter = 0;
|
|
1129
|
+
features.forEach((feat) => {
|
|
1130
|
+
try {
|
|
1131
|
+
const locatedOnUnitId = getFeatureUnit(feat);
|
|
1132
|
+
const openings = unitOpenings[locatedOnUnitId];
|
|
1133
|
+
const center8 = (0, import_center4.center)(feat);
|
|
1134
|
+
for (const opening of openings) {
|
|
1135
|
+
try {
|
|
1136
|
+
const openingCenter = (0, import_center4.center)(opening);
|
|
1137
|
+
const dis = (0, import_distance2.distance)(center8, openingCenter, { units: "meters" }) + BASE_POI_BASEDISTANCE;
|
|
1138
|
+
import_lodash9.default.set(nodeMap, `${opening.id}.${feat.id}`, dis);
|
|
1139
|
+
import_lodash9.default.set(nodeMap, `${feat.id}.${opening.id}`, dis);
|
|
1140
|
+
counter++;
|
|
1141
|
+
} catch (err) {
|
|
1142
|
+
console.log(err, opening);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
} catch (err) {
|
|
1146
|
+
console.log(err);
|
|
1147
|
+
console.log(`cannot connect poi to openings`, err.message, { feat });
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
const type = features.length > 0 ? features[0].feature_type : "-";
|
|
1151
|
+
const t1 = performance.now();
|
|
1152
|
+
trace("nav", ` \u2502 \u251C\u2500 add ${counter} ${type} relationships`, t1 - t0);
|
|
1153
|
+
return nodeMap;
|
|
1154
|
+
};
|
|
1155
|
+
|
|
1156
|
+
// src/data/navigate/graph/utils/mergeNodeMap.ts
|
|
1157
|
+
var mergeNodeMap = (nodeMaps) => {
|
|
1158
|
+
const out = {};
|
|
1159
|
+
for (const nodeMap of nodeMaps) {
|
|
1160
|
+
for (const from in nodeMap) {
|
|
1161
|
+
out[from] = {
|
|
1162
|
+
...out[from] ?? {},
|
|
1163
|
+
...nodeMap[from]
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
return out;
|
|
1168
|
+
};
|
|
1169
|
+
|
|
1170
|
+
// src/data/navigate/graph/utils/createUnitOpenings.ts
|
|
1171
|
+
var import_uniqBy = __toESM(require("lodash/uniqBy"));
|
|
1172
|
+
var createUnitOpenings = (relationships, units, openings) => {
|
|
1173
|
+
const openingConnections = {};
|
|
1174
|
+
const relationshipMap = /* @__PURE__ */ new Map();
|
|
1175
|
+
relationships.forEach((relationship) => {
|
|
1176
|
+
const originId = relationship.properties.origin?.id || null;
|
|
1177
|
+
const destinationId = relationship.properties.destination?.id || null;
|
|
1178
|
+
if (!relationshipMap.has(originId)) {
|
|
1179
|
+
relationshipMap.set(originId, []);
|
|
1180
|
+
}
|
|
1181
|
+
if (!relationshipMap.has(destinationId)) {
|
|
1182
|
+
relationshipMap.set(destinationId, []);
|
|
1183
|
+
}
|
|
1184
|
+
relationshipMap.get(originId).push(relationship);
|
|
1185
|
+
relationshipMap.get(destinationId).push(relationship);
|
|
1186
|
+
});
|
|
1187
|
+
units.forEach((unit) => {
|
|
1188
|
+
const unitId = unit.id;
|
|
1189
|
+
const connectedRelationshop = relationshipMap.get(unitId) || [];
|
|
1190
|
+
const relationshipIntermediaryTypeAndId = connectedRelationshop.map(
|
|
1191
|
+
(relationship) => relationship.properties.intermediary[0]
|
|
1192
|
+
// Assuming intermediary is always an array
|
|
1193
|
+
);
|
|
1194
|
+
const relationshipIntermediary = relationshipIntermediaryTypeAndId.map(({ id }) => {
|
|
1195
|
+
return openings.find((opening) => opening.id === id);
|
|
1196
|
+
});
|
|
1197
|
+
openingConnections[unitId] = (0, import_uniqBy.default)(
|
|
1198
|
+
[...openingConnections[unitId] || [], ...relationshipIntermediary],
|
|
1199
|
+
"id"
|
|
1200
|
+
);
|
|
1201
|
+
});
|
|
1202
|
+
return openingConnections;
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
// src/data/navigate/parsers.ts
|
|
1206
|
+
var parseOrdinalCoordinate = (id) => {
|
|
1207
|
+
return id.slice(0, -1).split(",").map(Number);
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
// src/data/navigate/graph/prepare.ts
|
|
1211
|
+
var prepareGraph = (options) => {
|
|
1212
|
+
const {
|
|
1213
|
+
data: {
|
|
1214
|
+
amenities = [],
|
|
1215
|
+
anchors = [],
|
|
1216
|
+
occupants = [],
|
|
1217
|
+
relationships = [],
|
|
1218
|
+
openings = [],
|
|
1219
|
+
units = [],
|
|
1220
|
+
kiosks = [],
|
|
1221
|
+
levels = []
|
|
1222
|
+
}
|
|
1223
|
+
} = options;
|
|
1224
|
+
const {
|
|
1225
|
+
traversal: traversalRelationships = [],
|
|
1226
|
+
escalator: escalatorRelationships = [],
|
|
1227
|
+
ramp: rampRelationships = [],
|
|
1228
|
+
elevator: elevatorRelationships = [],
|
|
1229
|
+
stairs: stairsRelationships = []
|
|
1230
|
+
} = import_lodash10.default.groupBy(relationships, "properties.category");
|
|
1231
|
+
const unitOpenings = createUnitOpenings(traversalRelationships, units, openings);
|
|
1232
|
+
const traversalNodeMap = createTraversalNodeMap(unitOpenings, options);
|
|
1233
|
+
const escalatorNodeMap = createEscalatorNodeMap(escalatorRelationships, options);
|
|
1234
|
+
const rampNodeMap = createRampNodeMap(rampRelationships, options);
|
|
1235
|
+
const elevatorNodeMap = createElevatorNodeMap(
|
|
1236
|
+
elevatorRelationships,
|
|
1237
|
+
unitOpenings,
|
|
1238
|
+
options
|
|
1239
|
+
);
|
|
1240
|
+
const stairNodeMap = createStairNodeMap(
|
|
1241
|
+
stairsRelationships,
|
|
1242
|
+
unitOpenings,
|
|
1243
|
+
options
|
|
1244
|
+
);
|
|
1245
|
+
const amenityNodeMap = createPOINodeMap(amenities, (amenity) => amenity.properties.unit_ids[0], unitOpenings);
|
|
1246
|
+
const anchorsNodeMap = createPOINodeMap(anchors, (anchor) => anchor.properties.unit_id, unitOpenings);
|
|
1247
|
+
const walkwayUnits = units.filter((unit) => unit.properties.category === "walkway");
|
|
1248
|
+
const kioskNodeMap = createPOINodeMap(kiosks, (kiosk) => findContainingUnit(kiosk, walkwayUnits)?.id, unitOpenings);
|
|
1249
|
+
const unitNodeMap = createPOINodeMap(units, (unit) => unit.id, unitOpenings);
|
|
1250
|
+
const occupantNodeMap = createOccupantNodeMap(occupants);
|
|
1251
|
+
const defaultGraph = new import_node_dijkstra.default(mergeNodeMap([
|
|
1252
|
+
traversalNodeMap,
|
|
1253
|
+
escalatorNodeMap,
|
|
1254
|
+
rampNodeMap,
|
|
1255
|
+
elevatorNodeMap,
|
|
1256
|
+
stairNodeMap,
|
|
1257
|
+
amenityNodeMap,
|
|
1258
|
+
anchorsNodeMap,
|
|
1259
|
+
kioskNodeMap,
|
|
1260
|
+
unitNodeMap,
|
|
1261
|
+
occupantNodeMap
|
|
1262
|
+
]));
|
|
1263
|
+
const accessibleGraph = new import_node_dijkstra.default(mergeNodeMap([
|
|
1264
|
+
traversalNodeMap,
|
|
1265
|
+
rampNodeMap,
|
|
1266
|
+
elevatorNodeMap,
|
|
1267
|
+
amenityNodeMap,
|
|
1268
|
+
anchorsNodeMap,
|
|
1269
|
+
kioskNodeMap,
|
|
1270
|
+
unitNodeMap,
|
|
1271
|
+
occupantNodeMap
|
|
1272
|
+
]));
|
|
1273
|
+
const addCoordinateOrdinalNode = (params, locatedOnUnit) => {
|
|
1274
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(params);
|
|
1275
|
+
if (locatedOnUnit) {
|
|
1276
|
+
const openings2 = unitOpenings[locatedOnUnit.id];
|
|
1277
|
+
for (const opening of openings2) {
|
|
1278
|
+
const openingCenter = (0, import_center5.center)(opening);
|
|
1279
|
+
const dis = (0, import_distance3.distance)([lat, lng], openingCenter, { units: "meters" });
|
|
1280
|
+
defaultGraph.addNode(params, { [opening.id]: dis }).addNode(opening.id, { [params]: dis });
|
|
1281
|
+
accessibleGraph.addNode(params, { [opening.id]: dis }).addNode(opening.id, { [params]: dis });
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
return { defaultGraph, accessibleGraph, unitOpenings, addCoordinateOrdinalNode };
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1288
|
+
// src/data/navigate/steps/createStepUtils.ts
|
|
1289
|
+
var import_lodash12 = require("lodash");
|
|
1290
|
+
var import_intersectionBy = __toESM(require("lodash/intersectionBy"));
|
|
1291
|
+
|
|
1292
|
+
// src/data/navigate/description/describe.ts
|
|
1293
|
+
var t = (template, locale, options) => {
|
|
1294
|
+
return template.replace(`{{intermediary}}`, options.intermediary ?? "").replace(`{{toward}}`, options.toward?.[locale] ?? "").replace(`{{landmark}}`, options.landmark?.[locale] ?? "");
|
|
1295
|
+
};
|
|
1296
|
+
var describeVerticalStep = (fromLevel, toLevel, intermediary) => {
|
|
1297
|
+
const dir = fromLevel.properties.ordinal < toLevel.properties.ordinal ? "up" : "down";
|
|
1298
|
+
const template = `Take the {{intermediary}} ${dir} to {{toward}}`;
|
|
1299
|
+
return {
|
|
1300
|
+
template,
|
|
1301
|
+
text: t(template, "en", { intermediary, toward: toLevel.properties.name })
|
|
1302
|
+
};
|
|
1303
|
+
};
|
|
1304
|
+
var describeHorizontalStep = (intermediary, toward, landmark) => {
|
|
1305
|
+
const template = `Follow the path ${intermediary === "walkway" ? `along the walkway` : `through {{intermediary}}`} ${toward ? `toward {{toward}}` : ``} ${landmark ? `near {{landmark}}` : ``}`.trim();
|
|
1306
|
+
return {
|
|
1307
|
+
text: t(template, "en", { intermediary, toward, landmark }),
|
|
1308
|
+
template
|
|
1309
|
+
};
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1312
|
+
// src/data/navigate/steps/path/index.ts
|
|
1313
|
+
var import_lodash11 = __toESM(require("lodash"));
|
|
1314
|
+
|
|
1315
|
+
// src/data/navigate/constants.ts
|
|
1316
|
+
var OBSTACLE_FEATURE_TYPES = [
|
|
1317
|
+
"kiosk"
|
|
1318
|
+
/* , "fixture" */
|
|
1319
|
+
];
|
|
1320
|
+
var OBSTACLE_CATEGORIES = [
|
|
1321
|
+
"fixture.water",
|
|
1322
|
+
"fixture.stage",
|
|
1323
|
+
"nonpublic",
|
|
1324
|
+
"opentobelow",
|
|
1325
|
+
"elevator",
|
|
1326
|
+
"escalator",
|
|
1327
|
+
"stairs",
|
|
1328
|
+
"stairs.emergencyexit",
|
|
1329
|
+
"room",
|
|
1330
|
+
"unspecified",
|
|
1331
|
+
"structure",
|
|
1332
|
+
"brick",
|
|
1333
|
+
"concrete",
|
|
1334
|
+
"drywall",
|
|
1335
|
+
"glass",
|
|
1336
|
+
"wood",
|
|
1337
|
+
"column"
|
|
1338
|
+
];
|
|
1339
|
+
var WALKABLE_CATEGORY = [
|
|
1340
|
+
"walkway",
|
|
1341
|
+
"parking",
|
|
1342
|
+
"room",
|
|
1343
|
+
"terrace",
|
|
1344
|
+
"unenclosedarea",
|
|
1345
|
+
"vegetation",
|
|
1346
|
+
"unspecified"
|
|
1347
|
+
];
|
|
1348
|
+
|
|
1349
|
+
// node_modules/@turf/helpers/dist/esm/index.js
|
|
1350
|
+
var earthRadius = 63710088e-1;
|
|
1351
|
+
var factors = {
|
|
1352
|
+
centimeters: earthRadius * 100,
|
|
1353
|
+
centimetres: earthRadius * 100,
|
|
1354
|
+
degrees: 360 / (2 * Math.PI),
|
|
1355
|
+
feet: earthRadius * 3.28084,
|
|
1356
|
+
inches: earthRadius * 39.37,
|
|
1357
|
+
kilometers: earthRadius / 1e3,
|
|
1358
|
+
kilometres: earthRadius / 1e3,
|
|
1359
|
+
meters: earthRadius,
|
|
1360
|
+
metres: earthRadius,
|
|
1361
|
+
miles: earthRadius / 1609.344,
|
|
1362
|
+
millimeters: earthRadius * 1e3,
|
|
1363
|
+
millimetres: earthRadius * 1e3,
|
|
1364
|
+
nauticalmiles: earthRadius / 1852,
|
|
1365
|
+
radians: 1,
|
|
1366
|
+
yards: earthRadius * 1.0936
|
|
1367
|
+
};
|
|
1368
|
+
function feature(geom, properties, options = {}) {
|
|
1369
|
+
const feat = { type: "Feature" };
|
|
1370
|
+
if (options.id === 0 || options.id) {
|
|
1371
|
+
feat.id = options.id;
|
|
1372
|
+
}
|
|
1373
|
+
if (options.bbox) {
|
|
1374
|
+
feat.bbox = options.bbox;
|
|
1375
|
+
}
|
|
1376
|
+
feat.properties = properties || {};
|
|
1377
|
+
feat.geometry = geom;
|
|
1378
|
+
return feat;
|
|
1379
|
+
}
|
|
1380
|
+
function point(coordinates, properties, options = {}) {
|
|
1381
|
+
if (!coordinates) {
|
|
1382
|
+
throw new Error("coordinates is required");
|
|
1383
|
+
}
|
|
1384
|
+
if (!Array.isArray(coordinates)) {
|
|
1385
|
+
throw new Error("coordinates must be an Array");
|
|
1386
|
+
}
|
|
1387
|
+
if (coordinates.length < 2) {
|
|
1388
|
+
throw new Error("coordinates must be at least 2 numbers long");
|
|
1389
|
+
}
|
|
1390
|
+
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
|
|
1391
|
+
throw new Error("coordinates must contain numbers");
|
|
1392
|
+
}
|
|
1393
|
+
const geom = {
|
|
1394
|
+
type: "Point",
|
|
1395
|
+
coordinates
|
|
1396
|
+
};
|
|
1397
|
+
return feature(geom, properties, options);
|
|
1398
|
+
}
|
|
1399
|
+
function polygon(coordinates, properties, options = {}) {
|
|
1400
|
+
for (const ring of coordinates) {
|
|
1401
|
+
if (ring.length < 4) {
|
|
1402
|
+
throw new Error(
|
|
1403
|
+
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
1407
|
+
throw new Error("First and last Position are not equivalent.");
|
|
1408
|
+
}
|
|
1409
|
+
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
1410
|
+
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
1411
|
+
throw new Error("First and last Position are not equivalent.");
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
const geom = {
|
|
1416
|
+
type: "Polygon",
|
|
1417
|
+
coordinates
|
|
1418
|
+
};
|
|
1419
|
+
return feature(geom, properties, options);
|
|
1420
|
+
}
|
|
1421
|
+
function lineString(coordinates, properties, options = {}) {
|
|
1422
|
+
if (coordinates.length < 2) {
|
|
1423
|
+
throw new Error("coordinates must be an array of two or more positions");
|
|
1424
|
+
}
|
|
1425
|
+
const geom = {
|
|
1426
|
+
type: "LineString",
|
|
1427
|
+
coordinates
|
|
1428
|
+
};
|
|
1429
|
+
return feature(geom, properties, options);
|
|
1430
|
+
}
|
|
1431
|
+
function featureCollection(features, options = {}) {
|
|
1432
|
+
const fc = { type: "FeatureCollection" };
|
|
1433
|
+
if (options.id) {
|
|
1434
|
+
fc.id = options.id;
|
|
1435
|
+
}
|
|
1436
|
+
if (options.bbox) {
|
|
1437
|
+
fc.bbox = options.bbox;
|
|
1438
|
+
}
|
|
1439
|
+
fc.features = features;
|
|
1440
|
+
return fc;
|
|
1441
|
+
}
|
|
1442
|
+
function multiPoint(coordinates, properties, options = {}) {
|
|
1443
|
+
const geom = {
|
|
1444
|
+
type: "MultiPoint",
|
|
1445
|
+
coordinates
|
|
1446
|
+
};
|
|
1447
|
+
return feature(geom, properties, options);
|
|
1448
|
+
}
|
|
1449
|
+
function isNumber(num) {
|
|
1450
|
+
return !isNaN(num) && num !== null && !Array.isArray(num);
|
|
1451
|
+
}
|
|
1452
|
+
function isObject(input) {
|
|
1453
|
+
return input !== null && typeof input === "object" && !Array.isArray(input);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// node_modules/@turf/invariant/dist/esm/index.js
|
|
1457
|
+
function getCoord(coord) {
|
|
1458
|
+
if (!coord) {
|
|
1459
|
+
throw new Error("coord is required");
|
|
1460
|
+
}
|
|
1461
|
+
if (!Array.isArray(coord)) {
|
|
1462
|
+
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
1463
|
+
return [...coord.geometry.coordinates];
|
|
1464
|
+
}
|
|
1465
|
+
if (coord.type === "Point") {
|
|
1466
|
+
return [...coord.coordinates];
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
1470
|
+
return [...coord];
|
|
1471
|
+
}
|
|
1472
|
+
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
1473
|
+
}
|
|
1474
|
+
function getGeom(geojson) {
|
|
1475
|
+
if (geojson.type === "Feature") {
|
|
1476
|
+
return geojson.geometry;
|
|
1477
|
+
}
|
|
1478
|
+
return geojson;
|
|
1479
|
+
}
|
|
1480
|
+
function getType(geojson, _name) {
|
|
1481
|
+
if (geojson.type === "FeatureCollection") {
|
|
1482
|
+
return "FeatureCollection";
|
|
1483
|
+
}
|
|
1484
|
+
if (geojson.type === "GeometryCollection") {
|
|
1485
|
+
return "GeometryCollection";
|
|
1486
|
+
}
|
|
1487
|
+
if (geojson.type === "Feature" && geojson.geometry !== null) {
|
|
1488
|
+
return geojson.geometry.type;
|
|
1489
|
+
}
|
|
1490
|
+
return geojson.type;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
// src/data/navigate/steps/path/index.ts
|
|
1494
|
+
var import_difference = __toESM(require("@turf/difference"));
|
|
1495
|
+
var import_envelope = __toESM(require("@turf/envelope"));
|
|
1496
|
+
var import_boolean_overlap = __toESM(require("@turf/boolean-overlap"));
|
|
1497
|
+
var import_boolean_intersects = __toESM(require("@turf/boolean-intersects"));
|
|
1498
|
+
|
|
1499
|
+
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
1500
|
+
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
1501
|
+
if (geojson === null) return;
|
|
1502
|
+
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;
|
|
1503
|
+
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
1504
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
1505
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
1506
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
1507
|
+
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
1508
|
+
var multiFeatureIndex = 0;
|
|
1509
|
+
var geometryIndex = 0;
|
|
1510
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
1511
|
+
if (geometry === null) continue;
|
|
1512
|
+
coords = geometry.coordinates;
|
|
1513
|
+
var geomType = geometry.type;
|
|
1514
|
+
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
1515
|
+
switch (geomType) {
|
|
1516
|
+
case null:
|
|
1517
|
+
break;
|
|
1518
|
+
case "Point":
|
|
1519
|
+
if (callback(
|
|
1520
|
+
coords,
|
|
1521
|
+
coordIndex,
|
|
1522
|
+
featureIndex,
|
|
1523
|
+
multiFeatureIndex,
|
|
1524
|
+
geometryIndex
|
|
1525
|
+
) === false)
|
|
1526
|
+
return false;
|
|
1527
|
+
coordIndex++;
|
|
1528
|
+
multiFeatureIndex++;
|
|
1529
|
+
break;
|
|
1530
|
+
case "LineString":
|
|
1531
|
+
case "MultiPoint":
|
|
1532
|
+
for (j = 0; j < coords.length; j++) {
|
|
1533
|
+
if (callback(
|
|
1534
|
+
coords[j],
|
|
1535
|
+
coordIndex,
|
|
1536
|
+
featureIndex,
|
|
1537
|
+
multiFeatureIndex,
|
|
1538
|
+
geometryIndex
|
|
1539
|
+
) === false)
|
|
1540
|
+
return false;
|
|
1541
|
+
coordIndex++;
|
|
1542
|
+
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
1543
|
+
}
|
|
1544
|
+
if (geomType === "LineString") multiFeatureIndex++;
|
|
1545
|
+
break;
|
|
1546
|
+
case "Polygon":
|
|
1547
|
+
case "MultiLineString":
|
|
1548
|
+
for (j = 0; j < coords.length; j++) {
|
|
1549
|
+
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
1550
|
+
if (callback(
|
|
1551
|
+
coords[j][k],
|
|
1552
|
+
coordIndex,
|
|
1553
|
+
featureIndex,
|
|
1554
|
+
multiFeatureIndex,
|
|
1555
|
+
geometryIndex
|
|
1556
|
+
) === false)
|
|
1557
|
+
return false;
|
|
1558
|
+
coordIndex++;
|
|
1559
|
+
}
|
|
1560
|
+
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
1561
|
+
if (geomType === "Polygon") geometryIndex++;
|
|
1562
|
+
}
|
|
1563
|
+
if (geomType === "Polygon") multiFeatureIndex++;
|
|
1564
|
+
break;
|
|
1565
|
+
case "MultiPolygon":
|
|
1566
|
+
for (j = 0; j < coords.length; j++) {
|
|
1567
|
+
geometryIndex = 0;
|
|
1568
|
+
for (k = 0; k < coords[j].length; k++) {
|
|
1569
|
+
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
1570
|
+
if (callback(
|
|
1571
|
+
coords[j][k][l],
|
|
1572
|
+
coordIndex,
|
|
1573
|
+
featureIndex,
|
|
1574
|
+
multiFeatureIndex,
|
|
1575
|
+
geometryIndex
|
|
1576
|
+
) === false)
|
|
1577
|
+
return false;
|
|
1578
|
+
coordIndex++;
|
|
1579
|
+
}
|
|
1580
|
+
geometryIndex++;
|
|
1581
|
+
}
|
|
1582
|
+
multiFeatureIndex++;
|
|
1583
|
+
}
|
|
1584
|
+
break;
|
|
1585
|
+
case "GeometryCollection":
|
|
1586
|
+
for (j = 0; j < geometry.geometries.length; j++)
|
|
1587
|
+
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
1588
|
+
return false;
|
|
1589
|
+
break;
|
|
1590
|
+
default:
|
|
1591
|
+
throw new Error("Unknown Geometry Type");
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
1598
|
+
function bbox(geojson, options = {}) {
|
|
1599
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
1600
|
+
return geojson.bbox;
|
|
1601
|
+
}
|
|
1602
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
1603
|
+
coordEach(geojson, (coord) => {
|
|
1604
|
+
if (result[0] > coord[0]) {
|
|
1605
|
+
result[0] = coord[0];
|
|
1606
|
+
}
|
|
1607
|
+
if (result[1] > coord[1]) {
|
|
1608
|
+
result[1] = coord[1];
|
|
1609
|
+
}
|
|
1610
|
+
if (result[2] < coord[0]) {
|
|
1611
|
+
result[2] = coord[0];
|
|
1612
|
+
}
|
|
1613
|
+
if (result[3] < coord[1]) {
|
|
1614
|
+
result[3] = coord[1];
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
return result;
|
|
1618
|
+
}
|
|
1619
|
+
var index_default = bbox;
|
|
1620
|
+
|
|
1621
|
+
// src/data/navigate/steps/path/turf/shortestPath.ts
|
|
1622
|
+
var import_boolean_point_in_polygon3 = __toESM(require("@turf/boolean-point-in-polygon"));
|
|
1623
|
+
var import_distance4 = __toESM(require("@turf/distance"));
|
|
1624
|
+
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
1625
|
+
var import_union = __toESM(require("@turf/union"));
|
|
1626
|
+
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
1627
|
+
var import_clean_coords = require("@turf/clean-coords");
|
|
1628
|
+
var import_pathfinding = __toESM(require("pathfinding"));
|
|
1629
|
+
var import_set3 = __toESM(require("lodash/set"));
|
|
1630
|
+
|
|
1631
|
+
// src/data/navigate/steps/path/turf/stringPull.ts
|
|
1632
|
+
function stringPull(grid, path) {
|
|
1633
|
+
const isWalkable = (x, y) => grid.isInside(x, y) && grid.isWalkableAt(x, y);
|
|
1634
|
+
function hasLOS(a, b) {
|
|
1635
|
+
let x0 = a[0], y0 = a[1];
|
|
1636
|
+
const x1 = b[0], y1 = b[1];
|
|
1637
|
+
if (!isWalkable(x0, y0) || !isWalkable(x1, y1)) return false;
|
|
1638
|
+
const dx = Math.abs(x1 - x0);
|
|
1639
|
+
const dy = Math.abs(y1 - y0);
|
|
1640
|
+
const sx = x0 < x1 ? 1 : -1;
|
|
1641
|
+
const sy = y0 < y1 ? 1 : -1;
|
|
1642
|
+
let err = dx - dy;
|
|
1643
|
+
while (true) {
|
|
1644
|
+
if (!isWalkable(x0, y0)) return false;
|
|
1645
|
+
if (x0 === x1 && y0 === y1) break;
|
|
1646
|
+
const e2 = err * 2;
|
|
1647
|
+
let nx = x0;
|
|
1648
|
+
let ny = y0;
|
|
1649
|
+
let movedX = false;
|
|
1650
|
+
let movedY = false;
|
|
1651
|
+
if (e2 > -dy) {
|
|
1652
|
+
err -= dy;
|
|
1653
|
+
nx += sx;
|
|
1654
|
+
movedX = true;
|
|
1655
|
+
}
|
|
1656
|
+
if (e2 < dx) {
|
|
1657
|
+
err += dx;
|
|
1658
|
+
ny += sy;
|
|
1659
|
+
movedY = true;
|
|
1660
|
+
}
|
|
1661
|
+
if (movedX && movedY) {
|
|
1662
|
+
if (!isWalkable(nx, y0) || !isWalkable(x0, ny)) return false;
|
|
1663
|
+
}
|
|
1664
|
+
x0 = nx;
|
|
1665
|
+
y0 = ny;
|
|
1666
|
+
}
|
|
1667
|
+
return true;
|
|
1668
|
+
}
|
|
1669
|
+
if (path.length <= 2) return path;
|
|
1670
|
+
const out = [path[0]];
|
|
1671
|
+
let i = 0;
|
|
1672
|
+
while (i < path.length - 1) {
|
|
1673
|
+
let best = i + 1;
|
|
1674
|
+
for (let j = i + 2; j < path.length; j++) {
|
|
1675
|
+
if (hasLOS(path[i], path[j])) best = j;
|
|
1676
|
+
else break;
|
|
1677
|
+
}
|
|
1678
|
+
out.push(path[best]);
|
|
1679
|
+
i = best;
|
|
1680
|
+
}
|
|
1681
|
+
return out;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
// src/data/navigate/steps/path/turf/pruneSmallAngle.ts
|
|
1685
|
+
function pruneSmallAngles(path, minDeg = 10) {
|
|
1686
|
+
if (path.length <= 2) return path;
|
|
1687
|
+
const out = [path[0]];
|
|
1688
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
1689
|
+
const a = out.at(-1);
|
|
1690
|
+
const b = path[i];
|
|
1691
|
+
const c = path[i + 1];
|
|
1692
|
+
const abx = b[0] - a[0], aby = b[1] - a[1];
|
|
1693
|
+
const bcx = c[0] - b[0], bcy = c[1] - b[1];
|
|
1694
|
+
const dot = abx * bcx + aby * bcy;
|
|
1695
|
+
const ab = Math.hypot(abx, aby);
|
|
1696
|
+
const bc = Math.hypot(bcx, bcy);
|
|
1697
|
+
const angle = Math.acos(dot / (ab * bc)) * 180 / Math.PI;
|
|
1698
|
+
if (angle > minDeg) out.push(b);
|
|
1699
|
+
}
|
|
1700
|
+
out.push(path.at(-1));
|
|
1701
|
+
return out;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
// src/data/navigate/steps/path/turf/pruneShortSegments.ts
|
|
1705
|
+
function pruneShortSegments(path, minLen = 5) {
|
|
1706
|
+
const out = [path[0]];
|
|
1707
|
+
for (let i = 1; i < path.length; i++) {
|
|
1708
|
+
const [x0, y0] = out.at(-1);
|
|
1709
|
+
const [x1, y1] = path[i];
|
|
1710
|
+
if (Math.hypot(x1 - x0, y1 - y0) >= minLen) {
|
|
1711
|
+
out.push(path[i]);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
return out;
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
// src/data/navigate/steps/path/turf/clearance.ts
|
|
1718
|
+
function buildClearanceGrid(matrix) {
|
|
1719
|
+
const h = matrix.length;
|
|
1720
|
+
const w = matrix[0].length;
|
|
1721
|
+
const INF = 1e9;
|
|
1722
|
+
const dist = Array.from({ length: h }, () => Array(w).fill(INF));
|
|
1723
|
+
const q = [];
|
|
1724
|
+
for (let y = 0; y < h; y++) {
|
|
1725
|
+
for (let x = 0; x < w; x++) {
|
|
1726
|
+
if (matrix[y][x] === 1) {
|
|
1727
|
+
dist[y][x] = 0;
|
|
1728
|
+
q.push([x, y]);
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
const dirs = [
|
|
1733
|
+
[1, 0],
|
|
1734
|
+
[-1, 0],
|
|
1735
|
+
[0, 1],
|
|
1736
|
+
[0, -1],
|
|
1737
|
+
[1, 1],
|
|
1738
|
+
[1, -1],
|
|
1739
|
+
[-1, 1],
|
|
1740
|
+
[-1, -1]
|
|
1741
|
+
];
|
|
1742
|
+
let qi = 0;
|
|
1743
|
+
while (qi < q.length) {
|
|
1744
|
+
const [x, y] = q[qi++];
|
|
1745
|
+
const d0 = dist[y][x];
|
|
1746
|
+
for (const [dx, dy] of dirs) {
|
|
1747
|
+
const nx = x + dx, ny = y + dy;
|
|
1748
|
+
if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
|
|
1749
|
+
const nd = d0 + 1;
|
|
1750
|
+
if (nd < dist[ny][nx]) {
|
|
1751
|
+
dist[ny][nx] = nd;
|
|
1752
|
+
q.push([nx, ny]);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return dist;
|
|
1757
|
+
}
|
|
1758
|
+
function snapPointToClearancePeak(p, clearance, isWalkableCell, radius = 4) {
|
|
1759
|
+
const [px, py] = p;
|
|
1760
|
+
let best = p;
|
|
1761
|
+
let bestScore = clearance[py]?.[px] ?? -Infinity;
|
|
1762
|
+
for (let dy = -radius; dy <= radius; dy++) {
|
|
1763
|
+
for (let dx = -radius; dx <= radius; dx++) {
|
|
1764
|
+
const x = px + dx;
|
|
1765
|
+
const y = py + dy;
|
|
1766
|
+
if (!isWalkableCell(x, y)) continue;
|
|
1767
|
+
const score = clearance[y][x];
|
|
1768
|
+
const penalty = Math.hypot(dx, dy) * 5e-3;
|
|
1769
|
+
const finalScore = score - penalty;
|
|
1770
|
+
if (finalScore > bestScore) {
|
|
1771
|
+
bestScore = finalScore;
|
|
1772
|
+
best = [x, y];
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
return best;
|
|
1777
|
+
}
|
|
1778
|
+
function centerlineSnapPath(path, clearance, isWalkableCell, radius = 4) {
|
|
1779
|
+
const snapped = path.map((p) => snapPointToClearancePeak(p, clearance, isWalkableCell, radius));
|
|
1780
|
+
return snapped;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
// src/data/navigate/steps/path/turf/shortestPath.ts
|
|
1784
|
+
function shortestPath(start, end, options) {
|
|
1785
|
+
options = options || {};
|
|
1786
|
+
if (!isObject(options)) throw new Error("options is invalid");
|
|
1787
|
+
let resolution = options.resolution;
|
|
1788
|
+
const smoothenPath = options.smoothenPath;
|
|
1789
|
+
let obstacles = options.obstacles || featureCollection([]);
|
|
1790
|
+
if (!start) throw new Error("start is required");
|
|
1791
|
+
if (!end) throw new Error("end is required");
|
|
1792
|
+
if (resolution && !isNumber(resolution) || resolution <= 0)
|
|
1793
|
+
throw new Error("options.resolution must be a number, greater than 0");
|
|
1794
|
+
const startCoord = getCoord(start);
|
|
1795
|
+
const endCoord = getCoord(end);
|
|
1796
|
+
start = point(startCoord);
|
|
1797
|
+
end = point(endCoord);
|
|
1798
|
+
switch (getType(obstacles)) {
|
|
1799
|
+
case "FeatureCollection":
|
|
1800
|
+
if (obstacles.features.length === 0)
|
|
1801
|
+
return lineString([startCoord, endCoord]);
|
|
1802
|
+
break;
|
|
1803
|
+
case "Polygon":
|
|
1804
|
+
obstacles = featureCollection([feature(getGeom(obstacles))]);
|
|
1805
|
+
break;
|
|
1806
|
+
default:
|
|
1807
|
+
throw new Error("invalid obstacles");
|
|
1808
|
+
}
|
|
1809
|
+
const collection = obstacles;
|
|
1810
|
+
collection.features.push(start, end);
|
|
1811
|
+
const box = index_default((0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(collection)), 1.15));
|
|
1812
|
+
if (!resolution) {
|
|
1813
|
+
const width = (0, import_distance4.default)([box[0], box[1]], [box[2], box[1]], options);
|
|
1814
|
+
resolution = width / 100;
|
|
1815
|
+
}
|
|
1816
|
+
collection.features.pop();
|
|
1817
|
+
collection.features.pop();
|
|
1818
|
+
const [west, south, east, north] = box;
|
|
1819
|
+
const xFraction = resolution / (0, import_distance4.default)([west, south], [east, south], options);
|
|
1820
|
+
const cellWidth = xFraction * (east - west);
|
|
1821
|
+
const yFraction = resolution / (0, import_distance4.default)([west, south], [west, north], options);
|
|
1822
|
+
const cellHeight = yFraction * (north - south);
|
|
1823
|
+
const bboxHorizontalSide = east - west;
|
|
1824
|
+
const bboxVerticalSide = north - south;
|
|
1825
|
+
const columns = Math.floor(bboxHorizontalSide / cellWidth);
|
|
1826
|
+
const rows = Math.floor(bboxVerticalSide / cellHeight);
|
|
1827
|
+
const deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;
|
|
1828
|
+
const deltaY = (bboxVerticalSide - rows * cellHeight) / 2;
|
|
1829
|
+
let closestToStart = null, closestToEnd = null, minDistStart = Infinity, minDistEnd = Infinity, currentY = north - deltaY, currentX = west + deltaX, row = 0, column = 0, distStart, distEnd, pt, isInsideObstacle;
|
|
1830
|
+
const roundLoopY = Math.ceil((currentY - south) / cellHeight);
|
|
1831
|
+
const roundLoopX = Math.ceil((east - currentX) / cellWidth);
|
|
1832
|
+
let totalRounds = roundLoopX * roundLoopY;
|
|
1833
|
+
const pointMatrix = [];
|
|
1834
|
+
const matrix = [];
|
|
1835
|
+
const obstacleTotal = collection.features.length;
|
|
1836
|
+
const obstacleFeatures = collection.features;
|
|
1837
|
+
let combinedObstacle = obstacleFeatures[0];
|
|
1838
|
+
let obstacleIndex = 0;
|
|
1839
|
+
for (obstacleIndex = 0; obstacleIndex < obstacleTotal; obstacleIndex++) {
|
|
1840
|
+
const nextObstacleFeature = obstacleFeatures[obstacleIndex + 1];
|
|
1841
|
+
if (!nextObstacleFeature) continue;
|
|
1842
|
+
try {
|
|
1843
|
+
combinedObstacle = (0, import_union.default)(
|
|
1844
|
+
featureCollection([combinedObstacle, nextObstacleFeature])
|
|
1845
|
+
);
|
|
1846
|
+
} catch (e) {
|
|
1847
|
+
console.log(e);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
while (totalRounds--) {
|
|
1851
|
+
pt = point([currentX, currentY]);
|
|
1852
|
+
isInsideObstacle = (0, import_boolean_point_in_polygon3.default)(pt, combinedObstacle);
|
|
1853
|
+
(0, import_set3.default)(matrix, `[${row}][${column}]`, isInsideObstacle ? 1 : 0);
|
|
1854
|
+
(0, import_set3.default)(pointMatrix, `[${row}][${column}]`, `${currentX}|${currentY}`);
|
|
1855
|
+
distStart = (0, import_distance4.default)(pt, start);
|
|
1856
|
+
if (!isInsideObstacle && distStart < minDistStart) {
|
|
1857
|
+
minDistStart = distStart;
|
|
1858
|
+
closestToStart = { x: column, y: row };
|
|
1859
|
+
}
|
|
1860
|
+
distEnd = (0, import_distance4.default)(pt, end);
|
|
1861
|
+
if (!isInsideObstacle && distEnd < minDistEnd) {
|
|
1862
|
+
minDistEnd = distEnd;
|
|
1863
|
+
closestToEnd = { x: column, y: row };
|
|
1864
|
+
}
|
|
1865
|
+
if (column < roundLoopX) {
|
|
1866
|
+
currentX += cellWidth;
|
|
1867
|
+
column++;
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
if (row < roundLoopY) {
|
|
1871
|
+
currentY -= cellHeight;
|
|
1872
|
+
currentX = west + deltaX;
|
|
1873
|
+
column = 0;
|
|
1874
|
+
row++;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
const finder = new import_pathfinding.default.AStarFinder({
|
|
1878
|
+
allowDiagonal: true,
|
|
1879
|
+
dontCrossCorners: true,
|
|
1880
|
+
heuristic: import_pathfinding.default.Heuristic.euclidean
|
|
1881
|
+
});
|
|
1882
|
+
const grid = new import_pathfinding.default.Grid(matrix);
|
|
1883
|
+
const startOnMatrix = [closestToStart.x, closestToStart.y];
|
|
1884
|
+
const endOnMatrix = [closestToEnd.x, closestToEnd.y];
|
|
1885
|
+
let result = finder.findPath(...startOnMatrix, ...endOnMatrix, grid);
|
|
1886
|
+
if (result.length > 0) {
|
|
1887
|
+
result = stringPull(grid, result);
|
|
1888
|
+
const clearanceGrid = buildClearanceGrid(matrix);
|
|
1889
|
+
const isWalkable = (x, y) => grid.isInside(x, y) && grid.isWalkableAt(x, y);
|
|
1890
|
+
result = centerlineSnapPath(result, clearanceGrid, isWalkable);
|
|
1891
|
+
result = stringPull(grid, result);
|
|
1892
|
+
result = pruneSmallAngles(result);
|
|
1893
|
+
result = pruneShortSegments(result);
|
|
1894
|
+
}
|
|
1895
|
+
result.pop();
|
|
1896
|
+
result.shift();
|
|
1897
|
+
const path = [startCoord];
|
|
1898
|
+
result.forEach((coord) => {
|
|
1899
|
+
const coords = pointMatrix[coord[1]][coord[0]].split("|");
|
|
1900
|
+
path.push([+coords[0], +coords[1]]);
|
|
1901
|
+
});
|
|
1902
|
+
path.push(endCoord);
|
|
1903
|
+
return (0, import_clean_coords.cleanCoords)(lineString(path));
|
|
1904
|
+
}
|
|
1905
|
+
var shortestPath_default = shortestPath;
|
|
1906
|
+
|
|
1907
|
+
// src/data/navigate/steps/path/index.ts
|
|
1908
|
+
var createStepPathUtils = (options) => {
|
|
1909
|
+
const resolution = options.resolution ?? 88e-5;
|
|
1910
|
+
const { units = [], kiosks = [], fixtures = [] } = options.data;
|
|
1911
|
+
const possibleObstacleFeatures = [...units, ...kiosks, ...fixtures];
|
|
1912
|
+
const filterObstaclesByOrdinal = (levelId) => {
|
|
1913
|
+
return possibleObstacleFeatures.filter(({ feature_type, properties, geometry }) => {
|
|
1914
|
+
return properties.level_id === levelId && ["Polygon", "MultiPolygon"].includes(geometry.type) && (OBSTACLE_FEATURE_TYPES.includes(feature_type) || "category" in properties && OBSTACLE_CATEGORIES.includes(properties.category));
|
|
1915
|
+
});
|
|
1916
|
+
};
|
|
1917
|
+
const findObstaclesFromWalkway = (intermediaryUnit, exceptionIds = []) => {
|
|
1918
|
+
const result = featureCollection([]);
|
|
1919
|
+
if (!intermediaryUnit) return result;
|
|
1920
|
+
const walkwayLevelId = intermediaryUnit.properties.level_id;
|
|
1921
|
+
const obstacleOnLevel = filterObstaclesByOrdinal(walkwayLevelId).filter(
|
|
1922
|
+
(obstacle) => !exceptionIds.includes(obstacle.id)
|
|
1923
|
+
);
|
|
1924
|
+
const relatedObstacleWithIntermediary = obstacleOnLevel.reduce(
|
|
1925
|
+
(obstacles, feature2) => {
|
|
1926
|
+
if (
|
|
1927
|
+
// Prevent detecting itself as an obstacle
|
|
1928
|
+
// Ex. Unable to draw a line to amenity located with in a room as room is also consider as obstacle
|
|
1929
|
+
feature2.id !== intermediaryUnit.id && ((0, import_boolean_overlap.default)(intermediaryUnit, feature2) || (0, import_boolean_intersects.default)(intermediaryUnit, feature2))
|
|
1930
|
+
) {
|
|
1931
|
+
const polygons = getType(feature2) === "Polygon" ? [polygon(feature2.geometry.coordinates, { id: feature2.id })] : feature2.geometry.coordinates.map((ring) => polygon(ring, { id: feature2.id }));
|
|
1932
|
+
obstacles.push(...polygons);
|
|
1933
|
+
}
|
|
1934
|
+
return obstacles;
|
|
1935
|
+
},
|
|
1936
|
+
[]
|
|
1937
|
+
);
|
|
1938
|
+
const intermediaryExtends = (0, import_envelope.default)(intermediaryUnit);
|
|
1939
|
+
const walkwayPerimeter = (0, import_difference.default)(
|
|
1940
|
+
featureCollection([intermediaryExtends, intermediaryUnit])
|
|
1941
|
+
);
|
|
1942
|
+
result.features.push(...relatedObstacleWithIntermediary, walkwayPerimeter);
|
|
1943
|
+
return result;
|
|
1944
|
+
};
|
|
1945
|
+
const findPathOnArea = (originPoint, destinationPoint, options2) => {
|
|
1946
|
+
const { obstacles = featureCollection([]), resolution: resolution2, properties } = options2 || {};
|
|
1947
|
+
const stepPath = shortestPath_default(originPoint, destinationPoint, {
|
|
1948
|
+
obstacles,
|
|
1949
|
+
smoothenPath: false,
|
|
1950
|
+
resolution: resolution2
|
|
1951
|
+
});
|
|
1952
|
+
stepPath.properties = properties;
|
|
1953
|
+
return stepPath;
|
|
1954
|
+
};
|
|
1955
|
+
const findStepPath = (from, to, intermediaries) => {
|
|
1956
|
+
const t0 = performance.now();
|
|
1957
|
+
const relatedWalkablePlatform = intermediaries.find(
|
|
1958
|
+
(feature2) => WALKABLE_CATEGORY.includes(feature2.properties.category)
|
|
1959
|
+
);
|
|
1960
|
+
const exceptionFeatureIds = [];
|
|
1961
|
+
const obstacles = findObstaclesFromWalkway(
|
|
1962
|
+
relatedWalkablePlatform,
|
|
1963
|
+
import_lodash11.default.compact(exceptionFeatureIds)
|
|
1964
|
+
);
|
|
1965
|
+
const line = findPathOnArea(from, to, {
|
|
1966
|
+
resolution,
|
|
1967
|
+
obstacles
|
|
1968
|
+
});
|
|
1969
|
+
return line.geometry.coordinates;
|
|
1970
|
+
};
|
|
1971
|
+
return {
|
|
1972
|
+
findStepPath
|
|
1973
|
+
};
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1976
|
+
// src/data/navigate/steps/utils/combineWalkwaySteps.ts
|
|
1977
|
+
var import_uniq = __toESM(require("lodash/uniq"));
|
|
1978
|
+
var combineWalkwaySteps = (steps) => {
|
|
1979
|
+
let result = [];
|
|
1980
|
+
for (let i = 0; i < steps.length; i++) {
|
|
1981
|
+
const thisStep = steps[i];
|
|
1982
|
+
if (i === steps.length - 1) {
|
|
1983
|
+
result.push(thisStep);
|
|
1984
|
+
continue;
|
|
1985
|
+
}
|
|
1986
|
+
const nextStep = steps[i + 1];
|
|
1987
|
+
if (thisStep.intermediaryCategory === "walkway" && nextStep.intermediaryCategory === "walkway" && thisStep.from.source.type === "opening" && nextStep.from.source.type === "opening") {
|
|
1988
|
+
result.push({
|
|
1989
|
+
from: thisStep.from,
|
|
1990
|
+
to: nextStep.to,
|
|
1991
|
+
levelIds: (0, import_uniq.default)([...thisStep.levelIds, ...nextStep.levelIds]),
|
|
1992
|
+
ordinals: (0, import_uniq.default)([...thisStep.ordinals, ...nextStep.ordinals]),
|
|
1993
|
+
intermediaryCategory: "walkway",
|
|
1994
|
+
description: nextStep.description,
|
|
1995
|
+
path: [
|
|
1996
|
+
...thisStep.path,
|
|
1997
|
+
...nextStep.path
|
|
1998
|
+
]
|
|
1999
|
+
});
|
|
2000
|
+
i++;
|
|
2001
|
+
} else {
|
|
2002
|
+
result.push(thisStep);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
return result;
|
|
2006
|
+
};
|
|
2007
|
+
|
|
2008
|
+
// src/data/navigate/steps/createStepUtils.ts
|
|
2009
|
+
var createStepUtils = (options) => {
|
|
2010
|
+
const { data: { units, relationships }, findByIdSync } = options;
|
|
2011
|
+
const stepPathUtils = createStepPathUtils({ ...options, resolution: 88e-5 });
|
|
2012
|
+
const findUnitBetweenOpenings = (originId, destinationId) => {
|
|
2013
|
+
const origin = findByIdSync(originId);
|
|
2014
|
+
const destination = findByIdSync(destinationId);
|
|
2015
|
+
const matchedOne = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(origin.id));
|
|
2016
|
+
const matchOneUnits = matchedOne ? [matchedOne.properties.origin, matchedOne.properties.destination] : [];
|
|
2017
|
+
const matchedTwo = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(destination.id));
|
|
2018
|
+
const matchTwoUnits = matchedTwo ? [matchedTwo.properties.origin, matchedTwo.properties.destination] : [];
|
|
2019
|
+
const unitIds = (0, import_intersectionBy.default)(matchOneUnits, matchTwoUnits, "id");
|
|
2020
|
+
return unitIds.map(({ id }) => findByIdSync(id));
|
|
2021
|
+
};
|
|
2022
|
+
const findHorizontalIntermediary = (from, to) => {
|
|
2023
|
+
if (from.source.type !== "opening") {
|
|
2024
|
+
const unit = findContainingUnitAtPoint(from.point, from.levelId, units);
|
|
2025
|
+
return unit ? [unit] : [];
|
|
2026
|
+
}
|
|
2027
|
+
if (to.source.type !== "opening") {
|
|
2028
|
+
const unit = findContainingUnitAtPoint(to.point, to.levelId, units);
|
|
2029
|
+
return unit ? [unit] : [];
|
|
2030
|
+
}
|
|
2031
|
+
return findUnitBetweenOpenings(from.source.id, to.source.id);
|
|
2032
|
+
};
|
|
2033
|
+
const findVerticalIntermediary = (from, to) => {
|
|
2034
|
+
const firstOpeningId = from.source.id;
|
|
2035
|
+
const secondOpeningId = to.source.id;
|
|
2036
|
+
const relationship = relationships.find((rel) => {
|
|
2037
|
+
return rel.properties.origin?.id === firstOpeningId && rel.properties.destination?.id === secondOpeningId || rel.properties.origin?.id === secondOpeningId && rel.properties.destination?.id === firstOpeningId;
|
|
2038
|
+
});
|
|
2039
|
+
const intermediaryTypeAndId = relationship.properties.intermediary;
|
|
2040
|
+
return intermediaryTypeAndId.map(({ id }) => findByIdSync(id));
|
|
2041
|
+
};
|
|
2042
|
+
const formatCategoryLabel = (category) => {
|
|
2043
|
+
return (0, import_lodash12.capitalize)(category);
|
|
2044
|
+
};
|
|
2045
|
+
const getNextStepIntermediary = (from, to, intermediary) => {
|
|
2046
|
+
if (to.type === "end") return to.name;
|
|
2047
|
+
const intermediaryIds = intermediary.map((int) => int.id);
|
|
2048
|
+
const relationship = relationships.find((rel) => rel.properties.intermediary.map((int) => int.id).includes(to.source.id));
|
|
2049
|
+
if (!relationship) return to.name;
|
|
2050
|
+
const candidates = [relationship.properties.origin.id, relationship.properties.destination.id];
|
|
2051
|
+
const nextUnitId = candidates.filter((id) => !intermediaryIds.includes(id))[0];
|
|
2052
|
+
if (!nextUnitId) return to.name;
|
|
2053
|
+
const nextUnit = findByIdSync(nextUnitId);
|
|
2054
|
+
return { en: formatCategoryLabel(`${nextUnit.properties.category}`) };
|
|
2055
|
+
};
|
|
2056
|
+
const createHorizontalStep = (from, to) => {
|
|
2057
|
+
const intermediary = findHorizontalIntermediary(from, to);
|
|
2058
|
+
const intermediaryCategories = intermediary.map((unit) => unit.properties.category);
|
|
2059
|
+
const intermediaryCategory = intermediaryCategories.length > 0 ? intermediaryCategories[0] : "unspecified";
|
|
2060
|
+
const toward = getNextStepIntermediary(from, to, intermediary);
|
|
2061
|
+
const landmark = to.hint?.kind === "landmark" ? to.hint.name : null;
|
|
2062
|
+
const path = stepPathUtils.findStepPath(from.point, to.point, intermediary);
|
|
2063
|
+
const step = {
|
|
2064
|
+
from,
|
|
2065
|
+
to,
|
|
2066
|
+
levelIds: [from.levelId],
|
|
2067
|
+
ordinals: [from.ordinal],
|
|
2068
|
+
intermediaryCategory,
|
|
2069
|
+
description: describeHorizontalStep(intermediaryCategory, toward, landmark),
|
|
2070
|
+
path: path.map((coord) => [...coord, from.ordinal * 9])
|
|
2071
|
+
};
|
|
2072
|
+
return step;
|
|
2073
|
+
};
|
|
2074
|
+
const createVerticalStep = (from, to) => {
|
|
2075
|
+
const intermediary = findVerticalIntermediary(from, to);
|
|
2076
|
+
const intermediaryCategories = intermediary.map((unit) => unit.properties.category);
|
|
2077
|
+
const intermediaryCategory = intermediaryCategories.length > 0 ? intermediaryCategories[0] : "unspecified";
|
|
2078
|
+
const fromLevel = findByIdSync(from.levelId);
|
|
2079
|
+
const toLevel = findByIdSync(to.levelId);
|
|
2080
|
+
return {
|
|
2081
|
+
from,
|
|
2082
|
+
to,
|
|
2083
|
+
levelIds: [from.levelId, to.levelId],
|
|
2084
|
+
ordinals: [from.ordinal, to.ordinal],
|
|
2085
|
+
intermediaryCategory,
|
|
2086
|
+
description: describeVerticalStep(fromLevel, toLevel, intermediaryCategory),
|
|
2087
|
+
path: [
|
|
2088
|
+
[...from.point, from.ordinal * 9],
|
|
2089
|
+
[...to.point, to.ordinal * 9]
|
|
2090
|
+
]
|
|
2091
|
+
};
|
|
2092
|
+
};
|
|
2093
|
+
const isVertical = (from, to) => {
|
|
2094
|
+
const fromLevel = findByIdSync(from.levelId);
|
|
2095
|
+
const toLevel = findByIdSync(to.levelId);
|
|
2096
|
+
return !!fromLevel && !!toLevel && fromLevel.properties.ordinal !== toLevel.properties.ordinal;
|
|
2097
|
+
};
|
|
2098
|
+
const toSteps = (waypoints) => {
|
|
2099
|
+
let steps = [];
|
|
2100
|
+
const t0_allSteps = performance.now();
|
|
2101
|
+
for (let i = 0; i < waypoints.length - 1; i++) {
|
|
2102
|
+
const from = waypoints[i];
|
|
2103
|
+
const to = waypoints[i + 1];
|
|
2104
|
+
const t0 = performance.now();
|
|
2105
|
+
const step = isVertical(from, to) ? createVerticalStep(from, to) : createHorizontalStep(from, to);
|
|
2106
|
+
steps.push(step);
|
|
2107
|
+
const t1 = performance.now();
|
|
2108
|
+
trace("nav", ` \u2502 \u251C\u2500 #${i} ${from.id.padEnd(25)} \u2192 ${`(${step.intermediaryCategory})`.padEnd(12)} \u2192 ${to.id}`, t1 - t0);
|
|
2109
|
+
trace("nav", ` \u2502 \u2502 ${step.description.text}`, void 0, "#bada55");
|
|
2110
|
+
}
|
|
2111
|
+
const simplifySteps = combineWalkwaySteps(steps);
|
|
2112
|
+
const t1_allSteps = performance.now();
|
|
2113
|
+
trace("nav", " \u2502 \u2514\u2500 Total ", t1_allSteps - t0_allSteps);
|
|
2114
|
+
return simplifySteps;
|
|
2115
|
+
};
|
|
2116
|
+
return {
|
|
2117
|
+
toSteps
|
|
2118
|
+
};
|
|
2119
|
+
};
|
|
2120
|
+
|
|
2121
|
+
// src/data/navigate/utils/timeDistance.ts
|
|
2122
|
+
var import_length = __toESM(require("@turf/length"));
|
|
2123
|
+
var WALKING_SPEED = 1.4;
|
|
2124
|
+
var calculatePathLength = (feature2) => (0, import_length.default)(feature2, { units: "kilometers" }) * 1e3;
|
|
2125
|
+
var calculateTravelingDuration = (distance5) => {
|
|
2126
|
+
const duration = distance5 / WALKING_SPEED;
|
|
2127
|
+
const minutes = Math.round(duration / 60);
|
|
2128
|
+
return minutes > 0 ? minutes : 1;
|
|
2129
|
+
};
|
|
2130
|
+
var calculateTotalDistance = (steps = []) => {
|
|
2131
|
+
return steps.reduce((acc, { path }) => acc + calculatePathLength(lineString(path)), 0);
|
|
2132
|
+
};
|
|
2133
|
+
var calculateRoundedDistance = (distance5) => {
|
|
2134
|
+
return Math.round(distance5 - distance5 % 25);
|
|
2135
|
+
};
|
|
2136
|
+
|
|
2137
|
+
// src/data/navigate/type-guard.ts
|
|
2138
|
+
function isCoordinateOrdinalString(id) {
|
|
2139
|
+
return /^-?\d+(\.\d+)?,-?\d+(\.\d+)?,-?\d+(\.\d+)?o$/.test(id);
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
// src/data/navigate/utils/createFindByIdSync.ts
|
|
2143
|
+
var createFindByIdSync = (data) => {
|
|
2144
|
+
const { amenities = [], anchors = [], fixtures = [], levels = [], kiosks = [], relationships = [], occupants = [], openings = [], units } = data;
|
|
2145
|
+
const featureById = /* @__PURE__ */ new Map();
|
|
2146
|
+
const entries = [
|
|
2147
|
+
...amenities,
|
|
2148
|
+
...anchors,
|
|
2149
|
+
...fixtures,
|
|
2150
|
+
...levels,
|
|
2151
|
+
...kiosks,
|
|
2152
|
+
...relationships,
|
|
2153
|
+
...occupants,
|
|
2154
|
+
...openings,
|
|
2155
|
+
...units
|
|
2156
|
+
];
|
|
2157
|
+
for (const f of entries) featureById.set(f.id, f);
|
|
2158
|
+
const findByIdSync = (id) => {
|
|
2159
|
+
return featureById.get(id);
|
|
2160
|
+
};
|
|
2161
|
+
return { findByIdSync };
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
// src/data/navigate/waypoint/createWaypointUtils.ts
|
|
2165
|
+
var import_center9 = require("@turf/center");
|
|
2166
|
+
|
|
2167
|
+
// src/data/navigate/waypoint/extractEndWaypoint.ts
|
|
2168
|
+
var import_center6 = require("@turf/center");
|
|
2169
|
+
|
|
2170
|
+
// src/data/navigate/waypoint/featureIdGuard.ts
|
|
2171
|
+
var isOccupant = (id) => !!id && id.startsWith("occupant-");
|
|
2172
|
+
var isUnit = (id) => !!id && id.startsWith("unit-");
|
|
2173
|
+
var isKiosk = (id) => !!id && id.startsWith("kiosk-");
|
|
2174
|
+
var isOpening = (id) => !!id && id.startsWith("opening-");
|
|
2175
|
+
|
|
2176
|
+
// src/data/navigate/waypoint/extractEndWaypoint.ts
|
|
2177
|
+
var extractEndPoint = (path, options) => {
|
|
2178
|
+
const { findByIdSync } = options;
|
|
2179
|
+
const [c, b, a] = path.slice(-3);
|
|
2180
|
+
if (isOccupant(a) && isUnit(b) && isOpening(c)) {
|
|
2181
|
+
const occ = findByIdSync(a);
|
|
2182
|
+
const opening = findByIdSync(c);
|
|
2183
|
+
const level = findByIdSync(opening.properties.level_id);
|
|
2184
|
+
return [
|
|
2185
|
+
{
|
|
2186
|
+
id: occ.id,
|
|
2187
|
+
type: "end",
|
|
2188
|
+
name: occ.properties.name,
|
|
2189
|
+
point: (0, import_center6.center)(opening).geometry.coordinates,
|
|
2190
|
+
levelId: opening.properties.level_id,
|
|
2191
|
+
ordinal: level.properties.ordinal,
|
|
2192
|
+
source: { type: "opening", id: opening.id }
|
|
2193
|
+
},
|
|
2194
|
+
path.slice(0, -3)
|
|
2195
|
+
];
|
|
2196
|
+
}
|
|
2197
|
+
if (isOccupant(a) && isKiosk(b)) {
|
|
2198
|
+
const occ = findByIdSync(a);
|
|
2199
|
+
const kiosk = findByIdSync(b);
|
|
2200
|
+
const level = findByIdSync(kiosk.properties.level_id);
|
|
2201
|
+
return [
|
|
2202
|
+
{
|
|
2203
|
+
id: occ.id,
|
|
2204
|
+
type: "end",
|
|
2205
|
+
name: occ.properties.name,
|
|
2206
|
+
point: (0, import_center6.center)(kiosk).geometry.coordinates,
|
|
2207
|
+
levelId: kiosk.properties.level_id,
|
|
2208
|
+
ordinal: level.properties.ordinal,
|
|
2209
|
+
source: { type: "kiosk", id: kiosk.id }
|
|
2210
|
+
},
|
|
2211
|
+
path.slice(0, -2)
|
|
2212
|
+
];
|
|
2213
|
+
}
|
|
2214
|
+
if (isCoordinateOrdinalString(a) && isOpening(b)) {
|
|
2215
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(a);
|
|
2216
|
+
const opening = findByIdSync(b);
|
|
2217
|
+
return [
|
|
2218
|
+
{
|
|
2219
|
+
id: a,
|
|
2220
|
+
type: "end",
|
|
2221
|
+
name: { en: a },
|
|
2222
|
+
point: [lng, lat],
|
|
2223
|
+
levelId: opening.properties.level_id,
|
|
2224
|
+
ordinal,
|
|
2225
|
+
source: { type: "coordinate", raw: a }
|
|
2226
|
+
},
|
|
2227
|
+
path.slice(0, -1)
|
|
2228
|
+
];
|
|
2229
|
+
}
|
|
2230
|
+
return [null, path];
|
|
2231
|
+
};
|
|
2232
|
+
|
|
2233
|
+
// src/data/navigate/waypoint/extractStartWaypoint.ts
|
|
2234
|
+
var import_center7 = require("@turf/center");
|
|
2235
|
+
var extractStartPoint = (path, options) => {
|
|
2236
|
+
const { findByIdSync } = options;
|
|
2237
|
+
const [a, b, c] = path;
|
|
2238
|
+
if (isOccupant(a) && isUnit(b) && isOpening(c)) {
|
|
2239
|
+
const occ = findByIdSync(a);
|
|
2240
|
+
const opening = findByIdSync(c);
|
|
2241
|
+
const level = findByIdSync(opening.properties.level_id);
|
|
2242
|
+
return [
|
|
2243
|
+
{
|
|
2244
|
+
id: occ.id,
|
|
2245
|
+
type: "start",
|
|
2246
|
+
name: occ.properties.name,
|
|
2247
|
+
point: (0, import_center7.center)(opening).geometry.coordinates,
|
|
2248
|
+
levelId: opening.properties.level_id,
|
|
2249
|
+
ordinal: level.properties.ordinal,
|
|
2250
|
+
source: { type: "opening", id: opening.id }
|
|
2251
|
+
},
|
|
2252
|
+
path.slice(3)
|
|
2253
|
+
];
|
|
2254
|
+
}
|
|
2255
|
+
if (isOccupant(a) && isKiosk(b)) {
|
|
2256
|
+
const occ = findByIdSync(a);
|
|
2257
|
+
const kiosk = findByIdSync(b);
|
|
2258
|
+
const level = findByIdSync(kiosk.properties.level_id);
|
|
2259
|
+
return [
|
|
2260
|
+
{
|
|
2261
|
+
id: occ.id,
|
|
2262
|
+
type: "start",
|
|
2263
|
+
name: occ.properties.name,
|
|
2264
|
+
point: (0, import_center7.center)(kiosk).geometry.coordinates,
|
|
2265
|
+
levelId: kiosk.properties.level_id,
|
|
2266
|
+
ordinal: level.properties.ordinal,
|
|
2267
|
+
source: { type: "kiosk", id: kiosk.id }
|
|
2268
|
+
},
|
|
2269
|
+
path.slice(2)
|
|
2270
|
+
];
|
|
2271
|
+
}
|
|
2272
|
+
if (isCoordinateOrdinalString(a) && isOpening(b)) {
|
|
2273
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(a);
|
|
2274
|
+
const opening = findByIdSync(b);
|
|
2275
|
+
return [
|
|
2276
|
+
{
|
|
2277
|
+
id: a,
|
|
2278
|
+
type: "start",
|
|
2279
|
+
name: { en: a },
|
|
2280
|
+
point: [lng, lat],
|
|
2281
|
+
levelId: opening.properties.level_id,
|
|
2282
|
+
ordinal,
|
|
2283
|
+
source: { type: "coordinate", raw: a }
|
|
2284
|
+
},
|
|
2285
|
+
path.slice(1)
|
|
2286
|
+
];
|
|
2287
|
+
}
|
|
2288
|
+
return [null, path];
|
|
2289
|
+
};
|
|
2290
|
+
|
|
2291
|
+
// src/data/navigate/landmark/createLandmarkUtils.ts
|
|
2292
|
+
var import_center8 = require("@turf/center");
|
|
2293
|
+
var import_distance5 = __toESM(require("@turf/distance"));
|
|
2294
|
+
var NEARBY_DISTANCE = 30;
|
|
2295
|
+
var createLandmarkUtils = (options) => {
|
|
2296
|
+
const { data, findByIdSync } = options;
|
|
2297
|
+
const { occupants = [] } = data;
|
|
2298
|
+
const occupantToLandmark = (occupant) => {
|
|
2299
|
+
const locationType = occupant.properties.unit_id ? "unit" : "kiosk";
|
|
2300
|
+
const locationId = locationType === "unit" ? occupant.properties.unit_id : occupant.properties.kiosk_id;
|
|
2301
|
+
const location = locationType === "unit" ? findByIdSync(locationId) : findByIdSync(locationId);
|
|
2302
|
+
const level = findByIdSync(location.properties.level_id);
|
|
2303
|
+
return {
|
|
2304
|
+
name: occupant.properties.name,
|
|
2305
|
+
point: (0, import_center8.center)(location.geometry).geometry.coordinates,
|
|
2306
|
+
level_id: location.properties.level_id,
|
|
2307
|
+
is_priority: occupant.properties.is_landmark,
|
|
2308
|
+
ordinal: level.properties.ordinal
|
|
2309
|
+
};
|
|
2310
|
+
};
|
|
2311
|
+
const landmarks = [
|
|
2312
|
+
...occupants.map(occupantToLandmark)
|
|
2313
|
+
];
|
|
2314
|
+
const findNearbyLandmarks = (point2, levelId) => {
|
|
2315
|
+
if (point2 === null || levelId === null) return [];
|
|
2316
|
+
return landmarks.map((landmark) => {
|
|
2317
|
+
const landmarkAndDistance = {
|
|
2318
|
+
landmark,
|
|
2319
|
+
d: (0, import_distance5.default)(point2, landmark.point, { units: "meters" })
|
|
2320
|
+
};
|
|
2321
|
+
return landmarkAndDistance;
|
|
2322
|
+
}).filter(({ landmark, d }) => d <= NEARBY_DISTANCE && landmark.level_id === levelId).sort((a, b) => {
|
|
2323
|
+
const aPriority = a.landmark.is_priority ? 0 : 1;
|
|
2324
|
+
const bPriority = b.landmark.is_priority ? 0 : 1;
|
|
2325
|
+
if (aPriority !== bPriority) return aPriority - bPriority;
|
|
2326
|
+
return a.d - b.d;
|
|
2327
|
+
}).map(({ landmark }) => landmark);
|
|
2328
|
+
};
|
|
2329
|
+
const findNearestLandmark = (point2, levelId) => {
|
|
2330
|
+
const nearbyLandmarks = findNearbyLandmarks(point2, levelId);
|
|
2331
|
+
const nearestLandmark = nearbyLandmarks.length > 0 ? nearbyLandmarks[0] : null;
|
|
2332
|
+
return nearestLandmark;
|
|
2333
|
+
};
|
|
2334
|
+
return { findNearbyLandmarks, findNearestLandmark };
|
|
2335
|
+
};
|
|
2336
|
+
|
|
2337
|
+
// src/data/navigate/waypoint/createWaypointUtils.ts
|
|
2338
|
+
var createWaypointUtils = (options) => {
|
|
2339
|
+
const { findByIdSync } = options;
|
|
2340
|
+
const landmarkUtils = createLandmarkUtils(options);
|
|
2341
|
+
const toWaypoints = (path) => {
|
|
2342
|
+
const [startPoint, middleAndEndPoints] = extractStartPoint(path, options);
|
|
2343
|
+
const [endPoint, middlePoints] = extractEndPoint(middleAndEndPoints, options);
|
|
2344
|
+
const waypoints = middlePoints.map((openingId) => {
|
|
2345
|
+
const opening = findByIdSync(openingId);
|
|
2346
|
+
const level = findByIdSync(opening.properties.level_id);
|
|
2347
|
+
const coordinates = (0, import_center9.center)(opening).geometry.coordinates;
|
|
2348
|
+
const landmark = landmarkUtils.findNearestLandmark(coordinates, opening.properties.level_id);
|
|
2349
|
+
return {
|
|
2350
|
+
id: `${opening.properties.level_id}:${openingId}`,
|
|
2351
|
+
type: "between",
|
|
2352
|
+
point: coordinates,
|
|
2353
|
+
name: null,
|
|
2354
|
+
levelId: opening.properties.level_id,
|
|
2355
|
+
ordinal: level.properties.ordinal,
|
|
2356
|
+
hint: landmark ? { kind: "landmark", name: landmark.name } : void 0,
|
|
2357
|
+
source: { type: "opening", id: opening.id }
|
|
2358
|
+
};
|
|
2359
|
+
});
|
|
2360
|
+
return [startPoint, ...waypoints, endPoint];
|
|
2361
|
+
};
|
|
2362
|
+
return { toWaypoints };
|
|
2363
|
+
};
|
|
2364
|
+
|
|
2365
|
+
// src/data/navigate/getNavigateClient.ts
|
|
2366
|
+
var getNavigateClient = (options) => {
|
|
2367
|
+
const { data } = options;
|
|
2368
|
+
const { levels, units } = data;
|
|
2369
|
+
trace("nav", "\u2713 prepare");
|
|
2370
|
+
const t0 = performance.now();
|
|
2371
|
+
trace("nav", " \u251C\u2500 createGraph (dijkstra)");
|
|
2372
|
+
const { defaultGraph, accessibleGraph, addCoordinateOrdinalNode } = prepareGraph({ data });
|
|
2373
|
+
const t1 = performance.now();
|
|
2374
|
+
trace("nav", " \u2502 \u2514\u2500 Total ", t1 - t0);
|
|
2375
|
+
const t2 = performance.now();
|
|
2376
|
+
const { findByIdSync } = createFindByIdSync(data);
|
|
2377
|
+
const t3 = performance.now();
|
|
2378
|
+
trace("nav", " \u2514\u2500 findByIdSync", t3 - t2);
|
|
2379
|
+
const findCoordinateOrdinalUnit = (params) => {
|
|
2380
|
+
const [lat, lng, ordinal] = parseOrdinalCoordinate(params);
|
|
2381
|
+
const levelIdsWithOrdinal = levels.filter((level) => level.properties.ordinal === ordinal).map((level) => level.id);
|
|
2382
|
+
const unit = units.find((unit2) => levelIdsWithOrdinal.includes(unit2.properties.level_id) && (0, import_boolean_point_in_polygon4.booleanPointInPolygon)([lat, lng], unit2));
|
|
2383
|
+
return unit;
|
|
2384
|
+
};
|
|
2385
|
+
const stepUtils = createStepUtils({ ...options, findByIdSync });
|
|
2386
|
+
const waypointUtils = createWaypointUtils({ ...options, findByIdSync });
|
|
2387
|
+
const findRoute = async (routeOriginParam, routeDestinationParam, options2) => {
|
|
2388
|
+
if (!routeOriginParam || !routeDestinationParam) return null;
|
|
2389
|
+
const graph = options2?.mode === "accessible" ? accessibleGraph : defaultGraph;
|
|
2390
|
+
if (isCoordinateOrdinalString(routeOriginParam)) {
|
|
2391
|
+
const walkwayUnit = findCoordinateOrdinalUnit(routeOriginParam);
|
|
2392
|
+
addCoordinateOrdinalNode(routeOriginParam, walkwayUnit);
|
|
2393
|
+
}
|
|
2394
|
+
if (isCoordinateOrdinalString(routeDestinationParam)) {
|
|
2395
|
+
const walkwayUnit = findCoordinateOrdinalUnit(routeDestinationParam);
|
|
2396
|
+
addCoordinateOrdinalNode(routeDestinationParam, walkwayUnit);
|
|
2397
|
+
}
|
|
2398
|
+
try {
|
|
2399
|
+
trace("nav", "\u2713 findRoute", 0);
|
|
2400
|
+
const t02 = performance.now();
|
|
2401
|
+
const path = graph.path(routeOriginParam, routeDestinationParam);
|
|
2402
|
+
const t12 = performance.now();
|
|
2403
|
+
trace("nav", " \u251C\u2500 path (dijkstra)", t12 - t02);
|
|
2404
|
+
const waypoints = waypointUtils.toWaypoints(path);
|
|
2405
|
+
const t22 = performance.now();
|
|
2406
|
+
trace("nav", " \u251C\u2500 toWaypoints", t22 - t12);
|
|
2407
|
+
trace("nav", " \u251C\u2500 toSteps", 0);
|
|
2408
|
+
const steps = stepUtils.toSteps(waypoints);
|
|
2409
|
+
const t32 = performance.now();
|
|
2410
|
+
const totalDistance = calculateTotalDistance(steps);
|
|
2411
|
+
const roundedDistance = calculateRoundedDistance(totalDistance);
|
|
2412
|
+
const duration = calculateTravelingDuration(totalDistance);
|
|
2413
|
+
const t4 = performance.now();
|
|
2414
|
+
trace("nav", " \u2514\u2500 postProcess", t4 - t32);
|
|
2415
|
+
return {
|
|
2416
|
+
distance: roundedDistance,
|
|
2417
|
+
duration,
|
|
2418
|
+
steps
|
|
2419
|
+
};
|
|
2420
|
+
} catch (error) {
|
|
2421
|
+
console.log(error);
|
|
2422
|
+
throw error;
|
|
2423
|
+
}
|
|
2424
|
+
};
|
|
2425
|
+
return {
|
|
2426
|
+
findRoute,
|
|
2427
|
+
findByIdSync
|
|
2428
|
+
};
|
|
2429
|
+
};
|
|
2430
|
+
|
|
2431
|
+
// src/data/getDataClient.ts
|
|
2432
|
+
var getDataClient = (options) => {
|
|
2433
|
+
let searchClient;
|
|
2434
|
+
let navigateClient;
|
|
2435
|
+
const observers = /* @__PURE__ */ new Map();
|
|
2436
|
+
const queryClient = options.queryClient ?? new import_query_core.QueryClient();
|
|
2437
|
+
const { mode = "delivery", projectId, apiKey, baseUrl, previewToken } = options;
|
|
2438
|
+
if (!projectId)
|
|
2439
|
+
throw new Error(
|
|
2440
|
+
"Cannot create VenueDataClient. Reason: `projectId` is missing"
|
|
2441
|
+
);
|
|
2442
|
+
if (mode === "delivery" && !apiKey)
|
|
2443
|
+
throw new Error(
|
|
2444
|
+
"Cannot create VenueDataClient. Reason: `apiKey` is missing"
|
|
2445
|
+
);
|
|
676
2446
|
if (mode === "preview" && !previewToken)
|
|
677
2447
|
throw new Error(
|
|
678
2448
|
"Cannot create VenueDataClient. Reason: `previewToken` is missing"
|
|
@@ -690,7 +2460,7 @@ var getDataClient = (options) => {
|
|
|
690
2460
|
}
|
|
691
2461
|
};
|
|
692
2462
|
const internalFindById = async (id) => {
|
|
693
|
-
if (id === null) return null;
|
|
2463
|
+
if (id === null || id === void 0) return null;
|
|
694
2464
|
const featureType = id.slice(0, id.lastIndexOf("-"));
|
|
695
2465
|
const feature2 = await queryClient.ensureQueryData({
|
|
696
2466
|
queryKey: ["_deliveryapi", featureType, id],
|
|
@@ -770,135 +2540,61 @@ var getDataClient = (options) => {
|
|
|
770
2540
|
id,
|
|
771
2541
|
params
|
|
772
2542
|
);
|
|
773
|
-
const feature2 = await queryClient.ensureQueryData(findQueryOptions);
|
|
774
|
-
return feature2;
|
|
775
|
-
}
|
|
776
|
-
return {
|
|
777
|
-
projectId,
|
|
778
|
-
queryClient,
|
|
779
|
-
registerObserver,
|
|
780
|
-
destroyObserver,
|
|
781
|
-
destroyObservers,
|
|
782
|
-
createFilterByTypeQueryOptions,
|
|
783
|
-
createFindByIdQueryOptions,
|
|
784
|
-
filterByType,
|
|
785
|
-
findById
|
|
786
|
-
};
|
|
787
|
-
};
|
|
788
|
-
|
|
789
|
-
// src/IndoorMap/IndoorMap.ts
|
|
790
|
-
var import_maptalks_gl = require("maptalks-gl");
|
|
791
|
-
var import_transcoders = require("@maptalks/transcoders.draco");
|
|
792
|
-
var import_tween = __toESM(require("@tweenjs/tween.js"));
|
|
793
|
-
var import_lodash6 = __toESM(require("lodash"));
|
|
794
|
-
|
|
795
|
-
// ../../node_modules/@turf/helpers/dist/esm/index.js
|
|
796
|
-
var earthRadius = 63710088e-1;
|
|
797
|
-
var factors = {
|
|
798
|
-
centimeters: earthRadius * 100,
|
|
799
|
-
centimetres: earthRadius * 100,
|
|
800
|
-
degrees: 360 / (2 * Math.PI),
|
|
801
|
-
feet: earthRadius * 3.28084,
|
|
802
|
-
inches: earthRadius * 39.37,
|
|
803
|
-
kilometers: earthRadius / 1e3,
|
|
804
|
-
kilometres: earthRadius / 1e3,
|
|
805
|
-
meters: earthRadius,
|
|
806
|
-
metres: earthRadius,
|
|
807
|
-
miles: earthRadius / 1609.344,
|
|
808
|
-
millimeters: earthRadius * 1e3,
|
|
809
|
-
millimetres: earthRadius * 1e3,
|
|
810
|
-
nauticalmiles: earthRadius / 1852,
|
|
811
|
-
radians: 1,
|
|
812
|
-
yards: earthRadius * 1.0936
|
|
813
|
-
};
|
|
814
|
-
function feature(geom, properties, options = {}) {
|
|
815
|
-
const feat = { type: "Feature" };
|
|
816
|
-
if (options.id === 0 || options.id) {
|
|
817
|
-
feat.id = options.id;
|
|
818
|
-
}
|
|
819
|
-
if (options.bbox) {
|
|
820
|
-
feat.bbox = options.bbox;
|
|
821
|
-
}
|
|
822
|
-
feat.properties = properties || {};
|
|
823
|
-
feat.geometry = geom;
|
|
824
|
-
return feat;
|
|
825
|
-
}
|
|
826
|
-
function point(coordinates, properties, options = {}) {
|
|
827
|
-
if (!coordinates) {
|
|
828
|
-
throw new Error("coordinates is required");
|
|
829
|
-
}
|
|
830
|
-
if (!Array.isArray(coordinates)) {
|
|
831
|
-
throw new Error("coordinates must be an Array");
|
|
832
|
-
}
|
|
833
|
-
if (coordinates.length < 2) {
|
|
834
|
-
throw new Error("coordinates must be at least 2 numbers long");
|
|
835
|
-
}
|
|
836
|
-
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
|
|
837
|
-
throw new Error("coordinates must contain numbers");
|
|
838
|
-
}
|
|
839
|
-
const geom = {
|
|
840
|
-
type: "Point",
|
|
841
|
-
coordinates
|
|
842
|
-
};
|
|
843
|
-
return feature(geom, properties, options);
|
|
844
|
-
}
|
|
845
|
-
function polygon(coordinates, properties, options = {}) {
|
|
846
|
-
for (const ring of coordinates) {
|
|
847
|
-
if (ring.length < 4) {
|
|
848
|
-
throw new Error(
|
|
849
|
-
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
850
|
-
);
|
|
851
|
-
}
|
|
852
|
-
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
853
|
-
throw new Error("First and last Position are not equivalent.");
|
|
854
|
-
}
|
|
855
|
-
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
856
|
-
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
857
|
-
throw new Error("First and last Position are not equivalent.");
|
|
858
|
-
}
|
|
859
|
-
}
|
|
2543
|
+
const feature2 = await queryClient.ensureQueryData(findQueryOptions);
|
|
2544
|
+
return feature2;
|
|
860
2545
|
}
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
|
|
2546
|
+
const searchFn = async (txt) => {
|
|
2547
|
+
if (!searchClient) {
|
|
2548
|
+
const [occupants, amenities] = await Promise.all([
|
|
2549
|
+
filterByType("occupant"),
|
|
2550
|
+
filterByType("amenity")
|
|
2551
|
+
]);
|
|
2552
|
+
const haystack = { occupants, amenities };
|
|
2553
|
+
searchClient = getSearchClient(haystack);
|
|
2554
|
+
}
|
|
2555
|
+
return searchClient.search(txt);
|
|
864
2556
|
};
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
2557
|
+
const navigateFn = async (origin, destination) => {
|
|
2558
|
+
if (!navigateClient) {
|
|
2559
|
+
const [levels, occupants, openings, relationships, units, fixtures, kiosks, amenities, anchors] = await Promise.all([
|
|
2560
|
+
filterByType("level"),
|
|
2561
|
+
filterByType("occupant"),
|
|
2562
|
+
filterByType("opening"),
|
|
2563
|
+
filterByType("relationship"),
|
|
2564
|
+
filterByType("unit"),
|
|
2565
|
+
filterByType("fixture"),
|
|
2566
|
+
filterByType("kiosk"),
|
|
2567
|
+
filterByType("amenity"),
|
|
2568
|
+
filterByType("anchor")
|
|
2569
|
+
]);
|
|
2570
|
+
const haystack = { levels, occupants, openings, relationships, units, fixtures, kiosks, amenities, anchors };
|
|
2571
|
+
navigateClient = getNavigateClient({ data: haystack });
|
|
2572
|
+
}
|
|
2573
|
+
return navigateClient.findRoute(origin, destination);
|
|
874
2574
|
};
|
|
875
|
-
return
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
function multiPoint(coordinates, properties, options = {}) {
|
|
889
|
-
const geom = {
|
|
890
|
-
type: "MultiPoint",
|
|
891
|
-
coordinates
|
|
2575
|
+
return {
|
|
2576
|
+
projectId,
|
|
2577
|
+
queryClient,
|
|
2578
|
+
registerObserver,
|
|
2579
|
+
destroyObserver,
|
|
2580
|
+
destroyObservers,
|
|
2581
|
+
createFilterByTypeQueryOptions,
|
|
2582
|
+
createFindByIdQueryOptions,
|
|
2583
|
+
_internalFindById: internalFindById,
|
|
2584
|
+
filterByType,
|
|
2585
|
+
findById,
|
|
2586
|
+
search: searchFn,
|
|
2587
|
+
navigate: navigateFn
|
|
892
2588
|
};
|
|
893
|
-
|
|
894
|
-
}
|
|
895
|
-
function isNumber(num) {
|
|
896
|
-
return !isNaN(num) && num !== null && !Array.isArray(num);
|
|
897
|
-
}
|
|
2589
|
+
};
|
|
898
2590
|
|
|
899
2591
|
// src/IndoorMap/IndoorMap.ts
|
|
900
|
-
var
|
|
901
|
-
var
|
|
2592
|
+
var import_maptalks_gl = require("maptalks-gl");
|
|
2593
|
+
var import_transcoders = require("@maptalks/transcoders.draco");
|
|
2594
|
+
var import_tween = __toESM(require("@tweenjs/tween.js"));
|
|
2595
|
+
var import_lodash20 = __toESM(require("lodash"));
|
|
2596
|
+
var import_distance6 = __toESM(require("@turf/distance"));
|
|
2597
|
+
var import_center13 = __toESM(require("@turf/center"));
|
|
902
2598
|
var import_three6 = require("three");
|
|
903
2599
|
var import_maptalks10 = require("maptalks.three");
|
|
904
2600
|
|
|
@@ -977,9 +2673,9 @@ var VENUE_EVENTS = {
|
|
|
977
2673
|
};
|
|
978
2674
|
|
|
979
2675
|
// src/IndoorMap/utils/createElements.js
|
|
980
|
-
var
|
|
2676
|
+
var import_lodash16 = __toESM(require("lodash"));
|
|
981
2677
|
var import_maptalks4 = require("maptalks");
|
|
982
|
-
var
|
|
2678
|
+
var import_center11 = __toESM(require("@turf/center"));
|
|
983
2679
|
var import_buffer = __toESM(require("@turf/buffer"));
|
|
984
2680
|
var import_three4 = require("three");
|
|
985
2681
|
|
|
@@ -987,7 +2683,7 @@ var import_three4 = require("three");
|
|
|
987
2683
|
var maptalks = __toESM(require("maptalks"));
|
|
988
2684
|
var import_maptalks = require("maptalks.three");
|
|
989
2685
|
var import_three = require("three");
|
|
990
|
-
var
|
|
2686
|
+
var import_lodash13 = __toESM(require("lodash"));
|
|
991
2687
|
var OPTIONS = {
|
|
992
2688
|
altitude: 25,
|
|
993
2689
|
scale: 15e-5,
|
|
@@ -1020,7 +2716,7 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
1020
2716
|
} = options;
|
|
1021
2717
|
this.properties = { ...properties };
|
|
1022
2718
|
this._createGroup();
|
|
1023
|
-
const divider =
|
|
2719
|
+
const divider = import_lodash13.default.clamp(window.innerWidth / 375 / 1.75, 1, 1.7);
|
|
1024
2720
|
if (showLeg) {
|
|
1025
2721
|
const lineMaterial = new import_three.LineBasicMaterial({
|
|
1026
2722
|
color: legColor,
|
|
@@ -1055,9 +2751,9 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
1055
2751
|
});
|
|
1056
2752
|
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
1057
2753
|
const position = layer.coordinateToVector3(coordinate, z);
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
2754
|
+
import_lodash13.default.set(this.properties, "default.position", position);
|
|
2755
|
+
import_lodash13.default.set(this.properties, "default.altitude", altitude);
|
|
2756
|
+
import_lodash13.default.set(this.properties, "default.scale", scale3);
|
|
1061
2757
|
this.getObject3d().position.copy(position);
|
|
1062
2758
|
}
|
|
1063
2759
|
setLineHeight(altitude) {
|
|
@@ -1073,7 +2769,7 @@ var Billboard = class extends import_maptalks.BaseObject {
|
|
|
1073
2769
|
// src/IndoorMap/object3d/SpriteMarker.ts
|
|
1074
2770
|
var import_maptalks2 = require("maptalks.three");
|
|
1075
2771
|
var import_three2 = require("three");
|
|
1076
|
-
var
|
|
2772
|
+
var import_lodash14 = __toESM(require("lodash"));
|
|
1077
2773
|
var DEFAULT_SCALE = 0.05;
|
|
1078
2774
|
var DEFAULT_ALTITUDE = 0;
|
|
1079
2775
|
var DEFAULT_ALPHATEST = 0.3;
|
|
@@ -1104,7 +2800,7 @@ var SpriteMarker = class extends import_maptalks2.BaseObject {
|
|
|
1104
2800
|
this.properties = { ...properties };
|
|
1105
2801
|
const modifiedAltitude = altitude + 2;
|
|
1106
2802
|
this.#default = { options: { scale: scale3, altitude: modifiedAltitude }, material };
|
|
1107
|
-
this.#highlight =
|
|
2803
|
+
this.#highlight = import_lodash14.default.merge({}, DEFAULT_OPTIONS.highlight, highlight);
|
|
1108
2804
|
if (material && material instanceof import_three2.SpriteMaterial)
|
|
1109
2805
|
material.alphaTest = alphaTest;
|
|
1110
2806
|
const sprite = new import_three2.Sprite(material);
|
|
@@ -1113,7 +2809,7 @@ var SpriteMarker = class extends import_maptalks2.BaseObject {
|
|
|
1113
2809
|
obj3d.add(sprite);
|
|
1114
2810
|
const z = layer.altitudeToVector3(modifiedAltitude, modifiedAltitude).x;
|
|
1115
2811
|
const position = layer.coordinateToVector3(coordinate, z);
|
|
1116
|
-
|
|
2812
|
+
import_lodash14.default.set(this.properties, "default.position", position);
|
|
1117
2813
|
this.getObject3d().position.copy(position);
|
|
1118
2814
|
}
|
|
1119
2815
|
// Different objects need to implement their own methods
|
|
@@ -1254,15 +2950,15 @@ var NavigationPath = class extends import_maptalks3.BaseObject {
|
|
|
1254
2950
|
};
|
|
1255
2951
|
|
|
1256
2952
|
// src/IndoorMap/utils/geometry.ts
|
|
1257
|
-
var
|
|
1258
|
-
var
|
|
2953
|
+
var import_center10 = __toESM(require("@turf/center"));
|
|
2954
|
+
var import_lodash15 = __toESM(require("lodash"));
|
|
1259
2955
|
var import_line_offset = __toESM(require("@turf/line-offset"));
|
|
1260
2956
|
var getCenterFromGeometry = (geometry) => {
|
|
1261
2957
|
try {
|
|
1262
2958
|
const { type = null, coordinates = null } = geometry;
|
|
1263
2959
|
if (!type || !coordinates) return null;
|
|
1264
|
-
const centerPoint = (0,
|
|
1265
|
-
return
|
|
2960
|
+
const centerPoint = (0, import_center10.default)(geometry);
|
|
2961
|
+
return import_lodash15.default.get(centerPoint, "geometry.coordinates");
|
|
1266
2962
|
} catch (error) {
|
|
1267
2963
|
return null;
|
|
1268
2964
|
}
|
|
@@ -1413,7 +3109,7 @@ var createWaterFixture = (feature2, style, options = {}) => {
|
|
|
1413
3109
|
const { geometry, properties } = feature2;
|
|
1414
3110
|
const { allowOverride, inheritFillColorToLine, zIndex } = options;
|
|
1415
3111
|
const symbolStyle = { ...style };
|
|
1416
|
-
if (allowOverride)
|
|
3112
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
1417
3113
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
1418
3114
|
return new GeometryType[geometry.type](geometry.coordinates, {
|
|
1419
3115
|
properties: {
|
|
@@ -1429,7 +3125,7 @@ var createVegetationFixture = (feature2, style, options = {}) => {
|
|
|
1429
3125
|
const { geometry, properties } = feature2;
|
|
1430
3126
|
const { allowOverride, inheritFillColorToLine, zIndex } = options;
|
|
1431
3127
|
const symbolStyle = { ...style };
|
|
1432
|
-
if (allowOverride)
|
|
3128
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
1433
3129
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
1434
3130
|
return new GeometryType[geometry.type](geometry.coordinates, {
|
|
1435
3131
|
properties: {
|
|
@@ -1446,8 +3142,8 @@ var createObstructionalFixture = (feature2, style = {}, options = {}) => {
|
|
|
1446
3142
|
const { model3d } = properties;
|
|
1447
3143
|
const { allowOverride, inheritFillColorToLine, zIndex } = options;
|
|
1448
3144
|
const symbolStyle = { ...style };
|
|
1449
|
-
if (!
|
|
1450
|
-
if (allowOverride)
|
|
3145
|
+
if (!import_lodash16.default.isEmpty(model3d)) return;
|
|
3146
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
1451
3147
|
if (inheritFillColorToLine) symbolStyle.lineColor = symbolStyle.polygonFill;
|
|
1452
3148
|
if (geometry.type === "LineString") {
|
|
1453
3149
|
const polygon2 = createPolygonFromLineString(geometry);
|
|
@@ -1517,7 +3213,7 @@ var createPrincipalOpening = (feature2, style, options = {}) => {
|
|
|
1517
3213
|
const { geometry, properties } = feature2;
|
|
1518
3214
|
const { allowOverride, zIndex } = options;
|
|
1519
3215
|
const symbolStyle = { ...style };
|
|
1520
|
-
if (allowOverride)
|
|
3216
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
1521
3217
|
try {
|
|
1522
3218
|
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
1523
3219
|
properties: {
|
|
@@ -1534,7 +3230,7 @@ var createEmergencyExitOpening = (feature2, style, options = {}) => {
|
|
|
1534
3230
|
const { geometry, properties } = feature2;
|
|
1535
3231
|
const { allowOverride, zIndex } = options;
|
|
1536
3232
|
const symbolStyle = { ...style };
|
|
1537
|
-
if (allowOverride)
|
|
3233
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
1538
3234
|
try {
|
|
1539
3235
|
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
1540
3236
|
properties: {
|
|
@@ -1551,7 +3247,7 @@ var createPedestrianOpening = (feature2, style, options = {}) => {
|
|
|
1551
3247
|
const { geometry, properties, id } = feature2;
|
|
1552
3248
|
const { allowOverride, zIndex } = options;
|
|
1553
3249
|
const symbolStyle = { ...style };
|
|
1554
|
-
if (allowOverride)
|
|
3250
|
+
if (allowOverride) import_lodash16.default.merge(symbolStyle, properties.style);
|
|
1555
3251
|
try {
|
|
1556
3252
|
return new import_maptalks4.LineString(geometry.coordinates, {
|
|
1557
3253
|
properties: {
|
|
@@ -1589,9 +3285,9 @@ var create3DMarker = (coordinates, options, material, threeLayer, markerProperti
|
|
|
1589
3285
|
};
|
|
1590
3286
|
var getExtrudeConfigByFeature = (baseExtrudeConfig, feature2 = {}) => {
|
|
1591
3287
|
const { feature_type: featureType } = feature2;
|
|
1592
|
-
const featureExtrudeConfig =
|
|
1593
|
-
const featureCategory =
|
|
1594
|
-
const baseFeatureExtrudeConfig =
|
|
3288
|
+
const featureExtrudeConfig = import_lodash16.default.get(feature2, "properties.extrude");
|
|
3289
|
+
const featureCategory = import_lodash16.default.get(feature2, "properties.category");
|
|
3290
|
+
const baseFeatureExtrudeConfig = import_lodash16.default.get(
|
|
1595
3291
|
baseExtrudeConfig,
|
|
1596
3292
|
`${featureType}.${featureCategory || featureType}`
|
|
1597
3293
|
);
|
|
@@ -1649,50 +3345,50 @@ var createStyledUIMarkerElement = ({
|
|
|
1649
3345
|
var styledFeatureGenerator = (mapTheme) => {
|
|
1650
3346
|
const getElementSymbol = (key) => {
|
|
1651
3347
|
const [featureType] = key.split(".");
|
|
1652
|
-
const featureTypeTheme =
|
|
3348
|
+
const featureTypeTheme = import_lodash16.default.get(mapTheme, `${featureType}.geometry.symbol`);
|
|
1653
3349
|
if (featureType === key) return featureTypeTheme;
|
|
1654
|
-
const categoryTheme =
|
|
1655
|
-
return
|
|
3350
|
+
const categoryTheme = import_lodash16.default.get(mapTheme, `${key}.geometry.symbol`);
|
|
3351
|
+
return import_lodash16.default.merge({}, featureTypeTheme, categoryTheme);
|
|
1656
3352
|
};
|
|
1657
3353
|
const getLabelSymbol = (key) => {
|
|
1658
3354
|
const [featureType] = key.split(".");
|
|
1659
|
-
const featureTypeTheme =
|
|
1660
|
-
const categoryTheme =
|
|
1661
|
-
const mergedSymbol =
|
|
1662
|
-
let symbols =
|
|
3355
|
+
const featureTypeTheme = import_lodash16.default.get(mapTheme, `${featureType}.label`);
|
|
3356
|
+
const categoryTheme = import_lodash16.default.get(mapTheme, `${key}.label`);
|
|
3357
|
+
const mergedSymbol = import_lodash16.default.merge({}, featureTypeTheme, categoryTheme);
|
|
3358
|
+
let symbols = import_lodash16.default.values(import_lodash16.default.map(mergedSymbol, "symbol"));
|
|
1663
3359
|
const markerIndexToMove = symbols.findIndex(
|
|
1664
3360
|
({ elementType }) => elementType === "label.marker"
|
|
1665
3361
|
);
|
|
1666
3362
|
if (markerIndexToMove >= 0) {
|
|
1667
|
-
const markerSymbolToMove =
|
|
3363
|
+
const markerSymbolToMove = import_lodash16.default.pullAt(symbols, markerIndexToMove)[0];
|
|
1668
3364
|
symbols.push(markerSymbolToMove);
|
|
1669
3365
|
}
|
|
1670
3366
|
return symbols;
|
|
1671
3367
|
};
|
|
1672
3368
|
const getUIMarkerSymbol = (key) => {
|
|
1673
3369
|
const [featureType] = key.split(".");
|
|
1674
|
-
const featureTypeTheme =
|
|
1675
|
-
const categoryTheme =
|
|
1676
|
-
const mergedSymbol =
|
|
1677
|
-
const symbol =
|
|
3370
|
+
const featureTypeTheme = import_lodash16.default.get(mapTheme, `${featureType}.ui.marker`);
|
|
3371
|
+
const categoryTheme = import_lodash16.default.get(mapTheme, `${key}.ui.marker`);
|
|
3372
|
+
const mergedSymbol = import_lodash16.default.merge({}, featureTypeTheme, categoryTheme);
|
|
3373
|
+
const symbol = import_lodash16.default.get(mergedSymbol, "symbol");
|
|
1678
3374
|
return symbol;
|
|
1679
3375
|
};
|
|
1680
3376
|
const getUIMarkerOptions = (key) => {
|
|
1681
3377
|
const [featureType] = key.split(".");
|
|
1682
|
-
const featureTypeTheme =
|
|
1683
|
-
const categoryTheme =
|
|
1684
|
-
const mergedSymbol =
|
|
1685
|
-
const options =
|
|
3378
|
+
const featureTypeTheme = import_lodash16.default.get(mapTheme, `${featureType}.ui.marker`);
|
|
3379
|
+
const categoryTheme = import_lodash16.default.get(mapTheme, `${key}.ui.marker`);
|
|
3380
|
+
const mergedSymbol = import_lodash16.default.merge({}, featureTypeTheme, categoryTheme);
|
|
3381
|
+
const options = import_lodash16.default.get(mergedSymbol, "options");
|
|
1686
3382
|
return options;
|
|
1687
3383
|
};
|
|
1688
3384
|
const getLabelOptions = (key) => {
|
|
1689
3385
|
const [featureType] = key.split(".");
|
|
1690
|
-
const featureTypeSymbol =
|
|
1691
|
-
const categorySymbol =
|
|
1692
|
-
const mergedSymbol =
|
|
1693
|
-
return
|
|
3386
|
+
const featureTypeSymbol = import_lodash16.default.get(mapTheme, `${featureType}.label`);
|
|
3387
|
+
const categorySymbol = import_lodash16.default.get(mapTheme, `${key}.label`);
|
|
3388
|
+
const mergedSymbol = import_lodash16.default.merge({}, featureTypeSymbol, categorySymbol);
|
|
3389
|
+
return import_lodash16.default.reduce(
|
|
1694
3390
|
mergedSymbol,
|
|
1695
|
-
(acc, symbol) => ({ ...acc, ...
|
|
3391
|
+
(acc, symbol) => ({ ...acc, ...import_lodash16.default.get(symbol, "options", {}) }),
|
|
1696
3392
|
{}
|
|
1697
3393
|
);
|
|
1698
3394
|
};
|
|
@@ -1707,13 +3403,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1707
3403
|
};
|
|
1708
3404
|
const generateSpriteHighlightMarkerOption = () => {
|
|
1709
3405
|
return SPRITE_HIGHLIGHT_MARKER_FEATURE.reduce((acc, featCate) => {
|
|
1710
|
-
const categoryKey =
|
|
3406
|
+
const categoryKey = import_lodash16.default.last(featCate.split("-"));
|
|
1711
3407
|
const defaultLabelSymbol = getLabelSymbol(categoryKey);
|
|
1712
3408
|
const highlightLabelSymbol = getLabelSymbol(featCate);
|
|
1713
3409
|
const [defaultBase, defaultIcon] = defaultLabelSymbol;
|
|
1714
3410
|
const [highlightBase, highlightIcon] = highlightLabelSymbol;
|
|
1715
|
-
const base =
|
|
1716
|
-
const icon =
|
|
3411
|
+
const base = import_lodash16.default.merge({}, defaultBase, highlightBase);
|
|
3412
|
+
const icon = import_lodash16.default.merge({}, defaultIcon, highlightIcon);
|
|
1717
3413
|
const material = createSpriteMaterialByLabelSymbol([base, icon]);
|
|
1718
3414
|
const options = getLabelOptions(featCate);
|
|
1719
3415
|
return { ...acc, [featCate]: { material, options } };
|
|
@@ -1723,32 +3419,32 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1723
3419
|
const spriteHighlightMarkerOptionObj = generateSpriteHighlightMarkerOption();
|
|
1724
3420
|
const getElementOptions = (key) => {
|
|
1725
3421
|
const [featureType] = key.split(".");
|
|
1726
|
-
const featureTypeOptions =
|
|
3422
|
+
const featureTypeOptions = import_lodash16.default.get(
|
|
1727
3423
|
mapTheme,
|
|
1728
3424
|
`${featureType}.geometry.options`
|
|
1729
3425
|
);
|
|
1730
|
-
const categoryOptions =
|
|
1731
|
-
return
|
|
3426
|
+
const categoryOptions = import_lodash16.default.get(mapTheme, `${key}.geometry.options`);
|
|
3427
|
+
return import_lodash16.default.merge({}, featureTypeOptions, categoryOptions);
|
|
1732
3428
|
};
|
|
1733
3429
|
const createOccupantMarker = (feature2, locatedFeature, mapConfig) => {
|
|
1734
3430
|
const { textMarkerType, featureExtrudeConfig } = getFeatureMarkerConfig(
|
|
1735
3431
|
feature2,
|
|
1736
3432
|
mapConfig
|
|
1737
3433
|
);
|
|
1738
|
-
const markerHeight =
|
|
3434
|
+
const markerHeight = import_lodash16.default.get(featureExtrudeConfig, "height", 0);
|
|
1739
3435
|
const { properties, id, feature_type } = feature2;
|
|
1740
3436
|
if (!properties.anchor) return;
|
|
1741
|
-
const mainLocationId =
|
|
3437
|
+
const mainLocationId = import_lodash16.default.get(properties, "unit.id") || import_lodash16.default.get(properties, "kiosk.id");
|
|
1742
3438
|
const isMainLocationFeature = mainLocationId === locatedFeature?.id;
|
|
1743
3439
|
const { geometry: mainLocationGeometry } = properties?.anchor;
|
|
1744
|
-
const geometry = isMainLocationFeature ? mainLocationGeometry : (0,
|
|
3440
|
+
const geometry = isMainLocationFeature ? mainLocationGeometry : (0, import_center11.default)(locatedFeature)?.geometry;
|
|
1745
3441
|
const baseProperties = {
|
|
1746
3442
|
id,
|
|
1747
3443
|
feature_type,
|
|
1748
3444
|
category: properties.category,
|
|
1749
3445
|
altitude: getAltitude(properties)
|
|
1750
3446
|
};
|
|
1751
|
-
const occupantName =
|
|
3447
|
+
const occupantName = import_lodash16.default.isEmpty(properties.short_name) ? properties.name : properties.short_name;
|
|
1752
3448
|
if (locatedFeature) {
|
|
1753
3449
|
const { feature_type: feature_type2, properties: properties2 } = locatedFeature;
|
|
1754
3450
|
const { category } = properties2;
|
|
@@ -1762,21 +3458,21 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1762
3458
|
}
|
|
1763
3459
|
return requestedType;
|
|
1764
3460
|
};
|
|
1765
|
-
const logoUrl =
|
|
1766
|
-
const requestedRenderType =
|
|
3461
|
+
const logoUrl = import_lodash16.default.get(properties, "logo.url");
|
|
3462
|
+
const requestedRenderType = import_lodash16.default.get(properties, "render_type", "Name");
|
|
1767
3463
|
const renderType = getValidatedRenderType(requestedRenderType, logoUrl);
|
|
1768
3464
|
if (renderType === "Label") return null;
|
|
1769
3465
|
const renderPriority = properties.render_priority || 3;
|
|
1770
|
-
const labelSymbol = getLabelSymbol(`occupant-${
|
|
1771
|
-
const markerSymbol =
|
|
1772
|
-
const coordinates =
|
|
3466
|
+
const labelSymbol = getLabelSymbol(`occupant-${import_lodash16.default.toLower(renderType)}`);
|
|
3467
|
+
const markerSymbol = import_lodash16.default.last(labelSymbol);
|
|
3468
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
1773
3469
|
const priorityLabelSymbol = getLabelSymbol(
|
|
1774
|
-
`occupant-${
|
|
3470
|
+
`occupant-${import_lodash16.default.toLower(renderType)}-${renderPriority}`
|
|
1775
3471
|
);
|
|
1776
|
-
const priorityMarkerSymbol =
|
|
3472
|
+
const priorityMarkerSymbol = import_lodash16.default.last(priorityLabelSymbol) || {};
|
|
1777
3473
|
switch (renderType) {
|
|
1778
3474
|
case "Logo":
|
|
1779
|
-
|
|
3475
|
+
import_lodash16.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
1780
3476
|
return new import_maptalks4.Marker(coordinates, {
|
|
1781
3477
|
properties: {
|
|
1782
3478
|
altitude: getAltitude(properties) + markerHeight,
|
|
@@ -1837,13 +3533,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1837
3533
|
});
|
|
1838
3534
|
}
|
|
1839
3535
|
const uiMarkerSymbol = getUIMarkerSymbol(
|
|
1840
|
-
`occupant-${
|
|
3536
|
+
`occupant-${import_lodash16.default.toLower(renderType)}`
|
|
1841
3537
|
);
|
|
1842
3538
|
const uiMarkerPrioritySymbol = getUIMarkerSymbol(
|
|
1843
|
-
`occupant-${
|
|
3539
|
+
`occupant-${import_lodash16.default.toLower(renderType)}-${renderPriority}`
|
|
1844
3540
|
);
|
|
1845
3541
|
const uiMarkerPriorityOptions = getUIMarkerOptions(
|
|
1846
|
-
`occupant-${
|
|
3542
|
+
`occupant-${import_lodash16.default.toLower(renderType)}-${renderPriority}`
|
|
1847
3543
|
);
|
|
1848
3544
|
const style = { ...uiMarkerSymbol, ...uiMarkerPrioritySymbol };
|
|
1849
3545
|
return new import_maptalks4.ui.UIMarker(coordinates, {
|
|
@@ -1865,7 +3561,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1865
3561
|
const { category, ordinal, style = {} } = properties;
|
|
1866
3562
|
const elementStyle = getElementSymbol(`${feature_type}.${category}`);
|
|
1867
3563
|
const { allowOverride } = getElementOptions(`${feature_type}.${category}`);
|
|
1868
|
-
if (allowOverride)
|
|
3564
|
+
if (allowOverride) import_lodash16.default.merge(elementStyle, style);
|
|
1869
3565
|
const { polygonFill: color } = elementStyle;
|
|
1870
3566
|
const featureProperty = {
|
|
1871
3567
|
id,
|
|
@@ -1954,9 +3650,9 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1954
3650
|
feature2,
|
|
1955
3651
|
mapConfig
|
|
1956
3652
|
);
|
|
1957
|
-
const markerHeight =
|
|
3653
|
+
const markerHeight = import_lodash16.default.get(featureExtrudeConfig, "height");
|
|
1958
3654
|
const { id, properties } = feature2;
|
|
1959
|
-
const geometry =
|
|
3655
|
+
const geometry = import_lodash16.default.get(feature2, "geometry") || import_lodash16.default.get(feature2, "properties.anchor.geometry");
|
|
1960
3656
|
const coordinates = getCenterFromGeometry(geometry);
|
|
1961
3657
|
const symbol = getElementSymbol("pin-marker");
|
|
1962
3658
|
try {
|
|
@@ -1976,10 +3672,10 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
1976
3672
|
feature2,
|
|
1977
3673
|
mapConfig
|
|
1978
3674
|
);
|
|
1979
|
-
const markerHeight =
|
|
3675
|
+
const markerHeight = import_lodash16.default.get(featureExtrudeConfig, "height", 0);
|
|
1980
3676
|
const { properties, id } = feature2;
|
|
1981
3677
|
const { geometry } = properties.anchor;
|
|
1982
|
-
const logoUrl =
|
|
3678
|
+
const logoUrl = import_lodash16.default.get(properties, "logo.url");
|
|
1983
3679
|
const coordinates = getCenterFromGeometry(geometry);
|
|
1984
3680
|
const [markerBase, markerLabel] = getLabelSymbol(
|
|
1985
3681
|
"highlighted-logo-marker"
|
|
@@ -2049,7 +3745,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2049
3745
|
feature2,
|
|
2050
3746
|
mapConfig
|
|
2051
3747
|
);
|
|
2052
|
-
const markerHeight =
|
|
3748
|
+
const markerHeight = import_lodash16.default.get(featureExtrudeConfig, "height");
|
|
2053
3749
|
const { id, feature_type, properties } = feature2;
|
|
2054
3750
|
if (!properties.anchor) return;
|
|
2055
3751
|
const markerProperties = {
|
|
@@ -2059,8 +3755,8 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2059
3755
|
altitude: getAltitude(properties) + markerHeight
|
|
2060
3756
|
};
|
|
2061
3757
|
const { geometry } = properties?.anchor;
|
|
2062
|
-
const coordinates =
|
|
2063
|
-
const logoUrl =
|
|
3758
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
3759
|
+
const logoUrl = import_lodash16.default.get(properties, "logo.url");
|
|
2064
3760
|
if (markerSymbol) {
|
|
2065
3761
|
return new import_maptalks4.Marker(coordinates, {
|
|
2066
3762
|
properties: markerProperties,
|
|
@@ -2075,8 +3771,8 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2075
3771
|
});
|
|
2076
3772
|
}
|
|
2077
3773
|
const labelSymbol = getLabelSymbol("highlight-occupant-logo");
|
|
2078
|
-
const priorityMarkerSymbol =
|
|
2079
|
-
|
|
3774
|
+
const priorityMarkerSymbol = import_lodash16.default.last(labelSymbol) || {};
|
|
3775
|
+
import_lodash16.default.set(priorityMarkerSymbol, "markerFile", logoUrl);
|
|
2080
3776
|
return new import_maptalks4.Marker(coordinates, {
|
|
2081
3777
|
properties: markerProperties,
|
|
2082
3778
|
symbol: labelSymbol
|
|
@@ -2084,14 +3780,14 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2084
3780
|
},
|
|
2085
3781
|
createHighlight2DAmenityMarkerFrom3DMarker: (feature2, mapConfig) => {
|
|
2086
3782
|
const { coordinates, units, kiosk } = feature2;
|
|
2087
|
-
const amenityLocatedUnit =
|
|
3783
|
+
const amenityLocatedUnit = import_lodash16.default.first(units);
|
|
2088
3784
|
const unitConfig = getExtrudeConfigByFeature(
|
|
2089
3785
|
mapConfig,
|
|
2090
3786
|
amenityLocatedUnit
|
|
2091
3787
|
);
|
|
2092
|
-
const unitHeight =
|
|
3788
|
+
const unitHeight = import_lodash16.default.get(unitConfig, "height", 0);
|
|
2093
3789
|
const kioskConfig = getExtrudeConfigByFeature(mapConfig, kiosk);
|
|
2094
|
-
const kioskHeight =
|
|
3790
|
+
const kioskHeight = import_lodash16.default.get(kioskConfig, "height", 0);
|
|
2095
3791
|
const markerHeight = unitHeight + kioskHeight;
|
|
2096
3792
|
const symbol = getElementSymbol("highlight-amenity-marker");
|
|
2097
3793
|
return new import_maptalks4.Marker(coordinates, {
|
|
@@ -2167,7 +3863,7 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2167
3863
|
}
|
|
2168
3864
|
},
|
|
2169
3865
|
createLineStringFromGeometries: (geometries) => {
|
|
2170
|
-
const mergedCoordinates = (0,
|
|
3866
|
+
const mergedCoordinates = (0, import_lodash16.default)(geometries).map((geometry) => {
|
|
2171
3867
|
switch (geometry.type) {
|
|
2172
3868
|
case "Point":
|
|
2173
3869
|
return [
|
|
@@ -2276,29 +3972,29 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2276
3972
|
create3DAmenityMarker: (feature2, threeLayer, config) => {
|
|
2277
3973
|
const { geometry, properties, feature_type, id } = feature2;
|
|
2278
3974
|
const { category, units, kiosk, is_clickable } = properties;
|
|
2279
|
-
const amenityLocatedUnit =
|
|
2280
|
-
const isLocatedUnitModel3dAvailable = !
|
|
3975
|
+
const amenityLocatedUnit = import_lodash16.default.first(units);
|
|
3976
|
+
const isLocatedUnitModel3dAvailable = !import_lodash16.default.isEmpty(
|
|
2281
3977
|
amenityLocatedUnit?.properties?.model3d
|
|
2282
3978
|
);
|
|
2283
|
-
const isLocatedKioskModel3dAvailable = !
|
|
3979
|
+
const isLocatedKioskModel3dAvailable = !import_lodash16.default.isEmpty(
|
|
2284
3980
|
kiosk?.properties?.model3d
|
|
2285
3981
|
);
|
|
2286
3982
|
const unitConfig = getExtrudeConfigByFeature(config, amenityLocatedUnit);
|
|
2287
|
-
const unitHeight = isLocatedUnitModel3dAvailable ? 0 :
|
|
3983
|
+
const unitHeight = isLocatedUnitModel3dAvailable ? 0 : import_lodash16.default.get(unitConfig, "height", 0);
|
|
2288
3984
|
const kioskConfig = getExtrudeConfigByFeature(config, kiosk);
|
|
2289
|
-
const kioskHeight = isLocatedKioskModel3dAvailable ? 0 :
|
|
2290
|
-
const coordinates =
|
|
3985
|
+
const kioskHeight = isLocatedKioskModel3dAvailable ? 0 : import_lodash16.default.get(kioskConfig, "height", 0);
|
|
3986
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
2291
3987
|
const markerProperties = {
|
|
2292
3988
|
...properties,
|
|
2293
3989
|
coordinates,
|
|
2294
3990
|
id,
|
|
2295
3991
|
feature_type
|
|
2296
3992
|
};
|
|
2297
|
-
const material =
|
|
3993
|
+
const material = import_lodash16.default.get(
|
|
2298
3994
|
spriteMarkerMaterialObj,
|
|
2299
3995
|
`${feature_type}.${category}`
|
|
2300
3996
|
);
|
|
2301
|
-
const highlightOptions =
|
|
3997
|
+
const highlightOptions = import_lodash16.default.get(
|
|
2302
3998
|
spriteHighlightMarkerOptionObj,
|
|
2303
3999
|
`${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
|
|
2304
4000
|
);
|
|
@@ -2321,24 +4017,24 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2321
4017
|
const { category, unit, kiosk } = properties;
|
|
2322
4018
|
const amenityLocation = kiosk || unit;
|
|
2323
4019
|
const locationConfig = getExtrudeConfigByFeature(config, amenityLocation);
|
|
2324
|
-
const coordinates =
|
|
4020
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
2325
4021
|
const markerProperties = {
|
|
2326
4022
|
...properties,
|
|
2327
4023
|
coordinates,
|
|
2328
4024
|
id,
|
|
2329
4025
|
feature_type
|
|
2330
4026
|
};
|
|
2331
|
-
const material =
|
|
4027
|
+
const material = import_lodash16.default.get(
|
|
2332
4028
|
spriteMarkerMaterialObj,
|
|
2333
4029
|
`${feature_type}.${category}`
|
|
2334
4030
|
);
|
|
2335
|
-
const highlightOptions =
|
|
4031
|
+
const highlightOptions = import_lodash16.default.get(
|
|
2336
4032
|
spriteHighlightMarkerOptionObj,
|
|
2337
4033
|
`${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
|
|
2338
4034
|
);
|
|
2339
4035
|
const options = {
|
|
2340
4036
|
scale: 0.05,
|
|
2341
|
-
altitude:
|
|
4037
|
+
altitude: import_lodash16.default.get(locationConfig, "height", 0),
|
|
2342
4038
|
highlight: highlightOptions
|
|
2343
4039
|
};
|
|
2344
4040
|
return create3DMarker(
|
|
@@ -2354,24 +4050,24 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2354
4050
|
const { category, unit, kiosk } = properties;
|
|
2355
4051
|
const amenityLocation = kiosk || unit;
|
|
2356
4052
|
const locationConfig = getExtrudeConfigByFeature(config, amenityLocation);
|
|
2357
|
-
const coordinates =
|
|
4053
|
+
const coordinates = import_lodash16.default.get(geometry, "coordinates");
|
|
2358
4054
|
const markerProperties = {
|
|
2359
4055
|
...properties,
|
|
2360
4056
|
coordinates,
|
|
2361
4057
|
id,
|
|
2362
4058
|
feature_type
|
|
2363
4059
|
};
|
|
2364
|
-
const material =
|
|
4060
|
+
const material = import_lodash16.default.get(
|
|
2365
4061
|
spriteMarkerMaterialObj,
|
|
2366
4062
|
`${feature_type}.${category}`
|
|
2367
4063
|
);
|
|
2368
|
-
const highlightOptions =
|
|
4064
|
+
const highlightOptions = import_lodash16.default.get(
|
|
2369
4065
|
spriteHighlightMarkerOptionObj,
|
|
2370
4066
|
`${PREFIX_HIGHLIGHTED_SYMBOL_KEY}-${feature_type}.${category}`
|
|
2371
4067
|
);
|
|
2372
4068
|
const options = {
|
|
2373
4069
|
scale: 0.05,
|
|
2374
|
-
altitude:
|
|
4070
|
+
altitude: import_lodash16.default.get(locationConfig, "height", 0),
|
|
2375
4071
|
highlight: highlightOptions
|
|
2376
4072
|
};
|
|
2377
4073
|
return create3DMarker(
|
|
@@ -2383,13 +4079,13 @@ var styledFeatureGenerator = (mapTheme) => {
|
|
|
2383
4079
|
);
|
|
2384
4080
|
},
|
|
2385
4081
|
createExtrudedUnit: (unit, threeLayer, options) => {
|
|
2386
|
-
const extrudeHeight =
|
|
4082
|
+
const extrudeHeight = import_lodash16.default.get(options, "height");
|
|
2387
4083
|
if (!extrudeHeight) return;
|
|
2388
4084
|
const unitProperty = getFeatureProperties(unit);
|
|
2389
4085
|
const options3d = {
|
|
2390
4086
|
// TODO: Move to extrude config later
|
|
2391
4087
|
offset: -0.1,
|
|
2392
|
-
altitude:
|
|
4088
|
+
altitude: import_lodash16.default.get(options, "altitude", 0)
|
|
2393
4089
|
};
|
|
2394
4090
|
const color = unitProperty.defaultColor;
|
|
2395
4091
|
if (color === "transparent") return;
|
|
@@ -2432,14 +4128,14 @@ var EXCEPT_AMENITY_LOCATION_CATEGORIES = [
|
|
|
2432
4128
|
"unspecified"
|
|
2433
4129
|
];
|
|
2434
4130
|
var getLocationByAmenity = (feature2) => {
|
|
2435
|
-
const unit =
|
|
2436
|
-
const unitCategory =
|
|
4131
|
+
const unit = import_lodash16.default.get(feature2, "properties.units[0]", null);
|
|
4132
|
+
const unitCategory = import_lodash16.default.get(unit, "properties.category");
|
|
2437
4133
|
if (!unit) return feature2.id;
|
|
2438
4134
|
return EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory) ? feature2 : unit;
|
|
2439
4135
|
};
|
|
2440
4136
|
var getLocationByOccupant = (feature2) => {
|
|
2441
|
-
const kiosk =
|
|
2442
|
-
const unit =
|
|
4137
|
+
const kiosk = import_lodash16.default.get(feature2, "properties.kiosk", null);
|
|
4138
|
+
const unit = import_lodash16.default.get(feature2, "properties.anchor.properties.unit", null);
|
|
2443
4139
|
return kiosk || unit;
|
|
2444
4140
|
};
|
|
2445
4141
|
var getLocationIdByFeature = (feature2) => {
|
|
@@ -2467,10 +4163,10 @@ var getFeatureByLocationId = (id, features = []) => {
|
|
|
2467
4163
|
});
|
|
2468
4164
|
};
|
|
2469
4165
|
var isClickableFeature = (feature2) => {
|
|
2470
|
-
const isClickable =
|
|
4166
|
+
const isClickable = import_lodash16.default.get(feature2, "properties.is_clickable");
|
|
2471
4167
|
switch (feature2?.feature_type) {
|
|
2472
4168
|
case "amenity":
|
|
2473
|
-
return
|
|
4169
|
+
return import_lodash16.default.isNull(isClickable) ? true : isClickable;
|
|
2474
4170
|
case "occupant":
|
|
2475
4171
|
return true;
|
|
2476
4172
|
default:
|
|
@@ -2488,24 +4184,24 @@ var getLocationByFeature = (feature2) => {
|
|
|
2488
4184
|
}
|
|
2489
4185
|
};
|
|
2490
4186
|
var getRelatedLocationsByOccupant = (feature2) => {
|
|
2491
|
-
const kiosks =
|
|
2492
|
-
const units =
|
|
4187
|
+
const kiosks = import_lodash16.default.get(feature2, "properties.kiosks", []);
|
|
4188
|
+
const units = import_lodash16.default.get(feature2, "properties.units", []);
|
|
2493
4189
|
return [...kiosks, ...units];
|
|
2494
4190
|
};
|
|
2495
4191
|
var getRelatedLocationsByAmenity = (feature2) => {
|
|
2496
|
-
const units =
|
|
4192
|
+
const units = import_lodash16.default.get(feature2, "properties.units", []);
|
|
2497
4193
|
if (units.length === 0) return [feature2];
|
|
2498
4194
|
return units.filter((unit) => {
|
|
2499
|
-
const unitCategory =
|
|
4195
|
+
const unitCategory = import_lodash16.default.get(unit, "properties.category");
|
|
2500
4196
|
return !EXCEPT_AMENITY_LOCATION_CATEGORIES.includes(unitCategory);
|
|
2501
4197
|
});
|
|
2502
4198
|
};
|
|
2503
4199
|
var getRelatedLocationIdsByFeature = (feature2) => {
|
|
2504
4200
|
switch (feature2?.feature_type) {
|
|
2505
4201
|
case "amenity":
|
|
2506
|
-
return getRelatedLocationsByAmenity(feature2).map((
|
|
4202
|
+
return getRelatedLocationsByAmenity(feature2).map((v) => v?.id);
|
|
2507
4203
|
case "occupant":
|
|
2508
|
-
return getRelatedLocationsByOccupant(feature2).map((
|
|
4204
|
+
return getRelatedLocationsByOccupant(feature2).map((v) => v?.id);
|
|
2509
4205
|
default:
|
|
2510
4206
|
return [];
|
|
2511
4207
|
}
|
|
@@ -2522,8 +4218,8 @@ var getRelatedLocationsByFeature = (feature2) => {
|
|
|
2522
4218
|
};
|
|
2523
4219
|
var getOrdinalByLocationId = (locationId, feature2) => {
|
|
2524
4220
|
if (!feature2) return null;
|
|
2525
|
-
const mainUnit =
|
|
2526
|
-
const mainKiosk =
|
|
4221
|
+
const mainUnit = import_lodash16.default.get(feature2, "properties.unit");
|
|
4222
|
+
const mainKiosk = import_lodash16.default.get(feature2, "properties.kiosk");
|
|
2527
4223
|
const relatedLocations = getRelatedLocationsByFeature(feature2);
|
|
2528
4224
|
const allLocations = [mainUnit, mainKiosk, ...relatedLocations].filter(
|
|
2529
4225
|
Boolean
|
|
@@ -2531,7 +4227,7 @@ var getOrdinalByLocationId = (locationId, feature2) => {
|
|
|
2531
4227
|
const targetLocation = allLocations.find(
|
|
2532
4228
|
(location) => location.id === locationId
|
|
2533
4229
|
);
|
|
2534
|
-
return targetLocation ?
|
|
4230
|
+
return targetLocation ? import_lodash16.default.get(targetLocation, "properties.level.properties.ordinal") || import_lodash16.default.get(targetLocation, "properties.ordinal") : null;
|
|
2535
4231
|
};
|
|
2536
4232
|
|
|
2537
4233
|
// src/IndoorMap/utils/math.ts
|
|
@@ -2544,140 +4240,16 @@ var getBearingBetweenPoints = (origin, destination) => {
|
|
|
2544
4240
|
return Math.floor(radToDegree(theta));
|
|
2545
4241
|
};
|
|
2546
4242
|
var getSuitablyValueBetweenBearings = (newBearing, currentBearing) => {
|
|
2547
|
-
const
|
|
2548
|
-
if (
|
|
4243
|
+
const difference2 = Math.abs(newBearing - currentBearing);
|
|
4244
|
+
if (difference2 > 180)
|
|
2549
4245
|
return newBearing > 0 ? newBearing - 360 : newBearing + 360;
|
|
2550
4246
|
return newBearing;
|
|
2551
4247
|
};
|
|
2552
4248
|
|
|
2553
4249
|
// src/IndoorMap/camera/CameraManager.ts
|
|
2554
4250
|
var import_maptalks5 = require("maptalks");
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
2558
|
-
if (geojson === null) return;
|
|
2559
|
-
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;
|
|
2560
|
-
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
2561
|
-
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
2562
|
-
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
2563
|
-
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
2564
|
-
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
2565
|
-
var multiFeatureIndex = 0;
|
|
2566
|
-
var geometryIndex = 0;
|
|
2567
|
-
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
2568
|
-
if (geometry === null) continue;
|
|
2569
|
-
coords = geometry.coordinates;
|
|
2570
|
-
var geomType = geometry.type;
|
|
2571
|
-
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
2572
|
-
switch (geomType) {
|
|
2573
|
-
case null:
|
|
2574
|
-
break;
|
|
2575
|
-
case "Point":
|
|
2576
|
-
if (callback(
|
|
2577
|
-
coords,
|
|
2578
|
-
coordIndex,
|
|
2579
|
-
featureIndex,
|
|
2580
|
-
multiFeatureIndex,
|
|
2581
|
-
geometryIndex
|
|
2582
|
-
) === false)
|
|
2583
|
-
return false;
|
|
2584
|
-
coordIndex++;
|
|
2585
|
-
multiFeatureIndex++;
|
|
2586
|
-
break;
|
|
2587
|
-
case "LineString":
|
|
2588
|
-
case "MultiPoint":
|
|
2589
|
-
for (j = 0; j < coords.length; j++) {
|
|
2590
|
-
if (callback(
|
|
2591
|
-
coords[j],
|
|
2592
|
-
coordIndex,
|
|
2593
|
-
featureIndex,
|
|
2594
|
-
multiFeatureIndex,
|
|
2595
|
-
geometryIndex
|
|
2596
|
-
) === false)
|
|
2597
|
-
return false;
|
|
2598
|
-
coordIndex++;
|
|
2599
|
-
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
2600
|
-
}
|
|
2601
|
-
if (geomType === "LineString") multiFeatureIndex++;
|
|
2602
|
-
break;
|
|
2603
|
-
case "Polygon":
|
|
2604
|
-
case "MultiLineString":
|
|
2605
|
-
for (j = 0; j < coords.length; j++) {
|
|
2606
|
-
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
2607
|
-
if (callback(
|
|
2608
|
-
coords[j][k],
|
|
2609
|
-
coordIndex,
|
|
2610
|
-
featureIndex,
|
|
2611
|
-
multiFeatureIndex,
|
|
2612
|
-
geometryIndex
|
|
2613
|
-
) === false)
|
|
2614
|
-
return false;
|
|
2615
|
-
coordIndex++;
|
|
2616
|
-
}
|
|
2617
|
-
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
2618
|
-
if (geomType === "Polygon") geometryIndex++;
|
|
2619
|
-
}
|
|
2620
|
-
if (geomType === "Polygon") multiFeatureIndex++;
|
|
2621
|
-
break;
|
|
2622
|
-
case "MultiPolygon":
|
|
2623
|
-
for (j = 0; j < coords.length; j++) {
|
|
2624
|
-
geometryIndex = 0;
|
|
2625
|
-
for (k = 0; k < coords[j].length; k++) {
|
|
2626
|
-
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
2627
|
-
if (callback(
|
|
2628
|
-
coords[j][k][l],
|
|
2629
|
-
coordIndex,
|
|
2630
|
-
featureIndex,
|
|
2631
|
-
multiFeatureIndex,
|
|
2632
|
-
geometryIndex
|
|
2633
|
-
) === false)
|
|
2634
|
-
return false;
|
|
2635
|
-
coordIndex++;
|
|
2636
|
-
}
|
|
2637
|
-
geometryIndex++;
|
|
2638
|
-
}
|
|
2639
|
-
multiFeatureIndex++;
|
|
2640
|
-
}
|
|
2641
|
-
break;
|
|
2642
|
-
case "GeometryCollection":
|
|
2643
|
-
for (j = 0; j < geometry.geometries.length; j++)
|
|
2644
|
-
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
2645
|
-
return false;
|
|
2646
|
-
break;
|
|
2647
|
-
default:
|
|
2648
|
-
throw new Error("Unknown Geometry Type");
|
|
2649
|
-
}
|
|
2650
|
-
}
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
|
|
2654
|
-
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
2655
|
-
function bbox(geojson, options = {}) {
|
|
2656
|
-
if (geojson.bbox != null && true !== options.recompute) {
|
|
2657
|
-
return geojson.bbox;
|
|
2658
|
-
}
|
|
2659
|
-
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
2660
|
-
coordEach(geojson, (coord) => {
|
|
2661
|
-
if (result[0] > coord[0]) {
|
|
2662
|
-
result[0] = coord[0];
|
|
2663
|
-
}
|
|
2664
|
-
if (result[1] > coord[1]) {
|
|
2665
|
-
result[1] = coord[1];
|
|
2666
|
-
}
|
|
2667
|
-
if (result[2] < coord[0]) {
|
|
2668
|
-
result[2] = coord[0];
|
|
2669
|
-
}
|
|
2670
|
-
if (result[3] < coord[1]) {
|
|
2671
|
-
result[3] = coord[1];
|
|
2672
|
-
}
|
|
2673
|
-
});
|
|
2674
|
-
return result;
|
|
2675
|
-
}
|
|
2676
|
-
var index_default = bbox;
|
|
2677
|
-
|
|
2678
|
-
// src/IndoorMap/camera/CameraManager.ts
|
|
2679
|
-
var import_transform_scale = __toESM(require("@turf/transform-scale"));
|
|
2680
|
-
var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
|
|
4251
|
+
var import_transform_scale2 = __toESM(require("@turf/transform-scale"));
|
|
4252
|
+
var import_bbox_polygon2 = __toESM(require("@turf/bbox-polygon"));
|
|
2681
4253
|
var CameraManager = class {
|
|
2682
4254
|
map;
|
|
2683
4255
|
constructor(map, options) {
|
|
@@ -2703,7 +4275,7 @@ var CameraManager = class {
|
|
|
2703
4275
|
}
|
|
2704
4276
|
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
2705
4277
|
const [minX, minY, maxX, maxY] = index_default(
|
|
2706
|
-
(0,
|
|
4278
|
+
(0, import_transform_scale2.default)((0, import_bbox_polygon2.default)(index_default(feature2)), scaleFactor)
|
|
2707
4279
|
);
|
|
2708
4280
|
return new import_maptalks5.Extent(minX, minY, maxX, maxY);
|
|
2709
4281
|
};
|
|
@@ -2740,8 +4312,8 @@ var CameraManager = class {
|
|
|
2740
4312
|
};
|
|
2741
4313
|
|
|
2742
4314
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
2743
|
-
var
|
|
2744
|
-
var
|
|
4315
|
+
var import_lodash19 = require("lodash");
|
|
4316
|
+
var import_center12 = require("@turf/center");
|
|
2745
4317
|
var THREE4 = __toESM(require("three"));
|
|
2746
4318
|
|
|
2747
4319
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
@@ -2749,10 +4321,10 @@ var maptalks4 = __toESM(require("maptalks-gl"));
|
|
|
2749
4321
|
var THREE = __toESM(require("three"));
|
|
2750
4322
|
var import_maptalks7 = require("maptalks.three");
|
|
2751
4323
|
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
2752
|
-
var
|
|
4324
|
+
var import_clean_coords2 = require("@turf/clean-coords");
|
|
2753
4325
|
var import_polygon_to_line = require("@turf/polygon-to-line");
|
|
2754
4326
|
var import_nearest_point_on_line = require("@turf/nearest-point-on-line");
|
|
2755
|
-
var
|
|
4327
|
+
var import_length2 = require("@turf/length");
|
|
2756
4328
|
var import_along = require("@turf/along");
|
|
2757
4329
|
var import_point_to_line_distance = require("@turf/point-to-line-distance");
|
|
2758
4330
|
|
|
@@ -2761,7 +4333,7 @@ var maptalks3 = __toESM(require("maptalks-gl"));
|
|
|
2761
4333
|
var import_maptalks6 = require("maptalks.three");
|
|
2762
4334
|
var import_three5 = require("three");
|
|
2763
4335
|
var import_d3plus_shape = require("d3plus-shape");
|
|
2764
|
-
var
|
|
4336
|
+
var import_lodash17 = require("lodash");
|
|
2765
4337
|
var OPTIONS3 = {
|
|
2766
4338
|
// Allowing click through and prevent interaction
|
|
2767
4339
|
interactive: false,
|
|
@@ -2779,9 +4351,9 @@ var defaultFlatLabelOptions = {
|
|
|
2779
4351
|
textBaseline: "middle",
|
|
2780
4352
|
fillStyle: "#000"
|
|
2781
4353
|
};
|
|
2782
|
-
var defaultRectAngleToCalc = (0,
|
|
4354
|
+
var defaultRectAngleToCalc = (0, import_lodash17.range)(-90, 92, 2);
|
|
2783
4355
|
var getMaterial = (text, flatLabelOptions) => {
|
|
2784
|
-
const options = (0,
|
|
4356
|
+
const options = (0, import_lodash17.merge)({}, defaultFlatLabelOptions, flatLabelOptions);
|
|
2785
4357
|
const {
|
|
2786
4358
|
fontSize: initialFontSize,
|
|
2787
4359
|
fontFamily,
|
|
@@ -2834,23 +4406,23 @@ var getMaterial = (text, flatLabelOptions) => {
|
|
|
2834
4406
|
const maxWidth = SIZE - 2 * margin;
|
|
2835
4407
|
texts = wrapText(ctx, text, maxWidth);
|
|
2836
4408
|
}
|
|
2837
|
-
let textWidth = (0,
|
|
4409
|
+
let textWidth = (0, import_lodash17.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
2838
4410
|
let scale3 = 1;
|
|
2839
4411
|
while (scale3 > 0 && textWidth + 2 * margin > SIZE) {
|
|
2840
4412
|
scale3 -= scaleStep;
|
|
2841
4413
|
ctx.font = `${fontWeight} ${scale3 * fontSize}px "${fontFamily}", Arial`;
|
|
2842
|
-
textWidth = (0,
|
|
4414
|
+
textWidth = (0, import_lodash17.max)(texts.map((text2) => ctx.measureText(text2).width));
|
|
2843
4415
|
}
|
|
2844
|
-
const
|
|
4416
|
+
const center8 = { x: 0.5 * SIZE, y: 0.5 * SIZE };
|
|
2845
4417
|
if (scale3 > scaleMin) {
|
|
2846
4418
|
const totalHeight = texts.length * (fontSize * scale3 * lineHeight);
|
|
2847
|
-
const startY =
|
|
4419
|
+
const startY = center8.y - totalHeight / 2 + fontSize * scale3 * lineHeight * 0.5;
|
|
2848
4420
|
texts.forEach((text2, index) => {
|
|
2849
4421
|
const yOffset = startY + index * (fontSize * scale3 * lineHeight);
|
|
2850
4422
|
if (strokeStyle && lineWidth) {
|
|
2851
|
-
ctx.strokeText(text2,
|
|
4423
|
+
ctx.strokeText(text2, center8.x, yOffset);
|
|
2852
4424
|
}
|
|
2853
|
-
ctx.fillText(text2,
|
|
4425
|
+
ctx.fillText(text2, center8.x, yOffset);
|
|
2854
4426
|
});
|
|
2855
4427
|
}
|
|
2856
4428
|
const texture = new import_three5.Texture(canvas);
|
|
@@ -2907,7 +4479,7 @@ var GroundLabel = class extends import_maptalks6.BaseObject {
|
|
|
2907
4479
|
strokeStyle,
|
|
2908
4480
|
lineWidth
|
|
2909
4481
|
});
|
|
2910
|
-
const rectAngles = (0,
|
|
4482
|
+
const rectAngles = (0, import_lodash17.isArray)(angle) ? angle : [angle];
|
|
2911
4483
|
material.needsUpdate = true;
|
|
2912
4484
|
const rect = (0, import_d3plus_shape.largestRect)(bound, {
|
|
2913
4485
|
cache: true,
|
|
@@ -2980,32 +4552,32 @@ var GroundLabel = class extends import_maptalks6.BaseObject {
|
|
|
2980
4552
|
return { x: this.#offsetX, y: this.#offsetY };
|
|
2981
4553
|
}
|
|
2982
4554
|
set offsetX(value) {
|
|
2983
|
-
if ((0,
|
|
4555
|
+
if ((0, import_lodash17.isNumber)(value)) {
|
|
2984
4556
|
this.#offsetX = value;
|
|
2985
4557
|
this.#updatePosition();
|
|
2986
4558
|
}
|
|
2987
4559
|
}
|
|
2988
4560
|
set offsetY(value) {
|
|
2989
|
-
if ((0,
|
|
4561
|
+
if ((0, import_lodash17.isNumber)(value)) {
|
|
2990
4562
|
this.#offsetY = value;
|
|
2991
4563
|
this.#updatePosition();
|
|
2992
4564
|
}
|
|
2993
4565
|
}
|
|
2994
4566
|
set angle(newAngle) {
|
|
2995
|
-
if ((0,
|
|
4567
|
+
if ((0, import_lodash17.isNumber)(newAngle)) {
|
|
2996
4568
|
this.#angle = newAngle;
|
|
2997
4569
|
this.getObject3d().rotation.z = Math.PI / 180 * this.#angle;
|
|
2998
4570
|
}
|
|
2999
4571
|
}
|
|
3000
4572
|
setOffset(offsetX, offsetY) {
|
|
3001
|
-
if ((0,
|
|
4573
|
+
if ((0, import_lodash17.isNumber)(offsetX) && (0, import_lodash17.isNumber)(offsetY)) {
|
|
3002
4574
|
this.#offsetX = offsetX;
|
|
3003
4575
|
this.#offsetY = offsetY;
|
|
3004
4576
|
this.#updatePosition();
|
|
3005
4577
|
}
|
|
3006
4578
|
}
|
|
3007
4579
|
addOffset(deltaX, deltaY) {
|
|
3008
|
-
if ((0,
|
|
4580
|
+
if ((0, import_lodash17.isNumber)(deltaX) && (0, import_lodash17.isNumber)(deltaY)) {
|
|
3009
4581
|
this.#offsetX += deltaX;
|
|
3010
4582
|
this.#offsetY += deltaY;
|
|
3011
4583
|
this.#updatePosition();
|
|
@@ -3107,6 +4679,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3107
4679
|
threeLayer;
|
|
3108
4680
|
scene;
|
|
3109
4681
|
lineMaterial;
|
|
4682
|
+
navigationLineMaterial;
|
|
3110
4683
|
materialByColorMap;
|
|
3111
4684
|
// Renderer is Ready
|
|
3112
4685
|
isReady = false;
|
|
@@ -3118,6 +4691,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3118
4691
|
this.threeLayer = groupLayer.getLayer("three");
|
|
3119
4692
|
this.gltfLayer = groupLayer.getLayer("gltf");
|
|
3120
4693
|
this.lineMaterial = new THREE.LineBasicMaterial({ color: "#000" });
|
|
4694
|
+
this.navigationLineMaterial = new THREE.LineBasicMaterial({ color: "#f00" });
|
|
3121
4695
|
this.render();
|
|
3122
4696
|
}
|
|
3123
4697
|
animation() {
|
|
@@ -3233,7 +4807,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3233
4807
|
const polygons = unit.geometry.type === "Polygon" ? [unit.geometry.coordinates] : unit.geometry.coordinates;
|
|
3234
4808
|
return polygons.map((plg) => {
|
|
3235
4809
|
return plg.map((ring) => {
|
|
3236
|
-
const roomWall = (0,
|
|
4810
|
+
const roomWall = (0, import_clean_coords2.cleanCoords)((0, import_polygon_to_line.polygonToLine)(polygon([ring])));
|
|
3237
4811
|
if (openings.length === 0) {
|
|
3238
4812
|
const color = "#ababab";
|
|
3239
4813
|
const material = this.getOrCreateMaterialByColor(color);
|
|
@@ -3261,7 +4835,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3261
4835
|
try {
|
|
3262
4836
|
const split = (0, import_line_split.default)(roomWall, multiPoint(openingPoints));
|
|
3263
4837
|
const wallsOnly = split.features.filter((seg) => {
|
|
3264
|
-
const mid = (0, import_along.along)(seg, (0,
|
|
4838
|
+
const mid = (0, import_along.along)(seg, (0, import_length2.length)(seg, { units: "meters" }) / 2, { units: "meters" });
|
|
3265
4839
|
for (const opening of openings) {
|
|
3266
4840
|
const dist = (0, import_point_to_line_distance.pointToLineDistance)(mid, opening, { units: "meters" });
|
|
3267
4841
|
if (dist < 0.05) return false;
|
|
@@ -3320,10 +4894,10 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3320
4894
|
this.threeLayer.addMesh(groundLabel);
|
|
3321
4895
|
return groundLabel;
|
|
3322
4896
|
}
|
|
3323
|
-
async createModel3d(
|
|
3324
|
-
const marker = new maptalks4.GLTFMarker(
|
|
4897
|
+
async createModel3d(center8, url) {
|
|
4898
|
+
const marker = new maptalks4.GLTFMarker(center8, {
|
|
3325
4899
|
symbol: {
|
|
3326
|
-
url
|
|
4900
|
+
url
|
|
3327
4901
|
}
|
|
3328
4902
|
});
|
|
3329
4903
|
marker.addTo(this.gltfLayer);
|
|
@@ -3382,11 +4956,23 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3382
4956
|
}
|
|
3383
4957
|
}
|
|
3384
4958
|
}
|
|
4959
|
+
drawNavigation = (route) => {
|
|
4960
|
+
const lines = [];
|
|
4961
|
+
route.steps.map((step) => {
|
|
4962
|
+
const lineString2 = new maptalks4.LineString(step.path);
|
|
4963
|
+
const line = this.threeLayer.toPath(lineString2, { altitude: 0.2, cornerRadius: 1, width: 1, asynchronous: true }, this.navigationLineMaterial);
|
|
4964
|
+
lines.push(line);
|
|
4965
|
+
});
|
|
4966
|
+
this.threeLayer.addMesh(lines);
|
|
4967
|
+
};
|
|
3385
4968
|
render() {
|
|
3386
4969
|
this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
|
|
3387
4970
|
if (this.threeLayer._needsUpdate) {
|
|
3388
4971
|
this.threeLayer.redraw();
|
|
3389
4972
|
}
|
|
4973
|
+
if (this.navigationLineMaterial?.map?.offset) {
|
|
4974
|
+
this.navigationLineMaterial.map.offset.x -= 2e-3;
|
|
4975
|
+
}
|
|
3390
4976
|
requestAnimationFrame(this.render.bind(this));
|
|
3391
4977
|
}
|
|
3392
4978
|
};
|
|
@@ -3526,6 +5112,8 @@ var Element2DRenderer = class extends EventTarget {
|
|
|
3526
5112
|
}
|
|
3527
5113
|
};
|
|
3528
5114
|
}
|
|
5115
|
+
drawNavigation(route) {
|
|
5116
|
+
}
|
|
3529
5117
|
};
|
|
3530
5118
|
|
|
3531
5119
|
// src/IndoorMap/renderer/2d/Marker2DRenderer.ts
|
|
@@ -3571,7 +5159,7 @@ var THREE3 = __toESM(require("three"));
|
|
|
3571
5159
|
var import_maptalks8 = require("maptalks");
|
|
3572
5160
|
var THREE2 = __toESM(require("three"));
|
|
3573
5161
|
var import_maptalks9 = require("maptalks.three");
|
|
3574
|
-
var
|
|
5162
|
+
var import_lodash18 = require("lodash");
|
|
3575
5163
|
|
|
3576
5164
|
// src/IndoorMap/renderer/utils/interpolateStops.ts
|
|
3577
5165
|
var interpolateStops = ({ stops }, zoom) => {
|
|
@@ -3581,8 +5169,8 @@ var interpolateStops = ({ stops }, zoom) => {
|
|
|
3581
5169
|
const [z1, v1] = stops[i];
|
|
3582
5170
|
const [z2, v2] = stops[i + 1];
|
|
3583
5171
|
if (zoom >= z1 && zoom <= z2) {
|
|
3584
|
-
const
|
|
3585
|
-
return v1 +
|
|
5172
|
+
const t2 = (zoom - z1) / (z2 - z1);
|
|
5173
|
+
return v1 + t2 * (v2 - v1);
|
|
3586
5174
|
}
|
|
3587
5175
|
}
|
|
3588
5176
|
};
|
|
@@ -3666,7 +5254,7 @@ var TextSpriteMarker = class extends import_maptalks9.BaseObject {
|
|
|
3666
5254
|
const paragraphs = String(text).split("\n");
|
|
3667
5255
|
const wrappedLines = [];
|
|
3668
5256
|
paragraphs.forEach((paragraph) => {
|
|
3669
|
-
if ((0,
|
|
5257
|
+
if ((0, import_lodash18.isNil)(maxWidth) || isNaN(maxWidth)) {
|
|
3670
5258
|
wrappedLines.push(paragraph);
|
|
3671
5259
|
return;
|
|
3672
5260
|
}
|
|
@@ -3727,7 +5315,7 @@ var TextSpriteMarker = class extends import_maptalks9.BaseObject {
|
|
|
3727
5315
|
const altitude = (options.altitude || 0) + this.#altitudeOffset;
|
|
3728
5316
|
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
3729
5317
|
const position = layer.coordinateToVector3(this._coordinate, z);
|
|
3730
|
-
(0,
|
|
5318
|
+
(0, import_lodash18.set)(this.properties, "default.position", position);
|
|
3731
5319
|
this.getObject3d().position.copy(position);
|
|
3732
5320
|
}
|
|
3733
5321
|
_animation() {
|
|
@@ -3901,478 +5489,11 @@ var angleBetweenLineStrings = (line1, line2) => {
|
|
|
3901
5489
|
return Math.atan2(dy, dx);
|
|
3902
5490
|
};
|
|
3903
5491
|
|
|
3904
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/util.js
|
|
3905
|
-
var epsilon = 11102230246251565e-32;
|
|
3906
|
-
var splitter = 134217729;
|
|
3907
|
-
var resulterrbound = (3 + 8 * epsilon) * epsilon;
|
|
3908
|
-
function sum(elen, e, flen, f, h) {
|
|
3909
|
-
let Q, Qnew, hh, bvirt;
|
|
3910
|
-
let enow = e[0];
|
|
3911
|
-
let fnow = f[0];
|
|
3912
|
-
let eindex = 0;
|
|
3913
|
-
let findex = 0;
|
|
3914
|
-
if (fnow > enow === fnow > -enow) {
|
|
3915
|
-
Q = enow;
|
|
3916
|
-
enow = e[++eindex];
|
|
3917
|
-
} else {
|
|
3918
|
-
Q = fnow;
|
|
3919
|
-
fnow = f[++findex];
|
|
3920
|
-
}
|
|
3921
|
-
let hindex = 0;
|
|
3922
|
-
if (eindex < elen && findex < flen) {
|
|
3923
|
-
if (fnow > enow === fnow > -enow) {
|
|
3924
|
-
Qnew = enow + Q;
|
|
3925
|
-
hh = Q - (Qnew - enow);
|
|
3926
|
-
enow = e[++eindex];
|
|
3927
|
-
} else {
|
|
3928
|
-
Qnew = fnow + Q;
|
|
3929
|
-
hh = Q - (Qnew - fnow);
|
|
3930
|
-
fnow = f[++findex];
|
|
3931
|
-
}
|
|
3932
|
-
Q = Qnew;
|
|
3933
|
-
if (hh !== 0) {
|
|
3934
|
-
h[hindex++] = hh;
|
|
3935
|
-
}
|
|
3936
|
-
while (eindex < elen && findex < flen) {
|
|
3937
|
-
if (fnow > enow === fnow > -enow) {
|
|
3938
|
-
Qnew = Q + enow;
|
|
3939
|
-
bvirt = Qnew - Q;
|
|
3940
|
-
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3941
|
-
enow = e[++eindex];
|
|
3942
|
-
} else {
|
|
3943
|
-
Qnew = Q + fnow;
|
|
3944
|
-
bvirt = Qnew - Q;
|
|
3945
|
-
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3946
|
-
fnow = f[++findex];
|
|
3947
|
-
}
|
|
3948
|
-
Q = Qnew;
|
|
3949
|
-
if (hh !== 0) {
|
|
3950
|
-
h[hindex++] = hh;
|
|
3951
|
-
}
|
|
3952
|
-
}
|
|
3953
|
-
}
|
|
3954
|
-
while (eindex < elen) {
|
|
3955
|
-
Qnew = Q + enow;
|
|
3956
|
-
bvirt = Qnew - Q;
|
|
3957
|
-
hh = Q - (Qnew - bvirt) + (enow - bvirt);
|
|
3958
|
-
enow = e[++eindex];
|
|
3959
|
-
Q = Qnew;
|
|
3960
|
-
if (hh !== 0) {
|
|
3961
|
-
h[hindex++] = hh;
|
|
3962
|
-
}
|
|
3963
|
-
}
|
|
3964
|
-
while (findex < flen) {
|
|
3965
|
-
Qnew = Q + fnow;
|
|
3966
|
-
bvirt = Qnew - Q;
|
|
3967
|
-
hh = Q - (Qnew - bvirt) + (fnow - bvirt);
|
|
3968
|
-
fnow = f[++findex];
|
|
3969
|
-
Q = Qnew;
|
|
3970
|
-
if (hh !== 0) {
|
|
3971
|
-
h[hindex++] = hh;
|
|
3972
|
-
}
|
|
3973
|
-
}
|
|
3974
|
-
if (Q !== 0 || hindex === 0) {
|
|
3975
|
-
h[hindex++] = Q;
|
|
3976
|
-
}
|
|
3977
|
-
return hindex;
|
|
3978
|
-
}
|
|
3979
|
-
function estimate(elen, e) {
|
|
3980
|
-
let Q = e[0];
|
|
3981
|
-
for (let i = 1; i < elen; i++) Q += e[i];
|
|
3982
|
-
return Q;
|
|
3983
|
-
}
|
|
3984
|
-
function vec(n) {
|
|
3985
|
-
return new Float64Array(n);
|
|
3986
|
-
}
|
|
3987
|
-
|
|
3988
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient2d.js
|
|
3989
|
-
var ccwerrboundA = (3 + 16 * epsilon) * epsilon;
|
|
3990
|
-
var ccwerrboundB = (2 + 12 * epsilon) * epsilon;
|
|
3991
|
-
var ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
|
|
3992
|
-
var B = vec(4);
|
|
3993
|
-
var C1 = vec(8);
|
|
3994
|
-
var C2 = vec(12);
|
|
3995
|
-
var D = vec(16);
|
|
3996
|
-
var u = vec(4);
|
|
3997
|
-
function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
|
|
3998
|
-
let acxtail, acytail, bcxtail, bcytail;
|
|
3999
|
-
let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u32;
|
|
4000
|
-
const acx = ax - cx;
|
|
4001
|
-
const bcx = bx - cx;
|
|
4002
|
-
const acy = ay - cy;
|
|
4003
|
-
const bcy = by - cy;
|
|
4004
|
-
s1 = acx * bcy;
|
|
4005
|
-
c = splitter * acx;
|
|
4006
|
-
ahi = c - (c - acx);
|
|
4007
|
-
alo = acx - ahi;
|
|
4008
|
-
c = splitter * bcy;
|
|
4009
|
-
bhi = c - (c - bcy);
|
|
4010
|
-
blo = bcy - bhi;
|
|
4011
|
-
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4012
|
-
t1 = acy * bcx;
|
|
4013
|
-
c = splitter * acy;
|
|
4014
|
-
ahi = c - (c - acy);
|
|
4015
|
-
alo = acy - ahi;
|
|
4016
|
-
c = splitter * bcx;
|
|
4017
|
-
bhi = c - (c - bcx);
|
|
4018
|
-
blo = bcx - bhi;
|
|
4019
|
-
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4020
|
-
_i = s0 - t0;
|
|
4021
|
-
bvirt = s0 - _i;
|
|
4022
|
-
B[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4023
|
-
_j = s1 + _i;
|
|
4024
|
-
bvirt = _j - s1;
|
|
4025
|
-
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4026
|
-
_i = _0 - t1;
|
|
4027
|
-
bvirt = _0 - _i;
|
|
4028
|
-
B[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4029
|
-
u32 = _j + _i;
|
|
4030
|
-
bvirt = u32 - _j;
|
|
4031
|
-
B[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4032
|
-
B[3] = u32;
|
|
4033
|
-
let det = estimate(4, B);
|
|
4034
|
-
let errbound = ccwerrboundB * detsum;
|
|
4035
|
-
if (det >= errbound || -det >= errbound) {
|
|
4036
|
-
return det;
|
|
4037
|
-
}
|
|
4038
|
-
bvirt = ax - acx;
|
|
4039
|
-
acxtail = ax - (acx + bvirt) + (bvirt - cx);
|
|
4040
|
-
bvirt = bx - bcx;
|
|
4041
|
-
bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
|
|
4042
|
-
bvirt = ay - acy;
|
|
4043
|
-
acytail = ay - (acy + bvirt) + (bvirt - cy);
|
|
4044
|
-
bvirt = by - bcy;
|
|
4045
|
-
bcytail = by - (bcy + bvirt) + (bvirt - cy);
|
|
4046
|
-
if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
|
|
4047
|
-
return det;
|
|
4048
|
-
}
|
|
4049
|
-
errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
|
|
4050
|
-
det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
|
|
4051
|
-
if (det >= errbound || -det >= errbound) return det;
|
|
4052
|
-
s1 = acxtail * bcy;
|
|
4053
|
-
c = splitter * acxtail;
|
|
4054
|
-
ahi = c - (c - acxtail);
|
|
4055
|
-
alo = acxtail - ahi;
|
|
4056
|
-
c = splitter * bcy;
|
|
4057
|
-
bhi = c - (c - bcy);
|
|
4058
|
-
blo = bcy - bhi;
|
|
4059
|
-
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4060
|
-
t1 = acytail * bcx;
|
|
4061
|
-
c = splitter * acytail;
|
|
4062
|
-
ahi = c - (c - acytail);
|
|
4063
|
-
alo = acytail - ahi;
|
|
4064
|
-
c = splitter * bcx;
|
|
4065
|
-
bhi = c - (c - bcx);
|
|
4066
|
-
blo = bcx - bhi;
|
|
4067
|
-
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4068
|
-
_i = s0 - t0;
|
|
4069
|
-
bvirt = s0 - _i;
|
|
4070
|
-
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4071
|
-
_j = s1 + _i;
|
|
4072
|
-
bvirt = _j - s1;
|
|
4073
|
-
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4074
|
-
_i = _0 - t1;
|
|
4075
|
-
bvirt = _0 - _i;
|
|
4076
|
-
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4077
|
-
u32 = _j + _i;
|
|
4078
|
-
bvirt = u32 - _j;
|
|
4079
|
-
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4080
|
-
u[3] = u32;
|
|
4081
|
-
const C1len = sum(4, B, 4, u, C1);
|
|
4082
|
-
s1 = acx * bcytail;
|
|
4083
|
-
c = splitter * acx;
|
|
4084
|
-
ahi = c - (c - acx);
|
|
4085
|
-
alo = acx - ahi;
|
|
4086
|
-
c = splitter * bcytail;
|
|
4087
|
-
bhi = c - (c - bcytail);
|
|
4088
|
-
blo = bcytail - bhi;
|
|
4089
|
-
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4090
|
-
t1 = acy * bcxtail;
|
|
4091
|
-
c = splitter * acy;
|
|
4092
|
-
ahi = c - (c - acy);
|
|
4093
|
-
alo = acy - ahi;
|
|
4094
|
-
c = splitter * bcxtail;
|
|
4095
|
-
bhi = c - (c - bcxtail);
|
|
4096
|
-
blo = bcxtail - bhi;
|
|
4097
|
-
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4098
|
-
_i = s0 - t0;
|
|
4099
|
-
bvirt = s0 - _i;
|
|
4100
|
-
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4101
|
-
_j = s1 + _i;
|
|
4102
|
-
bvirt = _j - s1;
|
|
4103
|
-
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4104
|
-
_i = _0 - t1;
|
|
4105
|
-
bvirt = _0 - _i;
|
|
4106
|
-
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4107
|
-
u32 = _j + _i;
|
|
4108
|
-
bvirt = u32 - _j;
|
|
4109
|
-
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4110
|
-
u[3] = u32;
|
|
4111
|
-
const C2len = sum(C1len, C1, 4, u, C2);
|
|
4112
|
-
s1 = acxtail * bcytail;
|
|
4113
|
-
c = splitter * acxtail;
|
|
4114
|
-
ahi = c - (c - acxtail);
|
|
4115
|
-
alo = acxtail - ahi;
|
|
4116
|
-
c = splitter * bcytail;
|
|
4117
|
-
bhi = c - (c - bcytail);
|
|
4118
|
-
blo = bcytail - bhi;
|
|
4119
|
-
s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4120
|
-
t1 = acytail * bcxtail;
|
|
4121
|
-
c = splitter * acytail;
|
|
4122
|
-
ahi = c - (c - acytail);
|
|
4123
|
-
alo = acytail - ahi;
|
|
4124
|
-
c = splitter * bcxtail;
|
|
4125
|
-
bhi = c - (c - bcxtail);
|
|
4126
|
-
blo = bcxtail - bhi;
|
|
4127
|
-
t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
|
|
4128
|
-
_i = s0 - t0;
|
|
4129
|
-
bvirt = s0 - _i;
|
|
4130
|
-
u[0] = s0 - (_i + bvirt) + (bvirt - t0);
|
|
4131
|
-
_j = s1 + _i;
|
|
4132
|
-
bvirt = _j - s1;
|
|
4133
|
-
_0 = s1 - (_j - bvirt) + (_i - bvirt);
|
|
4134
|
-
_i = _0 - t1;
|
|
4135
|
-
bvirt = _0 - _i;
|
|
4136
|
-
u[1] = _0 - (_i + bvirt) + (bvirt - t1);
|
|
4137
|
-
u32 = _j + _i;
|
|
4138
|
-
bvirt = u32 - _j;
|
|
4139
|
-
u[2] = _j - (u32 - bvirt) + (_i - bvirt);
|
|
4140
|
-
u[3] = u32;
|
|
4141
|
-
const Dlen = sum(C2len, C2, 4, u, D);
|
|
4142
|
-
return D[Dlen - 1];
|
|
4143
|
-
}
|
|
4144
|
-
function orient2d(ax, ay, bx, by, cx, cy) {
|
|
4145
|
-
const detleft = (ay - cy) * (bx - cx);
|
|
4146
|
-
const detright = (ax - cx) * (by - cy);
|
|
4147
|
-
const det = detleft - detright;
|
|
4148
|
-
const detsum = Math.abs(detleft + detright);
|
|
4149
|
-
if (Math.abs(det) >= ccwerrboundA * detsum) return det;
|
|
4150
|
-
return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
|
|
4151
|
-
}
|
|
4152
|
-
|
|
4153
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/orient3d.js
|
|
4154
|
-
var o3derrboundA = (7 + 56 * epsilon) * epsilon;
|
|
4155
|
-
var o3derrboundB = (3 + 28 * epsilon) * epsilon;
|
|
4156
|
-
var o3derrboundC = (26 + 288 * epsilon) * epsilon * epsilon;
|
|
4157
|
-
var bc = vec(4);
|
|
4158
|
-
var ca = vec(4);
|
|
4159
|
-
var ab = vec(4);
|
|
4160
|
-
var at_b = vec(4);
|
|
4161
|
-
var at_c = vec(4);
|
|
4162
|
-
var bt_c = vec(4);
|
|
4163
|
-
var bt_a = vec(4);
|
|
4164
|
-
var ct_a = vec(4);
|
|
4165
|
-
var ct_b = vec(4);
|
|
4166
|
-
var bct = vec(8);
|
|
4167
|
-
var cat = vec(8);
|
|
4168
|
-
var abt = vec(8);
|
|
4169
|
-
var u2 = vec(4);
|
|
4170
|
-
var _8 = vec(8);
|
|
4171
|
-
var _8b = vec(8);
|
|
4172
|
-
var _16 = vec(8);
|
|
4173
|
-
var _12 = vec(12);
|
|
4174
|
-
var fin = vec(192);
|
|
4175
|
-
var fin2 = vec(192);
|
|
4176
|
-
|
|
4177
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/incircle.js
|
|
4178
|
-
var iccerrboundA = (10 + 96 * epsilon) * epsilon;
|
|
4179
|
-
var iccerrboundB = (4 + 48 * epsilon) * epsilon;
|
|
4180
|
-
var iccerrboundC = (44 + 576 * epsilon) * epsilon * epsilon;
|
|
4181
|
-
var bc2 = vec(4);
|
|
4182
|
-
var ca2 = vec(4);
|
|
4183
|
-
var ab2 = vec(4);
|
|
4184
|
-
var aa = vec(4);
|
|
4185
|
-
var bb = vec(4);
|
|
4186
|
-
var cc = vec(4);
|
|
4187
|
-
var u3 = vec(4);
|
|
4188
|
-
var v = vec(4);
|
|
4189
|
-
var axtbc = vec(8);
|
|
4190
|
-
var aytbc = vec(8);
|
|
4191
|
-
var bxtca = vec(8);
|
|
4192
|
-
var bytca = vec(8);
|
|
4193
|
-
var cxtab = vec(8);
|
|
4194
|
-
var cytab = vec(8);
|
|
4195
|
-
var abt2 = vec(8);
|
|
4196
|
-
var bct2 = vec(8);
|
|
4197
|
-
var cat2 = vec(8);
|
|
4198
|
-
var abtt = vec(4);
|
|
4199
|
-
var bctt = vec(4);
|
|
4200
|
-
var catt = vec(4);
|
|
4201
|
-
var _82 = vec(8);
|
|
4202
|
-
var _162 = vec(16);
|
|
4203
|
-
var _16b = vec(16);
|
|
4204
|
-
var _16c = vec(16);
|
|
4205
|
-
var _32 = vec(32);
|
|
4206
|
-
var _32b = vec(32);
|
|
4207
|
-
var _48 = vec(48);
|
|
4208
|
-
var _64 = vec(64);
|
|
4209
|
-
var fin3 = vec(1152);
|
|
4210
|
-
var fin22 = vec(1152);
|
|
4211
|
-
|
|
4212
|
-
// ../../node_modules/point-in-polygon-hao/node_modules/robust-predicates/esm/insphere.js
|
|
4213
|
-
var isperrboundA = (16 + 224 * epsilon) * epsilon;
|
|
4214
|
-
var isperrboundB = (5 + 72 * epsilon) * epsilon;
|
|
4215
|
-
var isperrboundC = (71 + 1408 * epsilon) * epsilon * epsilon;
|
|
4216
|
-
var ab3 = vec(4);
|
|
4217
|
-
var bc3 = vec(4);
|
|
4218
|
-
var cd = vec(4);
|
|
4219
|
-
var de = vec(4);
|
|
4220
|
-
var ea = vec(4);
|
|
4221
|
-
var ac = vec(4);
|
|
4222
|
-
var bd = vec(4);
|
|
4223
|
-
var ce = vec(4);
|
|
4224
|
-
var da = vec(4);
|
|
4225
|
-
var eb = vec(4);
|
|
4226
|
-
var abc = vec(24);
|
|
4227
|
-
var bcd = vec(24);
|
|
4228
|
-
var cde = vec(24);
|
|
4229
|
-
var dea = vec(24);
|
|
4230
|
-
var eab = vec(24);
|
|
4231
|
-
var abd = vec(24);
|
|
4232
|
-
var bce = vec(24);
|
|
4233
|
-
var cda = vec(24);
|
|
4234
|
-
var deb = vec(24);
|
|
4235
|
-
var eac = vec(24);
|
|
4236
|
-
var adet = vec(1152);
|
|
4237
|
-
var bdet = vec(1152);
|
|
4238
|
-
var cdet = vec(1152);
|
|
4239
|
-
var ddet = vec(1152);
|
|
4240
|
-
var edet = vec(1152);
|
|
4241
|
-
var abdet = vec(2304);
|
|
4242
|
-
var cddet = vec(2304);
|
|
4243
|
-
var cdedet = vec(3456);
|
|
4244
|
-
var deter = vec(5760);
|
|
4245
|
-
var _83 = vec(8);
|
|
4246
|
-
var _8b2 = vec(8);
|
|
4247
|
-
var _8c = vec(8);
|
|
4248
|
-
var _163 = vec(16);
|
|
4249
|
-
var _24 = vec(24);
|
|
4250
|
-
var _482 = vec(48);
|
|
4251
|
-
var _48b = vec(48);
|
|
4252
|
-
var _96 = vec(96);
|
|
4253
|
-
var _192 = vec(192);
|
|
4254
|
-
var _384x = vec(384);
|
|
4255
|
-
var _384y = vec(384);
|
|
4256
|
-
var _384z = vec(384);
|
|
4257
|
-
var _768 = vec(768);
|
|
4258
|
-
var xdet = vec(96);
|
|
4259
|
-
var ydet = vec(96);
|
|
4260
|
-
var zdet = vec(96);
|
|
4261
|
-
var fin4 = vec(1152);
|
|
4262
|
-
|
|
4263
|
-
// ../../node_modules/point-in-polygon-hao/dist/esm/index.js
|
|
4264
|
-
function pointInPolygon(p, polygon2) {
|
|
4265
|
-
var i;
|
|
4266
|
-
var ii;
|
|
4267
|
-
var k = 0;
|
|
4268
|
-
var f;
|
|
4269
|
-
var u1;
|
|
4270
|
-
var v1;
|
|
4271
|
-
var u22;
|
|
4272
|
-
var v2;
|
|
4273
|
-
var currentP;
|
|
4274
|
-
var nextP;
|
|
4275
|
-
var x = p[0];
|
|
4276
|
-
var y = p[1];
|
|
4277
|
-
var numContours = polygon2.length;
|
|
4278
|
-
for (i = 0; i < numContours; i++) {
|
|
4279
|
-
ii = 0;
|
|
4280
|
-
var contour = polygon2[i];
|
|
4281
|
-
var contourLen = contour.length - 1;
|
|
4282
|
-
currentP = contour[0];
|
|
4283
|
-
if (currentP[0] !== contour[contourLen][0] && currentP[1] !== contour[contourLen][1]) {
|
|
4284
|
-
throw new Error("First and last coordinates in a ring must be the same");
|
|
4285
|
-
}
|
|
4286
|
-
u1 = currentP[0] - x;
|
|
4287
|
-
v1 = currentP[1] - y;
|
|
4288
|
-
for (ii; ii < contourLen; ii++) {
|
|
4289
|
-
nextP = contour[ii + 1];
|
|
4290
|
-
u22 = nextP[0] - x;
|
|
4291
|
-
v2 = nextP[1] - y;
|
|
4292
|
-
if (v1 === 0 && v2 === 0) {
|
|
4293
|
-
if (u22 <= 0 && u1 >= 0 || u1 <= 0 && u22 >= 0) {
|
|
4294
|
-
return 0;
|
|
4295
|
-
}
|
|
4296
|
-
} else if (v2 >= 0 && v1 <= 0 || v2 <= 0 && v1 >= 0) {
|
|
4297
|
-
f = orient2d(u1, u22, v1, v2, 0, 0);
|
|
4298
|
-
if (f === 0) {
|
|
4299
|
-
return 0;
|
|
4300
|
-
}
|
|
4301
|
-
if (f > 0 && v2 > 0 && v1 <= 0 || f < 0 && v2 <= 0 && v1 > 0) {
|
|
4302
|
-
k++;
|
|
4303
|
-
}
|
|
4304
|
-
}
|
|
4305
|
-
currentP = nextP;
|
|
4306
|
-
v1 = v2;
|
|
4307
|
-
u1 = u22;
|
|
4308
|
-
}
|
|
4309
|
-
}
|
|
4310
|
-
if (k % 2 === 0) {
|
|
4311
|
-
return false;
|
|
4312
|
-
}
|
|
4313
|
-
return true;
|
|
4314
|
-
}
|
|
4315
|
-
|
|
4316
|
-
// ../../node_modules/@turf/invariant/dist/esm/index.js
|
|
4317
|
-
function getCoord(coord) {
|
|
4318
|
-
if (!coord) {
|
|
4319
|
-
throw new Error("coord is required");
|
|
4320
|
-
}
|
|
4321
|
-
if (!Array.isArray(coord)) {
|
|
4322
|
-
if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
|
4323
|
-
return [...coord.geometry.coordinates];
|
|
4324
|
-
}
|
|
4325
|
-
if (coord.type === "Point") {
|
|
4326
|
-
return [...coord.coordinates];
|
|
4327
|
-
}
|
|
4328
|
-
}
|
|
4329
|
-
if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
|
4330
|
-
return [...coord];
|
|
4331
|
-
}
|
|
4332
|
-
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
4333
|
-
}
|
|
4334
|
-
function getGeom(geojson) {
|
|
4335
|
-
if (geojson.type === "Feature") {
|
|
4336
|
-
return geojson.geometry;
|
|
4337
|
-
}
|
|
4338
|
-
return geojson;
|
|
4339
|
-
}
|
|
4340
|
-
|
|
4341
|
-
// ../../node_modules/@turf/boolean-point-in-polygon/dist/esm/index.js
|
|
4342
|
-
function booleanPointInPolygon(point2, polygon2, options = {}) {
|
|
4343
|
-
if (!point2) {
|
|
4344
|
-
throw new Error("point is required");
|
|
4345
|
-
}
|
|
4346
|
-
if (!polygon2) {
|
|
4347
|
-
throw new Error("polygon is required");
|
|
4348
|
-
}
|
|
4349
|
-
const pt = getCoord(point2);
|
|
4350
|
-
const geom = getGeom(polygon2);
|
|
4351
|
-
const type = geom.type;
|
|
4352
|
-
const bbox2 = polygon2.bbox;
|
|
4353
|
-
let polys = geom.coordinates;
|
|
4354
|
-
if (bbox2 && inBBox(pt, bbox2) === false) {
|
|
4355
|
-
return false;
|
|
4356
|
-
}
|
|
4357
|
-
if (type === "Polygon") {
|
|
4358
|
-
polys = [polys];
|
|
4359
|
-
}
|
|
4360
|
-
let result = false;
|
|
4361
|
-
for (var i = 0; i < polys.length; ++i) {
|
|
4362
|
-
const polyResult = pointInPolygon(pt, polys[i]);
|
|
4363
|
-
if (polyResult === 0) return options.ignoreBoundary ? false : true;
|
|
4364
|
-
else if (polyResult) result = true;
|
|
4365
|
-
}
|
|
4366
|
-
return result;
|
|
4367
|
-
}
|
|
4368
|
-
function inBBox(pt, bbox2) {
|
|
4369
|
-
return bbox2[0] <= pt[0] && bbox2[1] <= pt[1] && bbox2[2] >= pt[0] && bbox2[3] >= pt[1];
|
|
4370
|
-
}
|
|
4371
|
-
|
|
4372
5492
|
// src/IndoorMap/renderer/utils/findUnitOnPoint.ts
|
|
5493
|
+
var import_boolean_point_in_polygon5 = require("@turf/boolean-point-in-polygon");
|
|
4373
5494
|
var findUnitOnPoint = (units, point2) => {
|
|
4374
5495
|
try {
|
|
4375
|
-
return units.find((unit) => booleanPointInPolygon(point2, polygon(unit.geometry.coordinates)));
|
|
5496
|
+
return units.find((unit) => (0, import_boolean_point_in_polygon5.booleanPointInPolygon)(point2, polygon(unit.geometry.coordinates)));
|
|
4376
5497
|
} catch (err) {
|
|
4377
5498
|
return null;
|
|
4378
5499
|
}
|
|
@@ -4421,9 +5542,9 @@ var RendererManager = class extends EventTarget {
|
|
|
4421
5542
|
const pos = geom?.attributes?.position?.array;
|
|
4422
5543
|
if (!pos || pos.length === 0) return;
|
|
4423
5544
|
for (let i = 0; i < pos.length; i++) {
|
|
4424
|
-
const
|
|
4425
|
-
if (!Number.isFinite(
|
|
4426
|
-
bad.push({ mesh: obj, index: i, value:
|
|
5545
|
+
const v = pos[i];
|
|
5546
|
+
if (!Number.isFinite(v)) {
|
|
5547
|
+
bad.push({ mesh: obj, index: i, value: v });
|
|
4427
5548
|
break;
|
|
4428
5549
|
}
|
|
4429
5550
|
}
|
|
@@ -4459,6 +5580,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4459
5580
|
options.onRendererReady();
|
|
4460
5581
|
}
|
|
4461
5582
|
_this.#createElements();
|
|
5583
|
+
_this.elementRenderer.createModel3d([100.54724407, 13.72699081], "https://s3.venue.in.th/all_park_f95ac5be3c.gltf");
|
|
4462
5584
|
setTimeout(() => {
|
|
4463
5585
|
findBadMeshes(scene);
|
|
4464
5586
|
}, 3e3);
|
|
@@ -4476,7 +5598,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4476
5598
|
if (this.#isClicked) return;
|
|
4477
5599
|
this.#isClicked = true;
|
|
4478
5600
|
const onClickElement = this.#onClickElement;
|
|
4479
|
-
if (!(0,
|
|
5601
|
+
if (!(0, import_lodash19.isFunction)(onClickElement)) return;
|
|
4480
5602
|
this.#onClickElement(e);
|
|
4481
5603
|
this.#isClicked = false;
|
|
4482
5604
|
};
|
|
@@ -4519,7 +5641,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4519
5641
|
populate: true
|
|
4520
5642
|
});
|
|
4521
5643
|
units.filter(
|
|
4522
|
-
(
|
|
5644
|
+
(u) => !["opentobelow", "escalator", "room"].includes(u.properties.category)
|
|
4523
5645
|
).forEach((unit) => {
|
|
4524
5646
|
const element = this.elementRenderer.createGeometry(unit);
|
|
4525
5647
|
if (element) {
|
|
@@ -4527,9 +5649,9 @@ var RendererManager = class extends EventTarget {
|
|
|
4527
5649
|
this.addElementsToManager(unit.id, _elements, unit.properties.level.properties.ordinal);
|
|
4528
5650
|
}
|
|
4529
5651
|
});
|
|
4530
|
-
units.filter((
|
|
5652
|
+
units.filter((u) => u.properties.category === "room").forEach((unit) => {
|
|
4531
5653
|
const openingRelationships = relationships.filter((r) => r.properties.origin?.id === unit.id || r.properties.destination?.id === unit.id);
|
|
4532
|
-
const roomOpenings = (0,
|
|
5654
|
+
const roomOpenings = (0, import_lodash19.compact)(openingRelationships.map((rel) => {
|
|
4533
5655
|
const openingId = rel?.properties.intermediary[0].id;
|
|
4534
5656
|
return openings.find((o) => o.id === openingId);
|
|
4535
5657
|
}));
|
|
@@ -4553,7 +5675,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4553
5675
|
this.addElementsToManager(kiosk.id, _elements, kiosk.properties.level.properties.ordinal);
|
|
4554
5676
|
}
|
|
4555
5677
|
});
|
|
4556
|
-
const escalators = units.filter((
|
|
5678
|
+
const escalators = units.filter((u) => u.properties.category === "escalator");
|
|
4557
5679
|
for (const escalator of escalators) {
|
|
4558
5680
|
try {
|
|
4559
5681
|
const escalatorRelationships = relationships.filter((r) => (r.properties?.intermediary || []).some((inter) => inter.id === escalator.id));
|
|
@@ -4575,7 +5697,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4575
5697
|
const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
|
|
4576
5698
|
const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
4577
5699
|
const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
|
|
4578
|
-
const escalatorEntryPoint = (0,
|
|
5700
|
+
const escalatorEntryPoint = (0, import_center12.center)(thisLevelOpening).geometry.coordinates;
|
|
4579
5701
|
const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
|
|
4580
5702
|
if (element) {
|
|
4581
5703
|
const _elements = Array.isArray(element) ? element : [element];
|
|
@@ -4587,8 +5709,8 @@ var RendererManager = class extends EventTarget {
|
|
|
4587
5709
|
}
|
|
4588
5710
|
const groundLabels = await this.#dataClient.filterByType("label");
|
|
4589
5711
|
for (const label of groundLabels) {
|
|
4590
|
-
const
|
|
4591
|
-
const unit = findUnitOnPoint(units,
|
|
5712
|
+
const center8 = (0, import_center12.center)(polygon(label.geometry.coordinates)).geometry.coordinates;
|
|
5713
|
+
const unit = findUnitOnPoint(units, center8);
|
|
4592
5714
|
if (unit) {
|
|
4593
5715
|
const element = this.elementRenderer.createGroundLabel(label, unit);
|
|
4594
5716
|
if (element) {
|
|
@@ -4597,12 +5719,6 @@ var RendererManager = class extends EventTarget {
|
|
|
4597
5719
|
}
|
|
4598
5720
|
}
|
|
4599
5721
|
}
|
|
4600
|
-
if (this.options.type === "3D") {
|
|
4601
|
-
const model3ds = await this.#dataClient.filterByType("model3d");
|
|
4602
|
-
for (const model3d of model3ds) {
|
|
4603
|
-
this.elementRenderer.createModel3d(model3d);
|
|
4604
|
-
}
|
|
4605
|
-
}
|
|
4606
5722
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
4607
5723
|
this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
|
|
4608
5724
|
}
|
|
@@ -4617,7 +5733,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4617
5733
|
this.markerRenderer.showMarkers(markers, ordinal - baseOrdinal);
|
|
4618
5734
|
}
|
|
4619
5735
|
} else {
|
|
4620
|
-
const baseOrdinal = Array.isArray(targetOrdinal) ? (0,
|
|
5736
|
+
const baseOrdinal = Array.isArray(targetOrdinal) ? (0, import_lodash19.min)(targetOrdinal) : targetOrdinal;
|
|
4621
5737
|
for (const [ordinal, elements] of this.elementsByOrdinal) {
|
|
4622
5738
|
const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal;
|
|
4623
5739
|
if (inOrdinal) {
|
|
@@ -4644,7 +5760,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4644
5760
|
const elements = elemIds.map((id) => this.elementsMap.get(id)).flat();
|
|
4645
5761
|
elements.forEach((element) => {
|
|
4646
5762
|
const controller = this.elementRenderer.createHighlightController(element);
|
|
4647
|
-
if (controller && (0,
|
|
5763
|
+
if (controller && (0, import_lodash19.isFunction)(controller.start)) {
|
|
4648
5764
|
controller.start();
|
|
4649
5765
|
this.highlightControllers.push(controller);
|
|
4650
5766
|
}
|
|
@@ -4652,7 +5768,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4652
5768
|
};
|
|
4653
5769
|
clearHighlightElements = () => {
|
|
4654
5770
|
this.highlightControllers.forEach((controller) => {
|
|
4655
|
-
if ((0,
|
|
5771
|
+
if ((0, import_lodash19.isFunction)(controller?.clear)) controller.clear();
|
|
4656
5772
|
});
|
|
4657
5773
|
};
|
|
4658
5774
|
/**
|
|
@@ -4687,6 +5803,9 @@ var RendererManager = class extends EventTarget {
|
|
|
4687
5803
|
this.markerRenderer.removeMarker(marker);
|
|
4688
5804
|
}
|
|
4689
5805
|
}
|
|
5806
|
+
drawNavigation(route) {
|
|
5807
|
+
this.elementRenderer.drawNavigation(route);
|
|
5808
|
+
}
|
|
4690
5809
|
};
|
|
4691
5810
|
|
|
4692
5811
|
// src/IndoorMap/IndoorMap.ts
|
|
@@ -4764,7 +5883,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4764
5883
|
};
|
|
4765
5884
|
constructor(elementId, options) {
|
|
4766
5885
|
super();
|
|
4767
|
-
const combinedOptions =
|
|
5886
|
+
const combinedOptions = import_lodash20.default.merge({}, defaultOptions, options);
|
|
4768
5887
|
this.options = combinedOptions;
|
|
4769
5888
|
const {
|
|
4770
5889
|
onMapReady,
|
|
@@ -4811,7 +5930,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4811
5930
|
this.dataClient = options.dataClient;
|
|
4812
5931
|
}
|
|
4813
5932
|
setOptions(options) {
|
|
4814
|
-
const combinedOptions =
|
|
5933
|
+
const combinedOptions = import_lodash20.default.merge({}, defaultOptions, options);
|
|
4815
5934
|
this.options = combinedOptions;
|
|
4816
5935
|
const maptalksOptions = parseMaptalksOptions(combinedOptions);
|
|
4817
5936
|
this.map.setOptions(maptalksOptions);
|
|
@@ -4821,10 +5940,10 @@ var IndoorMap = class extends EventTarget {
|
|
|
4821
5940
|
if (!this.options.camera?.defaultView?.center) {
|
|
4822
5941
|
this.#dataClient.filterByType("venue").then((venues) => {
|
|
4823
5942
|
this.#venues = venues;
|
|
4824
|
-
const venueCenters = (0,
|
|
5943
|
+
const venueCenters = (0, import_center13.default)(featureCollection(venues));
|
|
4825
5944
|
const [x, y] = venueCenters.geometry.coordinates;
|
|
4826
|
-
const
|
|
4827
|
-
this.camera.setView({ center:
|
|
5945
|
+
const center8 = new import_maptalks_gl.Coordinate(x, y);
|
|
5946
|
+
this.camera.setView({ center: center8, pitch: 60, zoom: 19 });
|
|
4828
5947
|
});
|
|
4829
5948
|
}
|
|
4830
5949
|
}
|
|
@@ -4837,7 +5956,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4837
5956
|
handleMapClick = ({ coordinate }) => {
|
|
4838
5957
|
const { x, y } = coordinate;
|
|
4839
5958
|
console.log(
|
|
4840
|
-
`[Coordinates]: x: ${
|
|
5959
|
+
`[Coordinates]: x: ${import_lodash20.default.round(x, 8)} y: ${import_lodash20.default.round(
|
|
4841
5960
|
y,
|
|
4842
5961
|
8
|
|
4843
5962
|
)}, [Bearing]: ${this.map.getBearing()}, [Pitch]: ${this.map.getPitch()}`
|
|
@@ -4923,7 +6042,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4923
6042
|
if (this.#isClicked) return;
|
|
4924
6043
|
this.#isClicked = true;
|
|
4925
6044
|
const onClickElement = this.#onClickElement;
|
|
4926
|
-
if (!
|
|
6045
|
+
if (!import_lodash20.default.isFunction(onClickElement)) return;
|
|
4927
6046
|
this.#onClickElement(e);
|
|
4928
6047
|
this.#isClicked = false;
|
|
4929
6048
|
};
|
|
@@ -4943,16 +6062,16 @@ var IndoorMap = class extends EventTarget {
|
|
|
4943
6062
|
for (const feature2 of this.#features) {
|
|
4944
6063
|
try {
|
|
4945
6064
|
const { feature_type: featureType, properties, id } = feature2;
|
|
4946
|
-
const layerName =
|
|
6065
|
+
const layerName = import_lodash20.default.get(
|
|
4947
6066
|
LAYER_FEATURE_TYPE_OBJ,
|
|
4948
6067
|
featureType,
|
|
4949
6068
|
featureType
|
|
4950
6069
|
);
|
|
4951
6070
|
const layer = this.map.getLayer(layerName);
|
|
4952
6071
|
let geometry;
|
|
4953
|
-
const category =
|
|
4954
|
-
const extrudeConfig =
|
|
4955
|
-
const textMarkerType =
|
|
6072
|
+
const category = import_lodash20.default.get(feature2, "properties.category");
|
|
6073
|
+
const extrudeConfig = import_lodash20.default.get(this.#mapConfig, "extrude");
|
|
6074
|
+
const textMarkerType = import_lodash20.default.get(
|
|
4956
6075
|
this.#mapConfig,
|
|
4957
6076
|
"text_marker_type",
|
|
4958
6077
|
"ui-marker"
|
|
@@ -4984,7 +6103,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4984
6103
|
case "opening": {
|
|
4985
6104
|
switch (category) {
|
|
4986
6105
|
case "emergencyexit":
|
|
4987
|
-
const { geometry: geometry2 } = (0,
|
|
6106
|
+
const { geometry: geometry2 } = (0, import_center13.default)(feature2);
|
|
4988
6107
|
const markerFeature = {
|
|
4989
6108
|
...feature2,
|
|
4990
6109
|
geometry: geometry2
|
|
@@ -5067,9 +6186,9 @@ var IndoorMap = class extends EventTarget {
|
|
|
5067
6186
|
const mapCenter = this.map.getCenter();
|
|
5068
6187
|
const result = this.#venues.reduce((closest, venue) => {
|
|
5069
6188
|
const { display_point: displayPoint } = venue.properties;
|
|
5070
|
-
const
|
|
5071
|
-
if (!closest ||
|
|
5072
|
-
return { venueId: venue.id, distance };
|
|
6189
|
+
const distance5 = (0, import_distance6.default)(displayPoint, [mapCenter.x, mapCenter.y]);
|
|
6190
|
+
if (!closest || distance5 < closest.distance) {
|
|
6191
|
+
return { venueId: venue.id, distance: distance5 };
|
|
5073
6192
|
}
|
|
5074
6193
|
return closest;
|
|
5075
6194
|
}, null);
|
|
@@ -5119,15 +6238,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
5119
6238
|
}
|
|
5120
6239
|
}
|
|
5121
6240
|
updateUserLocationSymbolByLocale(locale) {
|
|
5122
|
-
const userLocationGeometry =
|
|
6241
|
+
const userLocationGeometry = import_lodash20.default.get(
|
|
5123
6242
|
this.#elements,
|
|
5124
6243
|
`${USER_LOCATION_ELEMENT_ID}.geometry`
|
|
5125
6244
|
);
|
|
5126
6245
|
if (!userLocationGeometry) return;
|
|
5127
6246
|
const currentSymbol = userLocationGeometry.getSymbol();
|
|
5128
6247
|
const localeSymbolToUpdate = currentSymbol.map((symbol) => {
|
|
5129
|
-
const localeSymbol =
|
|
5130
|
-
if (!
|
|
6248
|
+
const localeSymbol = import_lodash20.default.get(symbol, `${LOCALE_SYMBOL_KEY}.${locale}`) || import_lodash20.default.get(symbol, `${LOCALE_SYMBOL_KEY}.default`);
|
|
6249
|
+
if (!import_lodash20.default.isPlainObject(localeSymbol)) return symbol;
|
|
5131
6250
|
return {
|
|
5132
6251
|
...symbol,
|
|
5133
6252
|
...localeSymbol
|
|
@@ -5201,14 +6320,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
5201
6320
|
* END of User Location
|
|
5202
6321
|
****************************/
|
|
5203
6322
|
showGeometryByElementId = (elementId) => {
|
|
5204
|
-
const geometry =
|
|
6323
|
+
const geometry = import_lodash20.default.get(
|
|
5205
6324
|
this.#elements,
|
|
5206
6325
|
`${elementId}.geometry`
|
|
5207
6326
|
);
|
|
5208
6327
|
if (geometry) geometry.show();
|
|
5209
6328
|
};
|
|
5210
6329
|
hideGeometryByElementId = (elementId) => {
|
|
5211
|
-
const geometry =
|
|
6330
|
+
const geometry = import_lodash20.default.get(this.#elements, `${elementId}.geometry`);
|
|
5212
6331
|
if (geometry) geometry.hide();
|
|
5213
6332
|
};
|
|
5214
6333
|
setSpriteMarkersOpacity = (opacity = 1) => {
|
|
@@ -5247,7 +6366,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5247
6366
|
* Navigation
|
|
5248
6367
|
****************************/
|
|
5249
6368
|
combineNearbyLineStrings(lineStrings, options = { properties: {}, distance: 3e-4 }) {
|
|
5250
|
-
const { properties = {}, distance = 3e-4 } = options || {};
|
|
6369
|
+
const { properties = {}, distance: distance5 = 3e-4 } = options || {};
|
|
5251
6370
|
const combinedLineStrings = [];
|
|
5252
6371
|
const accLine = [];
|
|
5253
6372
|
if (lineStrings.length === 1) return lineStrings;
|
|
@@ -5255,14 +6374,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
5255
6374
|
const line = lineStrings[i];
|
|
5256
6375
|
const coords = line.geometry.coordinates;
|
|
5257
6376
|
const prevLine = lineStrings[i - 1];
|
|
5258
|
-
const firstCoord =
|
|
6377
|
+
const firstCoord = import_lodash20.default.first(coords);
|
|
5259
6378
|
const isFirstLine = i === 0;
|
|
5260
6379
|
if (isFirstLine) {
|
|
5261
6380
|
accLine.push(...coords);
|
|
5262
6381
|
continue;
|
|
5263
6382
|
}
|
|
5264
|
-
const prevLastCoord =
|
|
5265
|
-
const isNearby = (0,
|
|
6383
|
+
const prevLastCoord = import_lodash20.default.last(prevLine.geometry.coordinates);
|
|
6384
|
+
const isNearby = (0, import_distance6.default)(point(firstCoord), point(prevLastCoord)) < distance5;
|
|
5266
6385
|
if (!isNearby) {
|
|
5267
6386
|
const remainingLines = lineStrings.slice(i);
|
|
5268
6387
|
const res = this.combineNearbyLineStrings(remainingLines, properties);
|
|
@@ -5282,8 +6401,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
5282
6401
|
create3DStepPath
|
|
5283
6402
|
} = this.#styler;
|
|
5284
6403
|
const routeMarkerLayer = this.map.getLayer(HIGHLIGHT_LAYER_NAME);
|
|
5285
|
-
const linesByOrdinal = (0,
|
|
5286
|
-
const joinedLines = (0,
|
|
6404
|
+
const linesByOrdinal = (0, import_lodash20.default)(stepGeometries).filter(({ geometry }) => geometry.type === "LineString").groupBy("properties.ordinal").value();
|
|
6405
|
+
const joinedLines = (0, import_lodash20.default)(linesByOrdinal).reduce((acc, lines, key) => {
|
|
5287
6406
|
const joined = this.combineNearbyLineStrings(lines, {
|
|
5288
6407
|
properties: { ordinal: +key }
|
|
5289
6408
|
});
|
|
@@ -5311,14 +6430,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
5311
6430
|
stepElement = createOriginMarker(stepGeometry).addTo(routeMarkerLayer);
|
|
5312
6431
|
break;
|
|
5313
6432
|
case "destination-marker":
|
|
5314
|
-
const extrudeConfig =
|
|
6433
|
+
const extrudeConfig = import_lodash20.default.get(this.#mapConfig, "extrude");
|
|
5315
6434
|
if (destinationFeature.feature_type === "occupant") {
|
|
5316
|
-
const stepId =
|
|
6435
|
+
const stepId = import_lodash20.default.get(stepGeometry, "id");
|
|
5317
6436
|
const normalizedDestinationFeature = {
|
|
5318
6437
|
...destinationFeature,
|
|
5319
6438
|
id: stepId
|
|
5320
6439
|
};
|
|
5321
|
-
const logoUrl =
|
|
6440
|
+
const logoUrl = import_lodash20.default.get(
|
|
5322
6441
|
normalizedDestinationFeature,
|
|
5323
6442
|
"properties.logo.url"
|
|
5324
6443
|
);
|
|
@@ -5363,15 +6482,15 @@ var IndoorMap = class extends EventTarget {
|
|
|
5363
6482
|
const routeMarkerLayer = this.map.getLayer(
|
|
5364
6483
|
HIGHLIGHT_LAYER_NAME
|
|
5365
6484
|
);
|
|
5366
|
-
const originMarkerGeometry =
|
|
6485
|
+
const originMarkerGeometry = import_lodash20.default.get(
|
|
5367
6486
|
this.#elements,
|
|
5368
6487
|
`${ORIGIN_MARKER_ID}.geometry`
|
|
5369
6488
|
);
|
|
5370
|
-
const destinationMarkerGeometry =
|
|
6489
|
+
const destinationMarkerGeometry = import_lodash20.default.get(
|
|
5371
6490
|
this.#elements,
|
|
5372
6491
|
`${DESTINATION_MARKER_ID}.geometry`
|
|
5373
6492
|
);
|
|
5374
|
-
const geometriesToRemove =
|
|
6493
|
+
const geometriesToRemove = import_lodash20.default.compact([
|
|
5375
6494
|
originMarkerGeometry,
|
|
5376
6495
|
destinationMarkerGeometry
|
|
5377
6496
|
]);
|
|
@@ -5382,7 +6501,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5382
6501
|
(obj) => !(obj instanceof NavigationPath)
|
|
5383
6502
|
);
|
|
5384
6503
|
const objects = this.#navigationGeometries || {};
|
|
5385
|
-
|
|
6504
|
+
import_lodash20.default.forEach(objects, (obj) => {
|
|
5386
6505
|
if (!obj) return;
|
|
5387
6506
|
this.#navigationGeometries[obj.properties.id] = null;
|
|
5388
6507
|
obj.remove();
|
|
@@ -5419,7 +6538,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5419
6538
|
}
|
|
5420
6539
|
if (this.threeLayer) {
|
|
5421
6540
|
const currentView = this.camera.getView();
|
|
5422
|
-
const objectOpacity =
|
|
6541
|
+
const objectOpacity = import_lodash20.default.clamp(38 - 2 * currentView.zoom, 0, 1);
|
|
5423
6542
|
this.#objects.forEach((object) => {
|
|
5424
6543
|
object.getObject3d().traverse((child) => {
|
|
5425
6544
|
if (child.isMesh) child.material.opacity = objectOpacity;
|
|
@@ -5429,7 +6548,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5429
6548
|
});
|
|
5430
6549
|
if (this.#billboardObjects) {
|
|
5431
6550
|
this.#billboardObjects.forEach((object) => {
|
|
5432
|
-
const objectScale =
|
|
6551
|
+
const objectScale = import_lodash20.default.clamp(
|
|
5433
6552
|
20 - 1 * currentView.zoom,
|
|
5434
6553
|
1,
|
|
5435
6554
|
1.05
|
|
@@ -5438,7 +6557,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5438
6557
|
});
|
|
5439
6558
|
}
|
|
5440
6559
|
if (this.#isLayersFadingOnZoom) {
|
|
5441
|
-
const layerOpacity =
|
|
6560
|
+
const layerOpacity = import_lodash20.default.clamp(1 - objectOpacity, 0, 1);
|
|
5442
6561
|
LAYERS.forEach((layerKey) => {
|
|
5443
6562
|
const layer = this.map.getLayer(layerKey);
|
|
5444
6563
|
if (layer) layer.setOpacity(layerOpacity);
|
|
@@ -5468,6 +6587,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5468
6587
|
GEOJSON_FEATURE_TYPES,
|
|
5469
6588
|
HIGHLIGHT_LAYER_NAME,
|
|
5470
6589
|
IMDF_FEATURE_TYPES,
|
|
6590
|
+
IMDF_UNIT_CATEGORIES,
|
|
5471
6591
|
IndoorMap,
|
|
5472
6592
|
LAST_USER_LOCATION_ELEMENT_ID_PREFIX,
|
|
5473
6593
|
LAYERS,
|
|
@@ -5499,11 +6619,13 @@ var IndoorMap = class extends EventTarget {
|
|
|
5499
6619
|
getLocationByFeature,
|
|
5500
6620
|
getLocationByOccupant,
|
|
5501
6621
|
getLocationIdByFeature,
|
|
6622
|
+
getNavigateClient,
|
|
5502
6623
|
getOrdinalByLocationId,
|
|
5503
6624
|
getRelatedLocationIdsByFeature,
|
|
5504
6625
|
getRelatedLocationsByAmenity,
|
|
5505
6626
|
getRelatedLocationsByFeature,
|
|
5506
6627
|
getRelatedLocationsByOccupant,
|
|
6628
|
+
getSearchClient,
|
|
5507
6629
|
getSuitablyValueBetweenBearings,
|
|
5508
6630
|
isClickableFeature,
|
|
5509
6631
|
isValidCoordinate,
|