UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.54 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{isAbortError as t}from"../../../../core/promiseUtils.js";import{PlacementEngine as e}from"./Placement.js";import s from"./TileParser.js";import{TileStatus as r}from"../../tiling/enums.js";class i{constructor(t,s,i,a){this.status=r.INITIALIZED,this.placementEngine=new e,this.tileKey=t,this.refKeys=s,this._workerTileHandler=i,this._styleRepository=a}release(){this.tileKey="",this.refKeys=null,this.status=r.INITIALIZED,this._workerTileHandler=null}async parse(e,s){const i=s?.signal;if(null!=i){const t=()=>{i.removeEventListener("abort",t),this.status=r.INVALID};i.addEventListener("abort",t)}let a;const n={bucketsWithData:[],emptyBuckets:null};try{a=await this._parse(e,s)}catch(c){if(t(c))throw c;return{result:n,transferList:[]}}this.status=r.READY;const l=n.bucketsWithData,o=[];for(const t of a)if(t.hasFeatures()){const e=t.serialize();l.push(e)}else o.push(t.layer.uid);const u=[...l];let h=null;return o.length>0&&(h=Uint32Array.from(o),u.push(h.buffer)),n.emptyBuckets=h,{result:n,transferList:u}}setObsolete(){this.status=r.INVALID}getLayers(){return this._workerTileHandler.getLayers()}getWorkerTileHandler(){return this._workerTileHandler}async _parse(t,e){const i=t.sourceName2DataAndRefKey;if(0===Object.keys(i).length)return[];this.status=r.MODIFIED;return new s(i,this,e.client,t.sourceDataMaxLOD,this._styleRepository,t.styleLayerUIDs).parse(e)}}export{i as default};