@urban-toolkit/autk-grammar 4.4.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/dist/autk-grammar.js +350 -329
- 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/package.json +1 -1
package/dist/autk-grammar.js
CHANGED
|
@@ -1,146 +1,167 @@
|
|
|
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
|
-
async function
|
|
10
|
-
let
|
|
9
|
+
async function i() {
|
|
10
|
+
let a;
|
|
11
11
|
if (e.data)
|
|
12
|
-
for (const
|
|
13
|
-
|
|
12
|
+
for (const s of e.data)
|
|
13
|
+
a = await r.db.resolveSource(a, s);
|
|
14
14
|
if (e.compute)
|
|
15
|
-
for (const
|
|
16
|
-
|
|
15
|
+
for (const s of e.compute)
|
|
16
|
+
a = await r.compute.resolveCompute(a, 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 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
|
-
for (const
|
|
28
|
-
await r.plot.resolvePlot(
|
|
27
|
+
for (const s of e.plot)
|
|
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",
|
|
35
|
-
|
|
33
|
+
function n(a) {
|
|
34
|
+
return console.log("Spec to update", a), 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: n, destroy: l, get context() {
|
|
42
42
|
return o;
|
|
43
43
|
} };
|
|
44
44
|
}
|
|
45
|
-
var
|
|
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
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 = (s) => new Error(`OSM source "${t.outputTableName}": ${s}`);
|
|
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((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 [
|
|
56
|
-
if (Math.abs(
|
|
55
|
+
const [i, n, l, a] = e.bbox;
|
|
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
|
-
if (
|
|
61
|
-
throw r(`queryArea.bbox west (${
|
|
62
|
-
if (
|
|
63
|
-
throw r(`queryArea.bbox south (${
|
|
64
|
-
return { bbox: [
|
|
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 (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
68
|
return { ...r, queryArea: at(t), autoLoadLayers: { layers: e?.layers ?? [] } };
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
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;
|
|
89
|
+
}
|
|
90
|
+
function lt(t, e) {
|
|
91
|
+
function r(o, i) {
|
|
92
|
+
if (!i || !i.db)
|
|
73
93
|
return;
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
for (const
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
const n = document.getElementById(i.db);
|
|
95
|
+
if (n) {
|
|
96
|
+
const l = o.getTablesMetadata();
|
|
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
|
-
async resolveSource(o,
|
|
85
|
-
let
|
|
86
|
-
|
|
87
|
-
let { type:
|
|
88
|
-
switch (
|
|
104
|
+
async resolveSource(o, i) {
|
|
105
|
+
let n = o;
|
|
106
|
+
n || (n = new z(), await n.init());
|
|
107
|
+
let { type: l, ...a } = i;
|
|
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
|
|
97
|
-
let
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
const f = { ...
|
|
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
|
-
})() :
|
|
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
|
|
124
|
-
return await
|
|
125
|
-
tableJoinName:
|
|
126
|
-
near: { distance:
|
|
127
|
-
outputTableName:
|
|
128
|
-
grid:
|
|
129
|
-
...
|
|
130
|
-
}), r(
|
|
144
|
+
const s = a;
|
|
145
|
+
return await n.buildHeatmap({
|
|
146
|
+
tableJoinName: s.tableJoinName,
|
|
147
|
+
near: { distance: s.near.distance },
|
|
148
|
+
outputTableName: s.outputTableName,
|
|
149
|
+
grid: s.grid,
|
|
150
|
+
...s.groupBy && { groupBy: s.groupBy }
|
|
151
|
+
}), r(n, t), n;
|
|
131
152
|
}
|
|
132
153
|
case "join": {
|
|
133
|
-
const
|
|
134
|
-
if (await
|
|
135
|
-
tableRootName:
|
|
136
|
-
tableJoinName:
|
|
137
|
-
...
|
|
138
|
-
...
|
|
154
|
+
const s = a;
|
|
155
|
+
if (await n.spatialQuery({
|
|
156
|
+
tableRootName: s.tableRootName,
|
|
157
|
+
tableJoinName: s.tableJoinName,
|
|
158
|
+
...s.near && { near: s.near },
|
|
159
|
+
...s.groupBy && { groupBy: s.groupBy }
|
|
139
160
|
}), e) {
|
|
140
|
-
const
|
|
141
|
-
e.set(
|
|
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;
|
|
@@ -151,156 +172,156 @@ function it(t, e) {
|
|
|
151
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
|
|
158
|
-
if (r.has(
|
|
159
|
-
throw new Error(`Map ${e} draws two layers with the id "${
|
|
160
|
-
r.add(
|
|
178
|
+
const i = N(o);
|
|
179
|
+
if (r.has(i))
|
|
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.`);
|
|
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
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
|
|
194
|
+
function pt(t, e) {
|
|
174
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
|
|
201
|
+
function dt(t, e, r, o, i) {
|
|
181
202
|
if (v.isCategorical(e.interpolator)) return;
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
184
|
-
return o === !0 ?
|
|
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;
|
|
185
206
|
}
|
|
186
207
|
if (!t) return;
|
|
187
|
-
let
|
|
188
|
-
for (let
|
|
189
|
-
const
|
|
190
|
-
Number.isFinite(
|
|
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))));
|
|
191
212
|
}
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
194
|
-
const
|
|
195
|
-
return o === !0 ? [...
|
|
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;
|
|
196
217
|
}
|
|
197
|
-
function
|
|
218
|
+
function ht(t, e) {
|
|
198
219
|
if (!(e == null || v.isCategorical(t.interpolator)))
|
|
199
220
|
return [e[0], e[1]];
|
|
200
221
|
}
|
|
201
|
-
function
|
|
222
|
+
function yt(t) {
|
|
202
223
|
const e = t.colorMapRange;
|
|
203
224
|
if (e === void 0) return;
|
|
204
|
-
const r = (
|
|
205
|
-
if (!Array.isArray(e) || e.length !== 2 || !e.every((
|
|
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)))
|
|
206
227
|
throw r("colorMapRange must hold two numbers, [low, high].");
|
|
207
|
-
const [o,
|
|
208
|
-
if (o >=
|
|
209
|
-
throw r(`colorMapRange low (${o}) must be less than high (${
|
|
228
|
+
const [o, i] = e;
|
|
229
|
+
if (o >= i)
|
|
230
|
+
throw r(`colorMapRange low (${o}) must be less than high (${i}).`);
|
|
210
231
|
if (t.colorMapDomain !== void 0)
|
|
211
232
|
throw r("set colorMapRange or colorMapDomain, not both.");
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
throw r(`colorMapCenter (${
|
|
233
|
+
const n = t.colorMapCenter;
|
|
234
|
+
if (n != null && (n < o || n > i))
|
|
235
|
+
throw r(`colorMapCenter (${n}) must lie within colorMapRange [${o}, ${i}].`);
|
|
215
236
|
}
|
|
216
|
-
function
|
|
237
|
+
function gt(t, e) {
|
|
217
238
|
return e && e.length > 0 ? { type: M.USER, params: e } : t?.mode === H.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
|
|
218
239
|
type: M.PERCENTILE,
|
|
219
240
|
params: [t.lowerPercentile ?? 0, t.upperPercentile ?? 100]
|
|
220
241
|
} : { type: M.PERCENTILE } : { type: M.MIN_MAX };
|
|
221
242
|
}
|
|
222
|
-
function
|
|
243
|
+
function bt(t, e) {
|
|
223
244
|
return e.split(".").reduce((r, o) => {
|
|
224
245
|
if (!(r == null || typeof r != "object"))
|
|
225
246
|
return r[o];
|
|
226
247
|
}, t);
|
|
227
248
|
}
|
|
228
|
-
function
|
|
229
|
-
const o = e.split("."),
|
|
230
|
-
let
|
|
231
|
-
for (let
|
|
232
|
-
|
|
233
|
-
return
|
|
249
|
+
function _t(t, e, r) {
|
|
250
|
+
const o = e.split("."), i = { ...t };
|
|
251
|
+
let n = i;
|
|
252
|
+
for (let l = 0; l < o.length - 1; l++)
|
|
253
|
+
n[o[l]] = { ...n[o[l]] ?? {} }, n = n[o[l]];
|
|
254
|
+
return n[o[o.length - 1]] = r, i;
|
|
234
255
|
}
|
|
235
|
-
function
|
|
256
|
+
function Et(t, e) {
|
|
236
257
|
const o = t.features?.[0]?.properties?.bands ?? [];
|
|
237
|
-
return o.find((
|
|
238
|
-
}
|
|
239
|
-
function
|
|
240
|
-
async function
|
|
241
|
-
let
|
|
242
|
-
for (const
|
|
243
|
-
|
|
244
|
-
for (const
|
|
245
|
-
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 : {
|
|
246
267
|
...h,
|
|
247
268
|
features: (h.features ?? []).filter((g) => g.geometry != null)
|
|
248
|
-
}, w =
|
|
249
|
-
|
|
250
|
-
const A =
|
|
251
|
-
Object.keys(A).length > 0 &&
|
|
252
|
-
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;
|
|
253
274
|
let F = y, T = R;
|
|
254
|
-
if (
|
|
275
|
+
if (m && b && R?.length) {
|
|
255
276
|
const g = new Set(R);
|
|
256
277
|
F = {
|
|
257
278
|
...y,
|
|
258
279
|
features: y.features.map((_) => {
|
|
259
|
-
const
|
|
260
|
-
return P == null || !g.has(String(P)) ? { ..._, properties:
|
|
280
|
+
const $ = _.properties, P = bt($, m);
|
|
281
|
+
return P == null || !g.has(String(P)) ? { ..._, properties: _t($, m, b) } : _;
|
|
261
282
|
})
|
|
262
283
|
}, T = g.has(b) ? R : [...R, b];
|
|
263
284
|
}
|
|
264
|
-
const O =
|
|
265
|
-
O &&
|
|
266
|
-
const C =
|
|
267
|
-
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) {
|
|
268
289
|
const g = {
|
|
269
290
|
// urban-grammar ColorMapInterpolator values are string-compatible
|
|
270
291
|
// with autk-core ColorMapInterpolator at runtime
|
|
271
|
-
interpolator:
|
|
272
|
-
domainSpec:
|
|
292
|
+
interpolator: c.colorMapInterpolator ?? l.layerManager.searchByLayerId(p)?.layerRenderInfo.colormap.config.interpolator ?? et.SEQ_REDS,
|
|
293
|
+
domainSpec: gt(c.normalization, T)
|
|
273
294
|
};
|
|
274
295
|
let _;
|
|
275
|
-
x ? _ =
|
|
276
|
-
} else O &&
|
|
277
|
-
if (
|
|
278
|
-
const g =
|
|
279
|
-
|
|
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 });
|
|
297
|
+
} else O && l.updateColorMap(p, { colorMap: {} });
|
|
298
|
+
if (m && f !== "raster") {
|
|
299
|
+
const g = m.startsWith("properties.") ? m : `properties.${m}`;
|
|
300
|
+
l.updateThematic(p, { collection: F, property: g });
|
|
280
301
|
}
|
|
281
302
|
}
|
|
282
303
|
}
|
|
283
304
|
return {
|
|
284
|
-
async resolveMap(
|
|
285
|
-
if (t && t.map &&
|
|
286
|
-
|
|
287
|
-
for (const
|
|
288
|
-
|
|
289
|
-
let
|
|
290
|
-
if (Array.isArray(t.map) ?
|
|
305
|
+
async resolveMap(l, a, s = 0) {
|
|
306
|
+
if (t && t.map && l) {
|
|
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)
|
|
291
312
|
throw new Error("Could not find rendering target for map: " + t.map);
|
|
292
|
-
if (!(
|
|
313
|
+
if (!(u instanceof HTMLCanvasElement))
|
|
293
314
|
throw new Error("Target for map is not a canvas: " + t.map);
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
for (const
|
|
297
|
-
e?.set(
|
|
298
|
-
o && (o[
|
|
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();
|
|
299
320
|
}
|
|
300
321
|
}
|
|
301
322
|
};
|
|
302
323
|
}
|
|
303
|
-
function
|
|
324
|
+
function At(t) {
|
|
304
325
|
return {
|
|
305
326
|
scatter: "scatterplot",
|
|
306
327
|
bar: "barchart",
|
|
@@ -311,42 +332,42 @@ function Et(t) {
|
|
|
311
332
|
heatmatrix: "heatmatrix"
|
|
312
333
|
}[t];
|
|
313
334
|
}
|
|
314
|
-
function
|
|
335
|
+
function Rt(t, e, r, o, i, n) {
|
|
315
336
|
return {
|
|
316
|
-
async resolvePlot(
|
|
337
|
+
async resolvePlot(l, a) {
|
|
317
338
|
if (!t || !t.plot) return;
|
|
318
|
-
const
|
|
319
|
-
if (!
|
|
320
|
-
const
|
|
321
|
-
if (!
|
|
322
|
-
const
|
|
323
|
-
type:
|
|
324
|
-
collection:
|
|
325
|
-
attributes: { axis:
|
|
326
|
-
labels: { axis:
|
|
327
|
-
events:
|
|
328
|
-
...
|
|
329
|
-
...
|
|
330
|
-
...
|
|
331
|
-
...
|
|
339
|
+
const s = document.getElementById(t.plot);
|
|
340
|
+
if (!s) throw new Error(`Could not find plot target: ${t.plot}`);
|
|
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 }
|
|
332
353
|
});
|
|
333
|
-
if (r?.set(
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
336
|
-
|
|
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 }) => {
|
|
337
358
|
p.setSelection(h);
|
|
338
359
|
});
|
|
339
|
-
for (const h of
|
|
360
|
+
for (const h of d)
|
|
340
361
|
p.events.on(h, ({ selection: y }) => {
|
|
341
|
-
|
|
362
|
+
f.setHighlightedIds(m, y);
|
|
342
363
|
});
|
|
343
364
|
}
|
|
344
365
|
}
|
|
345
366
|
}
|
|
346
367
|
};
|
|
347
368
|
}
|
|
348
|
-
const
|
|
349
|
-
function
|
|
369
|
+
const q = 134217728, Mt = 4, St = 32;
|
|
370
|
+
function Ct(t) {
|
|
350
371
|
return Array.isArray(t) ? t.join(`
|
|
351
372
|
`) : t;
|
|
352
373
|
}
|
|
@@ -362,178 +383,178 @@ function L(t, e) {
|
|
|
362
383
|
return r[o];
|
|
363
384
|
}, t);
|
|
364
385
|
}
|
|
365
|
-
function
|
|
386
|
+
function W(t) {
|
|
366
387
|
const e = [];
|
|
367
388
|
for (const r of [t.uniforms, t.uniformMatrices])
|
|
368
389
|
for (const o of Object.values(r ?? {}))
|
|
369
390
|
E(o) && e.push(o);
|
|
370
391
|
return e;
|
|
371
392
|
}
|
|
372
|
-
function
|
|
373
|
-
return [.../* @__PURE__ */ new Set([t.dataRef, ...
|
|
393
|
+
function It(t) {
|
|
394
|
+
return [.../* @__PURE__ */ new Set([t.dataRef, ...W(t).map((e) => e.fromFeature.layer)])];
|
|
374
395
|
}
|
|
375
|
-
function
|
|
376
|
-
for (const e of
|
|
396
|
+
function X(t) {
|
|
397
|
+
for (const e of W(t)) {
|
|
377
398
|
const { iterate: r, layer: o } = e.fromFeature;
|
|
378
399
|
if (r === "all" || r === "batched") return { mode: r, layer: o };
|
|
379
400
|
}
|
|
380
401
|
return null;
|
|
381
402
|
}
|
|
382
|
-
function
|
|
383
|
-
const o = t.fromFeature,
|
|
384
|
-
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;
|
|
385
406
|
}
|
|
386
|
-
function
|
|
407
|
+
function j(t, e, r) {
|
|
387
408
|
if (!t) return;
|
|
388
409
|
const o = {};
|
|
389
|
-
for (const [
|
|
390
|
-
if (!E(
|
|
391
|
-
o[
|
|
410
|
+
for (const [i, n] of Object.entries(t)) {
|
|
411
|
+
if (!E(n)) {
|
|
412
|
+
o[i] = n;
|
|
392
413
|
continue;
|
|
393
414
|
}
|
|
394
|
-
const
|
|
395
|
-
Number.isFinite(
|
|
415
|
+
const l = Number(J(n, e, r) ?? NaN);
|
|
416
|
+
Number.isFinite(l) ? o[i] = l : typeof n.default == "number" && (o[i] = n.default);
|
|
396
417
|
}
|
|
397
418
|
return o;
|
|
398
419
|
}
|
|
399
|
-
function
|
|
420
|
+
function U(t, e, r) {
|
|
400
421
|
if (!t) return;
|
|
401
422
|
const o = {};
|
|
402
|
-
for (const [
|
|
403
|
-
if (!E(
|
|
404
|
-
o[
|
|
423
|
+
for (const [i, n] of Object.entries(t)) {
|
|
424
|
+
if (!E(n)) {
|
|
425
|
+
o[i] = n;
|
|
405
426
|
continue;
|
|
406
427
|
}
|
|
407
|
-
const
|
|
408
|
-
if (!
|
|
409
|
-
const
|
|
410
|
-
|
|
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`);
|
|
411
432
|
}
|
|
412
433
|
return o;
|
|
413
434
|
}
|
|
414
|
-
function
|
|
435
|
+
function Lt(t) {
|
|
415
436
|
return t != null && !(typeof t == "number" && !Number.isFinite(t));
|
|
416
437
|
}
|
|
417
|
-
function
|
|
438
|
+
function Q(t) {
|
|
418
439
|
return E(t) && t.fromFeature.iterate === "batched";
|
|
419
440
|
}
|
|
420
|
-
function
|
|
421
|
-
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;
|
|
422
443
|
}
|
|
423
|
-
function
|
|
424
|
-
const o =
|
|
444
|
+
function vt(t, e, r = q) {
|
|
445
|
+
const o = K(t, e);
|
|
425
446
|
return o > 0 ? Math.floor(r / o) : Number.POSITIVE_INFINITY;
|
|
426
447
|
}
|
|
427
|
-
function
|
|
428
|
-
const
|
|
429
|
-
for (const
|
|
430
|
-
for (const
|
|
431
|
-
E(
|
|
432
|
-
if (
|
|
433
|
-
const
|
|
434
|
-
r = r.filter((
|
|
448
|
+
function Nt(t, e, r, o = q) {
|
|
449
|
+
const i = {}, n = {}, l = [];
|
|
450
|
+
for (const s of [t, e])
|
|
451
|
+
for (const u of Object.values(s ?? {}))
|
|
452
|
+
E(u) && u.fromFeature.iterate === "batched" && u.fromFeature.required && l.push(u.fromFeature.path);
|
|
453
|
+
if (l.length > 0) {
|
|
454
|
+
const s = r.length;
|
|
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(", ")}`);
|
|
435
456
|
}
|
|
436
|
-
const
|
|
437
|
-
r.length >
|
|
438
|
-
`[autk-grammar] batched compute capped at ${
|
|
439
|
-
), r = r.slice(0,
|
|
440
|
-
for (const [
|
|
441
|
-
if (E(
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
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);
|
|
445
466
|
return Number.isFinite(p) ? p : 0;
|
|
446
467
|
});
|
|
447
|
-
} else typeof
|
|
448
|
-
for (const [
|
|
449
|
-
if (!E(
|
|
450
|
-
const
|
|
451
|
-
for (const
|
|
452
|
-
const p = L(
|
|
453
|
-
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;
|
|
454
475
|
if (Array.isArray(p))
|
|
455
476
|
for (const w of p) {
|
|
456
477
|
if (!Array.isArray(w) || w.length < 2) continue;
|
|
457
478
|
const A = Number(w[0]), b = Number(w[1]);
|
|
458
|
-
!Number.isFinite(A) || !Number.isFinite(b) || (
|
|
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));
|
|
459
480
|
}
|
|
460
|
-
Number.isFinite(
|
|
481
|
+
Number.isFinite(f) || (f = 0, m = 0, h = 0, y = 0), c.push(f, m, h, m, h, y, f, y);
|
|
461
482
|
}
|
|
462
|
-
|
|
483
|
+
n[s] = c;
|
|
463
484
|
}
|
|
464
|
-
return
|
|
485
|
+
return i.num_features = r.length, { uniforms: i, uniformArrays: n };
|
|
465
486
|
}
|
|
466
|
-
function
|
|
487
|
+
function Y(t, e, r) {
|
|
467
488
|
const o = S(e, t.dataRef);
|
|
468
489
|
if (!o) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
|
|
469
|
-
const
|
|
490
|
+
const i = {
|
|
470
491
|
collection: o,
|
|
471
492
|
variableMapping: t.attributes,
|
|
472
|
-
wgslBody:
|
|
493
|
+
wgslBody: Ct(t.wglsFunction)
|
|
473
494
|
};
|
|
474
|
-
t.attributeArrays && (
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
477
|
-
const
|
|
478
|
-
return
|
|
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);
|
|
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;
|
|
479
500
|
}
|
|
480
|
-
const
|
|
481
|
-
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;
|
|
482
503
|
}
|
|
483
504
|
function V(t) {
|
|
484
505
|
if (t)
|
|
485
506
|
return Object.fromEntries(Object.entries(t).filter(([, e]) => !(E(e) && e.fromFeature.iterate === "batched")));
|
|
486
507
|
}
|
|
487
|
-
function
|
|
508
|
+
function Pt(t) {
|
|
488
509
|
return t.outputColumns ?? (t.outputColumnName ? [t.outputColumnName] : []);
|
|
489
510
|
}
|
|
490
|
-
async function
|
|
491
|
-
const o =
|
|
492
|
-
if (o?.mode !== "all") return r(
|
|
493
|
-
const
|
|
494
|
-
if (!
|
|
495
|
-
const
|
|
496
|
-
for (const
|
|
497
|
-
const
|
|
498
|
-
for (const
|
|
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);
|
|
515
|
+
if (!i) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
|
|
516
|
+
const n = Pt(t), l = structuredClone(i);
|
|
517
|
+
for (const s of l.features) {
|
|
518
|
+
const u = s.properties ??= {}, c = u.compute ??= {};
|
|
519
|
+
for (const d of n) c[d] = 0;
|
|
499
520
|
}
|
|
500
|
-
const
|
|
501
|
-
for (let
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
const p =
|
|
505
|
-
if (!(!p || !
|
|
506
|
-
for (const
|
|
507
|
-
const h = Number(m
|
|
508
|
-
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);
|
|
509
530
|
}
|
|
510
531
|
});
|
|
511
532
|
}
|
|
512
|
-
return
|
|
533
|
+
return l;
|
|
513
534
|
}
|
|
514
|
-
function
|
|
535
|
+
function Ft(t) {
|
|
515
536
|
return {
|
|
516
537
|
async resolveCompute(e, r) {
|
|
517
538
|
if (e) {
|
|
518
539
|
const o = {};
|
|
519
|
-
for (const
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
522
|
-
else if (
|
|
540
|
+
for (const l of It(r)) {
|
|
541
|
+
const a = t?.get(l);
|
|
542
|
+
if (a) o[l] = a;
|
|
543
|
+
else if (l === r.dataRef) o[l] = await e.getLayer(l);
|
|
523
544
|
else
|
|
524
545
|
try {
|
|
525
|
-
o[
|
|
546
|
+
o[l] = await e.getLayer(l);
|
|
526
547
|
} catch {
|
|
527
|
-
o[
|
|
548
|
+
o[l] = void 0;
|
|
528
549
|
}
|
|
529
550
|
}
|
|
530
|
-
const
|
|
531
|
-
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;
|
|
532
553
|
}
|
|
533
554
|
}
|
|
534
555
|
};
|
|
535
556
|
}
|
|
536
|
-
class
|
|
557
|
+
class Tt {
|
|
537
558
|
_listeners = /* @__PURE__ */ new Map();
|
|
538
559
|
on(e, r) {
|
|
539
560
|
this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
|
|
@@ -545,7 +566,7 @@ class Bt {
|
|
|
545
566
|
this._listeners.get(e)?.forEach((o) => o(r));
|
|
546
567
|
}
|
|
547
568
|
}
|
|
548
|
-
class
|
|
569
|
+
class jt {
|
|
549
570
|
dataAdapter;
|
|
550
571
|
mapAdapter;
|
|
551
572
|
plotAdapter;
|
|
@@ -559,10 +580,10 @@ class $t {
|
|
|
559
580
|
_plotRegistry = /* @__PURE__ */ new Map();
|
|
560
581
|
_fwdCleanups = [];
|
|
561
582
|
_plotMapLinks = /* @__PURE__ */ new Map();
|
|
562
|
-
interactions = new
|
|
583
|
+
interactions = new Tt();
|
|
563
584
|
constructor(e) {
|
|
564
585
|
const r = /* @__PURE__ */ new Map();
|
|
565
|
-
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);
|
|
566
587
|
}
|
|
567
588
|
/**
|
|
568
589
|
* The coordinate reference system used internally by the autk workspace.
|
|
@@ -573,7 +594,7 @@ class $t {
|
|
|
573
594
|
* instead of hard-coding a CRS string.
|
|
574
595
|
*/
|
|
575
596
|
get workspaceCrs() {
|
|
576
|
-
return
|
|
597
|
+
return k;
|
|
577
598
|
}
|
|
578
599
|
get data() {
|
|
579
600
|
return this._data;
|
|
@@ -611,7 +632,7 @@ class $t {
|
|
|
611
632
|
throw new Error("Plot adapter not initialized. Please call the constructor first.");
|
|
612
633
|
if (!this.computeAdapter)
|
|
613
634
|
throw new Error("Compute adapter not initialized. Please call the constructor first.");
|
|
614
|
-
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({
|
|
615
636
|
spec: e,
|
|
616
637
|
adapters: {
|
|
617
638
|
db: this.dataAdapter,
|
|
@@ -626,11 +647,11 @@ class $t {
|
|
|
626
647
|
return;
|
|
627
648
|
}
|
|
628
649
|
const o = {};
|
|
629
|
-
for (const
|
|
630
|
-
Object.defineProperty(o,
|
|
650
|
+
for (const i of r.getLayersMetadata())
|
|
651
|
+
Object.defineProperty(o, i.name, {
|
|
631
652
|
get: () => {
|
|
632
|
-
const
|
|
633
|
-
return
|
|
653
|
+
const n = this._computeCache.get(i.name);
|
|
654
|
+
return n ? Promise.resolve(n) : r.getLayer(i.name);
|
|
634
655
|
},
|
|
635
656
|
enumerable: !0,
|
|
636
657
|
configurable: !0
|
|
@@ -644,8 +665,8 @@ class $t {
|
|
|
644
665
|
highlightOnMap(e, r) {
|
|
645
666
|
const o = this.mapLayer(e);
|
|
646
667
|
o?.map.setHighlightedIds(o.layerId, r);
|
|
647
|
-
for (const [
|
|
648
|
-
|
|
668
|
+
for (const [i, n] of this._plotMapLinks)
|
|
669
|
+
n === e && this._plotRegistry.get(i)?.setSelection(r);
|
|
649
670
|
}
|
|
650
671
|
/**
|
|
651
672
|
* Clears highlighted features on the map layer that draws the table `dataRef` (see {@link mapLayer}).
|
|
@@ -654,8 +675,8 @@ class $t {
|
|
|
654
675
|
clearHighlightOnMap(e) {
|
|
655
676
|
const r = this.mapLayer(e);
|
|
656
677
|
r?.map.clearHighlightedIds(r.layerId);
|
|
657
|
-
for (const [o,
|
|
658
|
-
|
|
678
|
+
for (const [o, i] of this._plotMapLinks)
|
|
679
|
+
i === e && this._plotRegistry.get(o)?.setSelection([]);
|
|
659
680
|
}
|
|
660
681
|
/**
|
|
661
682
|
* Clears the selection on the plot identified by `plotId` (its dataRef).
|
|
@@ -672,8 +693,8 @@ class $t {
|
|
|
672
693
|
*/
|
|
673
694
|
setPlotSelection(e, r) {
|
|
674
695
|
this._plotRegistry.get(e)?.setSelection(r);
|
|
675
|
-
const o = this._plotMapLinks.get(e),
|
|
676
|
-
|
|
696
|
+
const o = this._plotMapLinks.get(e), i = o ? this.mapLayer(o) : void 0;
|
|
697
|
+
i?.map.setHighlightedIds(i.layerId, r);
|
|
677
698
|
}
|
|
678
699
|
_rewireInteractions() {
|
|
679
700
|
for (const r of this._fwdCleanups) r();
|
|
@@ -682,40 +703,40 @@ class $t {
|
|
|
682
703
|
for (const [r, o] of this._mapRegistry) {
|
|
683
704
|
if (e.has(o)) continue;
|
|
684
705
|
e.add(o);
|
|
685
|
-
const
|
|
686
|
-
this.interactions.emit("map:picking", { layerId: r, selection:
|
|
706
|
+
const i = ({ selection: n }) => {
|
|
707
|
+
this.interactions.emit("map:picking", { layerId: r, selection: n });
|
|
687
708
|
};
|
|
688
|
-
o.events.on(B.PICKING,
|
|
709
|
+
o.events.on(B.PICKING, i), this._fwdCleanups.push(() => o.events.off(B.PICKING, i));
|
|
689
710
|
}
|
|
690
711
|
for (const [r, o] of this._plotRegistry)
|
|
691
|
-
for (const
|
|
692
|
-
const
|
|
712
|
+
for (const i of [I.CLICK, I.BRUSH, I.BRUSH_X, I.BRUSH_Y]) {
|
|
713
|
+
const n = ({ selection: l }) => {
|
|
693
714
|
this.interactions.emit("plot:selection", {
|
|
694
715
|
plotId: r,
|
|
695
|
-
event:
|
|
696
|
-
selection:
|
|
716
|
+
event: i,
|
|
717
|
+
selection: l
|
|
697
718
|
});
|
|
698
719
|
};
|
|
699
|
-
o.events.on(
|
|
720
|
+
o.events.on(i, n), this._fwdCleanups.push(() => o.events.off(i, n));
|
|
700
721
|
}
|
|
701
722
|
}
|
|
702
723
|
}
|
|
703
724
|
export {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
725
|
+
jt as AutkGrammar,
|
|
726
|
+
nt as ColorMapInterpolator,
|
|
727
|
+
Tt as GrammarEventEmitter,
|
|
707
728
|
H as NormalizationMode,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
729
|
+
q as STORAGE_BUFFER_BINDING_SIZE,
|
|
730
|
+
Nt as buildBatchedUniforms,
|
|
731
|
+
It as computeLayerNames,
|
|
732
|
+
ot as createEngine,
|
|
733
|
+
X as findIterateSource,
|
|
713
734
|
E as isFromFeature,
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
735
|
+
Ct as joinWgsl,
|
|
736
|
+
vt as maxBatchedFeatures,
|
|
737
|
+
Y as resolveComputeParams,
|
|
738
|
+
U as resolveUniformMatrices,
|
|
739
|
+
j as resolveUniforms,
|
|
740
|
+
Bt as runCompute
|
|
720
741
|
};
|
|
721
742
|
//# sourceMappingURL=autk-grammar.js.map
|