@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.39 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{DictionaryScriptEvaluator as t}from"../../../../../renderers/support/DictionaryScriptEvaluator.js";import{FeatureMatcher as r}from"./Matcher.js";class e extends r{static async fromDictionaryRenderer(r,o){const n=await t.from(o.dictionaryInfo,o.userConfig,o.fieldMap);return new e(r,n)}constructor(t,r){super(),this._context=t,this._evaluator=r,this._controlStringToPromise=new Map,this._controlStringToGroup=new Map}async fetchResources(t,r){const e=r.getCursor(),o=new Set;for(;e.next();){const t=this._evaluateControlString(e);t&&o.add(t)}const n=Array.from(o.values()).map((r=>this._ensureGroup(t,r)));await Promise.all(n)}match(t,r){const e=this._evaluateControlString(t);return e?this._controlStringToGroup.get(e):null}_evaluateControlString(t){const r=t.readLegacyFeatureWorldSpace();return this._evaluator.evaluate(r,0,t.fields,null)}_ensureGroup(t,r){let e=this._controlStringToPromise.get(r);return null==e&&(e=this._fetchGroup(t,r),this._controlStringToPromise.set(r,e)),e}async _fetchGroup(t,r){const e=await t.fetchDictionaryResourceImmediate({type:"dictionary-request",controlString:r});if(!e)return;const o=await this._context.createMeshWriters(e.meshes);this._controlStringToGroup.set(r,o)}}export{e as DictionaryMatcher};