@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.
- package/README.md +57 -1
- package/build/autk-grammar-schema.json +170 -23
- package/dist/autk-grammar.js +368 -285
- 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 +148 -13
- package/package.json +6 -6
package/dist/autk-grammar.js
CHANGED
|
@@ -1,98 +1,118 @@
|
|
|
1
|
-
import { AutkDb as
|
|
2
|
-
import { AutkMap as
|
|
3
|
-
import { AutkPlot as
|
|
4
|
-
import { ColorMapDomainStrategy as S } from "@urban-toolkit/autk-core";
|
|
5
|
-
import { AutkComputeEngine as
|
|
6
|
-
function
|
|
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
|
|
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
|
+
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
|
|
51
|
-
function r(o,
|
|
52
|
-
if (!
|
|
70
|
+
function nt(t, e) {
|
|
71
|
+
function r(o, i) {
|
|
72
|
+
if (!i || !i.db)
|
|
53
73
|
return;
|
|
54
|
-
const a = document.getElementById(
|
|
74
|
+
const a = document.getElementById(i.db);
|
|
55
75
|
if (a) {
|
|
56
|
-
const
|
|
76
|
+
const l = o.getTablesMetadata();
|
|
57
77
|
a.innerHTML += "<ul>";
|
|
58
|
-
for (const
|
|
59
|
-
a.innerHTML += `<li>${
|
|
60
|
-
a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${
|
|
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,
|
|
84
|
+
async resolveSource(o, i) {
|
|
65
85
|
let a = o;
|
|
66
|
-
a || (a = new
|
|
67
|
-
let { type:
|
|
68
|
-
switch (
|
|
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(
|
|
90
|
+
return await a.loadOsm(at(n)), r(a, t), a;
|
|
71
91
|
case "csv":
|
|
72
|
-
return await a.loadCsv(
|
|
92
|
+
return await a.loadCsv(n), r(a, t), a;
|
|
73
93
|
case "json":
|
|
74
|
-
return await a.loadJson(
|
|
94
|
+
return await a.loadJson(n), r(a, t), a;
|
|
75
95
|
case "geojson": {
|
|
76
|
-
const
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
const f = { ...
|
|
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
|
-
})() :
|
|
102
|
+
})() : s;
|
|
83
103
|
try {
|
|
84
|
-
await a.loadGeojson(
|
|
104
|
+
await a.loadGeojson(u);
|
|
85
105
|
} catch (f) {
|
|
86
|
-
const p =
|
|
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 "${
|
|
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(
|
|
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 "${
|
|
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
|
|
123
|
+
const s = n;
|
|
104
124
|
return await a.buildHeatmap({
|
|
105
|
-
tableJoinName:
|
|
106
|
-
near: { distance:
|
|
107
|
-
outputTableName:
|
|
108
|
-
grid:
|
|
109
|
-
...
|
|
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
|
|
133
|
+
const s = n;
|
|
114
134
|
if (await a.spatialQuery({
|
|
115
|
-
tableRootName:
|
|
116
|
-
tableJoinName:
|
|
117
|
-
...
|
|
118
|
-
...
|
|
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
|
|
121
|
-
e.set(
|
|
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
|
|
132
|
-
return
|
|
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
|
|
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
|
|
144
|
-
const o = e.split("."),
|
|
145
|
-
let a =
|
|
146
|
-
for (let
|
|
147
|
-
a[o[
|
|
148
|
-
return a[o[o.length - 1]] = r,
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
},
|
|
238
|
+
}, T = g.has(b) ? R : [...R, b];
|
|
176
239
|
}
|
|
177
|
-
|
|
178
|
-
|
|
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.
|
|
182
|
-
domainSpec:
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
188
|
-
|
|
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(
|
|
194
|
-
if (t && t.map &&
|
|
195
|
-
|
|
196
|
-
|
|
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 (!(
|
|
265
|
+
if (!(c instanceof HTMLCanvasElement))
|
|
199
266
|
throw new Error("Target for map is not a canvas: " + t.map);
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
o && (o[
|
|
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
|
|
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
|
|
287
|
+
function bt(t, e, r, o, i, a) {
|
|
221
288
|
return {
|
|
222
|
-
async resolvePlot(
|
|
289
|
+
async resolvePlot(l, n) {
|
|
223
290
|
if (!t || !t.plot) return;
|
|
224
|
-
const
|
|
225
|
-
if (!
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
228
|
-
const
|
|
229
|
-
type:
|
|
230
|
-
collection:
|
|
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:
|
|
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,
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
246
|
-
|
|
247
|
-
|
|
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
|
|
255
|
-
function
|
|
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
|
|
326
|
+
function _(t) {
|
|
260
327
|
return !!t && typeof t == "object" && !Array.isArray(t) && typeof t.fromFeature == "object" && t.fromFeature !== null;
|
|
261
328
|
}
|
|
262
|
-
function
|
|
329
|
+
function C(t, e) {
|
|
263
330
|
return t instanceof Map ? t.get(e) : t[e];
|
|
264
331
|
}
|
|
265
|
-
function
|
|
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
|
|
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
|
-
|
|
342
|
+
_(o) && e.push(o);
|
|
276
343
|
return e;
|
|
277
344
|
}
|
|
278
|
-
function
|
|
279
|
-
return [.../* @__PURE__ */ new Set([t.dataRef, ...
|
|
345
|
+
function wt(t) {
|
|
346
|
+
return [.../* @__PURE__ */ new Set([t.dataRef, ...k(t).map((e) => e.fromFeature.layer)])];
|
|
280
347
|
}
|
|
281
|
-
function
|
|
282
|
-
for (const e of
|
|
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
|
|
289
|
-
const o = t.fromFeature,
|
|
290
|
-
return a ?
|
|
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
|
|
359
|
+
function G(t, e, r) {
|
|
293
360
|
if (!t) return;
|
|
294
361
|
const o = {};
|
|
295
|
-
for (const [
|
|
296
|
-
if (!
|
|
297
|
-
o[
|
|
362
|
+
for (const [i, a] of Object.entries(t)) {
|
|
363
|
+
if (!_(a)) {
|
|
364
|
+
o[i] = a;
|
|
298
365
|
continue;
|
|
299
366
|
}
|
|
300
|
-
const
|
|
301
|
-
Number.isFinite(
|
|
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
|
|
372
|
+
function $(t, e, r) {
|
|
306
373
|
if (!t) return;
|
|
307
374
|
const o = {};
|
|
308
|
-
for (const [
|
|
309
|
-
if (!
|
|
310
|
-
o[
|
|
375
|
+
for (const [i, a] of Object.entries(t)) {
|
|
376
|
+
if (!_(a)) {
|
|
377
|
+
o[i] = a;
|
|
311
378
|
continue;
|
|
312
379
|
}
|
|
313
|
-
const
|
|
314
|
-
if (!
|
|
315
|
-
const
|
|
316
|
-
|
|
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
|
|
387
|
+
function Rt(t) {
|
|
321
388
|
return t != null && !(typeof t == "number" && !Number.isFinite(t));
|
|
322
389
|
}
|
|
323
|
-
function
|
|
324
|
-
return
|
|
390
|
+
function j(t) {
|
|
391
|
+
return _(t) && t.fromFeature.iterate === "batched";
|
|
325
392
|
}
|
|
326
|
-
function
|
|
327
|
-
return Object.values(e ?? {}).some(
|
|
393
|
+
function X(t, e) {
|
|
394
|
+
return Object.values(e ?? {}).some(j) ? Et : Object.values(t ?? {}).some(j) ? _t : 0;
|
|
328
395
|
}
|
|
329
|
-
function
|
|
330
|
-
const o =
|
|
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
|
|
334
|
-
const
|
|
335
|
-
for (const
|
|
336
|
-
for (const
|
|
337
|
-
|
|
338
|
-
if (
|
|
339
|
-
const
|
|
340
|
-
r = r.filter((
|
|
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
|
|
343
|
-
r.length >
|
|
344
|
-
`[autk-grammar] batched compute capped at ${
|
|
345
|
-
), r = r.slice(0,
|
|
346
|
-
for (const [
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
a[
|
|
350
|
-
const p = Number(
|
|
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
|
|
354
|
-
for (const [
|
|
355
|
-
if (!
|
|
356
|
-
const
|
|
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 =
|
|
359
|
-
let m = 1 / 0, d = 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
|
|
362
|
-
if (!Array.isArray(
|
|
363
|
-
const
|
|
364
|
-
!Number.isFinite(
|
|
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,
|
|
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[
|
|
435
|
+
a[s] = u;
|
|
369
436
|
}
|
|
370
|
-
return
|
|
437
|
+
return i.num_features = r.length, { uniforms: i, uniformArrays: a };
|
|
371
438
|
}
|
|
372
|
-
function
|
|
373
|
-
const o =
|
|
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
|
|
442
|
+
const i = {
|
|
376
443
|
collection: o,
|
|
377
444
|
variableMapping: t.attributes,
|
|
378
|
-
wgslBody:
|
|
445
|
+
wgslBody: At(t.wglsFunction)
|
|
379
446
|
};
|
|
380
|
-
t.attributeArrays && (
|
|
381
|
-
const a =
|
|
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
|
|
384
|
-
return
|
|
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
|
|
387
|
-
return
|
|
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
|
|
456
|
+
function Q(t) {
|
|
390
457
|
if (t)
|
|
391
|
-
return Object.fromEntries(Object.entries(t).filter(([, e]) => !(
|
|
458
|
+
return Object.fromEntries(Object.entries(t).filter(([, e]) => !(_(e) && e.fromFeature.iterate === "batched")));
|
|
392
459
|
}
|
|
393
|
-
function
|
|
460
|
+
function Ct(t) {
|
|
394
461
|
return t.outputColumns ?? (t.outputColumnName ? [t.outputColumnName] : []);
|
|
395
462
|
}
|
|
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)
|
|
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
|
|
407
|
-
for (let
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
const p =
|
|
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
|
|
414
|
-
Number.isFinite(
|
|
480
|
+
const h = Number(m[d]);
|
|
481
|
+
Number.isFinite(h) && (p[d] += h);
|
|
415
482
|
}
|
|
416
483
|
});
|
|
417
484
|
}
|
|
418
|
-
return
|
|
485
|
+
return l;
|
|
419
486
|
}
|
|
420
|
-
function
|
|
487
|
+
function Lt(t) {
|
|
421
488
|
return {
|
|
422
489
|
async resolveCompute(e, r) {
|
|
423
490
|
if (e) {
|
|
424
491
|
const o = {};
|
|
425
|
-
for (const
|
|
426
|
-
const
|
|
427
|
-
if (
|
|
428
|
-
else if (
|
|
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[
|
|
498
|
+
o[l] = await e.getLayer(l);
|
|
432
499
|
} catch {
|
|
433
|
-
o[
|
|
500
|
+
o[l] = void 0;
|
|
434
501
|
}
|
|
435
502
|
}
|
|
436
|
-
const
|
|
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
|
|
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
|
|
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
|
|
535
|
+
interactions = new vt();
|
|
468
536
|
constructor(e) {
|
|
469
537
|
const r = /* @__PURE__ */ new Map();
|
|
470
|
-
this.dataAdapter =
|
|
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
|
|
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 =
|
|
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
|
|
522
|
-
Object.defineProperty(o,
|
|
602
|
+
for (const i of r.getLayersMetadata())
|
|
603
|
+
Object.defineProperty(o, i.name, {
|
|
523
604
|
get: () => {
|
|
524
|
-
const a = this._computeCache.get(
|
|
525
|
-
return a ? Promise.resolve(a) : r.getLayer(
|
|
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
|
|
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.
|
|
538
|
-
|
|
539
|
-
|
|
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
|
|
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.
|
|
547
|
-
|
|
548
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
658
|
+
const i = ({ selection: a }) => {
|
|
576
659
|
this.interactions.emit("map:picking", { layerId: r, selection: a });
|
|
577
660
|
};
|
|
578
|
-
o.events.on(
|
|
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
|
|
582
|
-
const a = ({ selection:
|
|
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:
|
|
586
|
-
selection:
|
|
668
|
+
event: i,
|
|
669
|
+
selection: l
|
|
587
670
|
});
|
|
588
671
|
};
|
|
589
|
-
o.events.on(
|
|
672
|
+
o.events.on(i, a), this._fwdCleanups.push(() => o.events.off(i, a));
|
|
590
673
|
}
|
|
591
674
|
}
|
|
592
675
|
}
|
|
593
676
|
export {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
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
|