@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.65 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{numberMaxFloat32 as e}from"../../../core/mathUtils.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 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 i,lookupPixels as r,lookupBandValues as l,remap as p,createRangeMaps as m}from"./pixelUtils.js";import c from"./RemapFunctionArguments.js";let g=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:e}=t;t.bandCount=1;const{statistics:s}=t;this._removeStatsHistColormapVAT(t);const{allowUnmatched:n,replacementValue:a,outputValues:r,inputRanges:l,noDataRanges:p,isLastInputRangeInclusive:m}=this.functionArguments,c="unknown"===this.outputPixelType||null==this.outputPixelType;if(this.outputPixelType=this._getOutputPixelType(e),r?.length){const u=s?.[0];if(n&&null==a){let e=u?.min??r[0],s=u?.max??r[0];e=Math.min.apply(null,[...r,e]),s=Math.max.apply(null,[...r,s]),t.statistics=[{min:e,max:s,avg:u?.avg??0,stddev:u?.stddev??-1}]}else{let e=r[0],s=e;for(let t=0;t<r.length;t++)e=e>r[t]?r[t]:e,s=s>r[t]?s:r[t];n&&null!=a&&(e=Math.min(e,a),s=Math.max(s,a)),t.statistics=[{min:e,max:s,avg:u?.avg??0,stddev:u?.stddev??-1}]}if(c){const{min:s,max:u}=t.statistics[0],i=["u8","s8","u16","s16","u32","s32","f32"],l=i.find((t=>{const[e,n]=o(t);return s>=e&&u<=n}))??"f64";r.some((t=>Math.floor(t)!==t))?this.outputPixelType="f64"===l?"f64":"f32":this.outputPixelType=n&&null==a&&i.indexOf(e)>i.indexOf(l)?e:l}}t.pixelType=this.outputPixelType,this.rasterInfo=t,this.lookup=n?null:u({srcPixelType:e,inputRanges:l,outputValues:r,noDataRanges:p,allowUnmatched:n,isLastInputRangeInclusive:m,outputPixelType:this.outputPixelType});return{success:!0,supportsGPU:(!r||r.length<=i)&&(!p||p.length<=i)}}_processPixels(t){const e=t.pixelBlocks?.[0];if(null==e)return null;const{lookup:s,outputPixelType:n}=this;if(s){const t=r(e,{lut:[s.lut],offset:s.offset,outputPixelType:n});return null!=t&&s.mask&&(t.mask=l(e.pixels[0],e.mask,s.mask,s.offset,"u8")),t}const{inputRanges:o,outputValues:a,noDataRanges:u,allowUnmatched:i,isLastInputRangeInclusive:m,replacementValue:c}=this.functionArguments;return p(e,{inputRanges:o,outputValues:a,noDataRanges:u,outputPixelType:n,allowUnmatched:i,isLastInputRangeInclusive:m,replacementValue:c})}_getWebGLParameters(){const{allowUnmatched:t,noDataRanges:s,isLastInputRangeInclusive:n}=this.functionArguments,a=this.functionArguments.inputRanges??[],u=this.functionArguments.outputValues??[],r=m(a,u,n),l=new Float32Array(2*i);l.fill(e),s?.length&&l.set(s);return{allowUnmatched:t,rangeMaps:r,noDataRanges:l,clampRange:o(this.outputPixelType),replacementValue:this.functionArguments.replacementValue}}};t([s({json:{write:!0,name:"rasterFunction"}})],g.prototype,"functionName",void 0),t([s({type:c,json:{write:!0,name:"rasterFunctionArguments"}})],g.prototype,"functionArguments",void 0),t([s()],g.prototype,"rasterArgumentNames",void 0),t([s({json:{write:!0}})],g.prototype,"lookup",void 0),g=t([n("esri.layers.support.rasterFunctions.RemapFunction")],g);const f=g;export{f as default};