UNPKG

@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
/* 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 s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{calculateNDVI as n,getBandMatrix3 as r}from"./bandIndexUtils.js";import i from"./BaseRasterFunction.js";import o from"./NDVIFunctionArguments.js";let u=class extends i{constructor(){super(...arguments),this.functionName="NDVI",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{scientificOutput:t,visibleBandID:s,infraredBandID:e}=this.functionArguments;this.outputPixelType=this._getOutputPixelType(t?"f32":"u8");const n=this.sourceRasterInfos[0],r=Math.max(s,e);if(n.bandCount<2||r>=n.bandCount)return{success:!1,supportsGPU:!1,error:"ndvi-function: source raster has insufficient amount of raster bands"};if(s<0||e<0)return{success:!1,supportsGPU:!1,error:"ndvi-function: invalid visible or infrared band id"};const i=n.clone();i.pixelType=this.outputPixelType,this._removeStatsHistColormapVAT(i),i.bandCount=1,i.keyProperties={...i.keyProperties,BandProperties:void 0};const[o,u,a,c]=t?[-1,1,0,.1]:[0,200,100,10];return i.statistics=[{min:o,max:u,avg:a,stddev:c}],this.rasterInfo=i,{success:!0,supportsGPU:!0}}_processPixels(t){const s=t.pixelBlocks?.[0];if(null==s)return null;const{visibleBandID:e,infraredBandID:r,scientificOutput:i}=this.functionArguments;return n(s,e,r,!i)}_getWebGLParameters(){const{visibleBandID:t,infraredBandID:s,scientificOutput:e}=this.functionArguments,n=this.isInputBandIdsSwizzled?[0,1,2]:[s,t,0];return{bandIndexMat3:r(n),scaled:!e}}_getInputBandIds(t){const{visibleBandID:s,infraredBandID:e}=this.functionArguments;return[e,s,0].map((s=>t[s]))}_swizzleBandIds(t){const{visibleBandID:s,infraredBandID:e}=this.functionArguments,n=[s,e].map((s=>t.indexOf(s)));return n[2]=n[1],this.isInputBandIdsSwizzled=!0,this.swizzledBandSelection=n,!1}};t([s({json:{write:!0,name:"rasterFunction"}})],u.prototype,"functionName",void 0),t([s({type:o,json:{write:!0,name:"rasterFunctionArguments"}})],u.prototype,"functionArguments",void 0),t([s()],u.prototype,"rasterArgumentNames",void 0),u=t([e("esri.layers.support.rasterFunctions.NDVIFunction")],u);const a=u;export{a as default};