@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.79 kB
JavaScript
/*
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 e from"../../core/JSONSupport.js";import{clone as n}from"../../core/lang.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{enumeration as o}from"../../core/accessorSupport/decorators/enumeration.js";import{reader as i}from"../../core/accessorSupport/decorators/reader.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../../core/accessorSupport/decorators/writer.js";import u from"./RasterFunctionTemplate.js";var c;const p=new Set(["raster","raster2","dem","fillraster"]),m=new Set(["rasters"]),f=t=>t?.rasterFunction?N.fromJSON(t):t,l=t=>t&&t instanceof N?t.toJSON():t,y=t=>t?.functionName&&!t.declaredClass,F=t=>y(t)?new N(t):t,h=t=>{if(null==t)return null;t=n(t);const e={};for(const n of Object.keys(t))p.has(n.toLowerCase())?e[n]=f(t[n]):m.has(n.toLowerCase())&&Array.isArray(t[n])?e[n]=t[n].map(f):e[n]=t[n];return e},d=t=>t?u.fromJSON({type:"RasterFunctionTemplate",...t}):void 0,g={types:{key:"type",base:null,typeMap:{RasterFunctionTemplate:u}},json:{write:!0,name:"rasterFunctionDefinition",read:d}};let N=c=class extends e{constructor(t){super(t),this.functionName=null,this.outputPixelType="unknown",this.variableName=null,this.functionDefinition=null}set functionArguments(t){if(t){const e=Object.keys(t);if(e.some((e=>p.has(e.toLowerCase())&&y(t[e])))||e.some((e=>m.has(e.toLowerCase())&&Array.isArray(t[e])&&t[e].some((t=>y(t)))))){t=n(t);for(const n of e)p.has(n.toLowerCase())?t[n]=F(t[n]):m.has(n.toLowerCase())&&Array.isArray(t[n])&&(t[n]=t[n].map((t=>F(t))))}}this._set("functionArguments",t)}readFunctionArguments(t){return h(t)}writeFunctionArguments(t,e,n){const r={};for(const o of Object.keys(t))p.has(o.toLowerCase())?r[o]=l(t[o]):m.has(o.toLowerCase())&&Array.isArray(t[o])?r[o]=t[o].map(l):r[o]=l(t[o]);e[n]=r}readFunctionName(t,e){const n=e.rasterFunctionInfos,r=e.name;return r||(n?.length&&"None"!==n[0].name?n[0].name:e.rasterFunction||e.rasterFunctionDefinition?.name)}get rasterFunctionDefinition(){return this.functionDefinition?.toJSON()}set rasterFunctionDefinition(t){this.functionDefinition=d(t)}get hasClipFunction(){return this.rasterFunctionDefinition?JSON.stringify(this.rasterFunctionDefinition).includes('"type":"ClipFunction"'):JSON.stringify(this).includes('"rasterFunction":"Clip"')}clone(){return new c({functionName:this.functionName,functionArguments:n(this.functionArguments),outputPixelType:this.outputPixelType,variableName:this.variableName,rasterFunctionDefinition:n(this.rasterFunctionDefinition)})}};t([r({json:{type:Object,name:"rasterFunctionArguments"}})],N.prototype,"functionArguments",null),t([i("functionArguments")],N.prototype,"readFunctionArguments",null),t([a("functionArguments")],N.prototype,"writeFunctionArguments",null),t([r({json:{type:String,write:{target:"rasterFunction"}}})],N.prototype,"functionName",void 0),t([i("functionName",["rasterFunction","rasterFunctionInfos","rasterFunctionDefinition"])],N.prototype,"readFunctionName",null),t([o({C128:"c128",C64:"c64",F32:"f32",F64:"f64",S16:"s16",S32:"s32",S8:"s8",U1:"u1",U16:"u16",U2:"u2",U32:"u32",U4:"u4",U8:"u8",UNKNOWN:"unknown"},{ignoreUnknown:!1,default:"unknown"})],N.prototype,"outputPixelType",void 0),t([r({type:String,json:{read:!0,write:!0}})],N.prototype,"variableName",void 0),t([r()],N.prototype,"rasterFunctionDefinition",null),t([r(g)],N.prototype,"functionDefinition",void 0),t([r()],N.prototype,"hasClipFunction",null),N=c=t([s("esri.layers.support.RasterFunction")],N);export{N as default};