DimensionAnalysis.js 2.5 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../chunks/tslib.es6.js";import t from"./Analysis.js";import n from"./DimensionSimpleStyle.js";import o from"./LengthDimension.js";import s from"../core/Collection.js";import{referenceSetter as i,castForReferenceSetter as r}from"../core/collectionUtils.js";import{isNone as l,isSome as p,unwrap as m}from"../core/maybe.js";import{watch as u,syncAndInitial as a}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import y from"../geometry/Extent.js";import{projectOrLoadMany as f}from"../geometry/projection.js";const h=s.ofType(o);let g=class extends t{constructor(e){super(e),this.type="dimension",this.style=new n,this.extent=null}initialize(){this.addHandles(u((()=>this._computeExtent()),(e=>{(l(e)||l(e.pending))&&this._set("extent",p(e)?e.extent:null)}),a))}get dimensions(){return this._get("dimensions")||new h}set dimensions(e){this._set("dimensions",i(e,this.dimensions,h))}get spatialReference(){for(const e of this.dimensions){if(p(e.startPoint))return e.startPoint.spatialReference;if(p(e.endPoint))return e.endPoint.spatialReference}return null}get requiredPropertiesForEditing(){return this.dimensions.reduce(((e,t)=>(e.push(t.startPoint,t.endPoint),e)),[])}async waitComputeExtent(){const e=this._computeExtent();return p(e)?m(e.pending):null}_computeExtent(){const e=this.spatialReference;if(l(e))return{pending:null,extent:null};const t=[];for(const s of this.dimensions)p(s.startPoint)&&t.push(s.startPoint),p(s.endPoint)&&t.push(s.endPoint);const n=f(t,e);if(p(n.pending))return{pending:n.pending,extent:null};let o=null;return p(n.geometries)&&(o=n.geometries.reduce(((e,t)=>l(e)?p(t)?y.fromPoint(t):null:p(t)?e.union(y.fromPoint(t)):e),null)),{pending:null,extent:o}}clear(){this.dimensions.removeAll()}};e([c({type:["dimension"]})],g.prototype,"type",void 0),e([c({cast:r,type:h,nonNullable:!0})],g.prototype,"dimensions",null),e([c({readOnly:!0})],g.prototype,"spatialReference",null),e([c({types:{key:"type",base:null,typeMap:{simple:n}},nonNullable:!0})],g.prototype,"style",void 0),e([c({value:null,readOnly:!0})],g.prototype,"extent",void 0),e([c({readOnly:!0})],g.prototype,"requiredPropertiesForEditing",null),g=e([d("esri.analysis.DimensionAnalysis")],g);const j=g;export{j as default};