geometryServiceUtils.1ff04b2b.js 1.9 KB

1
  1. import{_ as c,$ as l,a0 as h,cp as S,as as p,hE as d,dy as w,dR as R,U as v,hF as O,y as u,g as f,bO as J}from"./index.a33cbbbf.js";let n=class extends S{constructor(r){super(r),this.geometries=null,this.outSpatialReference=null,this.transformation=null,this.transformForward=null}toJSON(){const r=this.geometries.map(o=>o.toJSON()),t=this.geometries[0],e={};return e.outSR=this.outSpatialReference.wkid||JSON.stringify(this.outSpatialReference.toJSON()),e.inSR=t.spatialReference.wkid||JSON.stringify(t.spatialReference.toJSON()),e.geometries=JSON.stringify({geometryType:p(t),geometries:r}),this.transformation&&(e.transformation=this.transformation.wkid||JSON.stringify(this.transformation)),this.transformForward!=null&&(e.transformForward=this.transformForward),e}};c([l()],n.prototype,"geometries",void 0),c([l({json:{read:{source:"outSR"}}})],n.prototype,"outSpatialReference",void 0),c([l()],n.prototype,"transformation",void 0),c([l()],n.prototype,"transformForward",void 0),n=c([h("esri.rest.support.ProjectParameters")],n);const m=n,N=d(m);async function $(r,t,e){t=N(t);const o=w(r),s={...o.query,f:"json",...t.toJSON()},a=t.outSpatialReference,i=p(t.geometries[0]),g=R(s,e);return v(o.path+"/project",g).then(({data:{geometries:y}})=>O(y,i,a))}async function j(r=null,t){var s,a;if(u.geometryServiceUrl)return u.geometryServiceUrl;if(!r)throw new f("internal:geometry-service-url-not-configured");let e;e="portal"in r?r.portal||J.getDefault():r,await e.load({signal:t});const o=(a=(s=e.helperServices)==null?void 0:s.geometry)==null?void 0:a.url;if(!o)throw new f("internal:geometry-service-url-not-configured");return o}async function U(r,t,e=null,o){const s=await j(e,o),a=new m;a.geometries=[r],a.outSpatialReference=t;const i=await $(s,a,{signal:o});if(i&&Array.isArray(i)&&i.length===1)return i[0];throw new f("internal:geometry-service-projection-failed")}export{j as getGeometryServiceURL,U as projectGeometry};