@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
1 lines • 7.1 kB
JavaScript
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[6650],{69052(e,t,i){i.d(t,{hr:()=>s,ie:()=>a,uC:()=>l});var n=i(34727);class s{constructor(e,t){this.min=e,this.max=t,this.range=t-e}normalize(e,t=0,i=!1){return r(this.range,this.min,this.max,e,t,i)}clamp(e,t=0){return(0,n.qE)(e-t,this.min,this.max)+t}monotonic(e,t,i){return e<t?t:t+o(this.range,e-t,i)}minimalMonotonic(e,t,i){return r(this.range,e,e+this.range,t,i)}center(e,t,i){return t=this.monotonic(e,t,i),this.normalize((e+t)/2,i)}diff(e,t,i){return this.monotonic(e,t,i)-e}shortestSignedDiff(e,t){e=this.normalize(e);const i=(t=this.normalize(t))-e,n=t<e?this.minimalMonotonic(e,t)-e:t-this.minimalMonotonic(t,e);return Math.abs(i)<Math.abs(n)?i:n}contains(e,t,i){return t=this.minimalMonotonic(e,t),(i=this.minimalMonotonic(e,i))>e&&i<t}}function r(e,t,i,n,s=0,r=!1){return(n-=s)<t?n+=o(e,t-n):n>i&&(n-=o(e,n-i)),r&&n===i&&(n=t),n+s}function o(e,t,i=0){return Math.ceil((t-i)/e)*e+i}const l=new s(0,2*Math.PI),a=(new s(-Math.PI,Math.PI),new s(0,360))},96650(e,t,i){i.r(t),i.d(t,{default:()=>N});var n=i(5482),s=i(91715),r=i(69540),o=i(69052),l=i(25482),a=i(97768),u=i(91429),h=i(56507),d=i(86738);let p=class extends((0,l.T)(r.Pw)){constructor(e){super(e),this.observer=null,this.farDistance=1e3,this.heading=0,this.tilt=90,this.horizontalFieldOfView=45,this.verticalFieldOfView=45,this.feature=null}get valid(){return null!=this.observer&&this.farDistance>0}equals(e){return(0,a.CM)(this.observer,e.observer)&&this.farDistance===e.farDistance&&this.heading===e.heading&&this.tilt===e.tilt&&this.horizontalFieldOfView===e.horizontalFieldOfView&&this.verticalFieldOfView===e.verticalFieldOfView&&(0,s.xH)(this.feature,e.feature)}};(0,n.Cg)([(0,u.MZ)({type:d.A,json:{write:{isRequired:!0}}})],p.prototype,"observer",void 0),(0,n.Cg)([(0,u.MZ)({type:Number,nonNullable:!0,range:{min:0},json:{write:{isRequired:!0}}})],p.prototype,"farDistance",void 0),(0,n.Cg)([(0,u.MZ)({type:Number,nonNullable:!0,json:{write:{isRequired:!0}}}),(0,u.wg)(e=>o.ie.normalize((0,h.GB)(e),void 0,!0))],p.prototype,"heading",void 0),(0,n.Cg)([(0,u.MZ)({type:Number,nonNullable:!0,range:{min:0,max:180},json:{write:{isRequired:!0}}})],p.prototype,"tilt",void 0),(0,n.Cg)([(0,u.MZ)({type:Number,nonNullable:!0,range:{min:0,max:360},json:{write:{isRequired:!0}}})],p.prototype,"horizontalFieldOfView",void 0),(0,n.Cg)([(0,u.MZ)({type:Number,nonNullable:!0,range:{min:0,max:180},json:{write:{isRequired:!0}}})],p.prototype,"verticalFieldOfView",void 0),(0,n.Cg)([(0,u.MZ)(s.N1)],p.prototype,"feature",void 0),(0,n.Cg)([(0,u.MZ)({readOnly:!0,json:{read:!1}})],p.prototype,"valid",null),p=(0,n.Cg)([(0,u.$K)("esri.analysis.Viewshed")],p);var c=i(79608),w=i(4576),y=i(7762),g=i(62885),m=i(34727),v=i(36708),f=i(5443),M=i(91218);const x=y.A.ofType(p);let C=class extends c.A{constructor(e){super(e),this.type="viewshed",this._extent=null}initialize(){this.addHandles((0,v.wB)(()=>this._computeExtent(),e=>{null==e.pending&&(this._extent=e.extent)},v.pc))}get viewsheds(){return this._get("viewsheds")||new x}set viewsheds(e){this._set("viewsheds",(0,g.V)(e,this.viewsheds,x))}get spatialReference(){for(const e of this.viewsheds)if(null!=e.observer)return e.observer.spatialReference;return null}get extent(){return this._extent}get valid(){return this.viewsheds.every(e=>e.valid)}async waitComputeExtent(){const e=this._computeExtent();null!=e.pending&&await e.pending}_computeExtent(){const{spatialReference:e}=this;if(null==e)return{pending:null,extent:null};const t=this.viewsheds.filter(e=>null!=e.observer),i=t.map(e=>e.observer).toArray(),n=(0,M.projectOrLoadMany)(i,e);return null!=n.pending?{pending:n.pending,extent:null}:{pending:null,extent:n.geometries.map((e,i)=>{const n=t.at(i);return null!=e&&null!=n?this._computeViewshedExtent(this.viewsheds.at(i),e):null}).filter(e=>null!=e).reduce((e,t)=>function(e,t){return null==e?t:null==t?e:e.union(t)}(e,t),null)}}_computeViewshedExtent(e,t){const{farDistance:i,heading:n,tilt:s,horizontalFieldOfView:r,verticalFieldOfView:l}=e,{spatialReference:a}=t,u=r/2,h=l/2,d=i/a.metersPerUnit,p=[o.ie.normalize(n-u),n,o.ie.normalize(n+u)],c=f.A.fromPoint(t),w=e=>{const t=p.map(t=>o.ie.normalize(t-e));if(t[0]>t[2]||360===r)return d;const i=t.map(e=>Math.abs(e>180?360-e:e)).reduce((e,t)=>e>t?t:e);return i>90?0:d*Math.cos((0,m.kU)(i))};c.xmax+=w(90),c.xmin-=w(-90),c.ymax+=w(0),c.ymin-=w(180);const y=t.z;if(null!=y){let e=y,t=y;const n=s-90,r=(0,m.qE)(n+h,-90,90),o=(0,m.qE)(n-h,-90,90),l=a?.isGeographic?i:d;e+=l*Z(r),t+=l*Z(o);const p=b(h)*l,w=Z(n)*p*(1-b(u));s<90&&(e-=w),s>90&&(t-=w),c.zmax=Math.max(e,y),c.zmin=Math.min(t,y)}return c}equals(e){return this===e||super.equals(e)&&(0,w.aI)(this.viewsheds.toArray(),e.viewsheds.toArray(),(e,t)=>e.equals(t))}clear(){this.viewsheds.removeAll()}};function b(e){return Math.cos((0,m.kU)(e))}function Z(e){return Math.sin((0,m.kU)(e))}(0,n.Cg)([(0,u.MZ)({type:["viewshed"]})],C.prototype,"type",void 0),(0,n.Cg)([(0,u.MZ)({cast:g.H,type:x,nonNullable:!0})],C.prototype,"viewsheds",null),(0,n.Cg)([(0,u.MZ)({readOnly:!0})],C.prototype,"spatialReference",null),(0,n.Cg)([(0,u.MZ)()],C.prototype,"_extent",void 0),(0,n.Cg)([(0,u.MZ)()],C.prototype,"extent",null),(0,n.Cg)([(0,u.MZ)({readOnly:!0})],C.prototype,"valid",null),C=(0,n.Cg)([(0,u.$K)("esri.analysis.ViewshedAnalysis")],C);var O=i(25728),V=i(4146),z=i(16131),R=i(43937);let q=class extends((0,z.q)((0,O.M)(V.A))){constructor(e){super(e),this.type="viewshed",this.operationalLayerType="ViewshedLayer",this.source=new C,this.opacity=1}initialize(){this.addHandles((0,v.wB)(()=>this.source,(e,t)=>{null!=t&&t.parent===this&&(t.parent=null),null!=e&&(e.parent=this)},v.pc))}async load(){return this.addResolvingPromise(this.source.waitComputeExtent()),this}get spatialReference(){return this.source.spatialReference}get fullExtent(){return this.source.extent}releaseAnalysis(e){this.source===e&&(this.source=new C)}get analysis(){return this.source}set analysis(e){this.source=e}get viewsheds(){return this.source.viewsheds}set viewsheds(e){this.source.viewsheds=e}writeViewsheds(e,t,i,n){t.viewsheds=e.filter(e=>e.valid).toJSON(n)}};(0,n.Cg)([(0,u.MZ)({json:{read:!1},readOnly:!0})],q.prototype,"type",void 0),(0,n.Cg)([(0,u.MZ)({type:["ViewshedLayer"]})],q.prototype,"operationalLayerType",void 0),(0,n.Cg)([(0,u.MZ)({type:C,nonNullable:!0})],q.prototype,"source",void 0),(0,n.Cg)([(0,u.MZ)({readOnly:!0})],q.prototype,"spatialReference",null),(0,n.Cg)([(0,u.MZ)({readOnly:!0})],q.prototype,"fullExtent",null),(0,n.Cg)([(0,u.MZ)({readOnly:!0,json:{read:!1,write:!1,origins:{service:{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-document":{read:!1,write:!1}}}})],q.prototype,"opacity",void 0),(0,n.Cg)([(0,u.MZ)({type:["show","hide"]})],q.prototype,"listMode",void 0),(0,n.Cg)([(0,u.MZ)({type:y.A.ofType(p),json:{write:{ignoreOrigin:!0},origins:{"web-scene":{write:{ignoreOrigin:!0}}}}})],q.prototype,"viewsheds",null),(0,n.Cg)([(0,R.K)("web-scene","viewsheds")],q.prototype,"writeViewsheds",null),q=(0,n.Cg)([(0,u.$K)("esri.layers.ViewshedLayer")],q);const N=q}}]);