@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.33 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";import{property as s,subclass as n}from"../../../core/accessorSupport/decorators.js";import{calculateNDVI as e,getBandMatrix3 as i}from"./bandIndexUtils.js";import r from"./BaseRasterFunction.js";import o from"./NDVIFunctionArguments.js";let a=class extends r{constructor(){super(...arguments),this.functionName="NDVI",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{scientificOutput:t,visibleBandID:s,infraredBandID:n}=this.functionArguments;this.outputPixelType=this._getOutputPixelType(t?"f32":"u8");const e=this.sourceRasterInfos[0],i=Math.max(s,n);if(e.bandCount<2||i>=e.bandCount)return{success:!1,supportsGPU:!1,error:"ndvi-function: source raster has insufficient amount of raster bands"};if(s<0||n<0)return{success:!1,supportsGPU:!1,error:"ndvi-function: invalid visible or infrared band id"};const r=e.clone();r.pixelType=this.outputPixelType,this._removeStatsHistColormapVAT(r),r.bandCount=1,r.keyProperties={...r.keyProperties,BandProperties:void 0};const[o,a,u,d]=t?[-1,1,0,.1]:[0,200,100,10];return r.statistics=[{min:o,max:a,avg:u,stddev:d}],this.rasterInfo=r,{success:!0,supportsGPU:!0}}_processPixels(t){const s=t.pixelBlocks?.[0];if(null==s)return null;let{visibleBandID:n,infraredBandID:i,scientificOutput:r}=this.functionArguments;if(this.rasterInfo.storageInfo.isBsqTile){const{rawInputBandIds:t}=this;i=t.indexOf(i),n=t.indexOf(n)}return e(s,n,i,!r)}_getWebGLParameters(){const{visibleBandID:t,infraredBandID:s,scientificOutput:n}=this.functionArguments,e=this.isInputBandIdsSwizzled?[0,1,2]:[s,t,0];return{bandIndexMat3:i(e),scaled:!n}}_getInputBandIds(t){const{visibleBandID:s,infraredBandID:n}=this.functionArguments;return[n,s,0].map(s=>t[s])}_swizzleBandIds(t){const{visibleBandID:s,infraredBandID:n}=this.functionArguments,e=[s,n].map(s=>t.indexOf(s));return e[2]=e[1],this.isInputBandIdsSwizzled=!0,this.swizzledBandSelection=e,!1}};t([s({json:{write:!0,name:"rasterFunction"}})],a.prototype,"functionName",void 0),t([s({type:o,json:{write:!0,name:"rasterFunctionArguments"}})],a.prototype,"functionArguments",void 0),t([s()],a.prototype,"rasterArgumentNames",void 0),a=t([n("esri.layers.raster.functions.NDVIFunction")],a);const u=a;export{u as default};