UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 2.83 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t}from"../chunks/tslib.es6.js";import e from"./Analysis.js";import r from"./LineOfSightAnalysisObserver.js";import o from"./LineOfSightAnalysisTarget.js";import{equals as s}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{referenceSetter as n,castForReferenceSetter as l}from"../core/collectionUtils.js";import{equalsMaybe as p}from"../core/maybe.js";import{watch as a,syncAndInitial as u}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{projectOrLoad as g}from"../geometry/projectionUtils.js";import{fromValues as f,expandWithVec3 as h,toExtent as y}from"../geometry/support/aaBoundingBox.js";import{getGeometryEffectiveElevationMode as v}from"../support/elevationInfoUtils.js";const d=i.ofType(o);let j=class extends e{constructor(t){super(t),this.type="line-of-sight",this.observer=null,this.extent=null}initialize(){this.addHandles(a((()=>this._computeExtent()),(t=>{null==t?.pending&&this._set("extent",null!=t?t.extent:null)}),u))}get targets(){return this._get("targets")||new d}set targets(t){this._set("targets",n(t,this.targets,d))}get spatialReference(){return null!=this.observer?.position?this.observer.position.spatialReference:null}get valid(){return null!=this.observer?.position}async waitComputeExtent(){const t=this._computeExtent();return null!=t?t.pending:Promise.resolve()}_computeExtent(){const t=this.spatialReference;if(null==this.observer?.position||null==t)return null;const e=t=>"absolute-height"===v(t.position,t.elevationInfo),r=this.observer.position,o=f(r.x,r.y,r.z,r.x,r.y,r.z);for(const i of this.targets)if(null!=i.position){const e=g(i.position,t);if(null!=e.pending)return{pending:e.pending,extent:null};if(null!=e.geometry){const{x:t,y:r,z:s}=e.geometry;h(o,[t,r,s])}}const s=y(o,t);return e(this.observer)&&this.targets.every(e)||(s.zmin=void 0,s.zmax=void 0),{pending:null,extent:s}}clear(){this.observer=null,this.targets.removeAll()}equals(t){return this===t||super.equals(t)&&p(this.observer,t.observer)&&s(this.targets.toArray(),t.targets.toArray(),((t,e)=>t.equals(e)))}};t([c({type:["line-of-sight"]})],j.prototype,"type",void 0),t([c({type:r,json:{read:!0,write:!0}})],j.prototype,"observer",void 0),t([c({cast:l,type:d,nonNullable:!0,json:{read:!0,write:!0}})],j.prototype,"targets",null),t([c({value:null,readOnly:!0})],j.prototype,"extent",void 0),t([c()],j.prototype,"spatialReference",null),t([c({readOnly:!0})],j.prototype,"valid",null),j=t([m("esri.analysis.LineOfSightAnalysis")],j);export{j as default};