@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.
- package/README.md +41 -0
- package/build/autk-grammar-schema.json +141 -6
- package/dist/autk-grammar.js +342 -279
- package/dist/autk-grammar.js.map +1 -1
- package/dist/autk-grammar.umd.cjs +2 -2
- package/dist/autk-grammar.umd.cjs.map +1 -1
- package/dist/index.d.ts +117 -5
- package/package.json +1 -1
package/dist/autk-grammar.js
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import { AutkDb as
|
|
2
|
-
import { AutkMap as
|
|
3
|
-
import { AutkPlot as
|
|
4
|
-
import { ColorMapDomainStrategy as
|
|
5
|
-
import { AutkComputeEngine as
|
|
6
|
-
function
|
|
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
|
|
10
|
-
let
|
|
9
|
+
async function i() {
|
|
10
|
+
let n;
|
|
11
11
|
if (e.data)
|
|
12
|
-
for (const
|
|
13
|
-
|
|
12
|
+
for (const s of e.data)
|
|
13
|
+
n = await r.db.resolveSource(n, s);
|
|
14
14
|
if (e.compute)
|
|
15
|
-
for (const
|
|
16
|
-
|
|
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
|
|
20
|
-
let
|
|
21
|
-
await r.map.resolveMap(
|
|
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(
|
|
24
|
+
await r.map.resolveMap(n, e.map);
|
|
25
25
|
if (e.plot)
|
|
26
26
|
if (Array.isArray(e.plot))
|
|
27
|
-
for (const
|
|
28
|
-
await r.plot.resolvePlot(
|
|
27
|
+
for (const s of e.plot)
|
|
28
|
+
await r.plot.resolvePlot(n, s);
|
|
29
29
|
else
|
|
30
|
-
await r.plot.resolvePlot(
|
|
31
|
-
o =
|
|
30
|
+
await r.plot.resolvePlot(n, e.plot);
|
|
31
|
+
o = n;
|
|
32
32
|
}
|
|
33
|
-
function a(
|
|
34
|
-
return console.log("Spec to update",
|
|
35
|
-
|
|
33
|
+
function a(n) {
|
|
34
|
+
return console.log("Spec to update", n), new Promise((s) => {
|
|
35
|
+
s();
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function l() {
|
|
39
39
|
console.log("Function not implemented yet");
|
|
40
40
|
}
|
|
41
|
-
return { run:
|
|
41
|
+
return { run: i, updatedSpec: a, destroy: l, get context() {
|
|
42
42
|
return o;
|
|
43
43
|
} };
|
|
44
44
|
}
|
|
45
|
-
var
|
|
46
|
-
function
|
|
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
|
|
51
|
-
function r(o,
|
|
52
|
-
if (!
|
|
50
|
+
function at(t, e) {
|
|
51
|
+
function r(o, i) {
|
|
52
|
+
if (!i || !i.db)
|
|
53
53
|
return;
|
|
54
|
-
const a = document.getElementById(
|
|
54
|
+
const a = document.getElementById(i.db);
|
|
55
55
|
if (a) {
|
|
56
|
-
const
|
|
56
|
+
const l = o.getTablesMetadata();
|
|
57
57
|
a.innerHTML += "<ul>";
|
|
58
|
-
for (const
|
|
59
|
-
a.innerHTML += `<li>${
|
|
60
|
-
a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${
|
|
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,
|
|
64
|
+
async resolveSource(o, i) {
|
|
65
65
|
let a = o;
|
|
66
|
-
a || (a = new
|
|
67
|
-
let { type:
|
|
68
|
-
switch (
|
|
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(
|
|
70
|
+
return await a.loadOsm(ot(n)), r(a, t), a;
|
|
71
71
|
case "csv":
|
|
72
|
-
return await a.loadCsv(
|
|
72
|
+
return await a.loadCsv(n), r(a, t), a;
|
|
73
73
|
case "json":
|
|
74
|
-
return await a.loadJson(
|
|
74
|
+
return await a.loadJson(n), r(a, t), a;
|
|
75
75
|
case "geojson": {
|
|
76
|
-
const
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
const f = { ...
|
|
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
|
-
})() :
|
|
82
|
+
})() : s;
|
|
83
83
|
try {
|
|
84
|
-
await a.loadGeojson(
|
|
84
|
+
await a.loadGeojson(u);
|
|
85
85
|
} catch (f) {
|
|
86
|
-
const p =
|
|
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 "${
|
|
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(
|
|
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 "${
|
|
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
|
|
103
|
+
const s = n;
|
|
104
104
|
return await a.buildHeatmap({
|
|
105
|
-
tableJoinName:
|
|
106
|
-
near: { distance:
|
|
107
|
-
outputTableName:
|
|
108
|
-
grid:
|
|
109
|
-
...
|
|
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
|
|
113
|
+
const s = n;
|
|
114
114
|
if (await a.spatialQuery({
|
|
115
|
-
tableRootName:
|
|
116
|
-
tableJoinName:
|
|
117
|
-
...
|
|
118
|
-
...
|
|
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
|
|
121
|
-
e.set(
|
|
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
|
|
132
|
-
return
|
|
133
|
-
|
|
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:
|
|
176
|
+
} : { type: M.PERCENTILE } : { type: M.MIN_MAX };
|
|
136
177
|
}
|
|
137
|
-
function
|
|
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
|
|
144
|
-
const o = e.split("."),
|
|
145
|
-
let a =
|
|
146
|
-
for (let
|
|
147
|
-
a[o[
|
|
148
|
-
return a[o[o.length - 1]] = r,
|
|
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
|
|
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
|
|
155
|
-
async function
|
|
156
|
-
let
|
|
157
|
-
for (const
|
|
158
|
-
|
|
159
|
-
for (const
|
|
160
|
-
const
|
|
161
|
-
...
|
|
162
|
-
features: (
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
},
|
|
218
|
+
}, T = g.has(_) ? R : [...R, _];
|
|
176
219
|
}
|
|
177
|
-
|
|
178
|
-
|
|
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.
|
|
182
|
-
domainSpec:
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
188
|
-
|
|
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(
|
|
194
|
-
if (t && t.map &&
|
|
195
|
-
|
|
196
|
-
|
|
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 (!(
|
|
245
|
+
if (!(c instanceof HTMLCanvasElement))
|
|
199
246
|
throw new Error("Target for map is not a canvas: " + t.map);
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
o && (o[
|
|
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
|
|
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
|
|
267
|
+
function gt(t, e, r, o, i, a) {
|
|
221
268
|
return {
|
|
222
|
-
async resolvePlot(
|
|
269
|
+
async resolvePlot(l, n) {
|
|
223
270
|
if (!t || !t.plot) return;
|
|
224
|
-
const
|
|
225
|
-
if (!
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
228
|
-
const
|
|
229
|
-
type:
|
|
230
|
-
collection:
|
|
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:
|
|
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,
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
246
|
-
|
|
247
|
-
|
|
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
|
|
255
|
-
function
|
|
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
|
|
309
|
+
function C(t, e) {
|
|
263
310
|
return t instanceof Map ? t.get(e) : t[e];
|
|
264
311
|
}
|
|
265
|
-
function
|
|
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
|
|
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
|
|
279
|
-
return [.../* @__PURE__ */ new Set([t.dataRef, ...
|
|
325
|
+
function wt(t) {
|
|
326
|
+
return [.../* @__PURE__ */ new Set([t.dataRef, ...k(t).map((e) => e.fromFeature.layer)])];
|
|
280
327
|
}
|
|
281
|
-
function
|
|
282
|
-
for (const e of
|
|
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
|
|
289
|
-
const o = t.fromFeature,
|
|
290
|
-
return a ?
|
|
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
|
|
339
|
+
function j(t, e, r) {
|
|
293
340
|
if (!t) return;
|
|
294
341
|
const o = {};
|
|
295
|
-
for (const [
|
|
342
|
+
for (const [i, a] of Object.entries(t)) {
|
|
296
343
|
if (!E(a)) {
|
|
297
|
-
o[
|
|
344
|
+
o[i] = a;
|
|
298
345
|
continue;
|
|
299
346
|
}
|
|
300
|
-
const
|
|
301
|
-
Number.isFinite(
|
|
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
|
|
352
|
+
function x(t, e, r) {
|
|
306
353
|
if (!t) return;
|
|
307
354
|
const o = {};
|
|
308
|
-
for (const [
|
|
355
|
+
for (const [i, a] of Object.entries(t)) {
|
|
309
356
|
if (!E(a)) {
|
|
310
|
-
o[
|
|
357
|
+
o[i] = a;
|
|
311
358
|
continue;
|
|
312
359
|
}
|
|
313
|
-
const
|
|
314
|
-
if (!
|
|
315
|
-
const
|
|
316
|
-
|
|
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
|
|
367
|
+
function At(t) {
|
|
321
368
|
return t != null && !(typeof t == "number" && !Number.isFinite(t));
|
|
322
369
|
}
|
|
323
|
-
function
|
|
370
|
+
function U(t) {
|
|
324
371
|
return E(t) && t.fromFeature.iterate === "batched";
|
|
325
372
|
}
|
|
326
|
-
function
|
|
327
|
-
return Object.values(e ?? {}).some(
|
|
373
|
+
function J(t, e) {
|
|
374
|
+
return Object.values(e ?? {}).some(U) ? Et : Object.values(t ?? {}).some(U) ? _t : 0;
|
|
328
375
|
}
|
|
329
|
-
function
|
|
330
|
-
const o =
|
|
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
|
|
334
|
-
const
|
|
335
|
-
for (const
|
|
336
|
-
for (const
|
|
337
|
-
E(
|
|
338
|
-
if (
|
|
339
|
-
const
|
|
340
|
-
r = r.filter((
|
|
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
|
|
343
|
-
r.length >
|
|
344
|
-
`[autk-grammar] batched compute capped at ${
|
|
345
|
-
), r = r.slice(0,
|
|
346
|
-
for (const [
|
|
347
|
-
if (E(
|
|
348
|
-
const
|
|
349
|
-
a[
|
|
350
|
-
const p = Number(
|
|
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
|
|
354
|
-
for (const [
|
|
355
|
-
if (!E(
|
|
356
|
-
const
|
|
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 =
|
|
359
|
-
let m = 1 / 0, d = 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
|
|
362
|
-
if (!Array.isArray(
|
|
363
|
-
const
|
|
364
|
-
!Number.isFinite(
|
|
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,
|
|
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[
|
|
415
|
+
a[s] = u;
|
|
369
416
|
}
|
|
370
|
-
return
|
|
417
|
+
return i.num_features = r.length, { uniforms: i, uniformArrays: a };
|
|
371
418
|
}
|
|
372
|
-
function
|
|
373
|
-
const o =
|
|
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
|
|
422
|
+
const i = {
|
|
376
423
|
collection: o,
|
|
377
424
|
variableMapping: t.attributes,
|
|
378
|
-
wgslBody:
|
|
425
|
+
wgslBody: bt(t.wglsFunction)
|
|
379
426
|
};
|
|
380
|
-
t.attributeArrays && (
|
|
381
|
-
const a =
|
|
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
|
|
384
|
-
return
|
|
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
|
|
387
|
-
return
|
|
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
|
|
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
|
|
440
|
+
function Mt(t) {
|
|
394
441
|
return t.outputColumns ?? (t.outputColumnName ? [t.outputColumnName] : []);
|
|
395
442
|
}
|
|
396
|
-
async function
|
|
397
|
-
const o =
|
|
398
|
-
if (o?.mode !== "all") return r(
|
|
399
|
-
const
|
|
400
|
-
if (!
|
|
401
|
-
const a =
|
|
402
|
-
for (const
|
|
403
|
-
const
|
|
404
|
-
for (const f of a)
|
|
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
|
|
407
|
-
for (let
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
const p =
|
|
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
|
|
414
|
-
Number.isFinite(
|
|
460
|
+
const h = Number(m[d]);
|
|
461
|
+
Number.isFinite(h) && (p[d] += h);
|
|
415
462
|
}
|
|
416
463
|
});
|
|
417
464
|
}
|
|
418
|
-
return
|
|
465
|
+
return l;
|
|
419
466
|
}
|
|
420
|
-
function
|
|
467
|
+
function It(t) {
|
|
421
468
|
return {
|
|
422
469
|
async resolveCompute(e, r) {
|
|
423
470
|
if (e) {
|
|
424
471
|
const o = {};
|
|
425
|
-
for (const
|
|
426
|
-
const
|
|
427
|
-
if (
|
|
428
|
-
else if (
|
|
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[
|
|
478
|
+
o[l] = await e.getLayer(l);
|
|
432
479
|
} catch {
|
|
433
|
-
o[
|
|
480
|
+
o[l] = void 0;
|
|
434
481
|
}
|
|
435
482
|
}
|
|
436
|
-
const
|
|
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
|
|
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
|
|
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
|
|
515
|
+
interactions = new Lt();
|
|
468
516
|
constructor(e) {
|
|
469
517
|
const r = /* @__PURE__ */ new Map();
|
|
470
|
-
this.dataAdapter =
|
|
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
|
|
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 =
|
|
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
|
|
522
|
-
Object.defineProperty(o,
|
|
582
|
+
for (const i of r.getLayersMetadata())
|
|
583
|
+
Object.defineProperty(o, i.name, {
|
|
523
584
|
get: () => {
|
|
524
|
-
const a = this._computeCache.get(
|
|
525
|
-
return a ? Promise.resolve(a) : r.getLayer(
|
|
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
|
|
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.
|
|
538
|
-
|
|
539
|
-
|
|
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
|
|
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.
|
|
547
|
-
|
|
548
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
638
|
+
const i = ({ selection: a }) => {
|
|
576
639
|
this.interactions.emit("map:picking", { layerId: r, selection: a });
|
|
577
640
|
};
|
|
578
|
-
o.events.on(
|
|
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
|
|
582
|
-
const a = ({ selection:
|
|
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:
|
|
586
|
-
selection:
|
|
648
|
+
event: i,
|
|
649
|
+
selection: l
|
|
587
650
|
});
|
|
588
651
|
};
|
|
589
|
-
o.events.on(
|
|
652
|
+
o.events.on(i, a), this._fwdCleanups.push(() => o.events.off(i, a));
|
|
590
653
|
}
|
|
591
654
|
}
|
|
592
655
|
}
|
|
593
656
|
export {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
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
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
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
|