UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.58 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import t from"../../../../../core/Error.js";import"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import{debounce as r}from"../../../../../core/promiseUtils.js";import{generateUUID as s}from"../../../../../core/uuid.js";import{fetchPages as i}from"./strategies/support/snapshotUtils.js";const o=8e3;class h{constructor(h,a,c,n){this.store=h,this.queryInfo=a,this._options=c,this._fetch=n,this._nextBatch=new Set,this._fetchFeatures=r((async()=>{if(0===this._nextBatch.size||this._options.signal?.aborted)return;const r=Array.from(this._nextBatch);this._nextBatch.clear(),r.length>o&&e.getLogger("esri.views.2d.layers.FeatureLayerView2D").warn(new t("highlight-too-many-features",`highlight is limited to ${o} features on large layers configured with a display filter to avoid performance issues`));const h=this.queryInfo.objectIdsQueryPageSize,a=Math.ceil(o/h),c=Math.min(a,Math.ceil(r.length/h)),n=Array.from({length:c},((t,e)=>{const s=e*h,i=Math.min(s+h,r.length);return{num:e,query:this.queryInfo.createObjectIdsQuery(r.slice(s,i))}}));try{await i({chunkPrefix:"cache."+s(),fetch:this._fetch},this.store,n,this._options)}catch(f){}}))}prepareCacheUpdate(t,e){if(e)for(const r of e)this._nextBatch.delete(r);for(const r of t)this._nextBatch.add(r)}applyCacheUpdate(){return 0===this._nextBatch.size||this._options.signal?.aborted?null:this._fetchFeatures().catch((()=>{}))}}export{h as FeatureCache};