UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 3.16 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import{property as t,subclass as s}from"../../../core/accessorSupport/decorators.js";import{isIntegerPixelType as r}from"../formats/pixelRangeUtils.js";import o from"./BaseRasterFunction.js";import{createColormapLUT as i}from"./pixelUtils.js";import n from"./ShadedReliefFunctionArguments.js";import{getHillshadeOptions as a,hillshade as p,tintHillshade as u,calculateHillshadeParams as c,gcsFactor as l}from"./surfaceUtils.js";import{convertColorRampToColormap as m,createHsvMap as d}from"../../../renderers/support/colorRampUtils.js";import{isColormapSupportedByWebGL as f}from"../../../renderers/support/rasterRendererChecks.js";let h=class extends o{constructor(){super(...arguments),this.functionName="ShadedRelief",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isGCS=!1}_bindSourceRasters(){const e=this.sourceRasterInfos[0];if(e.bandCount>1)return{success:!1,supportsGPU:!1,error:"shadedrelief-function: source data must be single band"};let{colorRamp:t,colormap:s}=this.functionArguments;if(!t&&!s?.length)return{success:!1,supportsGPU:!1,error:"shadedrelief-function: a color ramp argument must be specified"};this.outputPixelType=this._getOutputPixelType("u8");const r=e.clone();this._removeStatsHistColormapVAT(r),r.pixelType=this.outputPixelType,r.bandCount=3,r.statistics=[{min:0,max:255,avg:60,stddev:10},{min:0,max:255,avg:60,stddev:10},{min:0,max:255,avg:60,stddev:10}],this.rasterInfo=r,this.isGCS=r.spatialReference?.isGeographic??!1,s?.length||(s=m(t,{interpolateAlpha:!0}));const{indexedColormap:o,offset:n}=i({colormap:s});if(!o?.length)return{success:!1,supportsGPU:!1,error:"shadedrelief-function: a valid colorramp is required"};const a=d(o);return this.lookup={indexedColormap:o,offset:n,hsvMap:a},{success:!0,supportsGPU:f(o)}}_processPixels(e){const t=e.pixelBlocks?.[0];if(!t||!this.lookup)return null;let s=e.primaryPixelSizes?.[0];if(null==s){const{extent:r}=e;s=r?{x:r.width/t.width,y:r.height/t.height}:{x:1,y:1}}const r=a(this.functionArguments,s,this.isGCS),o=p(t,r),i=this.sourceRasterInfos[0].statistics?.[0]??{min:0,max:8e3};return u(o,t,this.lookup.hsvMap,i),o.pixelType=this.outputPixelType,o}_getWebGLParameters(){const e=a(this.functionArguments,{x:1,y:1},this.isGCS),t=c(e),{slopeType:s,zFactor:o,pixelSizeFactor:i,pixelSizePower:n}=this.functionArguments,p="scaled"===s,{indexedColormap:u,offset:m}=this.lookup,d=this.sourceRasterInfos[0].statistics?.[0],f=r(this.outputPixelType);return{...t,indexedColormap:u,offset:m,zFactor:o,gcsFactor:this.isGCS?l:1,pixelSizeFactor:p?i:0,pixelSizePower:p?n:0,minValue:d?.min??0,maxValue:d?.max??8e3,isOutputRounded:f}}};e([t({json:{write:!0,name:"rasterFunction"}})],h.prototype,"functionName",void 0),e([t({type:n,json:{write:!0,name:"rasterFunctionArguments"}})],h.prototype,"functionArguments",void 0),e([t()],h.prototype,"rasterArgumentNames",void 0),e([t({json:{write:!0}})],h.prototype,"isGCS",void 0),e([t({json:{write:!0}})],h.prototype,"lookup",void 0),h=e([s("esri.layers.raster.functions.ShadedReliefFunction")],h);const x=h;export{x as default};