@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.77 kB
JavaScript
import{_ as e}from"../../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../../core/HandleOwner.js";import"../../../../core/has.js";import{watch as r}from"../../../../core/reactiveUtils.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as i}from"../../../../geometry/support/spatialReferenceUtils.js";import l from"../../../../layers/support/TileInfo.js";import{loadProcessorModule as n}from"./processors.js";import a from"./controllers/FeatureController2D.js";import c from"./support/TileStore.js";import{UpdateToken as p}from"./support/UpdateToken.js";import h from"../../tiling/TileInfoView.js";let d=class extends t{constructor(){super(...arguments),this.controller=null,this.processor=null,this.remoteClient=null,this.tileStore=null,this.service=null,this.viewState=null,this._paused=!1,this._pendingTileUpdates=[]}initialize(){this.handles.add(r((()=>this.updating),(e=>{this.remoteClient.invoke("setUpdating",e).catch((e=>{}))})))}destroy(){this.stop(),this.controller?.destroy(),this.processor?.destroy(),this.controller=this.processor=this.tileStore=this.remoteClient=null}get updating(){return!this.controller||this.controller.updating}stop(){this._paused=!0,Array.isArray(this.service?.source)&&(this.service.source.forEach((e=>e.close())),this.service.source.length=0),this.tileStore?.updateTiles({added:[],removed:this.tileStore.tiles.map((e=>e.id))}),this.tileStore?.destroy(),this.tileStore=null,this._pendingTileUpdates.length=0}async startup({service:e,config:t,tileInfo:r,tiles:s}){if(this._paused=!0,Array.isArray(this.service?.source)&&(this.service.source.forEach((e=>e.close())),this.service.source.length=0),this.service=e,!this.tileStore||!i(this.tileStore.tileScheme.spatialReference,r.spatialReference)){const e=new h(l.fromJSON(r));s.added.length=s.removed.length=0,this.tileStore?.updateTiles({added:[],removed:this.tileStore.tiles.map((e=>e.id))}),this.tileStore?.destroy(),this.tileStore=new c(e),this._pendingTileUpdates.length=0}for(await this._createProcessorAndController(t),await this.update({config:t}),this.controller.resume(),this.tileStore.clear(),this.tileStore.updateTiles(s),this._paused=!1;this._pendingTileUpdates.length;)this.tileStore.updateTiles(this._pendingTileUpdates.pop())}async updateTiles(e){this._paused?this._pendingTileUpdates.push(e):this.tileStore?.updateTiles(e)}async update({config:e}){const t=p.empty();return await Promise.all([this.processor.update(t,e),this.controller.update(t,e)]),t.toJSON()}async applyUpdate(e){return this.controller.applyUpdate(p.create(e))}async _createProcessorAndController(e){await Promise.all([this._handleControllerConfig(e),this._handleProcessorConfig(e)]),this.controller.processor=this.processor}async _handleControllerConfig(e){return this._createController(this.service,e)}async _handleProcessorConfig(e){return this._createProcessor(this.service,e)}async _createController(e,t){this.controller&&this.controller.destroy();const{tileStore:r,remoteClient:s}=this,o=new a({service:e,tileStore:r,remoteClient:s});return this.controller=o,o}async _createProcessor(e,t){const r=t.schema.processors[0].type,s=(await n(r)).default,{remoteClient:o,tileStore:i}=this,l=new s({service:e,config:t,tileStore:i,remoteClient:o});return this.processor&&this.processor.destroy(),this.processor=l,l}};e([s()],d.prototype,"controller",void 0),e([s()],d.prototype,"processor",void 0),e([s()],d.prototype,"updating",null),e([s()],d.prototype,"viewState",void 0),d=e([o("esri.views.2d.layers.features.Pipeline")],d);const u=d;export{u as default};