@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.51 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 o}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./BaseRasterFunction.js";import n from"./MaskFunctionArguments.js";import{createMaskLUT as u,maxMapSizeGpu as a,NoDataInterpretation as i,mask as l}from"./pixelUtils.js";let c=class extends r{constructor(){super(...arguments),this.functionName="Mask",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const t=this.sourceRasterInfos[0].clone(),{pixelType:e}=t;this.outputPixelType=this._getOutputPixelType(e),t.pixelType=this.outputPixelType,this.rasterInfo=t;const{includedRanges:s,normalizedNoDataValues:o}=this.functionArguments;if(!s?.length&&!o?.length)return{success:!1,supportsGPU:!1,error:"missing includedRanges or noDataValues argument"};let r=[];for(let a=0;a<t.bandCount;a++){const t=u(e,s?.slice(2*a,2*a+2),o?.[a]);if(null==t){r=null;break}r.push(t)}this.lookups=r;const n=null!=o&&o.every((t=>t?.length===o[0]?.length));return{success:!0,supportsGPU:(!s||s.length<=2*a)&&(!o||n&&o[0].length<=a)}}_processPixels(t){const e=t.pixelBlocks?.[0];if(null==e)return null;const{outputPixelType:s,lookups:o}=this,{includedRanges:r,noDataInterpretation:n,normalizedNoDataValues:u}=this.functionArguments,a=n===i.matchAll;return l(e,{includedRanges:r,noDataValues:u,outputPixelType:s,matchAll:a,lookups:o})}_getWebGLParameters(){const{includedRanges:t,normalizedNoDataValues:s}=this.functionArguments,o=new Float32Array(a);o.fill(e),s?.[0]?.length&&o.set(s[0]);const r=new Float32Array(6);for(let n=0;n<r.length;n+=2)r[n]=t?.[n]??-e,r[n+1]=t?.[n+1]??e;return t?.length&&r.set(t),{bandCount:this.sourceRasterInfos[0].bandCount,noDataValues:o,includedRanges:r}}};t([s({json:{write:!0,name:"rasterFunction"}})],c.prototype,"functionName",void 0),t([s({type:n,json:{write:!0,name:"rasterFunctionArguments"}})],c.prototype,"functionArguments",void 0),t([s()],c.prototype,"rasterArgumentNames",void 0),t([s({json:{write:!0}})],c.prototype,"lookups",void 0),c=t([o("esri.layers.support.rasterFunctions.MaskFunction")],c);const p=c;export{p as default};