// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../../../geometry ../../../core/Error ../../../core/has ../../../core/mathUtils ../../../core/unitUtils ../../../geometry/Extent ../../../geometry/SpatialReference ../../../geometry/support/aaBoundingRect ../../../geometry/support/spatialReferenceUtils ../../../geometry/support/webMercatorUtils ../../../layers/support/LOD ../../../layers/support/TileInfo ../../../geometry/Point".split(" "),function(v,D,m,E,l,z,A,x,B,C,p,q,r,t){function y(){return new m("tilingscheme:tile-info-missing", "Tiling scheme must have tiling information")}class f{constructor(a){var b=f.checkUnsupported(a);if(null!=b)throw b;this.spatialReference=a.spatialReference;this._isWebMercator=this.spatialReference.isWebMercator;this._isGCS=C.isGeographic(this.spatialReference);this.origin=[a.origin.x,a.origin.y];this.pixelSize=a.size[0];this.dpi=a.dpi;var c=a.lods.reduce((g,h)=>{h.levelnew q({level:b,scale:a.scale,resolution:a.resolution}))})}getExtent(a, b,c,d){var e=this.levels[a];a=e.tileSize[0];e=e.tileSize[1];d[0]=this.origin[0]+c*a;d[2]=this.origin[0]+(c+1)*a;d[3]=this.origin[1]-b*e;d[1]=this.origin[1]-(b+1)*e}convertExtentToRadians(a,b){this._isWebMercator?(b[0]=p.x2lon(a[0]),b[1]=p.y2lat(a[1]),b[2]=p.x2lon(a[2]),b[3]=p.y2lat(a[3])):this._isGCS&&(b[0]=l.deg2rad(a[0]),b[1]=l.deg2rad(a[1]),b[2]=l.deg2rad(a[2]),b[3]=l.deg2rad(a[3]))}getExtentGeometry(a,b,c,d=new A){this.getExtent(a,b,c,k);d.spatialReference=this.spatialReference;d.xmin=k[0];d.ymin= k[1];d.xmax=k[2];d.ymax=k[3];d.zmin=void 0;d.zmax=void 0;return d}ensureMaxLod(a){if(null==a)return!1;for(var b=!1;this.levels.length<=a;){const {resolution:c,scale:d}=this.levels[this.levels.length-1];b=c/2*this.pixelSize;this.levels.push({resolution:c/2,scale:d/2,tileSize:[b,b]});b=!0}return b}capMaxLod(a){this.levels.length>a+1&&(this.levels.length=a+1)}getMaxLod(){return this.levels.length-1}scaleAtLevel(a){return this.levels[0].scale/2**a}levelAtScale(a){const b=this.levels[0].scale;return a>= b?0:Math.log(b/a)*Math.LOG2E}resolutionAtLevel(a){return this.levels[0].resolution/2**a}compatibleWith(a,b=Infinity){if(f.checkUnsupported(a))return!1;a=new f(a);if(!a.spatialReference.equals(this.spatialReference)||a.pixelSize!==this.pixelSize)return!1;b=Math.min(this.levels.length-1,a.levels.length-1,b);const c=this.levels[b].resolution;let d=.5*c;if(!l.floatEqualAbsolute(a.origin[0],this.origin[0],d)||!l.floatEqualAbsolute(a.origin[1],this.origin[1],d))return!1;d=.5*c/2**b/this.pixelSize*12;return l.floatEqualAbsolute(c, a.levels[b].resolution,d)}rootTilesInExtent(a,b=null,c=Infinity){const d=[],e=this.levels[0].tileSize;if(null==a||0===e[0]||0===e[1])return d;f.computeRowColExtent(a,e,this.origin,k);a=k[1];let g=k[3],h=k[0],u=k[2];var n=u-h;const w=g-a;n*w>c&&(c=Math.floor(Math.sqrt(c)),w>c&&(a=a+Math.floor(.5*w)-Math.floor(.5*c),g=a+c),n>c&&(h=h+Math.floor(.5*n)-Math.floor(.5*c),u=h+c));for(c=a;c!l.floatEqualRelative(c.resolution,b/2**c.level))}static hasGapInLevels(a){a=a.lods.map(b=>b.level);a.sort((b, c)=>b-c);for(let b=1;b=b}static hasOriginPerLODs(a){const b=a.origin;return a.lods.some(c=>null!=c.origin&&(c.origin[0]!==b.x||c.origin[1]!==b.y))}static getMissingTileInfoError(){return new m("tilingscheme:tile-info-missing","Tiling scheme must have tiling information")}static checkUnsupported(a){return null==a?y():1>a.lods.length?new m("tilingscheme:generic", "Tiling scheme must have at least one level"):f.isPowerOfTwo(a)?f.hasGapInLevels(a)?new m("tilingscheme:gaps","Tiling scheme levels must not have gaps between min and max level"):f.tileSizeSupported(a)?f.hasOriginPerLODs(a)?new m("tilingscheme:multiple-origin","Tiling scheme levels must not have their own origin"):null:new m("tilingscheme:tile-size","Tiles must be square and size must be one of [128, 256, 512]"):new m("tilingscheme:power-of-two","Tiling scheme must be power of two")}static fromExtent(a, b){const c=a[2]-a[0],d=a[3]-a[1];var e=z.getMetersPerUnitForSR(b);const g=1.2*Math.max(c,d),h=g/256;e=96/.0254*e*h;a=new f(new r({size:[256,256],origin:new t({x:a[0]-.5*(g-c),y:a[3]+.5*(g-d)}),lods:[new q({level:0,resolution:h,scale:e})],spatialReference:b}));a.ensureMaxLod(20);return a}static makeWebMercatorAuxiliarySphere(a){const b=new f(f.WebMercatorAuxiliarySphereTileInfo);b.ensureMaxLod(a);return b}static makeGCSWithTileSize(a,b=256,c=16){const d=256/b;a=new f(new r({size:[b,b],origin:new t({x:-180, y:90,spatialReference:a}),spatialReference:a,lods:[new q({level:0,resolution:.703125*d,scale:2.95497598570834E8*d})]}));a.ensureMaxLod(c);return a}get test(){}}f.WebMercatorAuxiliarySphereTileInfo=new r({size:[256,256],origin:new t({x:-2.0037508342787E7,y:2.0037508342787E7,spatialReference:x.WebMercator}),spatialReference:x.WebMercator,lods:[new q({level:0,resolution:156543.03392800014,scale:5.91657527591555E8})]});f.WebMercatorAuxiliarySphere=f.makeWebMercatorAuxiliarySphere(19);const k=B.create(); v.TilingScheme=f;v.getMissingTileInfoError=y;Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});