@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.64 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as e}from"../chunks/tslib.es6.js";import t from"./Analysis.js";import n from"./DimensionSimpleStyle.js";import s from"./LengthDimension.js";import{equals as o}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{referenceSetter as r,castForReferenceSetter as l}from"../core/collectionUtils.js";import{watch as p,syncAndInitial as u}from"../core/reactiveUtils.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import c from"../geometry/Extent.js";import{projectOrLoadMany as d}from"../geometry/projectionUtils.js";const y=i.ofType(s);let f=class extends t{constructor(e){super(e),this.type="dimension",this.style=new n,this.extent=null}initialize(){this.addHandles(p((()=>this._computeExtent()),(e=>{null==e?.pending&&this._set("extent",null!=e?e.extent:null)}),u))}get dimensions(){return this._get("dimensions")||new y}set dimensions(e){this._set("dimensions",r(e,this.dimensions,y))}get spatialReference(){for(const e of this.dimensions){if(null!=e.startPoint)return e.startPoint.spatialReference;if(null!=e.endPoint)return e.endPoint.spatialReference}return null}get valid(){return this.dimensions.every((e=>e.valid))}async waitComputeExtent(){const e=this._computeExtent();return null!=e?e.pending:Promise.resolve()}_computeExtent(){const e=this.spatialReference;if(null==e)return{pending:null,extent:null};const t=[];for(const o of this.dimensions)null!=o.startPoint&&t.push(o.startPoint),null!=o.endPoint&&t.push(o.endPoint);const n=d(t,e);if(null!=n.pending)return{pending:n.pending,extent:null};let s=null;return null!=n.geometries&&(s=n.geometries.reduce(((e,t)=>null==e?null!=t?c.fromPoint(t):null:null!=t?e.union(c.fromPoint(t)):e),null)),{pending:null,extent:s}}clear(){this.dimensions.removeAll()}equals(e){return this===e||super.equals(e)&&this.style.equals(e.style)&&o(this.dimensions.toArray(),e.dimensions.toArray(),((e,t)=>e.equals(t)))}};e([m({type:["dimension"]})],f.prototype,"type",void 0),e([m({cast:l,type:y,nonNullable:!0})],f.prototype,"dimensions",null),e([m({readOnly:!0})],f.prototype,"spatialReference",null),e([m({types:{key:"type",base:null,typeMap:{simple:n}},nonNullable:!0})],f.prototype,"style",void 0),e([m({value:null,readOnly:!0})],f.prototype,"extent",void 0),e([m({readOnly:!0})],f.prototype,"valid",null),f=e([a("esri.analysis.DimensionAnalysis")],f);export{f as default};