UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.31 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 e}from"../../chunks/tslib.es6.js";import s from"../../core/Accessor.js";import t from"../../core/Collection.js";import{referenceSetter as r}from"../../core/collectionUtils.js";import{isAbortError as o}from"../../core/promiseUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{findFullModelSublayer as l}from"./support/buildingLayerUtils.js";import{LayerTreeNode as d}from"./support/LayerTreeNode.js";import{createLoadLayersFunction as n}from"./support/layerUtils.js";let p=class extends s{constructor(e){super(e),this.root=new d,this.state="disabled",this._loadLayers=n(),this.layers=new t}initialize(){this.addHandles(this.layers.on("change",(()=>this._onLayersChange()))),this._onLayersChange()}destroy(){this._set("state","disabled"),this.root.destroy()}set layers(e){const s=this._get("layers");this._set("layers",r(e,s))}_updateLayerTree(){this.root.destroy(),this._set("root",new d);const e=new Map,s=this.layers.length>1?"modelName":"id";return this.layers.forEach((t=>{const r=l(t);this._addNodesForSublayers(r??t,this.root,e,s)})),this}_addNodeForLayer(e,s,t,r){const o=String(e[r]).toLowerCase();if(null==o||e.isEmpty)return;const i=`${s.id}/${o}`;let a=t.get(i);a||(a=new d({id:o,level:s.level+1}),t.set(i,a)),a.layers.push(e),s.children.push(a),this._addNodesForSublayers(e,a,t,r)}_addNodesForSublayers(e,s,t,r){("building-scene"===e.type||"building-group"===e.type&&!e.isEmpty)&&e.sublayers.forEach((e=>this._addNodeForLayer(e,s,t,r)))}async _onLayersChange(){if(this._set("state","loading"),0!==this.layers.length)try{await this._loadLayers(this.layers),this._updateLayerTree(),this._set("state","ready")}catch(e){o(e)||this._set("state","failed")}}};e([i({readOnly:!0})],p.prototype,"root",void 0),e([i({type:t,nonNullable:!0})],p.prototype,"layers",null),e([i({readOnly:!0,nonNullable:!0})],p.prototype,"state",void 0),p=e([a("esri.widgets.BuildingExplorer.BuildingDisciplinesViewModel")],p);const y=p;export{y as default};