utils.js 1.7 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.24/esri/copyright.txt for details.
  4. */
  5. import{isNone as t}from"../../core/maybe.js";import{impedanceAttributeNameJsonMap as r}from"../support/networkEnums.js";function e(e,o){if(t(e))return null;const i={},s=new RegExp(`^${o}`,"i");for(const t of Object.keys(e))if(s.test(t)){const s=t.substring(o.length);i[r.fromJSON(s)]=e[t]}return i}function o(e,o,i){if(!t(e)){o.attributes||(o.attributes={});for(const t in e){const s=r.toJSON(t);o.attributes[`${i}${s}`]=e[t]}}}function i(t){const e={};for(const o of Object.keys(t)){const i=o;e[r.fromJSON(i)]=t[o]}return e}function s(t){const e={};for(const o of Object.keys(t)){const i=o;e[r.toJSON(i)]=t[o]}return e}function n(r,e){return t(r)||t(e)?null:Math.round((r-e)/6e4)}function u(t){const r=t.toJSON(),e=r;return e.accumulateAttributeNames&&(e.accumulateAttributeNames=r.accumulateAttributeNames.join()),e.attributeParameterValues&&(e.attributeParameterValues=JSON.stringify(r.attributeParameterValues)),e.barriers&&(e.barriers=JSON.stringify(r.barriers)),e.outSR&&(e.outSR=r.outSR.wkid),e.overrides&&(e.overrides=JSON.stringify(r.overrides)),e.polygonBarriers&&(e.polygonBarriers=JSON.stringify(r.polygonBarriers)),e.polylineBarriers&&(e.polylineBarriers=JSON.stringify(r.polylineBarriers)),e.restrictionAttributeNames&&(e.restrictionAttributeNames=r.restrictionAttributeNames.join()),e.stops&&(e.stops=JSON.stringify(r.stops)),e.travelMode&&(e.travelMode=JSON.stringify(r.travelMode)),e}export{s as fromKebabImpedanceAttributes,e as getPrefixedProperties,n as getTimezoneOffset,u as routeParametersToQueryParameters,o as setPrefixedProperties,i as toKebabImpedanceAttributes};