atriusmaps-node-sdk 3.3.1049 → 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.
- package/dist/cjs/package.json.js +1 -1
- package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +24 -11
- package/dist/cjs/src/utils/distance.js +7 -3
- package/dist/package.json.js +1 -1
- package/dist/plugins/wayfinder/src/stepBuilder.js +1 -1
- package/dist/src/utils/distance.js +1 -1
- package/package.json +1 -1
package/dist/cjs/package.json.js
CHANGED
|
@@ -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
|
|
25
|
-
const
|
|
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(
|
|
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
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
4
|
-
|
|
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.
|
|
10
|
+
exports.getDisplayDistance = getDisplayDistance;
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a="3.3.
|
|
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
|
|
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
|
-
|
|
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