// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/layers/vectorTiles/views/2d/tiling/LODInfo",["require","exports","./TileKey","../../../geometry/support/spatialReferenceUtils"],function(r,t,f,p){function l(b,a,d){b[0]=a;b[1]=d;return b}return function(){function b(a,d,c,b,e,g,h,k,q,n,f,l){this.level=a;this.resolution=d;this.scale=c;this.origin=b;this.first=e;this.last=g;this.size=h;this.norm=k;this.worldStart=q;this.worldEnd=n;this.worldSize=f;this.wrap=l}b.create=function(a,d,c){var m=p.getInfo(a.spatialReference),e=[a.origin.x,a.origin.y],
g=[a.size[0]*d.resolution,a.size[1]*d.resolution],h=[-Infinity,-Infinity],k=[Infinity,Infinity],f=[Infinity,Infinity];c&&(l(h,Math.max(0,Math.floor((c.xmin-e[0])/g[0])),Math.max(0,Math.floor((e[1]-c.ymax)/g[1]))),l(k,Math.max(0,Math.floor((c.xmax-e[0])/g[0])),Math.max(0,Math.floor((e[1]-c.ymin)/g[1]))),l(f,k[0]-h[0]+1,k[1]-h[1]+1));var n;a.isWrappable?(a=[Math.ceil(Math.round(2*m.origin[1]/d.resolution)/a.size[0]),f[1]],m=[Math.floor((m.origin[0]-e[0])/g[0]),h[1]],c=[a[0]+m[0]-1,k[1]],n=!0):(m=h,
c=k,a=f,n=!1);return new b(d.level,d.resolution,d.scale,e,h,k,f,g,m,c,a,n)};b.prototype.normalizeCol=function(a){if(!this.wrap)return a;var b=this.worldSize[0];return 0>a?b-1-Math.abs((a+1)%b):a%b};b.prototype.denormalizeCol=function(a,b){return this.wrap?this.worldSize[0]*b+a:a};b.prototype.getWorldForColumn=function(a){return this.wrap?Math.floor(a/this.worldSize[0]):0};b.prototype.getFirstColumnForWorld=function(a){return a*this.worldSize[0]+this.first[0]};b.prototype.getLastColumnForWorld=function(a){return a*
this.worldSize[0]+this.first[0]+this.size[0]-1};b.prototype.getColumnForX=function(a){return(a-this.origin[0])/this.norm[0]};b.prototype.getXForColumn=function(a){return this.origin[0]+a*this.norm[0]};b.prototype.getRowForY=function(a){return(this.origin[1]-a)/this.norm[1]};b.prototype.getYForRow=function(a){return this.origin[1]-a*this.norm[1]};b.prototype.getTileBounds=function(a,b){var c=f.pool.acquire(b),d=this.denormalizeCol(c.col,c.world),e=c.row,g=this.getXForColumn(d),h=this.getYForRow(e+
1),d=this.getXForColumn(d+1),e=this.getYForRow(e);a[0]=g;a[1]=h;a[2]=d;a[3]=e;f.pool.release(c);return a};b.prototype.getTileCoords=function(a,b){var c=f.pool.acquire(b);l(a,this.getXForColumn(this.denormalizeCol(c.col,c.world)),this.getYForRow(c.row));f.pool.release(c);return a};return b}()});