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) • 925 B
JavaScript
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});let{lat:a,lng:e,ord:u,ordinal:d,floorId:s,title: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===d&&void 0!==u&&(d=u);const g=await i(r);if(null==d){if(null==s)throw Error("Call to locationToEndpoint with no ordinal and no floorId");{const t=o(g,s);if(!t)throw Error(`floor with id ${s} not found.`);d=t.ordinal}}else if(null==s){const o=await r.bus.get("map/getViewBBox"),{structure:n,floor:i}=t(g,a,e,d,o,!0);s=i?.id,c=n?.id}return null!=s&&null==c&&(c=n(g,s)?.id),{lat:a,lng:e,floorId:s,ordinal:d,title:f,structureId:c}}const i=async o=>o.bus.get("venueData/getVenueData").then((o=>o.structures));export{i as getStructures,r as locationToEndpoint};