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