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