atriusmaps-node-sdk
Version:
This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information
2 lines (1 loc) • 539 B
JavaScript
const t=t=>t*Math.PI/180;function n(n,a,s,r){const e=t(n),h=t(s),o=t(s-n),i=t(r-a),w=Math.sin(o/2)*Math.sin(o/2)+Math.cos(e)*Math.cos(h)*Math.sin(i/2)*Math.sin(i/2);return 6371e3*(2*Math.atan2(Math.sqrt(w),Math.sqrt(1-w)))}function a(t,n){const a=(t+180)%360-180;return[n("wayfinder:north"),n("wayfinder:northeast"),n("wayfinder:east"),n("wayfinder:southeast"),n("wayfinder:south"),n("wayfinder:southwest"),n("wayfinder:west"),n("wayfinder:northwest")][(Math.round(a/45)+8)%8]}export{a as bearingToDirection,n as distance,t as toRadians};