UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.15 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import e from"../../../../core/Logger.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{hydrateGeometry as r}from"../../../../layers/graphics/hydratedFeatures.js";import{loadArcade as n}from"../../../../support/loadArcade.js";const c=()=>e.getLogger("esri.views.3d.layers.graphics.featureExpressionInfoUtils");function o(e){return{cachedResult:e.cachedResult,arcade:e.arcade?{func:e.arcade.func,context:e.arcade.modules.arcadeUtils.createExecContext(null,{sr:e.arcade.context.spatialReference}),modules:e.arcade.modules}:null}}function u(e){const t=e?.expression;if("string"==typeof t){const e=m(t);if(null!=e)return{cachedResult:e}}return null}async function a(e,r,c,o){const u=e?.expression;if("string"!=typeof u)return null;const a=m(u);if(null!=a)return{cachedResult:a};const s=await n();t(c);const l=s.arcadeUtils,i=l.createSyntaxTree(u);return l.dependsOnView(i)?(null!=o&&o.error("Expressions containing '$view' are not supported on ElevationInfo"),{cachedResult:0}):{arcade:{func:l.createFunction(i),context:l.createExecContext(null,{sr:r}),modules:s}}}function s(e,t,r){return e.arcadeUtils.createFeature(t.attributes,t.geometry,r)}function l(e,t){if(null!=e&&!p(e)){if(!t||!e.arcade)return void c().errorOncePerTick("Arcade support required but not provided");const n=t;n._geometry&&(n._geometry=r(n._geometry)),e.arcade.modules.arcadeUtils.updateExecContext(e.arcade.context,t)}}function i(e){if(null!=e){if(p(e))return e.cachedResult;const t=e.arcade;let r=t?.modules.arcadeUtils.executeFunction(t.func,t.context);return"number"!=typeof r&&(e.cachedResult=0,r=0),r}return 0}function d(e,t=!1){let r=e?.featureExpressionInfo;const n=r?.expression;return t||"0"===n||(r=null),r??null}const f={cachedResult:0};function p(e){return null!=e.cachedResult}function m(e){return"0"===e?0:null}export{o as clone,a as createContext,u as createContextWithoutExpressionSupport,s as createFeature,i as execute,d as extractExpressionInfo,l as setContextFeature,f as zeroContext};