@urban-toolkit/autk-grammar 4.1.1 → 4.3.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,118 @@
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 J, DEFAULT_WORKSPACE_COORDINATE_FORMAT as V } from "@urban-toolkit/autk-db";
2
+ import { AutkMap as K, MapEvent as N } 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 S, ColorMap as P } 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
+ const { queryArea: e } = t;
48
+ if (e.bbox === void 0) return { geocodeArea: e.geocodeArea, areas: e.areas };
49
+ const r = (s) => new Error(`OSM source "${t.outputTableName}": ${s}`);
50
+ if (e.geocodeArea !== void 0 || e.areas !== void 0)
51
+ throw r("queryArea takes either bbox or geocodeArea with areas, not both.");
52
+ const o = e.bbox;
53
+ if (!Array.isArray(o) || o.length !== 4 || !o.every((s) => typeof s == "number" && Number.isFinite(s)))
54
+ throw r("queryArea.bbox must hold four numbers, [west, south, east, north] in degrees.");
55
+ const [i, a, l, n] = e.bbox;
56
+ if (Math.abs(i) > 180 || Math.abs(l) > 180)
57
+ throw r("queryArea.bbox west and east must be longitudes from -180 to 180.");
58
+ if (Math.abs(a) > 90 || Math.abs(n) > 90)
59
+ throw r("queryArea.bbox south and north must be latitudes from -90 to 90.");
60
+ if (i >= l)
61
+ throw r(`queryArea.bbox west (${i}) must be less than east (${l}); a box across the antimeridian is not supported.`);
62
+ if (a >= n)
63
+ throw r(`queryArea.bbox south (${a}) must be less than north (${n}).`);
64
+ return { bbox: [i, a, l, n] };
65
+ }
66
+ function at(t) {
47
67
  const { autoLoadLayers: e, ...r } = t;
48
- return { ...r, autoLoadLayers: { layers: e?.layers ?? [] } };
68
+ return { ...r, queryArea: ot(t), autoLoadLayers: { layers: e?.layers ?? [] } };
49
69
  }
50
- function K(t, e) {
51
- function r(o, s) {
52
- if (!s || !s.db)
70
+ function nt(t, e) {
71
+ function r(o, i) {
72
+ if (!i || !i.db)
53
73
  return;
54
- const a = document.getElementById(s.db);
74
+ const a = document.getElementById(i.db);
55
75
  if (a) {
56
- const n = o.getTablesMetadata();
76
+ const l = o.getTablesMetadata();
57
77
  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>`;
78
+ for (const n of l)
79
+ a.innerHTML += `<li>${n.name}: (${n.source}, ${n.type}) </li>`;
80
+ a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${l.length}</p>`;
61
81
  }
62
82
  }
63
83
  return {
64
- async resolveSource(o, s) {
84
+ async resolveSource(o, i) {
65
85
  let a = o;
66
- a || (a = new $(), await a.init());
67
- let { type: n, ...u } = s;
68
- switch (n) {
86
+ a || (a = new J(), await a.init());
87
+ let { type: l, ...n } = i;
88
+ switch (l) {
69
89
  case "osm":
70
- return await a.loadOsm(J(u)), r(a, t), a;
90
+ return await a.loadOsm(at(n)), r(a, t), a;
71
91
  case "csv":
72
- return await a.loadCsv(u), r(a, t), a;
92
+ return await a.loadCsv(n), r(a, t), a;
73
93
  case "json":
74
- return await a.loadJson(u), r(a, t), a;
94
+ return await a.loadJson(n), r(a, t), a;
75
95
  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 };
96
+ const s = n;
97
+ let c;
98
+ s.geojsonFileUrl ? c = await (await fetch(s.geojsonFileUrl)).json() : c = s.geojsonObject, e && c && e.set(s.outputTableName, c);
99
+ const u = c ? (() => {
100
+ const f = { ...s, geojsonObject: c };
81
101
  return delete f.geojsonFileUrl, f;
82
- })() : i;
102
+ })() : s;
83
103
  try {
84
- await a.loadGeojson(c);
104
+ await a.loadGeojson(u);
85
105
  } 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)";
106
+ const p = u.coordinateFormat ? `coordinateFormat is set to "${u.coordinateFormat}"` : "no coordinateFormat was specified — defaulting to EPSG:4326 (WGS84 per RFC 7946)";
87
107
  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.`
108
+ `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
109
  );
90
110
  }
91
111
  try {
92
- const f = await a.getBoundingBoxFromLayer(c.outputTableName), p = 25e6;
112
+ const f = await a.getBoundingBoxFromLayer(u.outputTableName), p = 25e6;
93
113
  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
114
  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.`
115
+ `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
116
  );
97
117
  } catch (f) {
98
118
  if (f instanceof Error && f.message.includes("bounding box after transform")) throw f;
@@ -100,25 +120,25 @@ function K(t, e) {
100
120
  return r(a, t), a;
101
121
  }
102
122
  case "heatmap": {
103
- const i = u;
123
+ const s = n;
104
124
  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 }
125
+ tableJoinName: s.tableJoinName,
126
+ near: { distance: s.near.distance },
127
+ outputTableName: s.outputTableName,
128
+ grid: s.grid,
129
+ ...s.groupBy && { groupBy: s.groupBy }
110
130
  }), r(a, t), a;
