UNPKG

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) 1.01 kB
const e=[16,8,4,2,1],t="0123456789bcdefghjkmnpqrstuvwxyz",n={right:{even:"bc01fg45238967deuvhjyznpkmstqrwx"},left:{even:"238967debc01fg45kmstqrwxuvhjyznp"},top:{even:"p0r21436x8zb9dcf5h7kjnmqesgutwvy"},bottom:{even:"14365h7k9dcfesgujnmqp0r2twvyx8zb"}},o={right:{even:"bcfguvyz"},left:{even:"0145hjnp"},top:{even:"prxz"},bottom:{even:"028b"}};function d(e,v){const r=(e=e.toLowerCase()).charAt(e.length-1),f=e.length%2?"odd":"even";let g=e.substring(0,e.length-1);return-1!==o[v][f].indexOf(r)&&(g=d(g,v)),g+t[n[v][f].indexOf(r)]}function v(n,o,d){let v=1;const r=[-90,90],f=[-180,180];let g=0,h=0;d=d||12;let l="";for(;l.length<d;){let d;v?(d=(f[0]+f[1])/2,o>d?(h|=e[g],f[0]=d):f[1]=d):(d=(r[0]+r[1])/2,n>d?(h|=e[g],r[0]=d):r[1]=d),v=!v,g<4?g++:(l+=t[h],g=0,h=0)}return l}n.bottom.odd=n.left.even,n.top.odd=n.right.even,n.left.odd=n.bottom.even,n.right.odd=n.top.even,o.bottom.odd=o.left.even,o.top.odd=o.right.even,o.left.odd=o.bottom.even,o.right.odd=o.top.even;export{d as calculateAdjacent,v as encode};