UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 1.96 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as t}from"tslib";import e from"../../../../core/Error.js";import{property as r,subclass as a}from"../../../../core/accessorSupport/decorators.js";import i from"../../../../geometry/Extent.js";import{estimateStatisticsHistograms as s}from"../../../../layers/raster/functions/stretchUtils.js";import o from"./RasterLayerAdapter.js";let n=class extends o{async generateRasterInfo(t){const{layer:e}=this,r=t?.rasterFunction;if("imagery-tile"===e.type&&r)try{return await e.generateRasterInfo(r,{signal:t?.signal})}catch{return e.serviceRasterInfo}return this.rasterInfo}async estimateStatisticsHistograms(t){const{layer:r}=this,a=r.multidimensionalDefinition?.[0]?.variableName??"",i=`${r.rasterFunction?.functionName??"default"}${a}`,o=this._statsCache.get(i);if(o)return o;const{raster:n}=r,{extent:l,width:h,height:c}=m(n.rasterInfo),{pixelBlock:f}=await r.fetchPixels(l,h,c,t);if(null==f)throw new e("raster-layer-adapter","Unable to estimate histograms");const y=s(f);return y&&this._statsCache.put(i,y),y}supportsMultidirectionalHillshade(){return!0}load(t){return this.addResolvingPromise(this.layer.load(t).then(()=>this.rasterInfo=this.layer.raster.rasterInfo)),Promise.resolve(this)}};function m(t,e=1e3){const{pyramidScalingFactor:r,maximumPyramidLevel:a}=t.storageInfo;let{extent:s,width:o,height:n,pixelSize:m}=t,l=Math.max(0,Math.ceil(Math.log(Math.max(o,n)/e)/Math.log(r))-1),h=0,c=0;if(l<=a){const t=r**l;o=Math.floor(o/t),n=Math.floor(n/t)}else l=0,o=Math.min(o,e),n=Math.min(n,e),h=Math.max(Math.floor(o/2-500),0),c=Math.max(Math.floor(n/2-500),0),s=new i({xmin:s.xmin+h*m.x,xmax:Math.min(s.xmax,s.xmin+h*m.x*e),ymin:s.ymin+c*m.y,ymax:Math.min(s.ymax,s.ymin+c*m.y*e)});return{extent:s,width:o,height:n,origin:{x:h,y:c}}}t([r()],n.prototype,"layer",void 0),n=t([a("esri.smartMapping.raster.support.adapters.ImageryTileLayerAdapter")],n);const l=n;export{l as default};