@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.7 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as s}from"../../../chunks/tslib.es6.js";import{createTask as e}from"../../../core/asyncUtils.js";import i from"../../../core/Error.js";import{destroyMaybe as a,abortMaybe as t}from"../../../core/maybe.js";import{isAborted as r,createAbortError as o}from"../../../core/promiseUtils.js";import{watch as n,syncAndInitial as l}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerView3D as h}from"./LayerView3D.js";import c from"../../layers/LayerView.js";import d from"../../layers/ViewshedLayerView.js";const V="analysis-view-handles";let p=class extends(h(d(c))){constructor(s){super(s),this.type="viewshed-3d",this._analysisModule=null}initialize(){this.addHandles(n((()=>this.layer.source),(s=>{this._destroyAnalysisView(),null!=s&&this._createAnalysisView(s)}),l),V)}destroy(){this.removeHandles(V),this._destroyAnalysisView()}async whenAnalysisView(){if(null!=this.analysisView)return this.analysisView;if(null!=this._createAnalysisViewTask)return this._createAnalysisViewTask.promise;throw new i("layerview:no-analysisview-for-analysis","The analysis has not been set on the ViewshedLayer of this layer view")}isUpdating(){return null!=this._createAnalysisViewTask||null!=this.analysisView&&this.analysisView.updating}_createAnalysisView(s){const i=e((async e=>(this.analysisView=await this._createAnalysisViewPromise(s,e),this._createAnalysisViewTask===i&&(this._createAnalysisViewTask=null),this.analysisView)));this.addResolvingPromise(i.promise),this._createAnalysisViewTask=i}_destroyAnalysisView(){this.analysisView=a(this.analysisView),this._createAnalysisViewTask=t(this._createAnalysisViewTask)}async _createAnalysisViewPromise(s,e){let a=this._analysisModule;if(null==a){const s=await this._loadAnalysisModule();this._analysisModule=s,a=s}const t=new a.default({analysis:s,view:this.view,parent:this});if(await t.when(),r(e)){t.destroy();const e=this.layer.source;if(null!=e&&s!==e)throw o("Source has changed during creation.");throw new i("layerview:no-analysisview-for-analysis","The analysis has not been added to the ViewshedLayer of this layer view",{analysis:s})}return t}_loadAnalysisModule(){return import("../analysis/ViewshedAnalysisView3D.js")}};s([y()],p.prototype,"type",void 0),s([y()],p.prototype,"analysisView",void 0),s([y()],p.prototype,"_createAnalysisViewTask",void 0),p=s([w("esri.views.3d.layers.ViewshedLayerView3D")],p);const u=p;export{u as default};