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