@urban-toolkit/autk-grammar 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,98 +1,98 @@
1
- import { AutkDb as $, DEFAULT_WORKSPACE_COORDINATE_FORMAT as O } from "@urban-toolkit/autk-db";
2
- import { AutkMap as Y, MapEvent as L } from "@urban-toolkit/autk-map";
3
- import { AutkPlot as H, PlotEvent as w } from "@urban-toolkit/autk-plot";
4
- import { ColorMapDomainStrategy as S } from "@urban-toolkit/autk-core";
5
- import { AutkComputeEngine as V } from "@urban-toolkit/autk-compute";
6
- function k(t) {
1
+ import { AutkDb as K, DEFAULT_WORKSPACE_COORDINATE_FORMAT as V } from "@urban-toolkit/autk-db";
2
+ import { AutkMap as q, MapEvent as P } from "@urban-toolkit/autk-map";
3
+ import { AutkPlot as z, PlotEvent as I } from "@urban-toolkit/autk-plot";
4
+ import { ColorMapInterpolator as Z, ColorMapDomainStrategy as M, ColorMap as N } from "@urban-toolkit/autk-core";
5
+ import { AutkComputeEngine as tt } from "@urban-toolkit/autk-compute";
6
+ function et(t) {
7
7
  const { spec: e, adapters: r } = t;
8
8
  let o;
9
- async function s() {
10
- let u;
9
+ async function i() {
10
+ let n;
11
11
  if (e.data)
12
- for (const i of e.data)
13
- u = await r.db.resolveSource(u, i);
12
+ for (const s of e.data)
13
+ n = await r.db.resolveSource(n, s);
14
14
  if (e.compute)
15
- for (const i of e.compute)
16
- u = await r.compute.resolveCompute(u, i);
15
+ for (const s of e.compute)
16
+ n = await r.compute.resolveCompute(n, s);
17
17
  if (e.map)
18
18
  if (Array.isArray(e.map))
19
- for (let i = 0; i < e.map.length; i++) {
20
- let l = e.map[i];
21
- await r.map.resolveMap(u, l, i);
19
+ for (let s = 0; s < e.map.length; s++) {
20
+ let c = e.map[s];
21
+ await r.map.resolveMap(n, c, s);
22
22
  }
23
23
  else
24
- await r.map.resolveMap(u, e.map);
24
+ await r.map.resolveMap(n, e.map);
25
25
  if (e.plot)
26
26
  if (Array.isArray(e.plot))
27
- for (const i of e.plot)
28
- await r.plot.resolvePlot(u, i);
27
+ for (const s of e.plot)
28
+ await r.plot.resolvePlot(n, s);
29
29
  else
30
- await r.plot.resolvePlot(u, e.plot);
31
- o = u;
30
+ await r.plot.resolvePlot(n, e.plot);
31
+ o = n;
32
32
  }
33
- function a(u) {
34
- return console.log("Spec to update", u), new Promise((i) => {
35
- i();
33
+ function a(n) {
34
+ return console.log("Spec to update", n), new Promise((s) => {
35
+ s();
36
36
  });
37
37
  }
38
- function n() {
38
+ function l() {
39
39
  console.log("Function not implemented yet");
40
40
  }
41
- return { run: s, updatedSpec: a, destroy: n, get context() {
41
+ return { run: i, updatedSpec: a, destroy: l, get context() {
42
42
  return o;
43
43
  } };
44
44
  }
45
- var W = /* @__PURE__ */ ((t) => (t.CAT_ACCENT = "schemeAccent", t.CAT_DARK2 = "schemeDark2", t.CAT_CATEGORY10 = "schemeCategory10", t.CAT_OBSERVABLE10 = "schemeObservable10", t.CAT_PAIRED = "schemePaired", t.CAT_PASTEL1 = "schemePastel1", t.CAT_PASTEL2 = "schemePastel2", t.CAT_SET1 = "schemeSet1", t.CAT_SET2 = "schemeSet2", t.CAT_SET3 = "schemeSet3", t.CAT_TABLEAU10 = "schemeTableau10", t.SEQ_REDS = "interpolateReds", t.SEQ_BLUES = "interpolateBlues", t.SEQ_GREENS = "interpolateGreens", t.SEQ_GREYS = "interpolateGreys", t.SEQ_ORANGES = "interpolateOranges", t.SEQ_PURPLES = "interpolatePurples", t.SEQ_TURBO = "interpolateTurbo", t.SEQ_VIRIDIS = "interpolateViridis", t.SEQ_INFERNO = "interpolateInferno", t.SEQ_MAGMA = "interpolateMagma", t.SEQ_PLASMA = "interpolatePlasma", t.SEQ_CIVIDIS = "interpolateCividis", t.SEQ_WARM = "interpolateWarm", t.SEQ_COOL = "interpolateCool", t.SEQ_CUBEHELIX_DEFAULT = "interpolateCubehelixDefault", t.SEQ_BU_GN = "interpolateBuGn", t.SEQ_BU_PU = "interpolateBuPu", t.SEQ_GN_BU = "interpolateGnBu", t.SEQ_OR_RD = "interpolateOrRd", t.SEQ_PU_BU_GN = "interpolatePuBuGn", t.SEQ_PU_BU = "interpolatePuBu", t.SEQ_PU_RD = "interpolatePuRd", t.SEQ_RD_PU = "interpolateRdPu", t.SEQ_YL_GN_BU = "interpolateYlGnBu", t.SEQ_YL_GN = "interpolateYlGn", t.SEQ_YL_OR_BR = "interpolateYlOrBr", t.SEQ_YL_OR_RD = "interpolateYlOrRd", t.DIV_BR_BG = "interpolateBrBG", t.DIV_PR_GN = "interpolatePRGn", t.DIV_PI_YG = "interpolatePiYG", t.DIV_PU_OR = "interpolatePuOr", t.DIV_RED_BLUE = "interpolateRdBu", t.DIV_RED_GREY = "interpolateRdGy", t.DIV_RED_YELLOW_BLUE = "interpolateRdYlBu", t.DIV_RED_YELLOW_GREEN = "interpolateRdYlGn", t.DIV_SPECTRAL = "interpolateSpectral", t))(W || {}), G = /* @__PURE__ */ ((t) => (t.MIN_MAX = "minMax", t.PERCENTILE = "percentile", t))(G || {});
46
- function J(t) {
45
+ var rt = /* @__PURE__ */ ((t) => (t.CAT_ACCENT = "schemeAccent", t.CAT_DARK2 = "schemeDark2", t.CAT_CATEGORY10 = "schemeCategory10", t.CAT_OBSERVABLE10 = "schemeObservable10", t.CAT_PAIRED = "schemePaired", t.CAT_PASTEL1 = "schemePastel1", t.CAT_PASTEL2 = "schemePastel2", t.CAT_SET1 = "schemeSet1", t.CAT_SET2 = "schemeSet2", t.CAT_SET3 = "schemeSet3", t.CAT_TABLEAU10 = "schemeTableau10", t.SEQ_REDS = "interpolateReds", t.SEQ_BLUES = "interpolateBlues", t.SEQ_GREENS = "interpolateGreens", t.SEQ_GREYS = "interpolateGreys", t.SEQ_ORANGES = "interpolateOranges", t.SEQ_PURPLES = "interpolatePurples", t.SEQ_TURBO = "interpolateTurbo", t.SEQ_VIRIDIS = "interpolateViridis", t.SEQ_INFERNO = "interpolateInferno", t.SEQ_MAGMA = "interpolateMagma", t.SEQ_PLASMA = "interpolatePlasma", t.SEQ_CIVIDIS = "interpolateCividis", t.SEQ_WARM = "interpolateWarm", t.SEQ_COOL = "interpolateCool", t.SEQ_CUBEHELIX_DEFAULT = "interpolateCubehelixDefault", t.SEQ_BU_GN = "interpolateBuGn", t.SEQ_BU_PU = "interpolateBuPu", t.SEQ_GN_BU = "interpolateGnBu", t.SEQ_OR_RD = "interpolateOrRd", t.SEQ_PU_BU_GN = "interpolatePuBuGn", t.SEQ_PU_BU = "interpolatePuBu", t.SEQ_PU_RD = "interpolatePuRd", t.SEQ_RD_PU = "interpolateRdPu", t.SEQ_YL_GN_BU = "interpolateYlGnBu", t.SEQ_YL_GN = "interpolateYlGn", t.SEQ_YL_OR_BR = "interpolateYlOrBr", t.SEQ_YL_OR_RD = "interpolateYlOrRd", t.DIV_BR_BG = "interpolateBrBG", t.DIV_PR_GN = "interpolatePRGn", t.DIV_PI_YG = "interpolatePiYG", t.DIV_PU_OR = "interpolatePuOr", t.DIV_RED_BLUE = "interpolateRdBu", t.DIV_RED_GREY = "interpolateRdGy", t.DIV_RED_YELLOW_BLUE = "interpolateRdYlBu", t.DIV_RED_YELLOW_GREEN = "interpolateRdYlGn", t.DIV_SPECTRAL = "interpolateSpectral", t))(rt || {}), Y = /* @__PURE__ */ ((t) => (t.MIN_MAX = "minMax", t.PERCENTILE = "percentile", t))(Y || {});
46
+ function ot(t) {
47
47
  const { autoLoadLayers: e, ...r } = t;
48
48
  return { ...r, autoLoadLayers: { layers: e?.layers ?? [] } };
49
49
  }
50
- function K(t, e) {
51
- function r(o, s) {
52
- if (!s || !s.db)
50
+ function at(t, e) {
51
+ function r(o, i) {
52
+ if (!i || !i.db)
53
53
  return;
54
- const a = document.getElementById(s.db);
54
+ const a = document.getElementById(i.db);
55
55
  if (a) {
56
- const n = o.getTablesMetadata();
56
+ const l = o.getTablesMetadata();
57
57
  a.innerHTML += "<ul>";
58
- for (const u of n)
59
- a.innerHTML += `<li>${u.name}: (${u.source}, ${u.type}) </li>`;
60
- a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${n.length}</p>`;
58
+ for (const n of l)
59
+ a.innerHTML += `<li>${n.name}: (${n.source}, ${n.type}) </li>`;
60
+ a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${l.length}</p>`;
61
61
  }
62
62
  }
63
63
  return {
64
- async resolveSource(o, s) {
64
+ async resolveSource(o, i) {
65
65
  let a = o;
66
- a || (a = new $(), await a.init());
67
- let { type: n, ...u } = s;
68
- switch (n) {
66
+ a || (a = new K(), await a.init());
67
+ let { type: l, ...n } = i;
68
+ switch (l) {
69
69
  case "osm":
70
- return await a.loadOsm(J(u)), r(a, t), a;
70
+ return await a.loadOsm(ot(n)), r(a, t), a;
71
71
  case "csv":
72
- return await a.loadCsv(u), r(a, t), a;
72
+ return await a.loadCsv(n), r(a, t), a;
73
73
  case "json":
74
- return await a.loadJson(u), r(a, t), a;
74
+ return await a.loadJson(n), r(a, t), a;
75
75
  case "geojson": {
76
- const i = u;
77
- let l;
78
- i.geojsonFileUrl ? l = await (await fetch(i.geojsonFileUrl)).json() : l = i.geojsonObject, e && l && e.set(i.outputTableName, l);
79
- const c = l ? (() => {
80
- const f = { ...i, geojsonObject: l };
76
+ const s = n;
77
+ let c;
78
+ s.geojsonFileUrl ? c = await (await fetch(s.geojsonFileUrl)).json() : c = s.geojsonObject, e && c && e.set(s.outputTableName, c);
79
+ const u = c ? (() => {
80
+ const f = { ...s, geojsonObject: c };
81
81
  return delete f.geojsonFileUrl, f;
82
- })() : i;
82
+ })() : s;
83
83
  try {
84
- await a.loadGeojson(c);
84
+ await a.loadGeojson(u);
85
85
  } catch (f) {
86
- const p = c.coordinateFormat ? `coordinateFormat is set to "${c.coordinateFormat}"` : "no coordinateFormat was specified — defaulting to EPSG:4326 (WGS84 per RFC 7946)";
86
+ const p = u.coordinateFormat ? `coordinateFormat is set to "${u.coordinateFormat}"` : "no coordinateFormat was specified — defaulting to EPSG:4326 (WGS84 per RFC 7946)";
87
87
  throw new Error(
88
- `Failed to load GeoJSON layer "${c.outputTableName}": ${f instanceof Error ? f.message : String(f)}. ${p}. Verify that coordinateFormat matches the actual CRS of the input data.`
88
+ `Failed to load GeoJSON layer "${u.outputTableName}": ${f instanceof Error ? f.message : String(f)}. ${p}. Verify that coordinateFormat matches the actual CRS of the input data.`
89
89
  );
90
90
  }
91
91
  try {
92
- const f = await a.getBoundingBoxFromLayer(c.outputTableName), p = 25e6;
92
+ const f = await a.getBoundingBoxFromLayer(u.outputTableName), p = 25e6;
93
93
  if (!isFinite(f.minLon) || !isFinite(f.minLat) || !isFinite(f.maxLon) || !isFinite(f.maxLat) || Math.abs(f.minLon) > p || Math.abs(f.maxLon) > p || Math.abs(f.minLat) > p || Math.abs(f.maxLat) > p)
94
94
  throw new Error(
95
- `Geometry bounding box after transform is invalid for layer "${c.outputTableName}" (bbox: [${f.minLon}, ${f.minLat}, ${f.maxLon}, ${f.maxLat}]). Verify that coordinateFormat matches the actual CRS of the input data. The workspace uses ${O}; input is expected in EPSG:4326 by default.`
95
+ `Geometry bounding box after transform is invalid for layer "${u.outputTableName}" (bbox: [${f.minLon}, ${f.minLat}, ${f.maxLon}, ${f.maxLat}]). Verify that coordinateFormat matches the actual CRS of the input data. The workspace uses ${V}; input is expected in EPSG:4326 by default.`
96
96
  );
97
97
  } catch (f) {
98
98
  if (f instanceof Error && f.message.includes("bounding box after transform")) throw f;
@@ -100,25 +100,25 @@ function K(t, e) {
100
100
  return r(a, t), a;
101
101
  }
102
102
  case "heatmap": {
103
- const i = u;
103
+ const s = n;
104
104
  return await a.buildHeatmap({
105
- tableJoinName: i.tableJoinName,
106
- near: { distance: i.near.distance },
107
- outputTableName: i.outputTableName,
108
- grid: i.grid,
109
- ...i.groupBy && { groupBy: i.groupBy }
105
+ tableJoinName: s.tableJoinName,
106
+ near: { distance: s.near.distance },
107
+ outputTableName: s.outputTableName,
108
+ grid: s.grid,
109
+ ...s.groupBy && { groupBy: s.groupBy }
110
110
  }), r(a, t), a;
111
111
  }
112
112
  case "join": {
113
- const i = u;
113
+ const s = n;
114
114
  if (await a.spatialQuery({
115
- tableRootName: i.tableRootName,
116
- tableJoinName: i.tableJoinName,
117
- ...i.near && { near: i.near },
118
- ...i.groupBy && { groupBy: i.groupBy }
115
+ tableRootName: s.tableRootName,
116
+ tableJoinName: s.tableJoinName,
117
+ ...s.near && { near: s.near },
118
+ ...s.groupBy && { groupBy: s.groupBy }
119
119
  }), e) {
120
- const l = await a.getLayer(i.tableRootName);
121
- e.set(i.tableRootName, l);
120
+ const c = await a.getLayer(s.tableRootName);
121
+ e.set(s.tableRootName, c);
122
122
  }
123
123
  return r(a, t), a;
124
124
  }
@@ -128,85 +128,132 @@ function K(t, e) {
128
128
  }
129
129
  };
130
130
  }
131
- function X(t, e) {
132
- return e && e.length > 0 ? { type: S.USER, params: e } : t?.mode === G.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
133
- type: S.PERCENTILE,
131
+ function B(t) {
132
+ return typeof t.title == "string" && t.title !== "" ? t.title : t.dataRef;
133
+ }
134
+ function nt(t, e) {
135
+ const r = /* @__PURE__ */ new Set();
136
+ for (const o of t.layerRefs) {
137
+ const i = B(o);
138
+ if (r.has(i))
139
+ throw new Error(`Map ${e} draws two layers with the id "${i}". A layer's id is its title, else its dataRef: give each layer of a map its own title.`);
140
+ r.add(i);
141
+ }
142
+ }
143
+ const it = /^#[0-9a-fA-F]{6}$/;
144
+ function G(t, e, r) {
145
+ if (!it.test(t))
146
+ throw new Error(`Layer "${r}": ${e} must be a color written #rrggbb, not "${t}".`);
147
+ return N.hexToRgb(t);
148
+ }
149
+ function st(t, e) {
150
+ const r = {};
151
+ return t.color != null && (r.color = G(t.color, "color", e)), t.stroke === !1 ? r.showBorders = !1 : t.stroke != null && (r.strokeColor = G(t.stroke, "stroke", e)), t.width != null && (r.polylinesWidth = t.width), r;
152
+ }
153
+ function lt(t, e) {
154
+ return t.isColorMap != null ? t.isColorMap : e === "raster" ? t.colorMapInterpolator != null || t.colorMapCenter != null || t.colorMapReverse === !0 : t.color != null ? !1 : t.colorMapInterpolator != null || t.getFnv != null;
155
+ }
156
+ function ut(t, e) {
157
+ const r = t.features?.[0]?.properties?.[e];
158
+ return r instanceof Float32Array ? r : ArrayBuffer.isView(r) && !(r instanceof DataView) || Array.isArray(r) ? Float32Array.from(r, (o) => Number.isFinite(Number(o)) ? Number(o) : NaN) : null;
159
+ }
160
+ function ct(t, e, r, o) {
161
+ if (N.isCategorical(e.interpolator)) return;
162
+ let i = 0, a = 0;
163
+ for (let s = 0; s < t.length; s++) {
164
+ const c = t[s];
165
+ Number.isFinite(c) && (a++, r != null && (i = Math.max(i, Math.abs(c - r))));
166
+ }
167
+ const l = r != null && i > 0;
168
+ if (a === 0 || !l && o !== !0) return;
169
+ const n = l && r != null ? [r - i, r, r + i] : N.resolveDomainFromData(t, e);
170
+ return o === !0 ? [...n].reverse() : n;
171
+ }
172
+ function ft(t, e) {
173
+ return e && e.length > 0 ? { type: M.USER, params: e } : t?.mode === Y.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
174
+ type: M.PERCENTILE,
134
175
  params: [t.lowerPercentile ?? 0, t.upperPercentile ?? 100]
135
- } : { type: S.PERCENTILE } : { type: S.MIN_MAX };
176
+ } : { type: M.PERCENTILE } : { type: M.MIN_MAX };
136
177
  }
137
- function q(t, e) {
178
+ function pt(t, e) {
138
179
  return e.split(".").reduce((r, o) => {
139
180
  if (!(r == null || typeof r != "object"))
140
181
  return r[o];
141
182
  }, t);
142
183
  }
143
- function z(t, e, r) {
144
- const o = e.split("."), s = { ...t };
145
- let a = s;
146
- for (let n = 0; n < o.length - 1; n++)
147
- a[o[n]] = { ...a[o[n]] ?? {} }, a = a[o[n]];
148
- return a[o[o.length - 1]] = r, s;
184
+ function mt(t, e, r) {
185
+ const o = e.split("."), i = { ...t };
186
+ let a = i;
187
+ for (let l = 0; l < o.length - 1; l++)
188
+ a[o[l]] = { ...a[o[l]] ?? {} }, a = a[o[l]];
189
+ return a[o[o.length - 1]] = r, i;
149
190
  }
150
- function Z(t, e) {
191
+ function dt(t, e) {
151
192
  const o = t.features?.[0]?.properties?.bands ?? [];
152
193
  return o.find((a) => a.id === e || a.label === e?.replace(/\./g, "_"))?.id ?? o[0]?.id ?? e ?? "";
153
194
  }
154
- function tt(t, e, r, o) {
155
- async function s(a, n, u) {
156
- let i = {};
157
- for (const l of n.getTablesMetadata())
158
- l.type !== void 0 && (i[l.name] = l.type);
159
- for (const l of u.layerRefs) {
160
- const c = l.dataRef, f = i[c], p = l.getFnv, m = r?.get(c) ?? await n.getLayer(c), d = f === "raster" ? m : {
161
- ...m,
162
- features: (m.features ?? []).filter((_) => _.geometry != null)
163
- };
164
- f === "raster" ? a.loadCollection(c, { collection: d, type: "raster", property: Z(d, p) }) : a.loadCollection(c, { collection: d, type: f }), l.opacity != null && a.updateRenderInfo(c, { opacity: l.opacity }), (l.isColorMap ?? (p != null && f !== "raster")) && a.updateRenderInfo(c, { isColorMap: !0 }), l.isPick && a.updateRenderInfo(c, { isPick: !0 }), l.isSkip && a.updateRenderInfo(c, { isSkip: !0 });
165
- const { catchAllCategory: h, colorMapDomain: g } = l;
166
- let R = d, b = g;
167
- if (p && h && g?.length) {
168
- const _ = new Set(g);
169
- R = {
170
- ...d,
171
- features: d.features.map((M) => {
172
- const v = M.properties, P = q(v, p);
173
- return P == null || !_.has(String(P)) ? { ...M, properties: z(v, p, h) } : M;
195
+ function ht(t, e, r, o, i) {
196
+ async function a(l, n, s) {
197
+ let c = {};
198
+ for (const u of n.getTablesMetadata())
199
+ u.type !== void 0 && (c[u.name] = u.type);
200
+ for (const u of s.layerRefs) {
201
+ const f = u.dataRef, p = B(u), m = c[f], d = u.getFnv, h = r?.get(f) ?? await n.getLayer(f), y = m === "raster" ? h : {
202
+ ...h,
203
+ features: (h.features ?? []).filter((g) => g.geometry != null)
204
+ }, b = m === "raster" ? dt(y, d) : "";
205
+ m === "raster" ? l.loadCollection(p, { collection: y, type: "raster", property: b }) : l.loadCollection(p, { collection: y, type: m }), u.opacity != null && l.updateRenderInfo(p, { opacity: u.opacity });
206
+ const w = st(u, p);
207
+ Object.keys(w).length > 0 && l.updateRenderInfo(p, w), lt(u, m) && l.updateRenderInfo(p, { isColorMap: !0 }), u.isPick && l.updateRenderInfo(p, { isPick: !0 }), u.isSkip && l.updateRenderInfo(p, { isSkip: !0 });
208
+ const { catchAllCategory: _, colorMapDomain: R } = u;
209
+ let F = y, T = R;
210
+ if (d && _ && R?.length) {
211
+ const g = new Set(R);
212
+ F = {
213
+ ...y,
214
+ features: y.features.map((A) => {
215
+ const S = A.properties, v = pt(S, d);
216
+ return v == null || !g.has(String(v)) ? { ...A, properties: mt(S, d, _) } : A;
174
217
  })
175
- }, b = _.has(h) ? g : [...g, h];
218
+ }, T = g.has(_) ? R : [...R, _];
176
219
  }
177
- if (l.colorMapInterpolator) {
178
- const _ = {
220
+ const O = m === "raster" && u.transferFunction != null;
221
+ O && l.layerManager.searchByLayerId(p)?.setTransferFunction?.(u.transferFunction);
222
+ const D = m === "raster" && (u.colorMapCenter != null || u.colorMapReverse === !0);
223
+ if (u.colorMapInterpolator || D) {
224
+ const g = {
179
225
  // urban-grammar ColorMapInterpolator values are string-compatible
180
226
  // with autk-core ColorMapInterpolator at runtime
181
- interpolator: l.colorMapInterpolator,
182
- domainSpec: X(l.normalization, b)
183
- };
184
- a.updateRenderInfo(c, { colormap: { config: _ }, isColorMap: !0 });
185
- }
186
- if (p && f !== "raster") {
187
- const _ = p.startsWith("properties.") ? p : `properties.${p}`;
188
- a.updateThematic(c, { collection: R, property: _ });
227
+ interpolator: u.colorMapInterpolator ?? l.layerManager.searchByLayerId(p)?.layerRenderInfo.colormap.config.interpolator ?? Z.SEQ_REDS,
228
+ domainSpec: ft(u.normalization, T)
229
+ }, A = D ? ut(y, b) : null, S = A ? ct(A, g, u.colorMapCenter, u.colorMapReverse) : void 0;
230
+ S && (g.domainSpec = { type: M.USER, params: S }), l.updateColorMap(p, { colorMap: g });
231
+ } else O && l.updateColorMap(p, { colorMap: {} });
232
+ if (d && m !== "raster") {
233
+ const g = d.startsWith("properties.") ? d : `properties.${d}`;
234
+ l.updateThematic(p, { collection: F, property: g });
189
235
  }
190
236
  }
191
237
  }
192
238
  return {
193
- async resolveMap(a, n, u = 0) {
194
- if (t && t.map && a) {
195
- let i;
196
- if (Array.isArray(t.map) ? i = document.getElementById(t.map[u]) : i = document.getElementById(t.map), !i)
239
+ async resolveMap(l, n, s = 0) {
240
+ if (t && t.map && l) {
241
+ nt(n, s);
242
+ let c;
243
+ if (Array.isArray(t.map) ? c = document.getElementById(t.map[s]) : c = document.getElementById(t.map), !c)
197
244
  throw new Error("Could not find rendering target for map: " + t.map);
198
- if (!(i instanceof HTMLCanvasElement))
245
+ if (!(c instanceof HTMLCanvasElement))
199
246
  throw new Error("Target for map is not a canvas: " + t.map);
200
- const l = new Y(i);
201
- if (n.style && l.style.setPredefinedStyle(n.style), await l.init(), await s(l, a, n), e)
202
- for (const c of n.layerRefs)
203
- e.set(c.dataRef, l);
204
- o && (o[u] = l), l.draw();
247
+ const u = new q(c);
248
+ n.style && u.style.setPredefinedStyle(n.style), await u.init(), await a(u, l, n);
249
+ for (const f of n.layerRefs)
250
+ e?.set(f.dataRef, u), i?.set(f.dataRef, B(f));
251
+ o && (o[s] = u), u.draw();
205
252
  }
206
253
  }
207
254
  };
208
255
  }
209
- function et(t) {
256
+ function yt(t) {
210
257
  return {
211
258
  scatter: "scatterplot",
212
259
  bar: "barchart",
@@ -217,229 +264,229 @@ function et(t) {
217
264
  heatmatrix: "heatmatrix"
218
265
  }[t];
219
266
  }
220
- function rt(t, e, r, o, s) {
267
+ function gt(t, e, r, o, i, a) {
221
268
  return {
222
- async resolvePlot(a, n) {
269
+ async resolvePlot(l, n) {
223
270
  if (!t || !t.plot) return;
224
- const u = document.getElementById(t.plot);
225
- if (!u) throw new Error(`Could not find plot target: ${t.plot}`);
226
- const i = a;
227
- if (!i) throw new Error("No data context available for plot.");
228
- const l = s?.get(n.dataRef) ?? await i.getLayer(n.dataRef), c = n.events ?? [], f = new H(u, {
229
- type: et(n.mark),
230
- collection: l,
271
+ const s = document.getElementById(t.plot);
272
+ if (!s) throw new Error(`Could not find plot target: ${t.plot}`);
273
+ const c = l;
274
+ if (!c) throw new Error("No data context available for plot.");
275
+ const u = i?.get(n.dataRef) ?? await c.getLayer(n.dataRef), f = n.events ?? [], p = new z(s, {
276
+ type: yt(n.mark),
277
+ collection: u,
231
278
  attributes: { axis: n.axis, ...n.color && { color: n.color } },
232
279
  labels: { axis: n.axis, title: n.title },
233
- events: c,
280
+ events: f,
234
281
  ...n.width && { width: n.width },
235
282
  ...n.height && { height: n.height },
236
283
  ...n.margins && { margins: n.margins },
237
284
  ...n.transform && { transform: n.transform }
238
285
  });
239
- if (r?.set(n.dataRef, f), n.mapRef && o?.set(n.dataRef, n.mapRef), n.mapRef && e) {
240
- const p = e.get(n.mapRef);
241
- if (p) {
242
- p.updateRenderInfo(n.mapRef, { isPick: !0 }), p.events.on(L.PICKING, ({ selection: m }) => {
243
- f.setSelection(m);
286
+ if (r?.set(n.dataRef, p), n.mapRef && o?.set(n.dataRef, n.mapRef), n.mapRef && e) {
287
+ const m = e.get(n.mapRef), d = a?.get(n.mapRef) ?? n.mapRef;
288
+ if (m) {
289
+ m.updateRenderInfo(d, { isPick: !0 }), m.events.on(P.PICKING, ({ selection: h }) => {
290
+ p.setSelection(h);
244
291
  });
245
- for (const m of c)
246
- f.events.on(m, ({ selection: d }) => {
247
- p.setHighlightedIds(n.mapRef, d);
292
+ for (const h of f)
293
+ p.events.on(h, ({ selection: y }) => {
294
+ m.setHighlightedIds(d, y);
248
295
  });
249
296
  }
250
297
  }
251
298
  }
252
299
  };
253
300
  }
254
- const D = 134217728, at = 4, ot = 32;
255
- function nt(t) {
301
+ const H = 134217728, _t = 4, Et = 32;
302
+ function bt(t) {
256
303
  return Array.isArray(t) ? t.join(`
257
304
  `) : t;
258
305
  }
259
306
  function E(t) {
260
307
  return !!t && typeof t == "object" && !Array.isArray(t) && typeof t.fromFeature == "object" && t.fromFeature !== null;
261
308
  }
262
- function A(t, e) {
309
+ function C(t, e) {
263
310
  return t instanceof Map ? t.get(e) : t[e];
264
311
  }
265
- function C(t, e) {
312
+ function L(t, e) {
266
313
  return e.split(".").reduce((r, o) => {
267
314
  if (!(r == null || typeof r != "object"))
268
315
  return r[o];
269
316
  }, t);
270
317
  }
271
- function j(t) {
318
+ function k(t) {
272
319
  const e = [];
273
320
  for (const r of [t.uniforms, t.uniformMatrices])
274
321
  for (const o of Object.values(r ?? {}))
275
322
  E(o) && e.push(o);
276
323
  return e;
277
324
  }
278
- function it(t) {
279
- return [.../* @__PURE__ */ new Set([t.dataRef, ...j(t).map((e) => e.fromFeature.layer)])];
325
+ function wt(t) {
326
+ return [.../* @__PURE__ */ new Set([t.dataRef, ...k(t).map((e) => e.fromFeature.layer)])];
280
327
  }
281
- function x(t) {
282
- for (const e of j(t)) {
328
+ function W(t) {
329
+ for (const e of k(t)) {
283
330
  const { iterate: r, layer: o } = e.fromFeature;
284
331
  if (r === "all" || r === "batched") return { mode: r, layer: o };
285
332
  }
286
333
  return null;
287
334
  }
288
- function U(t, e, r) {
289
- const o = t.fromFeature, s = r !== void 0 && o.iterate === "all" ? r : o.index ?? 0, a = A(e, o.layer)?.features?.[s];
290
- return a ? C(a, o.path) : void 0;
335
+ function X(t, e, r) {
336
+ const o = t.fromFeature, i = r !== void 0 && o.iterate === "all" ? r : o.index ?? 0, a = C(e, o.layer)?.features?.[i];
337
+ return a ? L(a, o.path) : void 0;
291
338
  }
292
- function N(t, e, r) {
339
+ function j(t, e, r) {
293
340
  if (!t) return;
294
341
  const o = {};
295
- for (const [s, a] of Object.entries(t)) {
342
+ for (const [i, a] of Object.entries(t)) {
296
343
  if (!E(a)) {
297
- o[s] = a;
344
+ o[i] = a;
298
345
  continue;
299
346
  }
300
- const n = Number(U(a, e, r) ?? NaN);
301
- Number.isFinite(n) ? o[s] = n : typeof a.default == "number" && (o[s] = a.default);
347
+ const l = Number(X(a, e, r) ?? NaN);
348
+ Number.isFinite(l) ? o[i] = l : typeof a.default == "number" && (o[i] = a.default);
302
349
  }
303
350
  return o;
304
351
  }
305
- function I(t, e, r) {
352
+ function x(t, e, r) {
306
353
  if (!t) return;
307
354
  const o = {};
308
- for (const [s, a] of Object.entries(t)) {
355
+ for (const [i, a] of Object.entries(t)) {
309
356
  if (!E(a)) {
310
- o[s] = a;
357
+ o[i] = a;
311
358
  continue;
312
359
  }
313
- const n = U(a, e, r), u = Array.isArray(n) ? n : Array.isArray(a.default) ? a.default : void 0;
314
- if (!u) continue;
315
- const i = a.cols ?? (Array.isArray(u[0]) ? u[0].length : 0);
316
- i > 0 ? o[s] = { data: u, cols: i } : console.warn(`[autk-grammar] uniform matrix "${s}" has no column count; entry dropped`);
360
+ const l = X(a, e, r), n = Array.isArray(l) ? l : Array.isArray(a.default) ? a.default : void 0;
361
+ if (!n) continue;
362
+ const s = a.cols ?? (Array.isArray(n[0]) ? n[0].length : 0);
363
+ s > 0 ? o[i] = { data: n, cols: s } : console.warn(`[autk-grammar] uniform matrix "${i}" has no column count; entry dropped`);
317
364
  }
318
365
  return o;
319
366
  }
320
- function st(t) {
367
+ function At(t) {
321
368
  return t != null && !(typeof t == "number" && !Number.isFinite(t));
322
369
  }
323
- function B(t) {
370
+ function U(t) {
324
371
  return E(t) && t.fromFeature.iterate === "batched";
325
372
  }
326
- function Q(t, e) {
327
- return Object.values(e ?? {}).some(B) ? ot : Object.values(t ?? {}).some(B) ? at : 0;
373
+ function J(t, e) {
374
+ return Object.values(e ?? {}).some(U) ? Et : Object.values(t ?? {}).some(U) ? _t : 0;
328
375
  }
329
- function lt(t, e, r = D) {
330
- const o = Q(t, e);
376
+ function Rt(t, e, r = H) {
377
+ const o = J(t, e);
331
378
  return o > 0 ? Math.floor(r / o) : Number.POSITIVE_INFINITY;
332
379
  }
333
- function ut(t, e, r, o = D) {
334
- const s = {}, a = {}, n = [];
335
- for (const i of [t, e])
336
- for (const l of Object.values(i ?? {}))
337
- E(l) && l.fromFeature.iterate === "batched" && l.fromFeature.required && n.push(l.fromFeature.path);
338
- if (n.length > 0) {
339
- const i = r.length;
340
- r = r.filter((l) => n.every((c) => st(C(l, c)))), r.length < i && console.info(`[autk-grammar] batched compute dropped ${i - r.length} feature(s) missing ${n.join(", ")}`);
380
+ function St(t, e, r, o = H) {
381
+ const i = {}, a = {}, l = [];
382
+ for (const s of [t, e])
383
+ for (const c of Object.values(s ?? {}))
384
+ E(c) && c.fromFeature.iterate === "batched" && c.fromFeature.required && l.push(c.fromFeature.path);
385
+ if (l.length > 0) {
386
+ const s = r.length;
387
+ r = r.filter((c) => l.every((u) => At(L(c, u)))), r.length < s && console.info(`[autk-grammar] batched compute dropped ${s - r.length} feature(s) missing ${l.join(", ")}`);
341
388
  }
342
- const u = lt(t, e, o);
343
- r.length > u && (console.warn(
344
- `[autk-grammar] batched compute capped at ${u} features (got ${r.length}): its largest packed array takes ${Q(t, e)} B per feature, and a storage buffer binding holds ${o} B`
345
- ), r = r.slice(0, u));
346
- for (const [i, l] of Object.entries(t ?? {}))
347
- if (E(l) && l.fromFeature.iterate === "batched") {
348
- const c = typeof l.default == "number" ? l.default : void 0;
349
- a[i] = r.map((f) => {
350
- const p = Number(C(f, l.fromFeature.path) ?? c);
389
+ const n = Rt(t, e, o);
390
+ r.length > n && (console.warn(
391
+ `[autk-grammar] batched compute capped at ${n} features (got ${r.length}): its largest packed array takes ${J(t, e)} B per feature, and a storage buffer binding holds ${o} B`
392
+ ), r = r.slice(0, n));
393
+ for (const [s, c] of Object.entries(t ?? {}))
394
+ if (E(c) && c.fromFeature.iterate === "batched") {
395
+ const u = typeof c.default == "number" ? c.default : void 0;
396
+ a[s] = r.map((f) => {
397
+ const p = Number(L(f, c.fromFeature.path) ?? u);
351
398
  return Number.isFinite(p) ? p : 0;
352
399
  });
353
- } else typeof l == "number" && (s[i] = l);
354
- for (const [i, l] of Object.entries(e ?? {})) {
355
- if (!E(l) || l.fromFeature.iterate !== "batched") continue;
356
- const c = [];
400
+ } else typeof c == "number" && (i[s] = c);
401
+ for (const [s, c] of Object.entries(e ?? {})) {
402
+ if (!E(c) || c.fromFeature.iterate !== "batched") continue;
403
+ const u = [];
357
404
  for (const f of r) {
358
- const p = C(f, l.fromFeature.path);
359
- let m = 1 / 0, d = 1 / 0, y = -1 / 0, h = -1 / 0;
405
+ const p = L(f, c.fromFeature.path);
406
+ let m = 1 / 0, d = 1 / 0, h = -1 / 0, y = -1 / 0;
360
407
  if (Array.isArray(p))
361
- for (const g of p) {
362
- if (!Array.isArray(g) || g.length < 2) continue;
363
- const R = Number(g[0]), b = Number(g[1]);
364
- !Number.isFinite(R) || !Number.isFinite(b) || (m = Math.min(m, R), d = Math.min(d, b), y = Math.max(y, R), h = Math.max(h, b));
408
+ for (const b of p) {
409
+ if (!Array.isArray(b) || b.length < 2) continue;
410
+ const w = Number(b[0]), _ = Number(b[1]);
411
+ !Number.isFinite(w) || !Number.isFinite(_) || (m = Math.min(m, w), d = Math.min(d, _), h = Math.max(h, w), y = Math.max(y, _));
365
412
  }
366
- Number.isFinite(m) || (m = 0, d = 0, y = 0, h = 0), c.push(m, d, y, d, y, h, m, h);
413
+ Number.isFinite(m) || (m = 0, d = 0, h = 0, y = 0), u.push(m, d, h, d, h, y, m, y);
367
414
  }
368
- a[i] = c;
415
+ a[s] = u;
369
416
  }
370
- return s.num_features = r.length, { uniforms: s, uniformArrays: a };
417
+ return i.num_features = r.length, { uniforms: i, uniformArrays: a };
371
418
  }
372
- function T(t, e, r) {
373
- const o = A(e, t.dataRef);
419
+ function $(t, e, r) {
420
+ const o = C(e, t.dataRef);
374
421
  if (!o) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
375
- const s = {
422
+ const i = {
376
423
  collection: o,
377
424
  variableMapping: t.attributes,
378
- wgslBody: nt(t.wglsFunction)
425
+ wgslBody: bt(t.wglsFunction)
379
426
  };
380
- t.attributeArrays && (s.attributeArrays = t.attributeArrays), t.attributeMatrices && (s.attributeMatrices = t.attributeMatrices), t.uniformArrays && (s.uniformArrays = t.uniformArrays), t.outputColumnName && (s.resultField = t.outputColumnName), t.outputColumns && (s.outputColumns = t.outputColumns);
381
- const a = x(t);
427
+ t.attributeArrays && (i.attributeArrays = t.attributeArrays), t.attributeMatrices && (i.attributeMatrices = t.attributeMatrices), t.uniformArrays && (i.uniformArrays = t.uniformArrays), t.outputColumnName && (i.resultField = t.outputColumnName), t.outputColumns && (i.outputColumns = t.outputColumns);
428
+ const a = W(t);
382
429
  if (a?.mode === "batched") {
383
- const l = A(e, a.layer)?.features ?? [], c = ut(t.uniforms, t.uniformMatrices, l), f = N(F(t.uniforms), e) ?? {}, p = I(F(t.uniformMatrices), e);
384
- return s.uniforms = { ...f, ...c.uniforms }, s.uniformArrays = { ...s.uniformArrays ?? {}, ...c.uniformArrays }, p && Object.keys(p).length > 0 && (s.uniformMatrices = p), s;
430
+ const c = C(e, a.layer)?.features ?? [], u = St(t.uniforms, t.uniformMatrices, c), f = j(Q(t.uniforms), e) ?? {}, p = x(Q(t.uniformMatrices), e);
431
+ return i.uniforms = { ...f, ...u.uniforms }, i.uniformArrays = { ...i.uniformArrays ?? {}, ...u.uniformArrays }, p && Object.keys(p).length > 0 && (i.uniformMatrices = p), i;
385
432
  }
386
- const n = a?.mode === "all" ? r : void 0, u = N(t.uniforms, e, n), i = I(t.uniformMatrices, e, n);
387
- return u && (s.uniforms = u), i && (s.uniformMatrices = i), s;
433
+ const l = a?.mode === "all" ? r : void 0, n = j(t.uniforms, e, l), s = x(t.uniformMatrices, e, l);
434
+ return n && (i.uniforms = n), s && (i.uniformMatrices = s), i;
388
435
  }
389
- function F(t) {
436
+ function Q(t) {
390
437
  if (t)
391
438
  return Object.fromEntries(Object.entries(t).filter(([, e]) => !(E(e) && e.fromFeature.iterate === "batched")));
392
439
  }
393
- function ft(t) {
440
+ function Mt(t) {
394
441
  return t.outputColumns ?? (t.outputColumnName ? [t.outputColumnName] : []);
395
442
  }
396
- async function ct(t, e, r) {
397
- const o = x(t);
398
- if (o?.mode !== "all") return r(T(t, e));
399
- const s = A(e, t.dataRef);
400
- if (!s) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
401
- const a = ft(t), n = structuredClone(s);
402
- for (const i of n.features) {
403
- const l = i.properties ??= {}, c = l.compute ??= {};
404
- for (const f of a) c[f] = 0;
443
+ async function Ct(t, e, r) {
444
+ const o = W(t);
445
+ if (o?.mode !== "all") return r($(t, e));
446
+ const i = C(e, t.dataRef);
447
+ if (!i) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
448
+ const a = Mt(t), l = structuredClone(i);
449
+ for (const s of l.features) {
450
+ const c = s.properties ??= {}, u = c.compute ??= {};
451
+ for (const f of a) u[f] = 0;
405
452
  }
406
- const u = A(e, o.layer)?.features?.length ?? 0;
407
- for (let i = 0; i < u; i++) {
408
- const l = await r({ ...T(t, e, i), collection: n });
409
- n.features.forEach((c, f) => {
410
- const p = c.properties?.compute, m = l.features[f]?.properties?.compute;
453
+ const n = C(e, o.layer)?.features?.length ?? 0;
454
+ for (let s = 0; s < n; s++) {
455
+ const c = await r({ ...$(t, e, s), collection: l });
456
+ l.features.forEach((u, f) => {
457
+ const p = u.properties?.compute, m = c.features[f]?.properties?.compute;
411
458
  if (!(!p || !m))
412
459
  for (const d of a) {
413
- const y = Number(m[d]);
414
- Number.isFinite(y) && (p[d] += y);
460
+ const h = Number(m[d]);
461
+ Number.isFinite(h) && (p[d] += h);
415
462
  }
416
463
  });
417
464
  }
418
- return n;
465
+ return l;
419
466
  }
420
- function pt(t) {
467
+ function It(t) {
421
468
  return {
422
469
  async resolveCompute(e, r) {
423
470
  if (e) {
424
471
  const o = {};
425
- for (const n of it(r)) {
426
- const u = t?.get(n);
427
- if (u) o[n] = u;
428
- else if (n === r.dataRef) o[n] = await e.getLayer(n);
472
+ for (const l of wt(r)) {
473
+ const n = t?.get(l);
474
+ if (n) o[l] = n;
475
+ else if (l === r.dataRef) o[l] = await e.getLayer(l);
429
476
  else
430
477
  try {
431
- o[n] = await e.getLayer(n);
478
+ o[l] = await e.getLayer(l);
432
479
  } catch {
433
- o[n] = void 0;
480
+ o[l] = void 0;
434
481
  }
435
482
  }
436
- const s = new V(), a = await ct(r, o, (n) => s.gpgpuPipeline(n));
483
+ const i = new tt(), a = await Ct(r, o, (l) => i.gpgpuPipeline(l));
437
484
  return t && t.set(r.dataRef, a), e;
438
485
  }
439
486
  }
440
487
  };
441
488
  }
442
- class mt {
489
+ class Lt {
443
490
  _listeners = /* @__PURE__ */ new Map();
444
491
  on(e, r) {
445
492
  this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
@@ -451,7 +498,7 @@ class mt {
451
498
  this._listeners.get(e)?.forEach((o) => o(r));
452
499
  }
453
500
  }
454
- class Et {
501
+ class Tt {
455
502
  dataAdapter;
456
503
  mapAdapter;
457
504
  plotAdapter;
@@ -460,14 +507,15 @@ class Et {
460
507
  _computeCache = /* @__PURE__ */ new Map();
461
508
  _data = {};
462
509
  _mapRegistry = /* @__PURE__ */ new Map();
510
+ _mapLayerIds = /* @__PURE__ */ new Map();
463
511
  _maps = [];
464
512
  _plotRegistry = /* @__PURE__ */ new Map();
465
513
  _fwdCleanups = [];
466
514
  _plotMapLinks = /* @__PURE__ */ new Map();
467
- interactions = new mt();
515
+ interactions = new Lt();
468
516
  constructor(e) {
469
517
  const r = /* @__PURE__ */ new Map();
470
- this.dataAdapter = K(e, r), this.mapAdapter = tt(e, this._mapRegistry, this._computeCache, this._maps), this.plotAdapter = rt(e, this._mapRegistry, this._plotRegistry, this._plotMapLinks, r), this.computeAdapter = pt(this._computeCache);
518
+ this.dataAdapter = at(e, r), this.mapAdapter = ht(e, this._mapRegistry, this._computeCache, this._maps, this._mapLayerIds), this.plotAdapter = gt(e, this._mapRegistry, this._plotRegistry, this._plotMapLinks, r, this._mapLayerIds), this.computeAdapter = It(this._computeCache);
471
519
  }
472
520
  /**
473
521
  * The coordinate reference system used internally by the autk workspace.
@@ -478,7 +526,7 @@ class Et {
478
526
  * instead of hard-coding a CRS string.
479
527
  */
480
528
  get workspaceCrs() {
481
- return O;
529
+ return V;
482
530
  }
483
531
  get data() {
484
532
  return this._data;
@@ -494,6 +542,19 @@ class Et {
494
542
  get maps() {
495
543
  return this._maps;
496
544
  }
545
+ /**
546
+ * The layer a map of the last {@link run} draws for a table, found by the table's name (a layer's `dataRef`):
547
+ * the map that draws it, and the layer's id in that map, which is its `title`, else its `dataRef`.
548
+ * `undefined` when no map draws the table. When several layers draw it, the last one.
549
+ *
550
+ * @example
551
+ * const layer = grammar.mapLayer('buildings');
552
+ * layer?.map.updateRenderInfo(layer.layerId, { opacity: 0.5 });
553
+ */
554
+ mapLayer(e) {
555
+ const r = this._mapRegistry.get(e);
556
+ return r ? { map: r, layerId: this._mapLayerIds.get(e) ?? e } : void 0;
557
+ }
497
558
  async run(e) {
498
559
  if (!this.dataAdapter)
499
560
  throw new Error("Database adapter not initialized. Please call the constructor first.");
@@ -503,7 +564,7 @@ class Et {
503
564
  throw new Error("Plot adapter not initialized. Please call the constructor first.");
504
565
  if (!this.computeAdapter)
505
566
  throw new Error("Compute adapter not initialized. Please call the constructor first.");
506
- this._mapRegistry.clear(), this._maps.length = 0, this._plotRegistry.clear(), this._plotMapLinks.clear(), this._computeCache.clear(), this.grammarEngine = k({
567
+ this._mapRegistry.clear(), this._mapLayerIds.clear(), this._maps.length = 0, this._plotRegistry.clear(), this._plotMapLinks.clear(), this._computeCache.clear(), this.grammarEngine = et({
507
568
  spec: e,
508
569
  adapters: {
509
570
  db: this.dataAdapter,
@@ -518,11 +579,11 @@ class Et {
518
579
  return;
519
580
  }
520
581
  const o = {};
521
- for (const s of r.getLayersMetadata())
522
- Object.defineProperty(o, s.name, {
582
+ for (const i of r.getLayersMetadata())
583
+ Object.defineProperty(o, i.name, {
523
584
  get: () => {
524
- const a = this._computeCache.get(s.name);
525
- return a ? Promise.resolve(a) : r.getLayer(s.name);
585
+ const a = this._computeCache.get(i.name);
586
+ return a ? Promise.resolve(a) : r.getLayer(i.name);
526
587
  },
527
588
  enumerable: !0,
528
589
  configurable: !0
@@ -530,22 +591,24 @@ class Et {
530
591
  this._data = o;
531
592
  }
532
593
  /**
533
- * Highlights features on the map layer identified by `layerId`.
594
+ * Highlights features on the map layer that draws the table `dataRef` (see {@link mapLayer}).
534
595
  * If that layer is linked to a plot via `mapRef`, the plot selection is updated too.
535
596
  */
536
597
  highlightOnMap(e, r) {
537
- this._mapRegistry.get(e)?.setHighlightedIds(e, r);
538
- for (const [o, s] of this._plotMapLinks)
539
- s === e && this._plotRegistry.get(o)?.setSelection(r);
598
+ const o = this.mapLayer(e);
599
+ o?.map.setHighlightedIds(o.layerId, r);
600
+ for (const [i, a] of this._plotMapLinks)
601
+ a === e && this._plotRegistry.get(i)?.setSelection(r);
540
602
  }
541
603
  /**
542
- * Clears highlighted features on the map layer identified by `layerId`.
604
+ * Clears highlighted features on the map layer that draws the table `dataRef` (see {@link mapLayer}).
543
605
  * If that layer is linked to a plot via `mapRef`, the plot selection is cleared too.
544
606
  */
545
607
  clearHighlightOnMap(e) {
546
- this._mapRegistry.get(e)?.clearHighlightedIds(e);
547
- for (const [r, o] of this._plotMapLinks)
548
- o === e && this._plotRegistry.get(r)?.setSelection([]);
608
+ const r = this.mapLayer(e);
609
+ r?.map.clearHighlightedIds(r.layerId);
610
+ for (const [o, i] of this._plotMapLinks)
611
+ i === e && this._plotRegistry.get(o)?.setSelection([]);
549
612
  }
550
613
  /**
551
614
  * Clears the selection on the plot identified by `plotId` (its dataRef).
@@ -553,8 +616,8 @@ class Et {
553
616
  */
554
617
  clearHighlightOnPlot(e) {
555
618
  this._plotRegistry.get(e)?.setSelection([]);
556
- const r = this._plotMapLinks.get(e);
557
- r && this._mapRegistry.get(r)?.clearHighlightedIds(r);
619
+ const r = this._plotMapLinks.get(e), o = r ? this.mapLayer(r) : void 0;
620
+ o?.map.clearHighlightedIds(o.layerId);
558
621
  }
559
622
  /**
560
623
  * Applies a selection to the plot identified by `plotId` (its dataRef).
@@ -562,8 +625,8 @@ class Et {
562
625
  */
563
626
  setPlotSelection(e, r) {
564
627
  this._plotRegistry.get(e)?.setSelection(r);
565
- const o = this._plotMapLinks.get(e);
566
- o && this._mapRegistry.get(o)?.setHighlightedIds(o, r);
628
+ const o = this._plotMapLinks.get(e), i = o ? this.mapLayer(o) : void 0;
629
+ i?.map.setHighlightedIds(i.layerId, r);
567
630
  }
568
631
  _rewireInteractions() {
569
632
  for (const r of this._fwdCleanups) r();
@@ -572,40 +635,40 @@ class Et {
572
635
  for (const [r, o] of this._mapRegistry) {
573
636
  if (e.has(o)) continue;
574
637
  e.add(o);
575
- const s = ({ selection: a }) => {
638
+ const i = ({ selection: a }) => {
576
639
  this.interactions.emit("map:picking", { layerId: r, selection: a });
577
640
  };
578
- o.events.on(L.PICKING, s), this._fwdCleanups.push(() => o.events.off(L.PICKING, s));
641
+ o.events.on(P.PICKING, i), this._fwdCleanups.push(() => o.events.off(P.PICKING, i));
579
642
  }
580
643
  for (const [r, o] of this._plotRegistry)
581
- for (const s of [w.CLICK, w.BRUSH, w.BRUSH_X, w.BRUSH_Y]) {
582
- const a = ({ selection: n }) => {
644
+ for (const i of [I.CLICK, I.BRUSH, I.BRUSH_X, I.BRUSH_Y]) {
645
+ const a = ({ selection: l }) => {
583
646
  this.interactions.emit("plot:selection", {
584
647
  plotId: r,
585
- event: s,
586
- selection: n
648
+ event: i,
649
+ selection: l
587
650
  });
588
651
  };
589
- o.events.on(s, a), this._fwdCleanups.push(() => o.events.off(s, a));
652
+ o.events.on(i, a), this._fwdCleanups.push(() => o.events.off(i, a));
590
653
  }
591
654
  }
592
655
  }
593
656
  export {
594
- Et as AutkGrammar,
595
- W as ColorMapInterpolator,
596
- mt as GrammarEventEmitter,
597
- G as NormalizationMode,
598
- D as STORAGE_BUFFER_BINDING_SIZE,
599
- ut as buildBatchedUniforms,
600
- it as computeLayerNames,
601
- k as createEngine,
602
- x as findIterateSource,
657
+ Tt as AutkGrammar,
658
+ rt as ColorMapInterpolator,
659
+ Lt as GrammarEventEmitter,
660
+ Y as NormalizationMode,
661
+ H as STORAGE_BUFFER_BINDING_SIZE,
662
+ St as buildBatchedUniforms,
663
+ wt as computeLayerNames,
664
+ et as createEngine,
665
+ W as findIterateSource,
603
666
  E as isFromFeature,
604
- nt as joinWgsl,
605
- lt as maxBatchedFeatures,
606
- T as resolveComputeParams,
607
- I as resolveUniformMatrices,
608
- N as resolveUniforms,
609
- ct as runCompute
667
+ bt as joinWgsl,
668
+ Rt as maxBatchedFeatures,
669
+ $ as resolveComputeParams,
670
+ x as resolveUniformMatrices,
671
+ j as resolveUniforms,
672
+ Ct as runCompute
610
673
  };
611
674
  //# sourceMappingURL=autk-grammar.js.map