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

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/index.mjs CHANGED
@@ -870,7 +870,7 @@ var createElevatorNodeMap = (elevatorLikeRelationships, unitOpenings, options) =
870
870
  const level = levels.find((level2) => level2.id === destination.properties.level_id);
871
871
  return { opening, level };
872
872
  });
873
- const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
873
+ const intermediaryOpeningAndLevels = (intermediary || []).map((unitTypeAndId) => {
874
874
  const openings = unitOpenings[unitTypeAndId.id];
875
875
  const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
876
876
  const level = levels.find((level2) => level2.id === unit.properties.level_id);
@@ -914,11 +914,13 @@ var createEscalatorNodeMap = (relationships, options) => {
914
914
  const {
915
915
  properties: { direction, origin, destination }
916
916
  } = relationship;
917
- set(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
918
- if (direction === "undirected") {
919
- set(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
917
+ if (origin && destination) {
918
+ set(nodeMap, `${origin.id}.${destination.id}`, distanceOptions.baseDistance);
919
+ if (direction === "undirected") {
920
+ set(nodeMap, `${destination.id}.${origin.id}`, distanceOptions.baseDistance);
921
+ }
922
+ counter++;
920
923
  }
921
- counter++;
922
924
  }
923
925
  const t1 = performance.now();
924
926
  trace("nav", ` \u2502 \u251C\u2500 add ${counter} escalator relationships`, t1 - t0);
@@ -971,7 +973,9 @@ var createStairNodeMap = (elevatorLikeRelationships, unitOpenings, options) => {
971
973
  const intermediaryOpeningAndLevels = intermediary.map((unitTypeAndId) => {
972
974
  const openings2 = unitOpenings[unitTypeAndId.id];
973
975
  const unit = units.find((unit2) => unit2.id === unitTypeAndId.id);
976
+ if (!unit) return [];
974
977
  const level = levels.find((level2) => level2.id === unit.properties.level_id);
978
+ if (!level) return [];
975
979
  return openings2.map((opening) => ({ opening, level }));
976
980
  }).flat();
977
981
  const connections = [...intermediaryOpeningAndLevels, destinationOpeningAndLevel];
@@ -1043,17 +1047,19 @@ var createPOINodeMap = (features, getFeatureUnit, unitOpenings) => {
1043
1047
  features.forEach((feat) => {
1044
1048
  try {
1045
1049
  const locatedOnUnitId = getFeatureUnit(feat);
1046
- const openings = unitOpenings[locatedOnUnitId];
1047
- const center8 = turfCenter2(feat);
1048
- for (const opening of openings) {
1049
- try {
1050
- const openingCenter = turfCenter2(opening);
1051
- const dis = distance(center8, openingCenter, { units: "meters" }) + BASE_POI_BASEDISTANCE;
1052
- _5.set(nodeMap, `${opening.id}.${feat.id}`, dis);
1053
- _5.set(nodeMap, `${feat.id}.${opening.id}`, dis);
1054
- counter++;
1055
- } catch (err) {
1056
- console.log(err, opening);
1050
+ if (locatedOnUnitId) {
1051
+ const openings = unitOpenings[locatedOnUnitId] ?? [];
1052
+ const center8 = turfCenter2(feat);
1053
+ for (const opening of openings) {
1054
+ try {
1055
+ const openingCenter = turfCenter2(opening);
1056
+ const dis = distance(center8, openingCenter, { units: "meters" }) + BASE_POI_BASEDISTANCE;
1057
+ _5.set(nodeMap, `${opening.id}.${feat.id}`, dis);
1058
+ _5.set(nodeMap, `${feat.id}.${opening.id}`, dis);
1059
+ counter++;
1060
+ } catch (err) {
1061
+ console.log(err, opening);
1062
+ }
1057
1063
  }
1058
1064
  }
1059
1065
  } catch (err) {
@@ -1155,7 +1161,7 @@ var prepareGraph = (options) => {
1155
1161
  unitOpenings,
1156
1162
  options
1157
1163
  );
1158
- const amenityNodeMap = createPOINodeMap(amenities, (amenity) => amenity.properties.unit_ids[0], unitOpenings);
1164
+ const amenityNodeMap = createPOINodeMap(amenities, (amenity) => amenity.properties.unit_ids?.[0] || null, unitOpenings);
1159
1165
  const anchorsNodeMap = createPOINodeMap(anchors, (anchor) => anchor.properties.unit_id, unitOpenings);
1160
1166
  const walkwayUnits = units.filter((unit) => unit.properties.category === "walkway");
1161
1167
  const kioskNodeMap = createPOINodeMap(kiosks, (kiosk) => findContainingUnit(kiosk, walkwayUnits)?.id, unitOpenings);
@@ -2212,7 +2218,9 @@ var createLandmarkUtils = (options) => {
2212
2218
  const locationType = occupant.properties.unit_id ? "unit" : "kiosk";
2213
2219
  const locationId = locationType === "unit" ? occupant.properties.unit_id : occupant.properties.kiosk_id;
2214
2220
  const location = locationType === "unit" ? findByIdSync(locationId) : findByIdSync(locationId);
2215
- const level = findByIdSync(location.properties.level_id);
2221
+ if (!location) return null;
2222
+ const level = location.properties.level_id ? findByIdSync(location.properties.level_id) : null;
2223
+ if (!level) return null;
2216
2224
  return {
2217
2225
  name: occupant.properties.name,
2218
2226
  point: center5(location.geometry).geometry.coordinates,
@@ -2222,7 +2230,7 @@ var createLandmarkUtils = (options) => {
2222
2230
  };
2223
2231
  };
2224
2232
  const landmarks = [
2225
- ...occupants.map(occupantToLandmark)
2233
+ ...compact(occupants.map(occupantToLandmark))
2226
2234
  ];
2227
2235
  const findNearbyLandmarks = (point2, levelId) => {
2228
2236
  if (point2 === null || levelId === null) return [];
@@ -2312,6 +2320,7 @@ var getNavigateClient = (options) => {
2312
2320
  trace("nav", "\u2713 findRoute", 0);
2313
2321
  const t02 = performance.now();
2314
2322
  const path = graph.path(routeOriginParam, routeDestinationParam);
2323
+ if (path === null) return { steps: [], distance: 0, duration: 0 };
2315
2324
  const t12 = performance.now();
2316
2325
  trace("nav", " \u251C\u2500 path (dijkstra)", t12 - t02);
2317
2326
  const waypoints = waypointUtils.toWaypoints(path);