@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.61 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";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 m,subclass as c}from"../core/accessorSupport/decorators.js";import{projectOrLoad as g}from"../geometry/projectionUtils.js";import{fromValues as f,expandWithVec3 as y,toExtent as h}from"../geometry/support/aaBoundingBox.js";import{getGeometryEffectiveElevationMode as v}from"../support/elevationInfoUtils.js";const d=i.ofType(o);let x=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;y(o,[t,r,s])}}const s=h(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([m({type:["line-of-sight"]})],x.prototype,"type",void 0),t([m({type:r,json:{read:!0,write:!0}})],x.prototype,"observer",void 0),t([m({cast:l,type:d,nonNullable:!0,json:{read:!0,write:!0}})],x.prototype,"targets",null),t([m({value:null,readOnly:!0})],x.prototype,"extent",void 0),t([m()],x.prototype,"spatialReference",null),t([m({readOnly:!0})],x.prototype,"valid",null),x=t([c("esri.analysis.LineOfSightAnalysis")],x);export{x as default};