@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.63 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{numericHash as e}from"../../../../../core/string.js";import{createRendererExpression as t}from"../../../../../support/arcadeOnDemand.js";import{callExpressionWithCursor as r,callExpressionWithCursorWithDefault as a}from"../../../arcade/callExpressionWithCursor.js";import{AComputedField as s}from"./AComputedField.js";function c(e,t){const r=43758.5453*Math.sin(12.9898*e+78.233*t);return r-Math.floor(r)}class i extends s{static async create(r,a){const s=await t(r,a.spatialReference,a.fields),c=e(r);return new i(s,c)}constructor(e,t){super(),this._compiled=e,this._cacheKey=t}resize(e){}read(e,t){return this.hasArcadeDependency("scale")||"system"!==t.$view.timeZone?r(this._compiled,e,t):this._readCached(e,t)}readWithDefault(e,t,r){return this.hasArcadeDependency("scale")||"system"!==t.$view.timeZone?a(this._compiled,e,t,r):this._readWithDefaultCached(e,t,r)}hasArcadeDependency(e){return this._compiled?.references(e)??!1}_getCacheKey(e){if(!this._compiled?.references("timeProperties"))return this._cacheKey;const{currentStart:t,currentEnd:r}=e.$view.timeProperties;return this._cacheKey+c(t??1,r??1)}_readCached(e,t){if(e.setCache(this._getCacheKey(t)),e.hasCachedValue())return e.getCachedValue();const a=r(this._compiled,e,t);return e.setCachedValue(a),a}_readWithDefaultCached(e,t,r){if(e.setCache(this._getCacheKey(t)),e.hasCachedValue())return e.getCachedValue();const s=a(this._compiled,e,t,r);return e.setCachedValue(s),s}}export{i as ComputedExpression};