UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 5.33 kB
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../Graphic.js";import s from"../../../core/Accessor.js";import{groupToMap as t}from"../../../core/arrayUtils.js";import i from"../../../core/Collection.js";import{handlesGroup as o}from"../../../core/handleUtils.js";import n from"../../../core/Logger.js";import{abortMaybe as l,isNone as a,isSome as u}from"../../../core/maybe.js";import{isAbortError as p,eachAlwaysValues as h,createResolver as c}from"../../../core/promiseUtils.js";import{watch as y,syncAndInitial as d}from"../../../core/reactiveUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../core/accessorSupport/decorators/subclass.js";import"../../../layers/buildingSublayers/BuildingGroupSublayer.js";import m from"./BuildingComponentSublayerView3D.js";import{BuildingSublayerView3DMixin as b}from"./BuildingSublayerView3D.js";import{LayerView3D as w}from"./LayerView3D.js";import{parseFilterMode as V}from"./i3s/BuildingFilterUtil.js";import{checkSpatialReference as j}from"./i3s/I3SUtil.js";import{updatingProgress as _}from"../support/updatingProperties.js";import C from"../../layers/BuildingSceneLayerView.js";const S=b(s);let B=class extends(w(C)){constructor(e){super(e),this.type="building-scene-3d",this.sublayerViews=new i,this._abortController=new AbortController,this._loadingComponents=0,this._pendingWhenSublayerViews=new Map}get filterExpression(){const e=this.layer.activeFilterId,r=null!=e?this.layer.filters.find((r=>r.id===e)):null,s=null!=r?r.filterBlocks?.find((e=>"solid"===e.filterMode.type)):null;return s?s.filterExpression:null}get filterExpressions(){const e=this.layer.activeFilterId,r=null!=e?this.layer.filters.find((r=>r.id===e)):null;return r&&r.filterBlocks?r.filterBlocks.toArray().map((e=>[e.filterExpression??"",V(e)])):[]}get updatingProgressValue(){const e=this.sublayerViews,r=this._loadingComponents+(e?e.length:0);return e.reduce(((e,r)=>e+r.updatingProgress),0)/r}isUpdating(){return this._loadingComponents>0||this.sublayerViews&&this.sublayerViews.some((e=>e.updating))}initialize(){j(this.layer.spatialReference,this.view.spatialReference,this.view.viewingMode),this._initializeSubLayerViews(this.layer.sublayers,this)}destroy(){this.sublayerViews&&(this.sublayerViews.forEach((e=>e.destroy())),this.sublayerViews=null),this._abortController=l(this._abortController)}_initializeSubLayerViews(e,r){const s=this,t=this.view;e.forEach((e=>{if(!e.isEmpty)if("building-group"===e.type){const s=new S({sublayer:e,view:t,parent:r});this._initializeSubLayerViews(e.sublayers,s)}else"mesh"===e.geometryType&&(this._loadingComponents++,e.load({signal:this._abortController.signal}).then((()=>{const i=new m({sublayer:e,layerView:s,view:t,parent:r});this.sublayerViews.push(i);const o=this._pendingWhenSublayerViews.get(e);if(o){for(const e of o)e.resolve(i);this._pendingWhenSublayerViews.delete(e)}this.handles.add([y((()=>i.updating),(()=>this.notifyChange("updating")),d),y((()=>i.updatingProgress),(()=>this.notifyChange("updatingProgressValue")),d)])})).catch((r=>{p(r)||n.getLogger(this.declaredClass).error(`Error while creating view for sublayer ${e.id}\nLayer: ${this.layer.url}\n`,r)})).then((()=>{this._loadingComponents--,this.notifyChange("updating"),this.notifyChange("updatingProgressValue")})))}))}getGraphicFromIntersectorTarget(e){for(const r of this.sublayerViews.items)if(r.sublayer.uid===e.sublayerUid)return r.getGraphicFromIntersectorTarget(e);return null}async fetchPopupFeatures(e,r){if(a(r)||!r.clientGraphics||0===r.clientGraphics.length)return[];const s=t(r.clientGraphics,(e=>e.sourceLayer)),i=[];for(const[t,o]of s){const s=this._findComponent(t);u(s)&&i.push(s.fetchPopupFeatures(e,{...r,clientGraphics:o}))}return h(i).then((e=>e.flat()))}whenGraphicBounds(e){const r=this._findComponent(e.sourceLayer);return a(r)?Promise.reject():r.whenGraphicBounds(e)}getAABBFromIntersectorTarget(e){for(const r of this.sublayerViews.items)if(r.sublayer.uid===e.sublayerUid)return r.getAABBFromIntersectorTarget(e);return null}async whenSublayerView(e){const r=this._findComponent(e);if(u(r))return r;const s=this._pendingWhenSublayerViews.get(e),t=c();return s?s.push(t):this._pendingWhenSublayerViews.set(e,[t]),t.promise}_findComponent(e){return this.sublayerViews.find((r=>e===r.sublayer))}highlight(e){e instanceof r?e=[e]:e instanceof i&&(e=e.toArray());const s=[];if(Array.isArray(e)&&e.length>0&&e[0]instanceof r){const r=e,t=new Map;for(const e of r){let r=t.get(e.sourceLayer);null==r&&(r=[],t.set(e.sourceLayer,r)),r.push(e)}this.sublayerViews.forEach((e=>{const r=t.get(e.sublayer);r&&s.push(e.highlight(r))}))}return o(s)}getUsedMemory(){return this.sublayerViews.reduce(((e,r)=>e+r.getUsedMemory()),0)}getUnloadedMemory(){return this.sublayerViews.reduce(((e,r)=>e+r.getUnloadedMemory()),0)}ignoresMemoryFactor(){return!1}};e([g()],B.prototype,"sublayerViews",void 0),e([g({readOnly:!0})],B.prototype,"filterExpression",null),e([g({readOnly:!0})],B.prototype,"filterExpressions",null),e([g(_)],B.prototype,"updatingProgress",void 0),e([g({readOnly:!0,dependsOn:[]})],B.prototype,"updatingProgressValue",null),B=e([f("esri.views.3d.layers.BuildingSceneLayerView3D")],B);const v=B;export{v as default};