UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.76 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{internalTrackPartField as e,TrackPart as t}from"../../../../../layers/support/streamLayerUtils.js";import{DictionaryMatcher as r}from"./DictionaryMatcher.js";import{IntervalMatcher as a}from"./IntervalMatcher.js";import{LabelMatcher as s}from"./LabelMatcher.js";import{MapMatcher as c}from"./MapMatcher.js";import{FeatureMatcher as n}from"./Matcher.js";async function i(e,t){switch(t.type){case"simple":case"heatmap":case"dot-density":case"pie-chart":return n.from(e,t);case"interval":return a.fromIntervalSchema(e,t);case"dictionary":return r.fromDictionaryRenderer(e,t);case"label":return s.fromLabelSchema(e,t);case"map":return c.fromMatcherSchema(e,t);case"subtype":return h.fromSubtypes(e,t);case"cluster":return o.fromClusterSchema(e,t);case"track":return u.fromTrackSchema(e,t);default:throw new Error("Impl")}}class h extends n{constructor(e,t){super(),this._subMatchers=e,this._subtypeField=t}static async fromSubtypes(e,t){const r=new Map,a=[];for(const s in t.renderers){const c=parseInt(s,10),n=i(e,t.renderers[s]).then((e=>r.set(c,e)));a.push(n)}return await Promise.all(a),new h(r,t.subtypeField)}match(e,t,r){const a=e.readAttribute(this._subtypeField),s=this._subMatchers.get(a);return s?s.match(e,t,r):null}hasArcadeDependency(e){for(const t of this._subMatchers.values())if(t.hasArcadeDependency(e))return!0;return!1}}class o extends n{static async fromClusterSchema(e,t){const[r,a]=await Promise.all([i(e,t.feature),i(e,t.cluster)]);return new o(r,a)}constructor(e,t){super(),this._featureMatcher=e,this._clusterMatcher=t}match(e,t,r){return 1===e.readAttribute("cluster_count")?this._featureMatcher.match(e,t,r):this._clusterMatcher.match(e,t,r)}hasArcadeDependency(e){return this._featureMatcher.hasArcadeDependency(e)||this._clusterMatcher.hasArcadeDependency(e)}}class u extends n{static async fromTrackSchema(e,t){const[r,a,s]=await Promise.all([i(e,t.previousObservation),i(e,t.latestObservation),i(e,t.trackLine)]);return new u(r,a,s)}constructor(e,t,r){super(),this._previousObservationMatcher=e,this._latestObservationMatcher=t,this._trackLineMatcher=r}match(r,a,s){switch(r.readAttribute(e)){case t.TrackLine:return this._trackLineMatcher.match(r,a,s);case t.LatestObservation:return this._latestObservationMatcher.match(r,a,s);case t.PreviousObservation:return this._previousObservationMatcher.match(r,a,s)}return null}hasArcadeDependency(e){return this._trackLineMatcher.hasArcadeDependency(e)||this._latestObservationMatcher.hasArcadeDependency(e)||this._previousObservationMatcher.hasArcadeDependency(e)}}export{o as ClusterMatcher,h as SubtypeMatcher,i as createMatcher};