@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.22 kB
JavaScript
/*
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{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntegerPixelType as o}from"../rasterFormats/pixelRangeUtils.js";import r from"./BaseRasterFunction.js";import{lookupPixels as u}from"./pixelUtils.js";import i from"./StretchFunctionArguments.js";import{getStretchCutoff as n,createStretchLUT as p,stretch as a,computeGammaCorrection as m}from"./stretchUtils.js";let c=class extends r{constructor(){super(...arguments),this.functionName="Stretch",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null,this.cutOffs=null}_bindSourceRasters(){this.lookup=null,this.cutOffs=null;const t=this.sourceRasterInfos[0],{pixelType:s}=t,{functionArguments:e}=this,{dynamicRangeAdjustment:r,gamma:u,useGamma:i}=e;if(!r&&["u8","u16","s8","s16"].includes(s)){const r=n(e.toJSON(),{rasterInfo:t}),a=o(this.outputPixelType)?"round":"float";this.lookup=p({pixelType:s,...r,gamma:i?u:null,rounding:a}),this.cutOffs=r}else r||(this.cutOffs=n(e.toJSON(),{rasterInfo:t}));this.outputPixelType=this._getOutputPixelType(s);const a=t.clone();a.pixelType=this.outputPixelType,this._removeStatsHistColormapVAT(a),"u8"===this.outputPixelType&&(a.keyProperties.DataType="processed");const{outputMin:m=0,outputMax:c=255}=this.functionArguments;a.statistics=[];for(let o=0;o<a.bandCount;o++)a.statistics[o]={min:m,max:c};this.rasterInfo=a;return{success:!0,supportsGPU:!r}}_processPixels(t){const s=t.pixelBlocks?.[0];if(null==s)return s;const{lookup:e}=this;if(e)return u(s,{...e,outputPixelType:this.rasterInfo.pixelType});const{functionArguments:o}=this,r=this.cutOffs||n(o.toJSON(),{rasterInfo:this.sourceRasterInfos[0],pixelBlock:s}),i=o.useGamma?o.gamma:null;return a(s,{...r,gamma:i,outputPixelType:this.outputPixelType})}_getWebGLParameters(){const{outputMin:t=0,outputMax:s=255,gamma:e,useGamma:r}=this.functionArguments,u=this.rasterInfo.bandCount>=2?3:1,i=r&&e?.length?m(u,e):[1,1,1],{minCutOff:n,maxCutOff:p}=this.cutOffs??{minCutOff:[0,0,0],maxCutOff:[255,255,255]};1===n.length&&(n[1]=n[2]=n[0],p[1]=p[2]=p[0]);const a=p.map(((e,o)=>(s-t)/(p[o]-n[o]))),c=o(this.outputPixelType),f=r&&e?[e[0],e[1]??e[0],e[2]??e[0]]:[1,1,1],l=r?[i[0],i[1]??i[0],i[2]??i[0]]:[1,1,1];return{bandCount:u,minOutput:t,maxOutput:s,minCutOff:n,maxCutOff:p,factor:a,useGamma:r,gamma:f,gammaCorrection:l,stretchType:this.functionArguments.stretchType,isOutputRounded:c,type:"stretch"}}};t([s({json:{write:!0,name:"rasterFunction"}})],c.prototype,"functionName",void 0),t([s({type:i,json:{write:!0,name:"rasterFunctionArguments"}})],c.prototype,"functionArguments",void 0),t([s()],c.prototype,"rasterArgumentNames",void 0),t([s({json:{write:!0}})],c.prototype,"lookup",void 0),t([s({json:{write:!0}})],c.prototype,"cutOffs",void 0),c=t([e("esri.layers.support.rasterFunctions.StretchFunction")],c);const f=c;export{f as default};