venue-js 1.4.0-next.16 → 1.4.0-next.17

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.
@@ -27,6 +27,71 @@ var IMDF_FEATURE_TYPES = [
27
27
  "unit",
28
28
  "venue"
29
29
  ];
30
+ var IMDF_UNIT_CATEGORIES = [
31
+ "auditorium",
32
+ "brick",
33
+ "classroom",
34
+ "column",
35
+ "concrete",
36
+ "conferenceroom",
37
+ "drywall",
38
+ "elevator",
39
+ "escalator",
40
+ "fieldofplay",
41
+ "firstaid",
42
+ "fitnessroom",
43
+ "foodservice",
44
+ "footbridge",
45
+ "glass",
46
+ "huddleroom",
47
+ "kitchen",
48
+ "laboratory",
49
+ "library",
50
+ "lobby",
51
+ "lounge",
52
+ "mailroom",
53
+ "mothersroom",
54
+ "movietheater",
55
+ "movingwalkway",
56
+ "nonpublic",
57
+ "office",
58
+ "opentobelow",
59
+ "parking",
60
+ "phoneroom",
61
+ "platform",
62
+ "privatelounge",
63
+ "ramp",
64
+ "recreation",
65
+ "restroom",
66
+ "restroom.family",
67
+ "restroom.female",
68
+ "restroom.female.wheelchair",
69
+ "restroom.male",
70
+ "restroom.male.wheelchair",
71
+ "restroom.transgender",
72
+ "restroom.transgender.wheelchair",
73
+ "restroom.unisex",
74
+ "restroom.unisex.wheelchair",
75
+ "restroom.wheelchair",
76
+ "road",
77
+ "room",
78
+ "serverroom",
79
+ "shower",
80
+ "smokingarea",
81
+ "stairs",
82
+ "steps",
83
+ "storage",
84
+ "structure",
85
+ "terrace",
86
+ "theater",
87
+ "unenclosedarea",
88
+ "unspecified",
89
+ "vegetation",
90
+ "waitingroom",
91
+ "walkway",
92
+ "walkway.island",
93
+ "wood"
94
+ ];
30
95
  var NONIMDF_FEATURE_TYPES = [
31
96
  "taxonomy",
32
97
  "event",
@@ -326,7 +391,27 @@ import {
326
391
  } from "@tanstack/query-core";
327
392
 
328
393
  // src/data/populator/index.ts
329
- import { booleanWithin } from "@turf/boolean-within";
394
+ import { center as center2 } from "@turf/center";
395
+ import { booleanPointInPolygon as booleanPointInPolygon2 } from "@turf/boolean-point-in-polygon";
396
+
397
+ // src/data/utils/findContaining.ts
398
+ import { center } from "@turf/center";
399
+ import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
400
+ var findContainingUnit = (poi, units) => {
401
+ const unit = units.find(
402
+ (unit2) => {
403
+ try {
404
+ return unit2.properties.level_id === poi.properties.level_id && booleanPointInPolygon(center(poi), unit2);
405
+ } catch (e) {
406
+ console.log(`Cannot find containing unit of (${poi.id}):`, e.message);
407
+ return false;
408
+ }
409
+ }
410
+ );
411
+ return unit;
412
+ };
413
+
414
+ // src/data/populator/index.ts
330
415
  var createPopulator = ({
331
416
  internalFindById,
332
417
  internalFilterByType
@@ -336,7 +421,6 @@ var createPopulator = ({
336
421
  const populateDetail = (detail) => Promise.resolve(detail);
337
422
  const populateFootprint = (footprint) => Promise.resolve(footprint);
338
423
  const populateGeofence = (geofence) => Promise.resolve(geofence);
339
- const populateRelationship = (relationship) => Promise.resolve(relationship);
340
424
  const populatePrivilege = (privilege) => Promise.resolve(privilege);
341
425
  const populateEvent = (event) => Promise.resolve(event);
342
426
  const populatePromotion = async (promotion) => {
@@ -360,7 +444,7 @@ var createPopulator = ({
360
444
  const ordinalKiosks = kiosks.filter(
361
445
  (kiosk2) => kiosk2.properties.level_id === defaultLevel.id
362
446
  );
363
- const kiosk = ordinalKiosks.find((kiosk2) => booleanWithin(amenity, kiosk2));
447
+ const kiosk = ordinalKiosks.find((kiosk2) => booleanPointInPolygon2(amenity, kiosk2));
364
448
  return {
365
449
  ...amenity,
366
450
  properties: {
@@ -379,7 +463,7 @@ var createPopulator = ({
379
463
  const venue = await internalFindById(unit.properties.venue_id);
380
464
  const level = await internalFindById(unit.properties.level_id);
381
465
  const sections = await internalFilterByType("section");
382
- const section = sections.find((section2) => booleanWithin(anchor, section2));
466
+ const section = sections.find((section2) => booleanPointInPolygon2(anchor, section2));
383
467
  return {
384
468
  ...anchor,
385
469
  properties: {
@@ -412,20 +496,11 @@ var createPopulator = ({
412
496
  const venue = await internalFindById(kiosk.properties.venue_id);
413
497
  const anchor = await internalFindById(kiosk.properties.anchor_id);
414
498
  const units = await internalFilterByType("unit");
415
- const unit = units.find(
416
- (unit2) => {
417
- try {
418
- return unit2.properties.category === "walkway" && unit2.properties.level_id === kiosk.properties.level_id && booleanWithin(kiosk, unit2);
419
- } catch (e) {
420
- console.log(`Cannot find kiosk(${kiosk.id})'s units:`, e.message);
421
- return false;
422
- }
423
- }
424
- );
499
+ const unit = findContainingUnit(kiosk, units.filter((unit2) => unit2.properties.category === "walkway"));
425
500
  let section = null;
426
501
  if (anchor) {
427
502
  const sections = await internalFilterByType("section");
428
- section = sections.find((section2) => booleanWithin(anchor, section2));
503
+ section = sections.find((section2) => booleanPointInPolygon2(anchor, section2));
429
504
  }
430
505
  return {
431
506
  ...kiosk,
@@ -507,6 +582,23 @@ var createPopulator = ({
507
582
  }
508
583
  };
509
584
  };
585
+ const populateRelationship = async (relationship) => {
586
+ const originId = relationship.properties.origin?.id;
587
+ const destinationId = relationship.properties.destination?.id;
588
+ const origin = originId ? await internalFindById(originId) : null;
589
+ const destination = destinationId ? await internalFindById(destinationId) : null;
590
+ const intermediary_ids = (relationship.properties.intermediary || []).map(({ id }) => id);
591
+ const intermediary = await Promise.all(intermediary_ids.map(internalFindById));
592
+ return {
593
+ ...relationship,
594
+ properties: {
595
+ ...relationship.properties,
596
+ origin,
597
+ destination,
598
+ intermediary
599
+ }
600
+ };
601
+ };
510
602
  const populateSection = async (section) => {
511
603
  const venue = await internalFindById(section.properties.venue_id);
512
604
  const level = await internalFindById(section.properties.level_id);
@@ -525,7 +617,7 @@ var createPopulator = ({
525
617
  const level = await internalFindById(unit.properties.level_id);
526
618
  const sections = await internalFilterByType("section");
527
619
  try {
528
- const section = unit.geometry.type !== "MultiPolygon" ? sections.find((section2) => booleanWithin(unit, section2)) : null;
620
+ const section = unit.geometry.type !== "MultiPolygon" ? sections.find((section2) => booleanPointInPolygon2(center2(unit), section2)) : null;
529
621
  return {
530
622
  ...unit,
531
623
  properties: {
@@ -2097,6 +2189,7 @@ export {
2097
2189
  DEFAULT_BASE_URL,
2098
2190
  GEOJSON_FEATURE_TYPES,
2099
2191
  IMDF_FEATURE_TYPES,
2192
+ IMDF_UNIT_CATEGORIES,
2100
2193
  NONIMDF_FEATURE_TYPES,
2101
2194
  occupant_helper_exports as OccupantHelpers,
2102
2195
  QueryObserver2 as QueryObserver,