@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.17 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
const t=new Set(["objectid","circuitid","sectionid","startlocationsourceid","startlocationid","startlocationfirstunit","startlocationlastunit","stoplocationsourceid","stoplocationid","stoplocationfirstunit","stoplocationlastunit","role","sectiontype","globalid","created_user","created_date","last_edited_user","last_edited_date"]),e=new Set(["objectid","name","providerid","consumerid","globalid","created_user","created_date","last_edited_user","last_edited_date"]);function o(e,o){const a=e.fieldsIndex,n={},s=o.attributes[a.get("sectionId").name];null!=s&&(n.sectionId=s);const i=o.attributes[a.get("startLocationSourceId").name],r=o.attributes[a.get("startLocationId").name],l=o.attributes[a.get("startLocationFirstUnit").name],c=o.attributes[a.get("startLocationLastUnit").name];null!=i&&null!=r&&(n.startLocation={sourceId:i,globalId:r,firstUnit:l,lastUnit:c});const d=o.attributes[a.get("stopLocationSourceId").name],u=o.attributes[a.get("stopLocationId").name],b=o.attributes[a.get("stopLocationFirstUnit").name],m=o.attributes[a.get("stopLocationLastUnit").name];null!=d&&null!=u&&(n.stopLocation={sourceId:d,globalId:u,firstUnit:b,lastUnit:m});const g=a.get("role"),I=o.attributes[g.name];if(null!=I){const t=g.domain;n.role=t.getName(I)}const p=a.get("sectionType"),L=o.attributes[p.name];if(null!=L){const t=p.domain;n.sectionType=t.getName(L)}const f=o.attributes[a.get("globalId").name];null!=f&&(n.globalId=f);const _={};for(const[U,v]of Object.entries(o.attributes))t.has(U.toLocaleLowerCase())||(_[U]=v);return n.attributes=_,n}function a(t,o){const a=t.fieldsIndex,n={},s=o.attributes[a.get("globalId").name];null!=s&&(n.globalId=s);const i=o.attributes[a.get("name").name];null!=i&&(n.name=i);const r=o.attributes[a.get("providerId").name];null!=r&&(n.providerId=r);const l=o.attributes[a.get("consumerId").name];null!=l&&(n.consumerId=l),n.state=l?r===l?"Reserved":"Consumed":"Available";const c={};for(const[d,u]of Object.entries(o.attributes))e.has(d.toLocaleLowerCase())||(c[d]=u);return n.attributes=c,n}export{o as createSectionJsonFromGraphic,a as createSubcircuitJsonFromGraphic};