UNPKG

@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
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as t}from"../../../chunks/tslib.es6.js";import{numberMaxFloat32 as s}from"../../../core/mathUtils.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 n}from"../../../core/accessorSupport/decorators/subclass.js";import{getPixelValueRange as o}from"../rasterFormats/pixelRangeUtils.js";import a from"./BaseRasterFunction.js";import{createRemapLUT as u,maxMapSizeGpu as r,lookupPixels as i,lookupBandValues as l,remap as p}from"./pixelUtils.js";import c from"./RemapFunctionArguments.js";let m=class extends a{constructor(){super(...arguments),this.functionName="Remap",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null}_bindSourceRasters(){const t=this.sourceRasterInfos[0].clone(),{pixelType:s}=t;this.outputPixelType=this._getOutputPixelType(s),t.pixelType=this.outputPixelType,t.bandCount=1;const{statistics:e}=t;this._removeStatsHistColormapVAT(t);const{allowUnmatched:n,outputValues:o,inputRanges:a,noDataRanges:i,isLastInputRangeInclusive:l}=this.functionArguments;if(null!=e&&e.length&&o?.length)if(n){const s=Math.min.apply(null,[...o,e[0].min]),n=Math.max.apply(null,[...o,e[0].max]);t.statistics=[{...e[0],min:s,max:n}]}else{let s=o[0],n=s;for(let t=0;t<o.length;t++)s=s>o[t]?o[t]:s,n=n>o[t]?n:o[t];t.statistics=[{...e[0],min:s,max:n}]}this.rasterInfo=t,this.lookup=n?null:u({srcPixelType:s,inputRanges:a,outputValues:o,noDataRanges:i,allowUnmatched:n,isLastInputRangeInclusive:l,outputPixelType:this.outputPixelType});return{success:!0,supportsGPU:(!o||o.length<=r)&&(!i||i.length<=r)}}_processPixels(t){const s=t.pixelBlocks?.[0];if(null==s)return null;const{lookup:e,outputPixelType:n}=this;if(e){const t=i(s,{lut:[e.lut],offset:e.offset,outputPixelType:n});return null!=t&&e.mask&&(t.mask=l(s.pixels[0],s.mask,e.mask,e.offset,"u8")),t}const{inputRanges:o,outputValues:a,noDataRanges:u,allowUnmatched:r,isLastInputRangeInclusive:c}=this.functionArguments;return p(s,{inputRanges:o,outputValues:a,noDataRanges:u,outputPixelType:n,allowUnmatched:r,isLastInputRangeInclusive:c})}_getWebGLParameters(){const{allowUnmatched:t,noDataRanges:e,isLastInputRangeInclusive:n}=this.functionArguments,a=new Float32Array(3*r),u=1e-5,i=this.functionArguments.inputRanges??[],l=this.functionArguments.outputValues??[],p=l.length;for(let o=0;o<r;o++)a[3*o]=i[2*o]??s-1,a[3*o+1]=i[2*o+1]??s,a[3*o+2]=l[o]??0,o<p&&(o>0&&(a[3*o]-=u),(o<p-1||!n)&&(a[3*o+1]-=u));const c=new Float32Array(2*r);c.fill(s),e?.length&&c.set(e);return{allowUnmatched:t,rangeMaps:a,noDataRanges:c,clampRange:o(this.outputPixelType)}}};t([e({json:{write:!0,name:"rasterFunction"}})],m.prototype,"functionName",void 0),t([e({type:c,json:{write:!0,name:"rasterFunctionArguments"}})],m.prototype,"functionArguments",void 0),t([e()],m.prototype,"rasterArgumentNames",void 0),t([e({json:{write:!0}})],m.prototype,"lookup",void 0),m=t([n("esri.layers.support.rasterFunctions.RemapFunction")],m);const g=m;export{g as default};