UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.26 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Error.js";import{property as e}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../../geometry/Extent.js";import{estimateStatisticsHistograms as o}from"../../../../layers/support/rasterFunctions/stretchUtils.js";import i from"./RasterLayerAdapter.js";let n=class extends i{async generateRasterInfo(t){const{layer:r}=this,e=t?.rasterFunction;if("imagery-tile"===r.type&&e)try{return await r.generateRasterInfo(e,{signal:t?.signal})}catch{return r.serviceRasterInfo}return this.rasterInfo}async estimateStatisticsHistograms(t){const{layer:e}=this,a=e.multidimensionalDefinition?.[0]?.variableName??"",s=`${e.rasterFunction?.functionName??"default"}${a}`,i=this._statsCache.get(s);if(i)return i;const{raster:n}=e,{extent:l,width:h,height:c}=m(n.rasterInfo),{pixelBlock:p}=await e.fetchPixels(l,h,c,t);if(null==p)throw new r("raster-layer-adapter","Unable to estimate histograms");const f=o(p);return f&&this._statsCache.put(s,f),f}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,r=1e3){const{pyramidScalingFactor:e,maximumPyramidLevel:a}=t.storageInfo;let{extent:o,width:i,height:n,pixelSize:m}=t,l=Math.max(0,Math.ceil(Math.log(Math.max(i,n)/r)/Math.log(e))-1),h=0,c=0;if(l<=a){const t=e**l;i=Math.floor(i/t),n=Math.floor(n/t)}else l=0,i=Math.min(i,r),n=Math.min(n,r),h=Math.max(Math.floor(i/2-500),0),c=Math.max(Math.floor(n/2-500),0),o=new s({xmin:o.xmin+h*m.x,xmax:Math.min(o.xmax,o.xmin+h*m.x*r),ymin:o.ymin+c*m.y,ymax:Math.min(o.ymax,o.ymin+c*m.y*r)});return{extent:o,width:i,height:n,origin:{x:h,y:c}}}t([e()],n.prototype,"layer",void 0),n=t([a("esri.smartMapping.raster.support.adapters.ImageryTileLayerAdapter")],n);const l=n;export{l as default};