@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.71 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 e}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{convolutionKernel as s}from"../rasterFunctionConstants.js";import{getPixelValueRange as r}from"../rasterFormats/pixelRangeUtils.js";import n from"./BaseRasterFunction.js";import i from"./ConvolutionFunctionArguments.js";import{convolute as u}from"./convolutionUtils.js";const l=25;let c=class extends n{constructor(){super(...arguments),this.functionName="Convolution",this.rasterArgumentNames=["raster"]}get _normalizedKernel(){const{kernel:t,convolutionType:e}=this.functionArguments,o=t.reduce(((t,e)=>t+e));return-1===e||0===o||1===o?t:t.map((t=>t/o))}_bindSourceRasters(){const{convolutionType:t,rows:e,cols:o,kernel:r}=this.functionArguments;if(!Object.values(s).includes(t))return{success:!1,supportsGPU:!1,error:`convolution-function: the specified kernel type is not supported ${t}`};if(t!==s.none&&e*o!==r.length)return{success:!1,supportsGPU:!1,error:"convolution-function: the specified rows and cols do not match the length of the kernel"};const n=this.sourceRasterInfos[0];this.outputPixelType=this._getOutputPixelType(n.pixelType);const i=n.clone();i.pixelType=this.outputPixelType;const u=[s.none,s.sharpen,s.sharpen2,s.sharpening3x3,s.sharpening5x5];(-1===t||"u8"!==this.outputPixelType&&!u.includes(t))&&(i.statistics=null,i.histograms=null),i.colormap=null,i.attributeTable=null,this.rasterInfo=i;return{success:!0,supportsGPU:r.length<=l}}_processPixels(t){const e=t.pixelBlocks?.[0];if(null==e||this.functionArguments.convolutionType===s.none)return e;const{rows:o,cols:r}=this.functionArguments,{_normalizedKernel:n}=this;return u(e,{kernel:n,rows:o,cols:r,outputPixelType:this.outputPixelType})}_getWebGLParameters(){const t=new Float32Array(l),{rows:e,cols:o}=this.functionArguments,{_normalizedKernel:s}=this;for(let r=0;r<e;r++)for(let e=0;e<o;e++)t[5*r+e]=s[r*o+e];return{kernelRows:e,kernelCols:o,kernel:t,clampRange:r(this.outputPixelType)}}};t([e({json:{write:!0,name:"rasterFunction"}})],c.prototype,"functionName",void 0),t([e({type:i,json:{write:!0,name:"rasterFunctionArguments"}})],c.prototype,"functionArguments",void 0),t([e()],c.prototype,"rasterArgumentNames",void 0),t([e()],c.prototype,"_normalizedKernel",null),c=t([o("esri.layers.support.rasterFunctions.ConvolutionFunction")],c);const p=c;export{p as default};