@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.64 kB
JavaScript
import e from"../../../../../../core/Logger.js";import{analyzeCIMResource as t}from"../../../../../../symbols/cim/cimAnalyzer.js";import{evaluateValueOrFunction as a}from"../../../../../../symbols/cim/utils.js";import s from"./WGLMeshTemplate.js";const i=e.getLogger("esri.views.2d.engine.webgl.WGLDynamicMeshTemplate");class r extends s{constructor(e){super(),this._ongoingMaterialRequestMap=new Map,this._materialCache=new Map,this._dynamicPropertyMap=new Map,this._cimLayer=e}analyze(e,s,r,n,o){if(o&&0===o.length)return null;const l=o&&o.length>0,m=s.readLegacyFeature(),c=s.getObjectId(),h=this._materialCache,u=this._cimLayer.materialHash;if(!u)return i.error("A Dynamic mesh template must have a material hash value or function!"),Promise.reject(null);const p="function"==typeof u?u(m,r,n,c):u,g=h.get(p);if(null!=g)return Promise.resolve(g);const y=this._ongoingMaterialRequestMap.get(p);if(y)return y;const M=this._cimLayer,d=t(M.cim,this._cimLayer.materialOverrides);d.mosaicHash=p;const{type:f,url:_}=M,b={cim:d,type:f,mosaicHash:p,url:_,size:null,dashTemplate:null,text:null,fontName:null,objectId:c,animatedSymbolProperties:null};switch(f){case"marker":b.size=a(M.size,m,r,n),b.animatedSymbolProperties=a(M.animatedSymbolProperties,m,r,n);break;case"line":b.dashTemplate=M.dashTemplate;break;case"text":b.text=a(M.text,m,r,n),b.fontName=a(M.fontName,m,r,n)}const L=e.getMosaicItem(b,o).then((e=>(l||(this._ongoingMaterialRequestMap.delete(p),h.set(p,e)),e))).catch((e=>(this._ongoingMaterialRequestMap.delete(p),i.error(".analyze()",e.message),null)));return l||this._ongoingMaterialRequestMap.set(p,L),L}}export{r as default};