@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.14 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{MinPriority as e}from"../../../../core/MemCache.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{fromValues as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{create as o}from"../../../../geometry/support/aaBoundingRect.js";import{TileHandler as s}from"./TileHandler.js";import{VectorTile as r}from"./VectorTile.js";import n from"../../tiling/TileInfoViewPOT.js";import l from"../../tiling/TileKey.js";class a extends s{constructor(e,t,i,o){super(e,t,i,e.tileInfo.lods.length-1),this._memCache=o,this._ongoingTileRequests=new Map,this._ongoingRequestToController=new Map,this._tileInfoView=new n(e.tileInfo,e.fullExtent)}destroy(){super.destroy(),this._ongoingRequestToController.forEach((e=>e.abort())),this._ongoingRequestToController.clear(),this._ongoingTileRequests.clear()}async getVectorTile(s,n){const a=new l(s[0],s[1],s[2],0);let g=this._memCache.get(a.id);if(g)return g.retain(),g;const h=await this._getVectorTileData(a);if(t(n),!this._layer)return null;if(g=this._memCache.get(a.id),g)return g.retain(),g;const c=this._layer.tileInfo.getTileBounds(o(),a),m=this._tileInfoView.getTileResolution(s[0]);return g=new r(a,m,c[0],c[3],512,512,this._styleRepository,this._memCache),g.setData(h),h&&(g.retain(),this._memCache.put(a.id,g,e)),g.neededForCoverage=!0,g.transforms.tileUnitsToPixels=i(1/8,0,0,0,1/8,0,0,0,1),g}_getVectorTileData(e){const t=e.id;if(this._ongoingTileRequests.has(t))return this._ongoingTileRequests.get(t);const i=new AbortController,o={signal:i.signal},s=this._getParsedVectorTileData(e,o).then((e=>(this._ongoingTileRequests.delete(t),this._ongoingRequestToController.delete(t),e))).catch((()=>(this._ongoingTileRequests.delete(t),this._ongoingRequestToController.delete(t),null)));return this._ongoingTileRequests.set(t,s),this._ongoingRequestToController.set(t,i),s}_getParsedVectorTileData(e,t){return this.fetchTileData(e,t).then((i=>this.parseTileData({key:e,data:i},t)))}}export{a as default};