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) 932 B
import{getFloor as o,getStructureAndFloorAtPoint as t,getStructureForFloorId as n}from"./geom.js";async function r(r,l){if(l.poiId)return r.bus.get("wayfinder/getNavigationEndpoint",{ep:l.poiId});const{lat:a,lng:e,ord:u,title:d=""}=l;let{ordinal:s,floorId:f,structureId:c}=l;if(null==a||null==e)throw Error("To obtain a location, you must provide a lat,lng or a poiId");void 0===s&&void 0!==u&&(s=u);const g=await i(r);if(null==s){if(null==f)throw Error("Call to locationToEndpoint with no ordinal and no floorId");{const t=o(g,f);if(!t)throw Error(`floor with id ${f} not found.`);s=t.ordinal}}else if(null==f){const o=await r.bus.get("map/getViewBBox"),{structure:n,floor:i}=t(g,a,e,s,o,!0);f=i?.id,c=n?.id}return null!=f&&null==c&&(c=n(g,f)?.id),{lat:a,lng:e,floorId:f,ordinal:s,title:d,structureId:c}}const i=async o=>o.bus.get("venueData/getVenueData").then(o=>o.structures);export{i as getStructures,r as locationToEndpoint};