@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.67 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntegerPixelType as r}from"../rasterFormats/pixelRangeUtils.js";import i from"./BandArithmeticFunctionArguments.js";import{calculateBandIndex as n,getBandMatrix3 as a}from"./bandIndexUtils.js";import o from"./BaseRasterFunction.js";const c=new Set(["vari","mtvi2","rtvi-core","evi"]);let u=class extends o{constructor(){super(...arguments),this.functionName="BandArithmetic",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){this.outputPixelType=this._getOutputPixelType("f32");const e=this.sourceRasterInfos[0];if(e.bandCount<2)return{success:!1,supportsGPU:!1,error:"band-arithmetic-function: source raster has insufficient amount of raster bands"};const t=e.clone();t.pixelType=this.outputPixelType,t.bandCount="sultan"===this.functionArguments.method?3:1,this._removeStatsHistColormapVAT(t),t.keyProperties={...t.keyProperties,BandProperties:void 0},this.rasterInfo=t;return{success:!0,supportsGPU:!["custom","gvitm","sultan"].includes(this.functionArguments.method)}}_processPixels(e){const t=e.pixelBlocks?.[0];if(null==t)return t;const{method:s,bandIndexes:r}=this.functionArguments,i=r.split(" ").map((e=>parseFloat(e)));return n(t,{method:s,bandIndexes:i,equation:r,outputPixelType:this.outputPixelType})}_getWebGLParameters(){const e=this.functionArguments.bandIndexes.split(" ").map((e=>parseFloat(e)-1));2===e.length&&e.push(0);const t=this.isInputBandIdsSwizzled?[0,1,2]:e;let s,i;const n=new Float32Array(3),{method:o}=this.functionArguments;switch(o){case"gndvi":case"nbr":case"ndbi":case"ndvi":case"ndvi-re":case"ndsi":case"ndmi":case"mndwi":s=a([t[0],t[1],0]),i="ndxi";break;case"ndwi":s=a([t[1],t[0],0]),i="ndxi";break;case"sr":case"sr-re":case"iron-oxide":case"ferrous-minerals":case"clay-minerals":s=a([t[0],t[1],0]),i="sr";break;case"ci-g":case"ci-re":s=a([t[0],t[1],0]),i="ci";break;case"savi":s=a([t[0],t[1],0]),i="savi",n[0]=e[2]+1;break;case"tsavi":s=a([t[0],t[1],0]),i="tsavi",n[0]=e[2]+1,n[1]=e[3]+1,n[2]=e[4]+1;break;case"msavi":s=a([t[0],t[1],0]),i="msavi";break;case"gemi":s=a([t[0],t[1],0]),i="gemi";break;case"pvi":s=a([t[0],t[1],0]),i="tsavi",n[0]=e[2]+1,n[1]=e[3]+1;break;case"vari":s=a([t[0],t[1],t[2]]),i="vari";break;case"mtvi2":s=a([t[0],t[1],t[2]]),i="mtvi";break;case"rtvi-core":s=a([t[0],t[1],t[2]]),i="rtvicore";break;case"evi":s=a([t[0],t[1],t[2]]),i="evi";break;case"wndwi":s=a([t[0],t[1],0]),i="wndwi",n[0]=e[3]?e[3]+1:.5;break;case"bai":s=a([t[1],t[0],0]),i="bai";break;default:s=a([0,1,2]),i="custom"}return{bandIndexMat3:s,indexType:i,adjustments:n,isOutputRounded:r(this.outputPixelType)}}_getInputBandIds(e){if("custom"===this.functionArguments.method)return e;const t=this.functionArguments.bandIndexes.split(" ").map((e=>parseFloat(e)-1)),s=e.length,r=t.map((e=>e>=s?s-1:e)),i=c.has(this.functionArguments.method)?3:2,n=r.slice(0,i).map((t=>e[t]));return 2===n.length&&n.push(0),n}};e([t({json:{write:!0,name:"rasterFunction"}})],u.prototype,"functionName",void 0),e([t({type:i,json:{write:!0,name:"rasterFunctionArguments"}})],u.prototype,"functionArguments",void 0),e([t()],u.prototype,"rasterArgumentNames",void 0),u=e([s("esri.layers.support.rasterFunctions.BandArithmeticFunction")],u);const m=u;export{m as default};