atriusmaps-node-sdk 3.3.1050 → 3.3.1051

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "3.3.1050";
5
+ var version = "3.3.1051";
6
6
  var pkg = {
7
7
  version: version};
8
8
 
@@ -17,12 +17,13 @@ const calculateSegmentGeneralDirection = ({ waypoints }, T) => {
17
17
  const bearingDegrees = bearing.bearing(from, to);
18
18
  return geodesy.bearingToDirection(bearingDegrees, T);
19
19
  };
20
- function getSteps(segments, startName = "", destinationName = "", floorIdToNameMap, T, queueTypes = {}, requiresAccessibility, securityPois = [], currentUnits) {
20
+ function getSteps(segments, startName = "", destinationName = "", floorIdToNameMap, T, queueTypes = {}, requiresAccessibility, securityPois = [], currentUnits = "feet") {
21
21
  return segments.map((segment, index) => {
22
22
  const securityWaitTimes = findPropWaypoints("securityWaitTimes")(segment.waypoints);
23
23
  const eta = securityWaitTimes && !securityWaitTimes.isTemporarilyClosed ? securityWaitTimes.queueTime : Math.round(calculateSegmentEta(segment.waypoints));
24
- const distance$1 = Math.round(calculateSegmentDistance(segment.waypoints));
25
- const currentUnitsDistance = currentUnits === "yards" ? distance.metersToYards(distance$1) : distance$1;
24
+ const distanceInMeters = calculateSegmentDistance(segment.waypoints);
25
+ const distance$1 = Math.round(distanceInMeters);
26
+ const displayDistance = distance.getDisplayDistance(distanceInMeters, currentUnits);
26
27
  const icon = getIcon(segment.segmentCategory);
27
28
  const animationAnchor = getAnimationAnchor(segment.segmentCategory, segment.waypoints);
28
29
  const direction = calculateSegmentGeneralDirection(segment, T);
@@ -37,7 +38,15 @@ function getSteps(segments, startName = "", destinationName = "", floorIdToNameM
37
38
  queueTypes
38
39
  );
39
40
  const secondaryText = getSecondaryText(segment, eta, T, false);
40
- const secondaryTextUI = getSecondaryText(segment, eta, T, true, direction, currentUnits, currentUnitsDistance);
41
+ const secondaryTextUI = getSecondaryText(
42
+ segment,
43
+ eta,
44
+ T,
45
+ true,
46
+ direction,
47
+ displayDistance.unit,
48
+ displayDistance.distance
49
+ );
41
50
  const bounds$1 = bounds.findBoundsOfWaypoints(segment.waypoints);
42
51
  const isAccessible = checkIfAccessible(segment);
43
52
  const step = {
@@ -258,13 +267,17 @@ function getSecondaryText(segment, minutes, T, ui, direction, currentUnits, curr
258
267
  }
259
268
  }
260
269
  const createSecondaryTextWithHeading = (currentUnitsDistance, currentUnits, direction, T) => {
261
- return currentUnits === "meters" ? T(`wayfinder:Proceed __direction__ __count__ meter to`, {
262
- direction,
263
- count: currentUnitsDistance
264
- }) : T(`wayfinder:Proceed __direction__ __count__ yard to`, {
265
- direction,
266
- count: currentUnitsDistance
267
- });
270
+ const options = { direction, count: currentUnitsDistance };
271
+ switch (currentUnits) {
272
+ case "feet":
273
+ return T("wayfinder:Proceed __direction__ __count__ foot to", options);
274
+ case "miles":
275
+ return T("wayfinder:Proceed __direction__ __count__ mile to", options);
276
+ case "kilometers":
277
+ return T("wayfinder:Proceed __direction__ __count__ kilometer to", options);
278
+ default:
279
+ return T("wayfinder:Proceed __direction__ __count__ meter to", options);
280
+ }
268
281
  };
269
282
  const translateZeroOrOther = (count, T) => (zeroKey, otherKey) => count === 0 ? T("wayfinder:" + zeroKey) : T("wayfinder:" + otherKey, { count });
270
283
  const checkIfAccessible = R.compose(R.not, R.includes(R.__, ["escalator", "stairs"]), R.toLower, R.prop("type"));
@@ -1,6 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const yardsPerMeter = 1.0936132983377;
4
- const metersToYards = (meters) => Math.round(meters * yardsPerMeter);
3
+ function getDisplayDistance(meters, preferredUnits) {
4
+ if (preferredUnits === "feet") {
5
+ return meters < 152.4 ? { distance: Math.round(meters / 0.3048), unit: "feet" } : { distance: Math.round(meters / 1609.344 * 10) / 10, unit: "miles" };
6
+ }
7
+ return meters < 1e3 ? { distance: Math.round(meters), unit: "meters" } : { distance: Math.round(meters / 100) / 10, unit: "kilometers" };
8
+ }
5
9
 
6
- exports.metersToYards = metersToYards;
10
+ exports.getDisplayDistance = getDisplayDistance;
@@ -1 +1 @@
1
- var a="3.3.1050",e={version:a};export{e as default,a as version};
1
+ var a="3.3.1051",e={version:a};export{e as default,a as version};
@@ -1 +1 @@
1
- import{bearing as e}from"@turf/bearing";import{point as t}from"@turf/helpers";import{compose as r,not as n,includes as a,__ as s,toLower as i,prop as o,last as c,find as u,propEq as T}from"ramda";import{findBoundsOfWaypoints as A}from"../../../src/utils/bounds.js";import{metersToYards as S}from"../../../src/utils/distance.js";import{bearingToDirection as _,distance as R}from"../../../src/utils/geodesy.js";import E from"./segmentBadges.js";import d from"./segmentCategories.js";function I(r,n="",a="",s,i,c={},u,T=[],R){return r.map((u,I)=>{const L=N("securityWaitTimes")(u.waypoints),f=L&&!L.isTemporarilyClosed?L.queueTime:Math.round(function(e){if(1===e.length)return e[0].eta;return e.map(o("eta")).slice(1).reduce((e,t)=>e+t,0)}(u.waypoints)),w=Math.round(function(e){if(1===e.length)return e[0].distance;return e.map(e=>e.distance).slice(1).reduce((e,t)=>e+t,0)}(u.waypoints)),P="yards"===R?S(w):w,W=function(e){switch(e){case d.START:return E.START;case d.WALKING_TO_END:return E.END;case d.ELEVATOR:return E.ELEVATOR;case d.ELEVATOR_UP:return E.ELEVATOR_UP;case d.ELEVATOR_DOWN:return E.ELEVATOR_DOWN;case d.STAIRS:return E.STAIRS;case d.STAIRS_UP:return E.STAIRS_UP;case d.STAIRS_DOWN:return E.STAIRS_DOWN;case d.ACCESSIBLE_STAIRS:return E.ACCESSIBLE_STAIRS;case d.ACCESSIBLE_STAIRS_UP:return E.ACCESSIBLE_STAIRS_UP;case d.ACCESSIBLE_STAIRS_DOWN:return E.ACCESSIBLE_STAIRS_DOWN;case d.ESCALATOR:return E.ESCALATOR;case d.ESCALATOR_UP:return E.ESCALATOR_UP;case d.ESCALATOR_DOWN:return E.ESCALATOR_DOWN;case d.WALKING_TO_PORTAL:case d.WALK:case d.WALK_DOWN:case d.WALK_UP:return E.WALK;case d.TRAIN:return E.TRAIN;case d.TRAIN_UP:return E.TRAIN_UP;case d.TRAIN_DOWN:return E.TRAIN_DOWN;case d.BUS:return E.BUS;case d.BUS_UP:return E.BUS_UP;case d.BUS_DOWN:return E.BUS_DOWN;case d.SECURITY_CHECKPOINT:return E.SECURITY_CHECKPOINT;case d.RAMP:return E.RAMP;case d.RAMP_UP:return E.RAMP_UP;case d.RAMP_DOWN:return E.RAMP_DOWN;default:return E.WALK}}(u.segmentCategory),U=function(e,t){let r;switch(e){case d.START:r=0;break;case d.WALKING_TO_END:r=t.length-1;break;case d.WALKING_TO_PORTAL:r=Math.min(t.length-1,Math.ceil(t.length/2));break;default:r=t.length-1}return t[r].position}(u.segmentCategory,u.waypoints),D=(({waypoints:r},n)=>{const[a]=r,s=r[r.length-1],i=t([a.position.lng,a.position.lat]),o=t([s.position.lng,s.position.lat]),c=e(i,o);return _(c,n)})(u,i),g=function(e,t,r,n,a,s,i,o){const c=e[t];switch(c.segmentCategory){case d.START:return O(c.waypoints[0].position,r);case d.WALKING_TO_END:return O(c.waypoints[c.waypoints.length-1].position,n);case d.WALKING_TO_SECURITY_CHECKPOINT:{const r=e[t+1].waypoints,n=C(o,r),a=n?s("wayfinder:Security Lane",{laneName:n}):null,u=m(r,i);return a||u||s(`wayfinder:${c.type}`)}case d.WALKING_TO_PORTAL:return s(`wayfinder:${e[t+1].type}`);case d.SECURITY_CHECKPOINT:{const e=C(o,c.waypoints),t=e?s("wayfinder:Security Lane",{laneName:e}):null,r=m(c.waypoints,i);return t||r||l(c,a)}case d.ELEVATOR:case d.ELEVATOR_DOWN:case d.ELEVATOR_UP:case d.ESCALATOR:case d.ESCALATOR_DOWN:case d.ESCALATOR_UP:case d.STAIRS:case d.STAIRS_DOWN:case d.STAIRS_UP:case d.ACCESSIBLE_STAIRS:case d.ACCESSIBLE_STAIRS_DOWN:case d.ACCESSIBLE_STAIRS_UP:return l(c,a);default:return s(`wayfinder:${c.type}`)}}(r,I,n,a,s,i,T,c),K={primaryText:g,secondaryText:y(u,f,i,!1),secondaryTextUI:y(u,f,i,!0,D,R,P),icon:W,animationAnchor:U,eta:f,distance:w,bounds:A(u.waypoints),isAccessible:p(u),securityWaitTimes:L};return u.poiId&&(K.poiId=u.poiId),K})}function O(e,t){return e.name?e.name:t}function l(e,t){return t[c(e.waypoints).position.floorId]}function y(e,t,r,n,a,s,i){const o=f(t,r),c="Proceed";switch(e.segmentCategory){case d.START:return r("wayfinder:Begin route at");case d.ELEVATOR:return r("wayfinder:Take elevator to");case d.ELEVATOR_UP:return r("wayfinder:Take elevator up to");case d.ELEVATOR_DOWN:return r("wayfinder:Take elevator down to");case d.STAIRS:return r("wayfinder:Take stairs to");case d.STAIRS_UP:return r("wayfinder:Take stairs up to");case d.STAIRS_DOWN:return r("wayfinder:Take stairs down to");case d.ACCESSIBLE_STAIRS:return r("wayfinder:Take accessible stairs to");case d.ACCESSIBLE_STAIRS_UP:return r("wayfinder:Take accessible stairs up to");case d.ACCESSIBLE_STAIRS_DOWN:return r("wayfinder:Take accessible stairs down to");case d.ESCALATOR:return r("wayfinder:Take escalator to");case d.ESCALATOR_UP:return r("wayfinder:Take escalator up to");case d.ESCALATOR_DOWN:return r("wayfinder:Take escalator down to");case d.WALK:case d.WALKING_TO_SECURITY_CHECKPOINT:case d.WALKING_TO_PORTAL:case d.WALKING_TO_END:return n?L(i,s,a,r):o(`${c} <1 minute to`,`${c} xx minute to`);case d.WALK_DOWN:return o(`${c} <1 minute down to`,`${c} xx minute down to`);case d.WALK_UP:return o(`${c} <1 minute up to`,`${c} xx minute up to`);case d.TRAIN:return o("Take train <1 minute","Take train xx minute");case d.BUS:return o("Take bus <1 minute","Take bus xx minute");case d.SECURITY_CHECKPOINT:return r("wayfinder:Through");case d.RAMP:return r("wayfinder:Take ramp to");case d.RAMP_UP:return r("wayfinder:Take ramp up to");case d.RAMP_DOWN:return r("wayfinder:Take ramp down to");default:return""}}const L=(e,t,r,n)=>n("meters"===t?"wayfinder:Proceed __direction__ __count__ meter to":"wayfinder:Proceed __direction__ __count__ yard to",{direction:r,count:e}),f=(e,t)=>(r,n)=>0===e?t("wayfinder:"+r):t("wayfinder:"+n,{count:e}),p=r(n,a(s,["escalator","stairs"]),i,o("type")),C=(e,t)=>{const r=N("securityLane")(t);if(!r)return;const n=o(r.type,e),a=u(T(r.id,"id"),n);return a?.displayText},N=e=>t=>t.slice(1).find(t=>t[e])?.[e],m=(e,t)=>{if(!e||0===e.length)return null;const r=e[0],{lat:n,lng:a,floorId:s}=r.position,i=t.filter(e=>e.position&&e.position.floorId===s);let o=null,c=1/0;return i.forEach(e=>{const t=R(n,a,e.position.latitude,e.position.longitude);t<c&&(c=t,o=e)}),o?o.name:null};export{I as default};
1
+ import{bearing as e}from"@turf/bearing";import{point as t}from"@turf/helpers";import{compose as r,not as n,includes as a,__ as s,toLower as i,prop as o,last as c,find as u,propEq as _}from"ramda";import{findBoundsOfWaypoints as T}from"../../../src/utils/bounds.js";import{getDisplayDistance as A}from"../../../src/utils/distance.js";import{bearingToDirection as S,distance as d}from"../../../src/utils/geodesy.js";import R from"./segmentBadges.js";import E from"./segmentCategories.js";function I(r,n="",a="",s,i,c={},u,_=[],d="feet"){return r.map((u,I)=>{const y=m("securityWaitTimes")(u.waypoints),L=y&&!y.isTemporarilyClosed?y.queueTime:Math.round(function(e){if(1===e.length)return e[0].eta;return e.map(o("eta")).slice(1).reduce((e,t)=>e+t,0)}(u.waypoints)),w=function(e){if(1===e.length)return e[0].distance;return e.map(e=>e.distance).slice(1).reduce((e,t)=>e+t,0)}(u.waypoints),P=Math.round(w),W=A(w,d),U=function(e){switch(e){case E.START:return R.START;case E.WALKING_TO_END:return R.END;case E.ELEVATOR:return R.ELEVATOR;case E.ELEVATOR_UP:return R.ELEVATOR_UP;case E.ELEVATOR_DOWN:return R.ELEVATOR_DOWN;case E.STAIRS:return R.STAIRS;case E.STAIRS_UP:return R.STAIRS_UP;case E.STAIRS_DOWN:return R.STAIRS_DOWN;case E.ACCESSIBLE_STAIRS:return R.ACCESSIBLE_STAIRS;case E.ACCESSIBLE_STAIRS_UP:return R.ACCESSIBLE_STAIRS_UP;case E.ACCESSIBLE_STAIRS_DOWN:return R.ACCESSIBLE_STAIRS_DOWN;case E.ESCALATOR:return R.ESCALATOR;case E.ESCALATOR_UP:return R.ESCALATOR_UP;case E.ESCALATOR_DOWN:return R.ESCALATOR_DOWN;case E.WALKING_TO_PORTAL:case E.WALK:case E.WALK_DOWN:case E.WALK_UP:return R.WALK;case E.TRAIN:return R.TRAIN;case E.TRAIN_UP:return R.TRAIN_UP;case E.TRAIN_DOWN:return R.TRAIN_DOWN;case E.BUS:return R.BUS;case E.BUS_UP:return R.BUS_UP;case E.BUS_DOWN:return R.BUS_DOWN;case E.SECURITY_CHECKPOINT:return R.SECURITY_CHECKPOINT;case E.RAMP:return R.RAMP;case E.RAMP_UP:return R.RAMP_UP;case E.RAMP_DOWN:return R.RAMP_DOWN;default:return R.WALK}}(u.segmentCategory),D=function(e,t){let r;switch(e){case E.START:r=0;break;case E.WALKING_TO_END:r=t.length-1;break;case E.WALKING_TO_PORTAL:r=Math.min(t.length-1,Math.ceil(t.length/2));break;default:r=t.length-1}return t[r].position}(u.segmentCategory,u.waypoints),g=(({waypoints:r},n)=>{const[a]=r,s=r[r.length-1],i=t([a.position.lng,a.position.lat]),o=t([s.position.lng,s.position.lat]),c=e(i,o);return S(c,n)})(u,i),k=function(e,t,r,n,a,s,i,o){const c=e[t];switch(c.segmentCategory){case E.START:return O(c.waypoints[0].position,r);case E.WALKING_TO_END:return O(c.waypoints[c.waypoints.length-1].position,n);case E.WALKING_TO_SECURITY_CHECKPOINT:{const r=e[t+1].waypoints,n=C(o,r),a=n?s("wayfinder:Security Lane",{laneName:n}):null,u=N(r,i);return a||u||s(`wayfinder:${c.type}`)}case E.WALKING_TO_PORTAL:return s(`wayfinder:${e[t+1].type}`);case E.SECURITY_CHECKPOINT:{const e=C(o,c.waypoints),t=e?s("wayfinder:Security Lane",{laneName:e}):null,r=N(c.waypoints,i);return t||r||l(c,a)}case E.ELEVATOR:case E.ELEVATOR_DOWN:case E.ELEVATOR_UP:case E.ESCALATOR:case E.ESCALATOR_DOWN:case E.ESCALATOR_UP:case E.STAIRS:case E.STAIRS_DOWN:case E.STAIRS_UP:case E.ACCESSIBLE_STAIRS:case E.ACCESSIBLE_STAIRS_DOWN:case E.ACCESSIBLE_STAIRS_UP:return l(c,a);default:return s(`wayfinder:${c.type}`)}}(r,I,n,a,s,i,_,c),K={primaryText:k,secondaryText:f(u,L,i,!1),secondaryTextUI:f(u,L,i,!0,g,W.unit,W.distance),icon:U,animationAnchor:D,eta:L,distance:P,bounds:T(u.waypoints),isAccessible:p(u),securityWaitTimes:y};return u.poiId&&(K.poiId=u.poiId),K})}function O(e,t){return e.name?e.name:t}function l(e,t){return t[c(e.waypoints).position.floorId]}function f(e,t,r,n,a,s,i){const o=L(t,r),c="Proceed";switch(e.segmentCategory){case E.START:return r("wayfinder:Begin route at");case E.ELEVATOR:return r("wayfinder:Take elevator to");case E.ELEVATOR_UP:return r("wayfinder:Take elevator up to");case E.ELEVATOR_DOWN:return r("wayfinder:Take elevator down to");case E.STAIRS:return r("wayfinder:Take stairs to");case E.STAIRS_UP:return r("wayfinder:Take stairs up to");case E.STAIRS_DOWN:return r("wayfinder:Take stairs down to");case E.ACCESSIBLE_STAIRS:return r("wayfinder:Take accessible stairs to");case E.ACCESSIBLE_STAIRS_UP:return r("wayfinder:Take accessible stairs up to");case E.ACCESSIBLE_STAIRS_DOWN:return r("wayfinder:Take accessible stairs down to");case E.ESCALATOR:return r("wayfinder:Take escalator to");case E.ESCALATOR_UP:return r("wayfinder:Take escalator up to");case E.ESCALATOR_DOWN:return r("wayfinder:Take escalator down to");case E.WALK:case E.WALKING_TO_SECURITY_CHECKPOINT:case E.WALKING_TO_PORTAL:case E.WALKING_TO_END:return n?y(i,s,a,r):o(`${c} <1 minute to`,`${c} xx minute to`);case E.WALK_DOWN:return o(`${c} <1 minute down to`,`${c} xx minute down to`);case E.WALK_UP:return o(`${c} <1 minute up to`,`${c} xx minute up to`);case E.TRAIN:return o("Take train <1 minute","Take train xx minute");case E.BUS:return o("Take bus <1 minute","Take bus xx minute");case E.SECURITY_CHECKPOINT:return r("wayfinder:Through");case E.RAMP:return r("wayfinder:Take ramp to");case E.RAMP_UP:return r("wayfinder:Take ramp up to");case E.RAMP_DOWN:return r("wayfinder:Take ramp down to");default:return""}}const y=(e,t,r,n)=>{const a={direction:r,count:e};switch(t){case"feet":return n("wayfinder:Proceed __direction__ __count__ foot to",a);case"miles":return n("wayfinder:Proceed __direction__ __count__ mile to",a);case"kilometers":return n("wayfinder:Proceed __direction__ __count__ kilometer to",a);default:return n("wayfinder:Proceed __direction__ __count__ meter to",a)}},L=(e,t)=>(r,n)=>0===e?t("wayfinder:"+r):t("wayfinder:"+n,{count:e}),p=r(n,a(s,["escalator","stairs"]),i,o("type")),C=(e,t)=>{const r=m("securityLane")(t);if(!r)return;const n=o(r.type,e),a=u(_(r.id,"id"),n);return a?.displayText},m=e=>t=>t.slice(1).find(t=>t[e])?.[e],N=(e,t)=>{if(!e||0===e.length)return null;const r=e[0],{lat:n,lng:a,floorId:s}=r.position,i=t.filter(e=>e.position&&e.position.floorId===s);let o=null,c=1/0;return i.forEach(e=>{const t=d(n,a,e.position.latitude,e.position.longitude);t<c&&(c=t,o=e)}),o?o.name:null};export{I as default};
@@ -1 +1 @@
1
- const o=o=>Math.round(1.0936132983377*o);export{o as metersToYards};
1
+ function t(t,e){return"feet"===e?t<152.4?{distance:Math.round(t/.3048),unit:"feet"}:{distance:Math.round(t/1609.344*10)/10,unit:"miles"}:t<1e3?{distance:Math.round(t),unit:"meters"}:{distance:Math.round(t/100)/10,unit:"kilometers"}}export{t as getDisplayDistance};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atriusmaps-node-sdk",
3
- "version": "3.3.1050",
3
+ "version": "3.3.1051",
4
4
  "description": "This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information",
5
5
  "keywords": [
6
6
  "acuitybrands",