LineOfSightAnalysis.js 2.7 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 t}from"../chunks/tslib.es6.js";import e from"./Analysis.js";import r from"./LineOfSightAnalysisObserver.js";import o from"./LineOfSightAnalysisTarget.js";import s from"../core/Collection.js";import{referenceSetter as i,castForReferenceSetter as n}from"../core/collectionUtils.js";import{isNone as p,isSome as l,applySome as a,unwrap as c}from"../core/maybe.js";import{watch as u,syncAndInitial as m}from"../core/reactiveUtils.js";import{property as g}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as y}from"../core/accessorSupport/decorators/subclass.js";import{projectOrLoad as f}from"../geometry/projection.js";import{fromValues as h,expandWithVec3 as d,toExtent as v}from"../geometry/support/aaBoundingBox.js";import{getGeometryEffectiveElevationMode as j}from"../support/elevationInfoUtils.js";const b=s.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(u((()=>this._computeExtent()),(t=>{(p(t)||p(t.pending))&&this._set("extent",l(t)?t.extent:null)}),m))}get targets(){return this._get("targets")||new b}set targets(t){this._set("targets",i(t,this.targets,b))}get spatialReference(){return l(this.observer)&&l(this.observer.position)?this.observer.position.spatialReference:null}get requiredPropertiesForEditing(){return[a(this.observer,(t=>t.position))]}async waitComputeExtent(){const t=this._computeExtent();return l(t)?c(t.pending):null}_computeExtent(){const t=this.spatialReference;if(p(this.observer)||p(this.observer.position)||p(t))return null;const e=t=>"absolute-height"===j(t.position,t.elevationInfo),r=this.observer.position,o=h(r.x,r.y,r.z,r.x,r.y,r.z);for(const i of this.targets)if(l(i.position)){const e=f(i.position,t);if(l(e.pending))return{pending:e.pending,extent:null};if(l(e.geometry)){const{x:t,y:r,z:s}=e.geometry;d(o,[t,r,s])}}const s=v(o,t);return e(this.observer)&&this.targets.every(e)||(s.zmin=null,s.zmax=null),{pending:null,extent:s}}clear(){this.observer=null,this.targets.removeAll()}};t([g({type:["line-of-sight"]})],x.prototype,"type",void 0),t([g({type:r,json:{read:!0,write:!0}})],x.prototype,"observer",void 0),t([g({cast:n,type:b,nonNullable:!0,json:{read:!0,write:!0}})],x.prototype,"targets",null),t([g({value:null,readOnly:!0})],x.prototype,"extent",void 0),t([g({readOnly:!0})],x.prototype,"spatialReference",null),t([g({readOnly:!0})],x.prototype,"requiredPropertiesForEditing",null),x=t([y("esri.analysis.LineOfSightAnalysis")],x);const O=x;export{O as default};