111
131
  }
112
132
  case "join": {
113
- const i = u;
133
+ const s = n;
114
134
  if (await a.spatialQuery({
115
- tableRootName: i.tableRootName,
116
- tableJoinName: i.tableJoinName,
117
- ...i.near && { near: i.near },
118
- ...i.groupBy && { groupBy: i.groupBy }
135
+ tableRootName: s.tableRootName,
136
+ tableJoinName: s.tableJoinName,
137
+ ...s.near && { near: s.near },
138
+ ...s.groupBy && { groupBy: s.groupBy }
119
139
  }), e) {
120
- const l = await a.getLayer(i.tableRootName);
121
- e.set(i.tableRootName, l);
140
+ const c = await a.getLayer(s.tableRootName);
141
+ e.set(s.tableRootName, c);
122
142
  }
123
143
  return r(a, t), a;
124
144
  }
@@ -128,85 +148,132 @@ function K(t, e) {
128
148
  }
129
149
  };
130
150
  }
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 ? {
151
+ function B(t) {
152
+ return typeof t.title == "string" && t.title !== "" ? t.title : t.dataRef;
153
+ }
154
+ function it(t, e) {
155
+ const r = /* @__PURE__ */ new Set();
156
+ for (const o of t.layerRefs) {
157
+ const i = B(o);
158
+ if (r.has(i))
159
+ 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.`);
160
+ r.add(i);
161
+ }
162
+ }
163
+ const st = /^#[0-9a-fA-F]{6}$/;
164
+ function D(t, e, r) {
165
+ if (!st.test(t))
166
+ throw new Error(`Layer "${r}": ${e} must be a color written #rrggbb, not "${t}".`);
167
+ return P.hexToRgb(t);
168
+ }
169
+ function lt(t, e) {
170
+ const r = {};
171
+ return t.color != null && (r.color = D(t.color, "color", e)), t.stroke === !1 ? r.showBorders = !1 : t.stroke != null && (r.strokeColor = D(t.stroke, "stroke", e)), t.width != null && (r.polylinesWidth = t.width), r;
172
+ }
173
+ function ut(t, e) {
174
+ 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;
175
+ }
176
+ function ct(t, e) {
177
+ const r = t.features?.[0]?.properties?.[e];
178
+ 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;
179
+ }
180
+ function ft(t, e, r, o) {
181
+ if (P.isCategorical(e.interpolator)) return;
182
+ let i = 0, a = 0;
183
+ for (let s = 0; s < t.length; s++) {
184
+ const c = t[s];
185
+ Number.isFinite(c) && (a++, r != null && (i = Math.max(i, Math.abs(c - r))));
186
+ }
187
+ const l = r != null && i > 0;
188
+ if (a === 0 || !l && o !== !0) return;
189
+ const n = l && r != null ? [r - i, r, r + i] : P.resolveDomainFromData(t, e);
190
+ return o === !0 ? [...n].reverse() : n;
191
+ }
192
+ function pt(t, e) {
193
+ return e && e.length > 0 ? { type: S.USER, params: e } : t?.mode === Y.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
133
194
  type: S.PERCENTILE,
134
195
  params: [t.lowerPercentile ?? 0, t.upperPercentile ?? 100]
135
196
  } : { type: S.PERCENTILE } : { type: S.MIN_MAX };
136
197
  }
137
- function q(t, e) {
198
+ function mt(t, e) {
138
199
  return e.split(".").reduce((r, o) => {
139
200
  if (!(r == null || typeof r != "object"))
140
201
  return r[o];
141
202
  }, t);
142
203
  }
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;
204
+ function dt(t, e, r) {
205
+ const o = e.split("."), i = { ...t };
206
+ let a = i;
207
+ for (let l = 0; l < o.length - 1; l++)
208
+ a[o[l]] = { ...a[o[l]] ?? {} }, a = a[o[l]];
209
+ return a[o[o.length - 1]] = r, i;
149
210
  }
150
- function Z(t, e) {
211
+ function ht(t, e) {
151
212
  const o = t.features?.[0]?.properties?.bands ?? [];
152
213
  return o.find((a) => a.id === e || a.label === e?.replace(/\./g, "_"))?.id ?? o[0]?.id ?? e ?? "";
153
214
  }
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;
215
+ function yt(t, e, r, o, i) {
216
+ async function a(l, n, s) {
217
+ let c = {};
218
+ for (const u of n.getTablesMetadata())
219
+ u.type !== void 0 && (c[u.name] = u.type);
220
+ for (const u of s.layerRefs) {
221
+ 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 : {
222
+ ...h,
223
+ features: (h.features ?? []).filter((g) => g.geometry != null)
224
+ }, E = m === "raster" ? ht(y, d) : "";
225
+ m === "raster" ? l.loadCollection(p, { collection: y, type: "raster", property: E }) : l.loadCollection(p, { collection: y, type: m }), u.opacity != null && l.updateRenderInfo(p, { opacity: u.opacity });
226
+ const A = lt(u, p);
227
+ Object.keys(A).length > 0 && l.updateRenderInfo(p, A), ut(u, m) && l.updateRenderInfo(p, { isColorMap: !0 }), u.isPick && l.updateRenderInfo(p, { isPick: !0 }), u.isSkip && l.updateRenderInfo(p, { isSkip: !0 });
228
+ const { catchAllCategory: b, colorMapDomain: R } = u;
229
+ let F = y, T = R;
230
+ if (d && b && R?.length) {
231
+ const g = new Set(R);
232
+ F = {
233
+ ...y,
234
+ features: y.features.map((w) => {
235
+ const M = w.properties, v = mt(M, d);
236
+ return v == null || !g.has(String(v)) ? { ...w, properties: dt(M, d, b) } : w;
174
237
  })
175
- }, b = _.has(h) ? g : [...g, h];
238
+ }, T = g.has(b) ? R : [...R, b];
176
239
  }
177
- if (l.colorMapInterpolator) {
178
- const _ = {
240
+ const O = m === "raster" && u.transferFunction != null;
241
+ O && l.layerManager.searchByLayerId(p)?.setTransferFunction?.(u.transferFunction);
242
+ const x = m === "raster" && (u.colorMapCenter != null || u.colorMapReverse === !0);
243
+ if (u.colorMapInterpolator || x) {
244
+ const g = {
179
245
  // urban-grammar ColorMapInterpolator values are string-compatible
180
246
  // 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: _ });
247
+ interpolator: u.colorMapInterpolator ?? l.layerManager.searchByLayerId(p)?.layerRenderInfo.colormap.config.interpolator ?? Z.SEQ_REDS,
248
+ domainSpec: pt(u.normalization, T)
249
+ }, w = x ? ct(y, E) : null, M = w ? ft(w, g, u.colorMapCenter, u.colorMapReverse) : void 0;
250
+ M && (g.domainSpec = { type: S.USER, params: M }), l.updateColorMap(p, { colorMap: g });
251
+ } else O && l.updateColorMap(p, { colorMap: {} });
252
+ if (d && m !== "raster") {
253
+ const g = d.startsWith("properties.") ? d : `properties.${d}`;
254
+ l.updateThematic(p, { collection: F, property: g });
189
255
  }
190
256
  }
191
257
  }
192
258
  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)
259
+ async resolveMap(l, n, s = 0) {
260
+ if (t && t.map && l) {
261
+ it(n, s);
262
+ let c;
263
+ if (Array.isArray(t.map) ? c = document.getElementById(t.map[s]) : c = document.getElementById(t.map), !c)
197
264
  throw new Error("Could not find rendering target for map: " + t.map);
198
- if (!(i instanceof HTMLCanvasElement))
265
+ if (!(c instanceof HTMLCanvasElement))
199
266
  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();
267
+ const u = new K(c);
268
+ n.style && u.style.setPredefinedStyle(n.style), await u.init(), await a(u, l, n);
269
+ for (const f of n.layerRefs)
270
+ e?.set(f.dataRef, u), i?.set(f.dataRef, B(f));
271
+ o && (o[s] = u), u.draw();
205
272
  }
206
273
  }
207
274
  };
208
275
  }
209
- function et(t) {
276
+ function gt(t) {
210
277
  return {
211
278
  scatter: "scatterplot",
212
279
  bar: "barchart",
@@ -217,229 +284,229 @@ function et(t) {
217
284
  heatmatrix: "heatmatrix"
218
285
  }[t];
219
286
  }
220
- function rt(t, e, r, o, s) {
287
+ function bt(t, e, r, o, i, a) {
221
288
  return {
222
- async resolvePlot(a, n) {
289
+ async resolvePlot(l, n) {
223
290
  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,
291
+ const s = document.getElementById(t.plot);
292
+ if (!s) throw new Error(`Could not find plot target: ${t.plot}`);
293
+ const c = l;
294
+ if (!c) throw new Error("No data context available for plot.");
295
+ const u = i?.get(n.dataRef) ?? await c.getLayer(n.dataRef), f = n.events ?? [], p = new z(s, {
296
+ type: gt(n.mark),
297
+ collection: u,
231
298
  attributes: { axis: n.axis, ...n.color && { color: n.color } },
232
299
  labels: { axis: n.axis, title: n.title },
233
- events: c,
300
+ events: f,
234
301
  ...n.width && { width: n.width },
235
302
  ...n.height && { height: n.height },
236
303
  ...n.margins && { margins: n.margins },
237
304
  ...n.transform && { transform: n.transform }
238
305
  });
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);
306
+ if (r?.set(n.dataRef, p), n.mapRef && o?.set(n.dataRef, n.mapRef), n.mapRef && e) {
307
+ const m = e.get(n.mapRef), d = a?.get(n.mapRef) ?? n.mapRef;
308
+ if (m) {
309
+ m.updateRenderInfo(d, { isPick: !0 }), m.events.on(N.PICKING, ({ selection: h }) => {
310
+ p.setSelection(h);
244
311
  });
245
- for (const m of c)
246
- f.events.on(m, ({ selection: d }) => {
247
- p.setHighlightedIds(n.mapRef, d);
312
+ for (const h of f)
313
+ p.events.on(h, ({ selection: y }) => {
314
+ m.setHighlightedIds(d, y);
248
315
  });
249
316
  }
250
317
  }
251
318
  }
252
319
  };
253
320
  }
254
- const D = 134217728, at = 4, ot = 32;
255
- function nt(t) {
321
+ const H = 134217728, _t = 4, Et = 32;
322
+ function At(t) {
256
323
  return Array.isArray(t) ? t.join(`
257
324
  `) : t;
258
325
  }
259
- function E(t) {
326
+ function _(t) {
260
327
  return !!t && typeof t == "object" && !Array.isArray(t) && typeof t.fromFeature == "object" && t.fromFeature !== null;
261
328
  }
262
- function A(t, e) {
329
+ function C(t, e) {
263
330
  return t instanceof Map ? t.get(e) : t[e];
264
331
  }
265
- function C(t, e) {
332
+ function L(t, e) {
266
333
  return e.split(".").reduce((r, o) => {
267
334
  if (!(r == null || typeof r != "object"))
268
335
  return r[o];
269
336
  }, t);
270
337
  }
271
- function j(t) {
338
+ function k(t) {
272
339
  const e = [];
273
340
  for (const r of [t.uniforms, t.uniformMatrices])
274
341
  for (const o of Object.values(r ?? {}))
275
- E(o) && e.push(o);
342
+ _(o) && e.push(o);
276
343
  return e;
277
344
  }
278
- function it(t) {
279
- return [.../* @__PURE__ */ new Set([t.dataRef, ...j(t).map((e) => e.fromFeature.layer)])];
345
+ function wt(t) {
346
+ return [.../* @__PURE__ */ new Set([t.dataRef, ...k(t).map((e) => e.fromFeature.layer)])];
280
347
  }
281
- function x(t) {
282
- for (const e of j(t)) {
348
+ function q(t) {
349
+ for (const e of k(t)) {
283
350
  const { iterate: r, layer: o } = e.fromFeature;
284
351
  if (r === "all" || r === "batched") return { mode: r, layer: o };
285
352
  }
286
353
  return null;
287
354
  }
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;
355
+ function W(t, e, r) {
356
+ const o = t.fromFeature, i = r !== void 0 && o.iterate === "all" ? r : o.index ?? 0, a = C(e, o.layer)?.features?.[i];
357
+ return a ? L(a, o.path) : void 0;
291
358
  }
292
- function N(t, e, r) {
359
+ function G(t, e, r) {
293
360
  if (!t) return;
294
361
  const o = {};
295
- for (const [s, a] of Object.entries(t)) {
296
- if (!E(a)) {
297
- o[s] = a;
362
+ for (const [i, a] of Object.entries(t)) {
363
+ if (!_(a)) {
364
+ o[i] = a;
298
365
  continue;
299
366
  }
300
- const n = Number(U(a, e, r) ?? NaN);
301
- Number.isFinite(n) ? o[s] = n : typeof a.default == "number" && (o[s] = a.default);
367
+ const l = Number(W(a, e, r) ?? NaN);
368
+ Number.isFinite(l) ? o[i] = l : typeof a.default == "number" && (o[i] = a.default);
302
369
  }
303
370
  return o;
304
371
  }
305
- function I(t, e, r) {
372
+ function $(t, e, r) {
306
373
  if (!t) return;
307
374
  const o = {};
308
- for (const [s, a] of Object.entries(t)) {
309
- if (!E(a)) {
310
- o[s] = a;
375
+ for (const [i, a] of Object.entries(t)) {
376
+ if (!_(a)) {
377
+ o[i] = a;
311
378
  continue;
312
379
  }
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`);
380
+ const l = W(a, e, r), n = Array.isArray(l) ? l : Array.isArray(a.default) ? a.default : void 0;
381
+ if (!n) continue;
382
+ const s = a.cols ?? (Array.isArray(n[0]) ? n[0].length : 0);
383
+ s > 0 ? o[i] = { data: n, cols: s } : console.warn(`[autk-grammar] uniform matrix "${i}" has no column count; entry dropped`);
317
384
  }
318
385
  return o;
319
386
  }
320
- function st(t) {
387
+ function Rt(t) {
321
388
  return t != null && !(typeof t == "number" && !Number.isFinite(t));
322
389
  }
323
- function B(t) {
324
- return E(t) && t.fromFeature.iterate === "batched";
390
+ function j(t) {
391
+ return _(t) && t.fromFeature.iterate === "batched";
325
392
  }
326
- function Q(t, e) {
327
- return Object.values(e ?? {}).some(B) ? ot : Object.values(t ?? {}).some(B) ? at : 0;
393
+ function X(t, e) {
394
+ return Object.values(e ?? {}).some(j) ? Et : Object.values(t ?? {}).some(j) ? _t : 0;
328
395
  }
329
- function lt(t, e, r = D) {
330
- const o = Q(t, e);
396
+ function Mt(t, e, r = H) {
397
+ const o = X(t, e);
331
398
  return o > 0 ? Math.floor(r / o) : Number.POSITIVE_INFINITY;
332
399
  }
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(", ")}`);
400
+ function St(t, e, r, o = H) {
401
+ const i = {}, a = {}, l = [];
402
+ for (const s of [t, e])
403
+ for (const c of Object.values(s ?? {}))
404
+ _(c) && c.fromFeature.iterate === "batched" && c.fromFeature.required && l.push(c.fromFeature.path);
405
+ if (l.length > 0) {
406
+ const s = r.length;
407
+ r = r.filter((c) => l.every((u) => Rt(L(c, u)))), r.length < s && console.info(`[autk-grammar] batched compute dropped ${s - r.length} feature(s) missing ${l.join(", ")}`);
341
408
  }
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);
409
+ const n = Mt(t, e, o);
410
+ r.length > n && (console.warn(
411
+ `[autk-grammar] batched compute capped at ${n} features (got ${r.length}): its largest packed array takes ${X(t, e)} B per feature, and a storage buffer binding holds ${o} B`
412
+ ), r = r.slice(0, n));
413
+ for (const [s, c] of Object.entries(t ?? {}))
414
+ if (_(c) && c.fromFeature.iterate === "batched") {
415
+ const u = typeof c.default == "number" ? c.default : void 0;
416
+ a[s] = r.map((f) => {
417
+ const p = Number(L(f, c.fromFeature.path) ?? u);
351
418
  return Number.isFinite(p) ? p : 0;
352
419
  });
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 = [];
420
+ } else typeof c == "number" && (i[s] = c);
421
+ for (const [s, c] of Object.entries(e ?? {})) {
422
+ if (!_(c) || c.fromFeature.iterate !== "batched") continue;
423
+ const u = [];
357
424
  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;
425
+ const p = L(f, c.fromFeature.path);
426
+ let m = 1 / 0, d = 1 / 0, h = -1 / 0, y = -1 / 0;
360
427
  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));
428
+ for (const E of p) {
429
+ if (!Array.isArray(E) || E.length < 2) continue;
430
+ const A = Number(E[0]), b = Number(E[1]);
431
+ !Number.isFinite(A) || !Number.isFinite(b) || (m = Math.min(m, A), d = Math.min(d, b), h = Math.max(h, A), y = Math.max(y, b));
365
432
  }
366
- Number.isFinite(m) || (m = 0, d = 0, y = 0, h = 0), c.push(m, d, y, d, y, h, m, h);
433
+ Number.isFinite(m) || (m = 0, d = 0, h = 0, y = 0), u.push(m, d, h, d, h, y, m, y);
367
434
  }
368
- a[i] = c;
435
+ a[s] = u;
369
436
  }
370
- return s.num_features = r.length, { uniforms: s, uniformArrays: a };
437
+ return i.num_features = r.length, { uniforms: i, uniformArrays: a };
371
438
  }
372
- function T(t, e, r) {
373
- const o = A(e, t.dataRef);
439
+ function U(t, e, r) {
440
+ const o = C(e, t.dataRef);
374
441
  if (!o) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
375
- const s = {
442
+ const i = {
376
443
  collection: o,
377
444
  variableMapping: t.attributes,
378
- wgslBody: nt(t.wglsFunction)
445
+ wgslBody: At(t.wglsFunction)
379
446
  };
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);
447
+ 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);
448
+ const a = q(t);
382
449
  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;
450
+ const c = C(e, a.layer)?.features ?? [], u = St(t.uniforms, t.uniformMatrices, c), f = G(Q(t.uniforms), e) ?? {}, p = $(Q(t.uniformMatrices), e);
451
+ return i.uniforms = { ...f, ...u.uniforms }, i.uniformArrays = { ...i.uniformArrays ?? {}, ...u.uniformArrays }, p && Object.keys(p).length > 0 && (i.uniformMatrices = p), i;
385
452
  }
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;
453
+ const l = a?.mode === "all" ? r : void 0, n = G(t.uniforms, e, l), s = $(t.uniformMatrices, e, l);
454
+ return n && (i.uniforms = n), s && (i.uniformMatrices = s), i;
388
455
  }
389
- function F(t) {
456
+ function Q(t) {
390
457
  if (t)
391
- return Object.fromEntries(Object.entries(t).filter(([, e]) => !(E(e) && e.fromFeature.iterate === "batched")));
458
+ return Object.fromEntries(Object.entries(t).filter(([, e]) => !(_(e) && e.fromFeature.iterate === "batched")));
392
459
  }
393
- function ft(t) {
460
+ function Ct(t) {
394
461
  return t.outputColumns ?? (t.outputColumnName ? [t.outputColumnName] : []);
395
462
  }
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;
463
+ async function It(t, e, r) {
464
+ const o = q(t);
465
+ if (o?.mode !== "all") return r(U(t, e));
466
+ const i = C(e, t.dataRef);
467
+ if (!i) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
468
+ const a = Ct(t), l = structuredClone(i);
469
+ for (const s of l.features) {
470
+ const c = s.properties ??= {}, u = c.compute ??= {};
471
+ for (const f of a) u[f] = 0;
405
472
  }
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;
473
+ const n = C(e, o.layer)?.features?.length ?? 0;
474
+ for (let s = 0; s < n; s++) {
475
+ const c = await r({ ...U(t, e, s), collection: l });
476
+ l.features.forEach((u, f) => {
477
+ const p = u.properties?.compute, m = c.features[f]?.properties?.compute;
411
478
  if (!(!p || !m))
412
479
  for (const d of a) {
413
- const y = Number(m[d]);
414
- Number.isFinite(y) && (p[d] += y);
480
+ const h = Number(m[d]);
481
+ Number.isFinite(h) && (p[d] += h);
415
482
  }
416
483
  });
417
484
  }
418
- return n;
485
+ return l;
419
486
  }
420
- function pt(t) {
487
+ function Lt(t) {
421
488
  return {
422
489
  async resolveCompute(e, r) {
423
490
  if (e) {
424
491
  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);
492
+ for (const l of wt(r)) {
493
+ const n = t?.get(l);
494
+ if (n) o[l] = n;
495
+ else if (l === r.dataRef) o[l] = await e.getLayer(l);
429
496
  else
430
497
  try {
431
- o[n] = await e.getLayer(n);
498
+ o[l] = await e.getLayer(l);
432
499
  } catch {
433
- o[n] = void 0;
500
+ o[l] = void 0;
434
501
  }
435
502
  }
436
- const s = new V(), a = await ct(r, o, (n) => s.gpgpuPipeline(n));
503
+ const i = new tt(), a = await It(r, o, (l) => i.gpgpuPipeline(l));
437
504
  return t && t.set(r.dataRef, a), e;
438
505
  }
439
506
  }
440
507
  };
441
508
  }
442
- class mt {
509
+ class vt {
443
510
  _listeners = /* @__PURE__ */ new Map();
444
511
  on(e, r) {
445
512
  this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
@@ -451,7 +518,7 @@ class mt {
451
518
  this._listeners.get(e)?.forEach((o) => o(r));
452
519
  }
453
520
  }
454
- class Et {
521
+ class Ot {
455
522
  dataAdapter;
456
523
  mapAdapter;
457
524
  plotAdapter;
@@ -460,14 +527,15 @@ class Et {
460
527
  _computeCache = /* @__PURE__ */ new Map();
461
528
  _data = {};
462
529
  _mapRegistry = /* @__PURE__ */ new Map();
530
+ _mapLayerIds = /* @__PURE__ */ new Map();
463
531
  _maps = [];
464
532
  _plotRegistry = /* @__PURE__ */ new Map();
465
533
  _fwdCleanups = [];
466
534
  _plotMapLinks = /* @__PURE__ */ new Map();
467
- interactions = new mt();
535
+ interactions = new vt();
468
536
  constructor(e) {
469
537
  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);
538
+ this.dataAdapter = nt(e, r), this.mapAdapter = yt(e, this._mapRegistry, this._computeCache, this._maps, this._mapLayerIds), this.plotAdapter = bt(e, this._mapRegistry, this._plotRegistry, this._plotMapLinks, r, this._mapLayerIds), this.computeAdapter = Lt(this._computeCache);
471
539
  }
472
540
  /**
473
541
  * The coordinate reference system used internally by the autk workspace.
@@ -478,7 +546,7 @@ class Et {
478
546
  * instead of hard-coding a CRS string.
479
547
  */
480
548
  get workspaceCrs() {
481
- return O;
549
+ return V;
482
550
  }
483
551
  get data() {
484
552
  return this._data;
@@ -494,6 +562,19 @@ class Et {
494
562
  get maps() {
495
563
  return this._maps;
496
564
  }
565
+ /**
566
+ * The layer a map of the last {@link run} draws for a table, found by the table's name (a layer's `dataRef`):
567
+ * the map that draws it, and the layer's id in that map, which is its `title`, else its `dataRef`.
568
+ * `undefined` when no map draws the table. When several layers draw it, the last one.
569
+ *
570
+ * @example
571
+ * const layer = grammar.mapLayer('buildings');
572
+ * layer?.map.updateRenderInfo(layer.layerId, { opacity: 0.5 });
573
+ */
574
+ mapLayer(e) {
575
+ const r = this._mapRegistry.get(e);
576
+ return r ? { map: r, layerId: this._mapLayerIds.get(e) ?? e } : void 0;
577
+ }
497
578
  async run(e) {
498
579
  if (!this.dataAdapter)
499
580
  throw new Error("Database adapter not initialized. Please call the constructor first.");
@@ -503,7 +584,7 @@ class Et {
503
584
  throw new Error("Plot adapter not initialized. Please call the constructor first.");
504
585
  if (!this.computeAdapter)
505
586
  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({
587
+ this._mapRegistry.clear(), this._mapLayerIds.clear(), this._maps.length = 0, this._plotRegistry.clear(), this._plotMapLinks.clear(), this._computeCache.clear(), this.grammarEngine = et({
507
588
  spec: e,
508
589
  adapters: {
509
590
  db: this.dataAdapter,
@@ -518,11 +599,11 @@ class Et {
518
599
  return;
519
600
  }
520
601
  const o = {};
521
- for (const s of r.getLayersMetadata())
522
- Object.defineProperty(o, s.name, {
602
+ for (const i of r.getLayersMetadata())
603
+ Object.defineProperty(o, i.name, {
523
604
  get: () => {
524
- const a = this._computeCache.get(s.name);
525
- return a ? Promise.resolve(a) : r.getLayer(s.name);
605
+ const a = this._computeCache.get(i.name);
606
+ return a ? Promise.resolve(a) : r.getLayer(i.name);
526
607
  },
527
608
  enumerable: !0,
528
609
  configurable: !0
@@ -530,22 +611,24 @@ class Et {
530
611
  this._data = o;
531
612
  }
532
613
  /**
533
- * Highlights features on the map layer identified by `layerId`.
614
+ * Highlights features on the map layer that draws the table `dataRef` (see {@link mapLayer}).
534
615
  * If that layer is linked to a plot via `mapRef`, the plot selection is updated too.
535
616
  */
536
617
  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);
618
+ const o = this.mapLayer(e);
619
+ o?.map.setHighlightedIds(o.layerId, r);
620
+ for (const [i, a] of this._plotMapLinks)
621
+ a === e && this._plotRegistry.get(i)?.setSelection(r);
540
622
  }
541
623
  /**
542
- * Clears highlighted features on the map layer identified by `layerId`.
624
+ * Clears highlighted features on the map layer that draws the table `dataRef` (see {@link mapLayer}).
543
625
  * If that layer is linked to a plot via `mapRef`, the plot selection is cleared too.
544
626
  */
545
627
  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([]);
628
+ const r = this.mapLayer(e);
629
+ r?.map.clearHighlightedIds(r.layerId);
630
+ for (const [o, i] of this._plotMapLinks)
631
+ i === e && this._plotRegistry.get(o)?.setSelection([]);
549
632
  }
550
633
  /**
551
634
  * Clears the selection on the plot identified by `plotId` (its dataRef).
@@ -553,8 +636,8 @@ class Et {
553
636
  */
554
637
  clearHighlightOnPlot(e) {
555
638
  this._plotRegistry.get(e)?.setSelection([]);
556
- const r = this._plotMapLinks.get(e);
557
- r && this._mapRegistry.get(r)?.clearHighlightedIds(r);
639
+ const r = this._plotMapLinks.get(e), o = r ? this.mapLayer(r) : void 0;
640
+ o?.map.clearHighlightedIds(o.layerId);
558
641
  }
559
642
  /**
560
643
  * Applies a selection to the plot identified by `plotId` (its dataRef).
@@ -562,8 +645,8 @@ class Et {
562
645
  */
563
646
  setPlotSelection(e, r) {
564
647
  this._plotRegistry.get(e)?.setSelection(r);
565
- const o = this._plotMapLinks.get(e);
566
- o && this._mapRegistry.get(o)?.setHighlightedIds(o, r);
648
+ const o = this._plotMapLinks.get(e), i = o ? this.mapLayer(o) : void 0;
649
+ i?.map.setHighlightedIds(i.layerId, r);
567
650
  }
568
651
  _rewireInteractions() {
569
652
  for (const r of this._fwdCleanups) r();
@@ -572,40 +655,40 @@ class Et {
572
655
  for (const [r, o] of this._mapRegistry) {
573
656
  if (e.has(o)) continue;
574
657
  e.add(o);
575
- const s = ({ selection: a }) => {
658
+ const i = ({ selection: a }) => {
576
659
  this.interactions.emit("map:picking", { layerId: r, selection: a });
577
660
  };
578
- o.events.on(L.PICKING, s), this._fwdCleanups.push(() => o.events.off(L.PICKING, s));
661
+ o.events.on(N.PICKING, i), this._fwdCleanups.push(() => o.events.off(N.PICKING, i));
579
662
  }
580
663
  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 }) => {
664
+ for (const i of [I.CLICK, I.BRUSH, I.BRUSH_X, I.BRUSH_Y]) {
665
+ const a = ({ selection: l }) => {
583
666
  this.interactions.emit("plot:selection", {
584
667
  plotId: r,
585
- event: s,
586
- selection: n
668
+ event: i,
669
+ selection: l
587
670
  });
588
671
  };
589
- o.events.on(s, a), this._fwdCleanups.push(() => o.events.off(s, a));
672
+ o.events.on(i, a), this._fwdCleanups.push(() => o.events.off(i, a));
590
673
  }
591
674
  }
592
675
  }
593
676
  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,
603
- 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
677
+ Ot as AutkGrammar,
678
+ rt as ColorMapInterpolator,
679
+ vt as GrammarEventEmitter,
680
+ Y as NormalizationMode,
681
+ H as STORAGE_BUFFER_BINDING_SIZE,
682
+ St as buildBatchedUniforms,
683
+ wt as computeLayerNames,
684
+ et as createEngine,
685
+ q as findIterateSource,
686
+ _ as isFromFeature,
687
+ At as joinWgsl,
688
+ Mt as maxBatchedFeatures,
689
+ U as resolveComputeParams,
690
+ $ as resolveUniformMatrices,
691
+ G as resolveUniforms,
692
+ It as runCompute
610
693
  };
611
694
  //# sourceMappingURL=autk-grammar.js.map