UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 3.38 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{getNamedColor as t,hexToRgba as e}from"../../../../colorUtils.js";import{createRasterFunction as n}from"./utils.js";import{colormapName as o}from"../../../support/rasterFunctionConstants.js";import{colorRampDict as r}from"../../../../renderers/support/colorRampUtils.js";function a(t){return"colormap"in t?s(t):"colorRamp"in t?i(t):u(t)}function s(o){const r=o.colormap.map(n=>{if("value"in n){const o="string"==typeof n.color?t(n.color)??e(n.color):n.color;(n=[n.value,...o])[4]&&n[4]<=1&&(n[4]=Math.round(255*n[4]))}return n}),{raster:a,outputPixelType:s}=o;return n("Colormap",{colormap:r,raster:a},s)}function i(t){const{raster:e,colorRamp:o,outputPixelType:r}=t,a={colorRamp:"toJSON"in o?o.toJSON():o,raster:e};return n("Colormap",a,r)}function u(t){const{colorRampName:e}=t,a=Object.values(o).find(t=>t.toLowerCase()===e?.toLowerCase()),s=r.toJSON(e),{raster:i,outputPixelType:u="unknown"}=t;return n("Colormap",a?{colormapName:a,raster:i}:{colorRampName:s,raster:i},u)}function l(t){const{raster:e,outputPixelType:o="u8"}=t;return n("ColormapToRGB",{raster:e},o)}function p(t){const{raster:e,histograms:o,outputPixelType:r}=t,a=t.statistics?.map(t=>({min:t.min,max:t.max,mean:t.avg,standardDeviation:t.stddev}));return n("StatisticsHistograms",{raster:e,statistics:a,histograms:o},r)}function c(t){const{raster:e,attributeTable:o,outputPixelType:r="unknown"}=t,a="toJSON"in o?o.toJSON():o;return n("Table",{raster:e,attributeTableAsRecordSet:a},r)}function m(t){const{raster:e,outputPixelType:o="unknown"}=t,r={raster:e,missingBandAction:"fail"===t.missingBandAction?1:0};return"bandIds"in t?r.bandIds=t.bandIds:"bandNames"in t?r.bandNames=t.bandNames:"bandWavelengths"in t&&(r.bandWavelengths=t.bandWavelengths),n("ExtractBand",r,o)}function d(t){const{redBand:e,greenBand:o,blueBand:r,raster:a,outputPixelType:s}=t,i="name"===t.method?0:2;return n("CreateColorComposite",{raster:a,method:i,bandIndexesR:e,bandIndexesG:o,bandIndexesB:r},s)}function f(t){const{rasters:e,outputPixelType:o}=t;return n("CompositeBand",{rasters:e},o)}function g(t){const{allowUnmatched:e,raster:o,rangeMaps:r,outputPixelType:a,replacementValue:s}=t,i=r?.filter(({output:t})=>null!=t),u=i?.flatMap(({range:t})=>t),l=i?.map(({output:t})=>t),p=r?.filter(t=>null==t.output)?.flatMap(({range:t})=>t);return n("Remap",{allowUnmatched:e,raster:o,inputRanges:u,outputValues:l,noDataRanges:p,replacementValue:s},a)}function b(t){const{inputBitPositions:e,raster:o,fillRaster:r,outputBitPositions:a,outputPixelType:s}=t,i={inputBitPositions:e,outputBitPositions:a,raster:o};return null!=r&&("number"==typeof r?(i.constantFillCheck=!0,i.constantFillValue=r):i.fillRaster=r),n("TransposeBits",i,s)}function x(t){const{raster:e,outputPixelType:o="unknown"}=t,r=t.includedRanges?.flat(),a=t.noDataValues?.map(t=>t.join(" ")),s="match-all"===t.noDataInterpretation?1:0;return n("Mask",{raster:e,includedRanges:r,noDataInterpretation:s,noDataValues:a},o)}function T(t){const{geometry:e,keepOutside:o,outputPixelType:r="unknown",raster:a}=t,s="declaredClass"in e?e.toJSON():e;return n("Clip",{clippingGeometry:s,clippingType:o?2:1,raster:a},r)}export{T as clip,a as colormap,l as colormapToRGB,f as compositeBand,d as createColorComposite,m as extractBand,x as mask,g as remap,p as statisticsHistogram,c as table,b as transposeBits};