/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import e from"../../../layers/support/TileInfo.js";import l from"./TileInfoView.js";import s from"./TileKey.js";class t extends l{constructor(){super(...arguments),this._fullCacheLodInfos=null,this._levelByScale={}}getTileParentId(e){const l=s.pool.acquire(e),t=0===l.level?null:s.getId(l.level-1,l.row>>1,l.col>>1,l.world);return s.pool.release(l),t}getTileCoverage(e,l,s=!0,t){const o=super.getTileCoverage(e,l,s,t);if(!o)return o;const r=1<<o.lodInfo.level;return o.spans=o.spans.filter(e=>e.row>=0&&e.row<r),o}scaleToLevel(e){if(this._fullCacheLodInfos||this._initializeFullCacheLODs(this._lodInfos),this._levelByScale[e])return this._levelByScale[e];{const l=this._fullCacheLodInfos;if(e>l[0].scale)return l[0].level;let s,t;for(let o=0;o<l.length-1;o++)if(t=l[o+1],e>t.scale)return s=l[o],s.level+(s.scale-e)/(s.scale-t.scale);return l[l.length-1].level}}_initializeFullCacheLODs(l){let s;if(0===l[0].level)s=l.map(e=>({level:e.level,resolution:e.resolution,scale:e.scale}));else{const l=this.size[0],t=this.spatialReference;s=e.create({size:l,spatialReference:t}).lods.map(e=>({level:e.level,resolution:e.resolution,scale:e.scale}))}for(let e=0;e<s.length;e++)this._levelByScale[s[e].scale]=s[e].level;this._fullCacheLodInfos=s}}export{t as default};
