venue-js 1.4.0-next.21 → 1.4.0-next.22

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.
@@ -918,7 +918,7 @@ var createElevatorNodeMap = (elevatorLikeRelationships, unitOpenings, options) =
918
918
  const level = levels.find((level2) => level2.id === destination.properties.level_id);
919
919
  return { opening, level };
920
920
  });
921
- const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
921
+ const intermediaryOpeningAndLevels = (intermediary || []).map((unitTypeAndId) => {
922
922
  const openings = unitOpenings[unitTypeAndId.id];
923
923
  const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
924
924
  const level = levels.find((level2) => level2.id === unit.properties.level_id);
@@ -962,11 +962,13 @@ var createEscalatorNodeMap = (relationships, options) => {
962
962
  const {
963
963
  properties: { direction, origin, destination }
964
964
  } = relationship;
965
- (0, import_set.default)(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
966
- if (direction === "undirected") {
967
- (0, import_set.default)(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
965
+ if (origin && destination) {
966
+ (0, import_set.default)(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
967
+ if (direction === "undirected") {
968
+ (0, import_set.default)(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
969
+ }
970
+ counter++;
968
971
  }
969
- counter++;
970
972
  }
971
973
  const t1 = performance.now();
972
974
  trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
@@ -1091,17 +1093,19 @@ var createPOINodeMap = (features, getFeatureUnit, unitOpenings) => {
1091
1093
  features.forEach((feat) => {
1092
1094
  try {
1093
1095
  const locatedOnUnitId = getFeatureUnit(feat);
1094
- const openings = unitOpenings[locatedOnUnitId];
1095
- const center7 = (0, import_center4.center)(feat);
1096
- for (const opening of openings) {
1097
- try {
1098
- const openingCenter = (0, import_center4.center)(opening);
1099
- const dis = (0, import_distance2.distance)(center7, openingCenter, { units: "meters" }) + BASE_POI_BASEDISTANCE;
1100
- import_lodash9.default.set(nodeMap, `${opening.id}.${feat.id}`, dis);
1101
- import_lodash9.default.set(nodeMap, `${feat.id}.${opening.id}`, dis);
1102
- counter++;
1103
- } catch (err) {
1104
- console.log(err, opening);
1096
+ if (locatedOnUnitId) {
1097
+ const openings = unitOpenings[locatedOnUnitId] ?? [];
1098
+ const center7 = (0, import_center4.center)(feat);
1099
+ for (const opening of openings) {
1100
+ try {
1101
+ const openingCenter = (0, import_center4.center)(opening);
1102
+ const dis = (0, import_distance2.distance)(center7, openingCenter, { units: "meters" }) + BASE_POI_BASEDISTANCE;
1103
+ import_lodash9.default.set(nodeMap, `${opening.id}.${feat.id}`, dis);
1104
+ import_lodash9.default.set(nodeMap, `${feat.id}.${opening.id}`, dis);
1105
+ counter++;
1106
+ } catch (err) {
1107
+ console.log(err, opening);
1108
+ }
1105
1109
  }
1106
1110
  }
1107
1111
  } catch (err) {
@@ -1203,7 +1207,7 @@ var prepareGraph = (options) => {
1203
1207
  unitOpenings,
1204
1208
  options
1205
1209
  );
1206
- const amenityNodeMap = createPOINodeMap(amenities, (amenity) => amenity.properties.unit_ids[0], unitOpenings);
1210
+ const amenityNodeMap = createPOINodeMap(amenities, (amenity) => amenity.properties.unit_ids?.[0] || null, unitOpenings);
1207
1211
  const anchorsNodeMap = createPOINodeMap(anchors, (anchor) => anchor.properties.unit_id, unitOpenings);
1208
1212
  const walkwayUnits = units.filter((unit) => unit.properties.category === "walkway");
1209
1213
  const kioskNodeMap = createPOINodeMap(kiosks, (kiosk) => findContainingUnit(kiosk, walkwayUnits)?.id, unitOpenings);
@@ -2253,7 +2257,9 @@ var createLandmarkUtils = (options) => {
2253
2257
  const locationType = occupant.properties.unit_id ? "unit" : "kiosk";
2254
2258
  const locationId = locationType === "unit" ? occupant.properties.unit_id : occupant.properties.kiosk_id;
2255
2259
  const location = locationType === "unit" ? findByIdSync(locationId) : findByIdSync(locationId);
2256
- const level = findByIdSync(location.properties.level_id);
2260
+ if (!location) return null;
2261
+ const level = location.properties.level_id ? findByIdSync(location.properties.level_id) : null;
2262
+ if (!level) return null;
2257
2263
  return {
2258
2264
  name: occupant.properties.name,
2259
2265
  point: (0, import_center8.center)(location.geometry).geometry.coordinates,
@@ -2263,7 +2269,7 @@ var createLandmarkUtils = (options) => {
2263
2269
  };
2264
2270
  };
2265
2271
  const landmarks = [
2266
- ...occupants.map(occupantToLandmark)
2272
+ ...compact(occupants.map(occupantToLandmark))
2267
2273
  ];
2268
2274
  const findNearbyLandmarks = (point2, levelId) => {
2269
2275
  if (point2 === null || levelId === null) return [];
@@ -2353,6 +2359,7 @@ var getNavigateClient = (options) => {
2353
2359
  trace("nav", "\u2713 findRoute", 0);
2354
2360
  const t02 = performance.now();
2355
2361
  const path = graph.path(routeOriginParam, routeDestinationParam);
2362
+ if (path === null) return { steps: [], distance: 0, duration: 0 };
2356
2363
  const t12 = performance.now();
2357
2364
  trace("nav", " \u251C\u2500 path (dijkstra)", t12 - t02);
2358
2365
  const waypoints = waypointUtils.toWaypoints(path);