UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.6 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{baseArrayMemory as e,baseObjectMemory as t,estimateNumberMemory as s}from"../../../../../core/memoryEstimations.js";class n{constructor(n,a,r){this.descriptor=n,this._pages=a,this._pageSize=r;const i=e+a.reduce(((e,{usedMemory:t})=>e+t),0),d=3*s;this.usedMemory=t+i+d,this.featureCount=a.reduce(((e,t)=>e+t.featureCount),0)}get id(){return this.descriptor.id}getObjectId(e){const{pageIndex:t,featurePageIndex:s}=this._translateIndex(e);return this._pages[t].getObjectId(s)}getAttribute(e,t){const{pageIndex:s,featurePageIndex:n}=this._translateIndex(e);return this._pages[s].getAttribute(n,t)}getAttributeAsTimestamp(e,t){const{pageIndex:s,featurePageIndex:n}=this._translateIndex(e);return this._pages[s].getAttributeAsTimestamp(n,t)}getAttributes(e){const{pageIndex:t,featurePageIndex:s}=this._translateIndex(e);return this._pages[t].getAttributes(s)}getCoordinates(e,t,s){const{pageIndex:n,featurePageIndex:a}=this._translateIndex(e);this._pages[n].getCoordinates(a,t,s)}getOptimizedGeometry(e){const{pageIndex:t,featurePageIndex:s}=this._translateIndex(e);return this._pages[t].getOptimizedGeometry(s)}getCentroid(e,t){const{pageIndex:s,featurePageIndex:n}=this._translateIndex(e);return this._pages[s].getCentroid(n,t)}getBounds(e){const{pageIndex:t,featurePageIndex:s}=this._translateIndex(e);return this._pages[t].getBounds(s)}getBoundingBox(e){const{pageIndex:t,featurePageIndex:s}=this._translateIndex(e);return this._pages[t].getBoundingBox(s)}getObjectIdsArray(e,t=this._allFeatureIndices(),s=0){let n=s;for(const{page:a,indices:r}of this._batchPageIndices(t))n=a.getObjectIdsArray(e,r,n);return n}getCoordinatesArray(e,t=this._allFeatureIndices(),s=0){let n=s;for(const{page:a,indices:r}of this._batchPageIndices(t))n=a.getCoordinatesArray(e,r,n);return n}*objectIds(e=this._allFeatureIndices()){for(const{page:t,indices:s}of this._batchPageIndices(e))for(const e of t.objectIds(s))yield e}*_allFeatureIndices(){const{featureCount:e}=this;for(let t=0;t<e;++t)yield t}_translateIndex(e){const{_pageSize:t}=this;return{pageIndex:Math.floor(e/t),featurePageIndex:e%t}}*_batchPageIndices(e){const t=new Array;{let s=0,n=new Array;for(const a of e){const{pageIndex:e,featurePageIndex:r}=this._translateIndex(a);s!==e&&(0!==n.length&&t.push({pageIndex:s,indices:n}),s=e,n=[]),n.push(r)}0!==n.length&&t.push({pageIndex:s,indices:n})}const{_pages:s}=this;for(const{pageIndex:n,indices:a}of t)yield{page:s[n],indices:a}}}export{n as Tile};