@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.06 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{toSymbolId as r}from"./arcadeEnvironment.js";import{ArcadeExecutionError as e}from"./executionError.js";import{getArcadeVariableForField as t,convertAttributeToArcadeValue as s}from"./Feature.js";import i from"./ImmutableArray.js";import{d as a,c as n}from"../chunks/languageUtils.js";import o from"../core/Logger.js";import{getOrCreateMapValue as l}from"../core/MapUtils.js";import{isImageryGraphicOrigin as m}from"../graphic/isImageryGraphicOrigin.js";import{isImageryTileGraphicOrigin as p}from"../graphic/isImageryTileGraphicOrigin.js";import{isRasterPixelValueField as u}from"../layers/support/fieldUtils.js";import{rasterFieldPrefix as f}from"../layers/support/rasterFieldUtils.js";import{isDate as c}from"../support/guards.js";const g=()=>o.getLogger("esri.arcade.Pixel");function h(r){return r.rasterFields.filter(r=>r.name.startsWith(f))}class d{constructor(e,t,s){this._graphic=t,this._timeZone=s,this.arcadeDeclaredClass="esri.arcade.Pixel",this._values=new Map,this._fields=new Map(e.map(e=>[r(e.name),e]))}static fromImageryGraphic(r,t){if(!m(r.origin)&&!p(r.origin))throw new e(null,"InvalidParameter",null);return new d(h(r.origin.layer),r,t)}static getDeclaredMembers(r){return h(r).map(r=>u(r.name)&&"string"===r.type?{name:r.name,type:"array",elementType:{type:"text"}}:t(r)).filter(r=>null!=r)}keys(){return Array.from(this._fields.values()).map(r=>r.name).sort()}hasField(e){return this._fields.has(r(e))}field(t){const n=this._fields.get(r(t));if(null==n)throw new e(null,"FieldNotFound",null,{key:t});return l(this._values,n.name,()=>{const r=this._graphic.getAttribute(n.name);return null==r?null:u(n.name)&&"string"==typeof r?new i(r.split(/,\s*|\s+/)):c(r)||a(r)?s(r,n.type,this._timeZone??"system"):(g().warn(`Unsupported type for attribute: ${n.name}. Ignoring value.`),null)})}isEmpty(){return this._fields.size<=0}castToText(r=!1){const e={};for(const t of this._fields.values())e[t.name]=this.field(t.name);return n(e,{useNumbersForDates:r})}}export{d as Pixel};