@urban-toolkit/autk-grammar 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -8
- package/build/autk-grammar-schema.json +999 -4
- package/dist/autk-grammar.js +833 -597
- 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/data/autk-grammar-data.cjs +1 -1
- package/dist/data/autk-grammar-data.cjs.map +1 -1
- package/dist/data/autk-grammar-data.d.ts +172 -5
- package/dist/data/autk-grammar-data.js +220 -116
- package/dist/data/autk-grammar-data.js.map +1 -1
- package/dist/index.d.ts +315 -13
- package/package.json +1 -1
package/dist/autk-grammar.js
CHANGED
|
@@ -1,227 +1,290 @@
|
|
|
1
|
-
import { DEFAULT_WORKSPACE_NAME as
|
|
2
|
-
import { AutkMap as
|
|
3
|
-
import { AutkPlot as
|
|
4
|
-
import { ColorMapInterpolator as
|
|
5
|
-
import { AutkComputeEngine as
|
|
6
|
-
function
|
|
7
|
-
const { spec: e, adapters:
|
|
8
|
-
let
|
|
1
|
+
import { DEFAULT_WORKSPACE_NAME as G, isVectorTable as Dt, AutkDb as Gt, isRenderableTable as yt, DEFAULT_WORKSPACE_COORDINATE_FORMAT as Ut } from "@urban-toolkit/autk-db";
|
|
2
|
+
import { AutkMap as Qt, MapEvent as Y } from "@urban-toolkit/autk-map";
|
|
3
|
+
import { AutkPlot as Wt, PlotStyle as F, PlotEvent as x } from "@urban-toolkit/autk-plot";
|
|
4
|
+
import { ColorMapDomainStrategy as $, ColorMapInterpolator as gt, ColorMap as N, valueAtPath as Yt } from "@urban-toolkit/autk-core";
|
|
5
|
+
import { AutkComputeEngine as et } from "@urban-toolkit/autk-compute";
|
|
6
|
+
function Vt(t) {
|
|
7
|
+
const { spec: e, adapters: o } = t;
|
|
8
|
+
let r;
|
|
9
9
|
async function n() {
|
|
10
|
-
let
|
|
11
|
-
if (e.data)
|
|
12
|
-
for (const
|
|
13
|
-
|
|
10
|
+
let s;
|
|
11
|
+
if (e.workspaces?.length && o.db.resolveWorkspaces && (s = await o.db.resolveWorkspaces(s, e.workspaces)), e.data)
|
|
12
|
+
for (const i of e.data)
|
|
13
|
+
s = await o.db.resolveSource(s, i);
|
|
14
14
|
if (e.compute)
|
|
15
|
-
for (const
|
|
16
|
-
|
|
15
|
+
for (const i of e.compute)
|
|
16
|
+
s = await o.compute.resolveCompute(s, i);
|
|
17
17
|
if (e.map)
|
|
18
18
|
if (Array.isArray(e.map))
|
|
19
|
-
for (let
|
|
20
|
-
let u = e.map[
|
|
21
|
-
await
|
|
19
|
+
for (let i = 0; i < e.map.length; i++) {
|
|
20
|
+
let u = e.map[i];
|
|
21
|
+
await o.map.resolveMap(s, u, i);
|
|
22
22
|
}
|
|
23
23
|
else
|
|
24
|
-
await
|
|
24
|
+
await o.map.resolveMap(s, e.map);
|
|
25
25
|
if (e.plot)
|
|
26
26
|
if (Array.isArray(e.plot))
|
|
27
|
-
for (let
|
|
28
|
-
await
|
|
27
|
+
for (let i = 0; i < e.plot.length; i++)
|
|
28
|
+
await o.plot.resolvePlot(s, e.plot[i], i);
|
|
29
29
|
else
|
|
30
|
-
await
|
|
31
|
-
|
|
30
|
+
await o.plot.resolvePlot(s, e.plot);
|
|
31
|
+
r = s;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return console.log("Spec to update",
|
|
35
|
-
|
|
33
|
+
function l(s) {
|
|
34
|
+
return console.log("Spec to update", s), new Promise((i) => {
|
|
35
|
+
i();
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function a() {
|
|
39
39
|
console.log("Function not implemented yet");
|
|
40
40
|
}
|
|
41
|
-
return { run: n, updatedSpec:
|
|
42
|
-
return
|
|
41
|
+
return { run: n, updatedSpec: l, destroy: a, get context() {
|
|
42
|
+
return r;
|
|
43
43
|
} };
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function ot(t) {
|
|
46
46
|
return t === void 0 ? [] : Array.isArray(t) ? t : [t];
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const e = t.layout ?? {},
|
|
50
|
-
if (
|
|
51
|
-
throw new Error(`Layout type must be vertical, horizontal or grid, not ${JSON.stringify(
|
|
52
|
-
const
|
|
53
|
-
if (typeof
|
|
54
|
-
throw new Error(`Layout gap must be a number of pixels, 0 or more, not ${JSON.stringify(
|
|
48
|
+
function to(t) {
|
|
49
|
+
const e = t.layout ?? {}, o = e.type ?? "vertical";
|
|
50
|
+
if (o !== "vertical" && o !== "horizontal" && o !== "grid")
|
|
51
|
+
throw new Error(`Layout type must be vertical, horizontal or grid, not ${JSON.stringify(o)}.`);
|
|
52
|
+
const r = e.gap ?? 0;
|
|
53
|
+
if (typeof r != "number" || !Number.isFinite(r) || r < 0)
|
|
54
|
+
throw new Error(`Layout gap must be a number of pixels, 0 or more, not ${JSON.stringify(r)}.`);
|
|
55
55
|
const n = e.columns ?? 2;
|
|
56
56
|
if (!Number.isInteger(n) || n < 1)
|
|
57
57
|
throw new Error(`Layout columns must be a whole number, 1 or more, not ${JSON.stringify(n)}.`);
|
|
58
|
-
const
|
|
59
|
-
...
|
|
60
|
-
...
|
|
61
|
-
],
|
|
62
|
-
kind:
|
|
58
|
+
const l = [
|
|
59
|
+
...ot(t.map).map((i, u) => ({ kind: "map", index: u, id: i.id, key: i.id ?? u })),
|
|
60
|
+
...ot(t.plot).map((i, u) => ({ kind: "plot", index: u, id: i.id, key: i.id ?? i.dataRef }))
|
|
61
|
+
], a = o === "vertical" ? 1 : o === "horizontal" ? Math.max(l.length, 1) : n, s = l.map(({ kind: i, index: u, id: d, key: c }, f) => ({
|
|
62
|
+
kind: i,
|
|
63
63
|
index: u,
|
|
64
|
-
...
|
|
65
|
-
key:
|
|
66
|
-
row: Math.floor(
|
|
67
|
-
column:
|
|
64
|
+
...d !== void 0 && { id: d },
|
|
65
|
+
key: c,
|
|
66
|
+
row: Math.floor(f / a),
|
|
67
|
+
column: f % a
|
|
68
68
|
}));
|
|
69
|
-
return { type:
|
|
69
|
+
return { type: o, rows: Math.ceil(l.length / a), columns: a, gap: r, panes: s };
|
|
70
70
|
}
|
|
71
|
-
var
|
|
72
|
-
async function
|
|
73
|
-
const
|
|
74
|
-
t.getCurrentWorkspace() !==
|
|
71
|
+
var Ht = /* @__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))(Ht || {}), wt = /* @__PURE__ */ ((t) => (t.MIN_MAX = "minMax", t.PERCENTILE = "percentile", t))(wt || {});
|
|
72
|
+
async function P(t, e) {
|
|
73
|
+
const o = e ?? G;
|
|
74
|
+
t.getCurrentWorkspace() !== o && await t.setWorkspace(o);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
return t === void 0 || t ===
|
|
76
|
+
function b(t, e) {
|
|
77
|
+
return t === void 0 || t === G ? e : `${t}/${e}`;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
const bt = /* @__PURE__ */ new WeakMap();
|
|
80
|
+
function Jt(t, e) {
|
|
81
|
+
bt.set(t, e);
|
|
82
|
+
}
|
|
83
|
+
function qt(t, e) {
|
|
84
|
+
const o = t && bt.get(t);
|
|
85
|
+
return o !== void 0 && o.toUpperCase() === e.toUpperCase() ? t : void 0;
|
|
86
|
+
}
|
|
87
|
+
function Et(t) {
|
|
80
88
|
const e = /* @__PURE__ */ new Set();
|
|
81
|
-
for (const
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
return t.map((
|
|
85
|
-
if (
|
|
86
|
-
let
|
|
87
|
-
for (; e.has(JSON.stringify(
|
|
88
|
-
return
|
|
89
|
+
for (const r of t)
|
|
90
|
+
r?.id != null && e.add(JSON.stringify(r.id));
|
|
91
|
+
const o = /* @__PURE__ */ new Set();
|
|
92
|
+
return t.map((r, n) => {
|
|
93
|
+
if (r?.id != null) return r.id;
|
|
94
|
+
let l = `autk-feature-${n}`;
|
|
95
|
+
for (; e.has(JSON.stringify(l)) || o.has(JSON.stringify(l)); ) l = `${l}-generated`;
|
|
96
|
+
return o.add(JSON.stringify(l)), l;
|
|
89
97
|
});
|
|
90
98
|
}
|
|
91
|
-
function
|
|
99
|
+
function _t(t) {
|
|
92
100
|
const e = /* @__PURE__ */ new Map();
|
|
93
|
-
return
|
|
94
|
-
const
|
|
95
|
-
return e.set(
|
|
101
|
+
return Et(t).map((o) => {
|
|
102
|
+
const r = JSON.stringify(o), n = e.get(r) ?? 0;
|
|
103
|
+
return e.set(r, n + 1), n === 0 ? r : `${r} ${n}`;
|
|
96
104
|
});
|
|
97
105
|
}
|
|
98
|
-
const
|
|
99
|
-
function
|
|
100
|
-
let e =
|
|
101
|
-
return e || (e = /* @__PURE__ */ new Map(), t.forEach((
|
|
102
|
-
const n = e.get(
|
|
103
|
-
n ? n.push(
|
|
104
|
-
}),
|
|
105
|
-
}
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
for (const
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
for (const
|
|
106
|
+
const rt = /* @__PURE__ */ new WeakMap();
|
|
107
|
+
function Kt(t) {
|
|
108
|
+
let e = rt.get(t);
|
|
109
|
+
return e || (e = /* @__PURE__ */ new Map(), t.forEach((o, r) => {
|
|
110
|
+
const n = e.get(o);
|
|
111
|
+
n ? n.push(r) : e.set(o, [r]);
|
|
112
|
+
}), rt.set(t, e), e);
|
|
113
|
+
}
|
|
114
|
+
function D(t, e, o) {
|
|
115
|
+
const r = Kt(o), n = /* @__PURE__ */ new Set();
|
|
116
|
+
for (const l of t) {
|
|
117
|
+
const a = e[l];
|
|
118
|
+
if (a !== void 0)
|
|
119
|
+
for (const s of r.get(a) ?? []) n.add(s);
|
|
112
120
|
}
|
|
113
121
|
return [...n];
|
|
114
122
|
}
|
|
115
|
-
const
|
|
116
|
-
function
|
|
117
|
-
const e = t.features ?? [],
|
|
118
|
-
let
|
|
119
|
-
const n = e.map((
|
|
120
|
-
return
|
|
123
|
+
const zt = { type: "GeometryCollection", geometries: [] };
|
|
124
|
+
function Xt(t) {
|
|
125
|
+
const e = t.features ?? [], o = Et(e);
|
|
126
|
+
let r = !1;
|
|
127
|
+
const n = e.map((a, s) => a == null || a.id != null && a.geometry != null ? a : (r = !0, { ...a, id: o[s], geometry: a.geometry ?? zt })), l = e.findIndex((a) => a?.geometry != null);
|
|
128
|
+
return l > 0 && e[0] != null && e[0].geometry == null && ([n[0], n[l]] = [n[l], n[0]], r = !0), r ? { ...t, features: n } : t;
|
|
121
129
|
}
|
|
122
|
-
function
|
|
130
|
+
function Zt(t) {
|
|
123
131
|
const { queryArea: e } = t;
|
|
124
132
|
if (e.bbox === void 0) return { geocodeArea: e.geocodeArea, areas: e.areas };
|
|
125
|
-
const
|
|
133
|
+
const o = (i) => new Error(`OSM source "${t.outputTableName}": ${i}`);
|
|
126
134
|
if (e.geocodeArea !== void 0 || e.areas !== void 0)
|
|
127
|
-
throw
|
|
128
|
-
const
|
|
129
|
-
if (!Array.isArray(
|
|
130
|
-
throw
|
|
131
|
-
const [n, a, s
|
|
132
|
-
if (Math.abs(n) > 180 || Math.abs(
|
|
133
|
-
throw
|
|
134
|
-
if (Math.abs(
|
|
135
|
-
throw
|
|
136
|
-
if (n >=
|
|
137
|
-
throw
|
|
138
|
-
if (
|
|
139
|
-
throw
|
|
140
|
-
return { bbox: [n, a, s
|
|
141
|
-
}
|
|
142
|
-
function
|
|
143
|
-
const { autoLoadLayers: e, ...
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
135
|
+
throw o("queryArea takes either bbox or geocodeArea with areas, not both.");
|
|
136
|
+
const r = e.bbox;
|
|
137
|
+
if (!Array.isArray(r) || r.length !== 4 || !r.every((i) => typeof i == "number" && Number.isFinite(i)))
|
|
138
|
+
throw o("queryArea.bbox must hold four numbers, [west, south, east, north] in degrees.");
|
|
139
|
+
const [n, l, a, s] = e.bbox;
|
|
140
|
+
if (Math.abs(n) > 180 || Math.abs(a) > 180)
|
|
141
|
+
throw o("queryArea.bbox west and east must be longitudes from -180 to 180.");
|
|
142
|
+
if (Math.abs(l) > 90 || Math.abs(s) > 90)
|
|
143
|
+
throw o("queryArea.bbox south and north must be latitudes from -90 to 90.");
|
|
144
|
+
if (n >= a)
|
|
145
|
+
throw o(`queryArea.bbox west (${n}) must be less than east (${a}); a box across the antimeridian is not supported.`);
|
|
146
|
+
if (l >= s)
|
|
147
|
+
throw o(`queryArea.bbox south (${l}) must be less than north (${s}).`);
|
|
148
|
+
return { bbox: [n, l, a, s] };
|
|
149
|
+
}
|
|
150
|
+
function te(t) {
|
|
151
|
+
const { autoLoadLayers: e, ...o } = t;
|
|
152
|
+
if (t.pbfFileUrl !== void 0 && (t.tagSets?.length ?? 0) > 0)
|
|
153
|
+
throw new Error(`OSM source "${t.outputTableName}": tagSets are read from the Overpass API only, so a source with pbfFileUrl cannot take them.`);
|
|
154
|
+
return {
|
|
155
|
+
...o,
|
|
156
|
+
queryArea: Zt(t),
|
|
157
|
+
autoLoadLayers: {
|
|
158
|
+
layers: e?.layers ?? [],
|
|
159
|
+
...e?.coordinateFormat !== void 0 && { coordinateFormat: e.coordinateFormat }
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function nt(t) {
|
|
147
164
|
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.`;
|
|
148
165
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
166
|
+
function Q(t) {
|
|
167
|
+
return t === void 0 || t === G ? "the default workspace" : `the workspace "${t}"`;
|
|
168
|
+
}
|
|
169
|
+
function at(t) {
|
|
170
|
+
if (t != null)
|
|
171
|
+
return typeof t == "string" ? t : JSON.stringify(t);
|
|
172
|
+
}
|
|
173
|
+
async function ee(t, e, o, r) {
|
|
174
|
+
const n = /* @__PURE__ */ new Map();
|
|
175
|
+
for (const s of (await t.getLayer(e.name)).features) {
|
|
176
|
+
const i = at(s.properties?.[r]);
|
|
177
|
+
if (i !== void 0) {
|
|
178
|
+
if (s.id === void 0 || s.id === null)
|
|
179
|
+
throw new Error("its rows have no feature id to update them by.");
|
|
180
|
+
n.set(i, [...n.get(i) ?? [], s.id]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const l = o.features.flatMap((s) => {
|
|
184
|
+
const i = at(s.properties?.[r]);
|
|
185
|
+
return i === void 0 ? [] : (n.get(i) ?? []).map((u) => ({ ...s, id: u }));
|
|
186
|
+
}), a = e.columns.some((s) => s.name === "geojson_id") ? "geojson_id" : "id";
|
|
187
|
+
return { data: { ...o, features: l }, idColumn: a };
|
|
188
|
+
}
|
|
189
|
+
async function it(t) {
|
|
190
|
+
if (t) return t;
|
|
191
|
+
const e = new Gt();
|
|
192
|
+
return await e.init(), e;
|
|
193
|
+
}
|
|
194
|
+
function vt(t) {
|
|
195
|
+
let e = 1 / 0, o = 1 / 0, r = -1 / 0, n = -1 / 0;
|
|
196
|
+
const l = (s) => {
|
|
197
|
+
if (Array.isArray(s)) {
|
|
198
|
+
if (typeof s[0] == "number") {
|
|
199
|
+
const [i, u] = s;
|
|
200
|
+
i < e && (e = i), i > r && (r = i), u < o && (o = u), u > n && (n = u);
|
|
156
201
|
return;
|
|
157
202
|
}
|
|
158
|
-
for (const
|
|
203
|
+
for (const i of s) l(i);
|
|
159
204
|
}
|
|
160
|
-
},
|
|
161
|
-
|
|
205
|
+
}, a = (s) => {
|
|
206
|
+
s && (s.type === "GeometryCollection" ? s.geometries.forEach(a) : l(s.coordinates));
|
|
162
207
|
};
|
|
163
|
-
for (const
|
|
164
|
-
return e <=
|
|
208
|
+
for (const s of t.features ?? []) a(s?.geometry);
|
|
209
|
+
return e <= r ? [e, o, r, n] : void 0;
|
|
165
210
|
}
|
|
166
|
-
function
|
|
167
|
-
function
|
|
168
|
-
if (!
|
|
211
|
+
function oe(t, e) {
|
|
212
|
+
function o(n, l) {
|
|
213
|
+
if (!l || !l.db)
|
|
169
214
|
return;
|
|
170
|
-
const a = document.getElementById(
|
|
215
|
+
const a = document.getElementById(l.db);
|
|
171
216
|
if (a) {
|
|
172
|
-
const s =
|
|
217
|
+
const s = n.getTablesMetadata();
|
|
173
218
|
a.innerHTML += "<ul>";
|
|
174
219
|
for (const i of s)
|
|
175
220
|
a.innerHTML += `<li>${i.name}: (${i.source}, ${i.type}) </li>`;
|
|
176
221
|
a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${s.length}</p>`;
|
|
177
222
|
}
|
|
178
223
|
}
|
|
224
|
+
async function r(n, l, a) {
|
|
225
|
+
if (!e) return;
|
|
226
|
+
const s = b(l, a), i = n.getTablesMetadata().find((u) => u.name === a);
|
|
227
|
+
i && yt(i) ? e.set(s, await n.getLayer(a)) : e.delete(s);
|
|
228
|
+
}
|
|
179
229
|
return {
|
|
180
|
-
async
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
230
|
+
async resolveWorkspaces(n, l) {
|
|
231
|
+
const a = await it(n), s = /* @__PURE__ */ new Set();
|
|
232
|
+
for (const { name: i, coordinateFormat: u, precisionGrid: d } of l) {
|
|
233
|
+
const c = i ?? G;
|
|
234
|
+
if (s.has(c))
|
|
235
|
+
throw new Error(`workspaces sets ${Q(i)} twice; give each workspace one entry.`);
|
|
236
|
+
s.add(c);
|
|
237
|
+
try {
|
|
238
|
+
await a.setWorkspace(c, { coordinateFormat: u, precisionGrid: d });
|
|
239
|
+
} catch (f) {
|
|
240
|
+
throw new Error(`workspaces, ${Q(i)}: ${f instanceof Error ? f.message : String(f)}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return await P(a), a;
|
|
244
|
+
},
|
|
245
|
+
async resolveSource(n, l) {
|
|
246
|
+
const a = await it(n), { workspace: s } = l;
|
|
247
|
+
await P(a, s);
|
|
248
|
+
let { type: i, workspace: u, ...d } = l;
|
|
186
249
|
switch (i) {
|
|
187
250
|
case "osm":
|
|
188
|
-
return await a.loadOsm(
|
|
251
|
+
return await a.loadOsm(te(d)), o(a, t), a;
|
|
189
252
|
case "csv":
|
|
190
|
-
return await a.loadCsv(
|
|
253
|
+
return await a.loadCsv(d), o(a, t), a;
|
|
191
254
|
case "json":
|
|
192
|
-
return await a.loadJson(
|
|
255
|
+
return await a.loadJson(d), o(a, t), a;
|
|
193
256
|
case "geojson": {
|
|
194
|
-
const c =
|
|
257
|
+
const c = d;
|
|
195
258
|
let f;
|
|
196
|
-
c.geojsonFileUrl ? f = await (await fetch(c.geojsonFileUrl)).json() : f = c.geojsonObject, e && f && e.set(
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
return delete
|
|
200
|
-
})() : c,
|
|
201
|
-
if (
|
|
259
|
+
c.geojsonFileUrl ? f = await (await fetch(c.geojsonFileUrl)).json() : f = c.geojsonObject, e && f && (e.set(b(s, c.outputTableName), f), Jt(f, c.coordinateFormat ?? "EPSG:4326"));
|
|
260
|
+
const m = f ? (() => {
|
|
261
|
+
const p = { ...c, geojsonObject: Xt(f) };
|
|
262
|
+
return delete p.geojsonFileUrl, p;
|
|
263
|
+
})() : c, h = /^EPSG:4326$/i.test(m.coordinateFormat ?? "EPSG:4326"), y = f && h ? vt(f) : void 0;
|
|
264
|
+
if (y && (y[1] < -90 || y[3] > 90))
|
|
202
265
|
throw new Error(
|
|
203
|
-
`GeoJSON layer "${
|
|
266
|
+
`GeoJSON layer "${m.outputTableName}" has y coordinates outside -90 to 90 (bbox: [${y.join(", ")}]), so they cannot be EPSG:4326 degrees. ${nt(m.coordinateFormat)}`
|
|
204
267
|
);
|
|
205
268
|
try {
|
|
206
|
-
await a.loadGeojson(
|
|
207
|
-
} catch (
|
|
208
|
-
throw new Error(`Failed to load GeoJSON layer "${
|
|
269
|
+
await a.loadGeojson(m);
|
|
270
|
+
} catch (p) {
|
|
271
|
+
throw new Error(`Failed to load GeoJSON layer "${m.outputTableName}": ${p instanceof Error ? p.message : String(p)}`);
|
|
209
272
|
}
|
|
210
273
|
try {
|
|
211
|
-
const
|
|
212
|
-
if (!isFinite(
|
|
274
|
+
const p = await a.getBoundingBoxFromLayer(m.outputTableName), g = 25e6;
|
|
275
|
+
if (!isFinite(p.minLon) || !isFinite(p.minLat) || !isFinite(p.maxLon) || !isFinite(p.maxLat) || Math.abs(p.minLon) > g || Math.abs(p.maxLon) > g || Math.abs(p.minLat) > g || Math.abs(p.maxLat) > g)
|
|
213
276
|
throw new Error(
|
|
214
|
-
`Geometry bounding box after transform is invalid for layer "${
|
|
277
|
+
`Geometry bounding box after transform is invalid for layer "${m.outputTableName}" (bbox: [${p.minLon}, ${p.minLat}, ${p.maxLon}, ${p.maxLat}]). ${nt(m.coordinateFormat)} The workspace uses ${a.getWorkspaceConfiguration().coordinateFormat}; input is expected in EPSG:4326 by default.`
|
|
215
278
|
);
|
|
216
|
-
} catch (
|
|
217
|
-
if (
|
|
279
|
+
} catch (p) {
|
|
280
|
+
if (p instanceof Error && p.message.includes("bounding box after transform")) throw p;
|
|
218
281
|
}
|
|
219
|
-
return
|
|
282
|
+
return o(a, t), a;
|
|
220
283
|
}
|
|
221
284
|
case "geotiff":
|
|
222
|
-
return await a.loadGeoTiff(
|
|
285
|
+
return await a.loadGeoTiff(d), o(a, t), a;
|
|
223
286
|
case "heatmap": {
|
|
224
|
-
const c =
|
|
287
|
+
const c = d;
|
|
225
288
|
if (c.groupBy?.some((f) => f.aggregateFn === "collect"))
|
|
226
289
|
throw new Error(`Heatmap "${c.outputTableName}": aggregateFn "collect" lists the rows near a cell, and a cell holds one value; use sum, avg, count, min, max or weighted.`);
|
|
227
290
|
return await a.buildHeatmap({
|
|
@@ -230,10 +293,10 @@ function xt(t, e) {
|
|
|
230
293
|
outputTableName: c.outputTableName,
|
|
231
294
|
grid: c.grid,
|
|
232
295
|
...c.groupBy && { groupBy: c.groupBy }
|
|
233
|
-
}),
|
|
296
|
+
}), o(a, t), a;
|
|
234
297
|
}
|
|
235
298
|
case "join": {
|
|
236
|
-
const c =
|
|
299
|
+
const c = d;
|
|
237
300
|
if (await a.spatialQuery({
|
|
238
301
|
tableRootName: c.dataRef,
|
|
239
302
|
tableJoinName: c.joinDataRef,
|
|
@@ -241,246 +304,403 @@ function xt(t, e) {
|
|
|
241
304
|
...c.groupBy && { groupBy: c.groupBy }
|
|
242
305
|
}), e) {
|
|
243
306
|
const f = await a.getLayer(c.dataRef);
|
|
244
|
-
e.set(
|
|
307
|
+
e.set(b(s, c.dataRef), f);
|
|
308
|
+
}
|
|
309
|
+
return o(a, t), a;
|
|
310
|
+
}
|
|
311
|
+
case "sql": {
|
|
312
|
+
const c = d;
|
|
313
|
+
try {
|
|
314
|
+
await a.rawQuery({
|
|
315
|
+
query: c.query,
|
|
316
|
+
output: {
|
|
317
|
+
type: "CREATE_TABLE",
|
|
318
|
+
tableName: c.outputTableName,
|
|
319
|
+
source: "user",
|
|
320
|
+
...c.layerType !== void 0 && { tableType: c.layerType }
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
} catch (f) {
|
|
324
|
+
throw new Error(`SQL source "${c.outputTableName}": ${f instanceof Error ? f.message : String(f)}`);
|
|
325
|
+
}
|
|
326
|
+
return e?.delete(b(s, c.outputTableName)), o(a, t), a;
|
|
327
|
+
}
|
|
328
|
+
case "update": {
|
|
329
|
+
const c = d, f = (y) => new Error(`Update of "${c.dataRef}": ${y}`);
|
|
330
|
+
if (c.geojsonObject === void 0 == (c.jsonObject === void 0))
|
|
331
|
+
throw f("give its rows in geojsonObject or in jsonObject, one of the two.");
|
|
332
|
+
if (c.strategy === "update" && !c.idColumn)
|
|
333
|
+
throw f("the update strategy needs an idColumn, the column that matches a given row to the table's rows.");
|
|
334
|
+
let m = c.geojsonObject ?? c.jsonObject, h = c.idColumn;
|
|
335
|
+
try {
|
|
336
|
+
const y = a.getTablesMetadata().find((p) => p.name === c.dataRef);
|
|
337
|
+
if (c.strategy === "update" && c.geojsonObject && h?.startsWith("properties.") && y && Dt(y) && ({ data: m, idColumn: h } = await ee(a, y, c.geojsonObject, h.slice(11)), m.features.length === 0))
|
|
338
|
+
return o(a, t), a;
|
|
339
|
+
await a.updateTable({
|
|
340
|
+
tableName: c.dataRef,
|
|
341
|
+
data: m,
|
|
342
|
+
strategy: c.strategy,
|
|
343
|
+
...h !== void 0 && { idColumn: h }
|
|
344
|
+
});
|
|
345
|
+
} catch (y) {
|
|
346
|
+
throw f(y instanceof Error ? y.message : String(y));
|
|
245
347
|
}
|
|
246
|
-
return r(a, t), a;
|
|
348
|
+
return await r(a, s, c.dataRef), o(a, t), a;
|
|
349
|
+
}
|
|
350
|
+
case "drop": {
|
|
351
|
+
const c = d;
|
|
352
|
+
if (!a.getTablesMetadata().some((f) => f.name === c.dataRef))
|
|
353
|
+
throw new Error(`Drop of "${c.dataRef}": ${Q(s)} holds no table of that name.`);
|
|
354
|
+
return await a.removeLayer(c.dataRef), e?.delete(b(s, c.dataRef)), o(a, t), a;
|
|
247
355
|
}
|
|
248
356
|
default:
|
|
249
|
-
|
|
357
|
+
throw new Error(`Unknown data source type "${String(i)}".`);
|
|
250
358
|
}
|
|
251
359
|
}
|
|
252
360
|
};
|
|
253
361
|
}
|
|
254
|
-
function
|
|
255
|
-
|
|
256
|
-
let o = t.get(e);
|
|
257
|
-
return o || (o = r(), t.set(e, o)), o;
|
|
362
|
+
function Mt(t, e) {
|
|
363
|
+
return e === !0 ? `${t} osm-elements` : t;
|
|
258
364
|
}
|
|
259
|
-
function
|
|
365
|
+
function At(t) {
|
|
366
|
+
return t === !0 ? { osmElements: !0 } : void 0;
|
|
367
|
+
}
|
|
368
|
+
function Ct(t, e, o) {
|
|
369
|
+
if (!t) return o();
|
|
370
|
+
let r = t.get(e);
|
|
371
|
+
return r || (r = o(), t.set(e, r)), r;
|
|
372
|
+
}
|
|
373
|
+
function St(t, e) {
|
|
260
374
|
return t?.id ?? e;
|
|
261
375
|
}
|
|
262
|
-
function
|
|
376
|
+
function W(t, e) {
|
|
263
377
|
return e === void 0 ? !0 : typeof e == "number" ? t.mapIndex === e : t.mapId === e;
|
|
264
378
|
}
|
|
265
|
-
function
|
|
266
|
-
const
|
|
267
|
-
|
|
379
|
+
function Rt(t, e, o) {
|
|
380
|
+
const r = t?.get(e) ?? [];
|
|
381
|
+
r.includes(o) || t?.set(e, [...r, o]);
|
|
268
382
|
}
|
|
269
|
-
const
|
|
270
|
-
function
|
|
383
|
+
const It = 6378137, V = 0.0818191908426215;
|
|
384
|
+
function re(t, e) {
|
|
271
385
|
if (t === void 0 || typeof t == "number" && Number.isFinite(t) && t > 0) return;
|
|
272
|
-
const
|
|
273
|
-
throw new Error(`Layer "${e}": pointSize must be a number of meters greater than 0, not ${
|
|
274
|
-
}
|
|
275
|
-
function
|
|
276
|
-
const e = Math.exp(-t /
|
|
277
|
-
let
|
|
278
|
-
for (let
|
|
279
|
-
const n =
|
|
280
|
-
if (Math.abs(
|
|
281
|
-
|
|
386
|
+
const o = typeof t == "number" ? String(t) : JSON.stringify(t);
|
|
387
|
+
throw new Error(`Layer "${e}": pointSize must be a number of meters greater than 0, not ${o}.`);
|
|
388
|
+
}
|
|
389
|
+
function ne(t) {
|
|
390
|
+
const e = Math.exp(-t / It);
|
|
391
|
+
let o = Math.PI / 2 - 2 * Math.atan(e);
|
|
392
|
+
for (let r = 0; r < 10; r++) {
|
|
393
|
+
const n = V * Math.sin(o), l = Math.PI / 2 - 2 * Math.atan(e * ((1 - n) / (1 + n)) ** (V / 2));
|
|
394
|
+
if (Math.abs(l - o) < 1e-12) return l;
|
|
395
|
+
o = l;
|
|
282
396
|
}
|
|
283
|
-
return
|
|
397
|
+
return o;
|
|
284
398
|
}
|
|
285
|
-
function
|
|
399
|
+
function ae(t, e) {
|
|
286
400
|
if (/^EPSG:3395$/i.test(t)) {
|
|
287
|
-
const
|
|
288
|
-
return Math.sqrt(1 -
|
|
401
|
+
const o = ne(e), r = V * Math.sin(o);
|
|
402
|
+
return Math.sqrt(1 - r * r) / Math.cos(o);
|
|
289
403
|
}
|
|
290
|
-
return /^EPSG:3857$/i.test(t) ? Math.cosh(e /
|
|
404
|
+
return /^EPSG:3857$/i.test(t) ? Math.cosh(e / It) : 1;
|
|
291
405
|
}
|
|
292
|
-
function
|
|
406
|
+
function ie(t, e, o, r) {
|
|
293
407
|
if (t === void 0 || e !== "points") return;
|
|
294
|
-
const n =
|
|
408
|
+
const n = r();
|
|
295
409
|
if (n)
|
|
296
|
-
return t *
|
|
410
|
+
return t * ae(o, (n[1] + n[3]) / 2);
|
|
411
|
+
}
|
|
412
|
+
const $t = /^#[0-9a-fA-F]{6}$/;
|
|
413
|
+
function Pt(t, e) {
|
|
414
|
+
if (t === void 0) return;
|
|
415
|
+
if (!Array.isArray(t) || t.length !== 2 || !t.every((n) => typeof n == "number" && Number.isFinite(n)))
|
|
416
|
+
return "colorMapRange must hold two numbers, [low, high].";
|
|
417
|
+
const [o, r] = t;
|
|
418
|
+
if (o >= r)
|
|
419
|
+
return `colorMapRange low (${o}) must be less than high (${r}).`;
|
|
420
|
+
if (e !== void 0)
|
|
421
|
+
return "set colorMapRange or colorMapDomain, not both.";
|
|
422
|
+
}
|
|
423
|
+
function Lt(t, e) {
|
|
424
|
+
return e && e.length > 0 ? { type: $.USER, params: e } : t?.mode === wt.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
|
|
425
|
+
type: $.PERCENTILE,
|
|
426
|
+
params: [t.lowerPercentile ?? 0, t.upperPercentile ?? 100]
|
|
427
|
+
} : { type: $.PERCENTILE } : { type: $.MIN_MAX };
|
|
297
428
|
}
|
|
298
|
-
function
|
|
429
|
+
function R(t) {
|
|
299
430
|
return typeof t.title == "string" && t.title !== "" ? t.title : t.dataRef;
|
|
300
431
|
}
|
|
301
|
-
function
|
|
302
|
-
const
|
|
303
|
-
for (const
|
|
304
|
-
const n =
|
|
305
|
-
if (
|
|
432
|
+
function se(t, e) {
|
|
433
|
+
const o = /* @__PURE__ */ new Set();
|
|
434
|
+
for (const r of t.layerRefs) {
|
|
435
|
+
const n = R(r);
|
|
436
|
+
if (o.has(n))
|
|
306
437
|
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.`);
|
|
307
|
-
|
|
438
|
+
o.add(n);
|
|
308
439
|
}
|
|
309
440
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
return B.hexToRgb(t);
|
|
441
|
+
function st(t, e, o) {
|
|
442
|
+
if (!$t.test(t))
|
|
443
|
+
throw new Error(`Layer "${o}": ${e} must be a color written #rrggbb, not "${t}".`);
|
|
444
|
+
return N.hexToRgb(t);
|
|
315
445
|
}
|
|
316
|
-
function
|
|
317
|
-
const
|
|
318
|
-
return t.color != null && (
|
|
446
|
+
function le(t, e) {
|
|
447
|
+
const o = {};
|
|
448
|
+
return t.color != null && (o.color = st(t.color, "color", e)), t.stroke === !1 ? o.showBorders = !1 : t.stroke != null && (o.strokeColor = st(t.stroke, "stroke", e)), t.width != null && (o.polylinesWidth = t.width), o;
|
|
319
449
|
}
|
|
320
|
-
function
|
|
450
|
+
function ue(t, e) {
|
|
321
451
|
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;
|
|
322
452
|
}
|
|
323
|
-
function
|
|
324
|
-
const
|
|
325
|
-
return
|
|
453
|
+
function ce(t, e) {
|
|
454
|
+
const o = t.features?.[0]?.properties?.[e];
|
|
455
|
+
return o instanceof Float32Array ? o : ArrayBuffer.isView(o) && !(o instanceof DataView) || Array.isArray(o) ? Float32Array.from(o, (r) => Number.isFinite(Number(r)) ? Number(r) : NaN) : null;
|
|
326
456
|
}
|
|
327
|
-
function
|
|
328
|
-
if (
|
|
457
|
+
function fe(t, e, o, r, n) {
|
|
458
|
+
if (N.isCategorical(e.interpolator)) return;
|
|
329
459
|
if (n != null) {
|
|
330
|
-
const u =
|
|
331
|
-
return
|
|
460
|
+
const u = o != null ? [n[0], o, n[1]] : [n[0], n[1]];
|
|
461
|
+
return r === !0 ? u.reverse() : u;
|
|
332
462
|
}
|
|
333
463
|
if (!t) return;
|
|
334
|
-
let
|
|
464
|
+
let l = 0, a = 0;
|
|
335
465
|
for (let u = 0; u < t.length; u++) {
|
|
336
|
-
const
|
|
337
|
-
Number.isFinite(
|
|
466
|
+
const d = t[u];
|
|
467
|
+
Number.isFinite(d) && (a++, o != null && (l = Math.max(l, Math.abs(d - o))));
|
|
338
468
|
}
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
341
|
-
const
|
|
342
|
-
return
|
|
469
|
+
const s = o != null && l > 0;
|
|
470
|
+
if (a === 0 || !s && r !== !0) return;
|
|
471
|
+
const i = s && o != null ? [o - l, o, o + l] : N.resolveDomainFromData(t, e);
|
|
472
|
+
return r === !0 ? [...i].reverse() : i;
|
|
343
473
|
}
|
|
344
|
-
function
|
|
345
|
-
if (!(e == null ||
|
|
474
|
+
function de(t, e) {
|
|
475
|
+
if (!(e == null || N.isCategorical(t.interpolator)))
|
|
346
476
|
return [e[0], e[1]];
|
|
347
477
|
}
|
|
348
|
-
function
|
|
478
|
+
function pe(t) {
|
|
349
479
|
const e = t.colorMapRange;
|
|
350
480
|
if (e === void 0) return;
|
|
351
|
-
const
|
|
352
|
-
if (
|
|
353
|
-
throw r
|
|
354
|
-
const [
|
|
355
|
-
if (
|
|
356
|
-
throw
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
function Kt(t, e) {
|
|
364
|
-
return e && e.length > 0 ? { type: I.USER, params: e } : t?.mode === ct.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
|
|
365
|
-
type: I.PERCENTILE,
|
|
366
|
-
params: [t.lowerPercentile ?? 0, t.upperPercentile ?? 100]
|
|
367
|
-
} : { type: I.PERCENTILE } : { type: I.MIN_MAX };
|
|
368
|
-
}
|
|
369
|
-
function Xt(t, e) {
|
|
370
|
-
return e.split(".").reduce((r, o) => {
|
|
371
|
-
if (!(r == null || typeof r != "object"))
|
|
372
|
-
return r[o];
|
|
481
|
+
const o = (s) => new Error(`Layer "${R(t)}": ${s}`), r = Pt(e, t.colorMapDomain);
|
|
482
|
+
if (r)
|
|
483
|
+
throw o(r);
|
|
484
|
+
const [n, l] = e, a = t.colorMapCenter;
|
|
485
|
+
if (a != null && (a < n || a > l))
|
|
486
|
+
throw o(`colorMapCenter (${a}) must lie within colorMapRange [${n}, ${l}].`);
|
|
487
|
+
}
|
|
488
|
+
function me(t, e) {
|
|
489
|
+
return e.split(".").reduce((o, r) => {
|
|
490
|
+
if (!(o == null || typeof o != "object"))
|
|
491
|
+
return o[r];
|
|
373
492
|
}, t);
|
|
374
493
|
}
|
|
375
|
-
function
|
|
376
|
-
const
|
|
377
|
-
let
|
|
378
|
-
for (let
|
|
379
|
-
|
|
380
|
-
return
|
|
494
|
+
function he(t, e, o) {
|
|
495
|
+
const r = e.split("."), n = { ...t };
|
|
496
|
+
let l = n;
|
|
497
|
+
for (let a = 0; a < r.length - 1; a++)
|
|
498
|
+
l[r[a]] = { ...l[r[a]] ?? {} }, l = l[r[a]];
|
|
499
|
+
return l[r[r.length - 1]] = o, n;
|
|
381
500
|
}
|
|
382
|
-
function
|
|
383
|
-
const
|
|
384
|
-
return
|
|
501
|
+
function ye(t, e) {
|
|
502
|
+
const r = t.features?.[0]?.properties?.bands ?? [];
|
|
503
|
+
return r.find((l) => l.id === e || l.label === e?.replace(/\./g, "_"))?.id ?? r[0]?.id ?? e ?? "";
|
|
385
504
|
}
|
|
386
|
-
function
|
|
505
|
+
function Nt(t) {
|
|
506
|
+
const { pitch: e } = t;
|
|
507
|
+
return e === void 0 || typeof e == "number" && e >= 0 && e < 90 ? void 0 : `camera.pitch must be at least 0 and less than 90 degrees, not ${typeof e == "number" ? String(e) : JSON.stringify(e)}: at 90 the eye would sit on the ground, edge-on to the map's flat layers, and the map could not pan.`;
|
|
508
|
+
}
|
|
509
|
+
function ge(t, e) {
|
|
510
|
+
const o = Nt(e);
|
|
511
|
+
if (o) throw new Error(o);
|
|
387
512
|
if (e.zoom === void 0 && !e.pitch && !e.bearing) return;
|
|
388
|
-
const r = t.camera, [
|
|
389
|
-
|
|
390
|
-
|
|
513
|
+
const r = t.camera, [n, l] = r.getLookAt(), a = e.zoom !== void 0 ? 1e4 / Math.pow(2, e.zoom - 10) : Math.abs(r.getEye()[2]), s = (e.pitch ?? 0) * Math.PI / 180, i = (e.bearing ?? 0) * Math.PI / 180, u = [
|
|
514
|
+
n - a * Math.sin(s) * Math.sin(i),
|
|
515
|
+
l - a * Math.sin(s) * Math.cos(i),
|
|
391
516
|
a * Math.cos(s)
|
|
392
|
-
];
|
|
393
|
-
r.resetCamera(
|
|
394
|
-
}
|
|
395
|
-
function
|
|
396
|
-
const
|
|
397
|
-
return Array.isArray(
|
|
398
|
-
const
|
|
399
|
-
return r[
|
|
400
|
-
}) :
|
|
401
|
-
}
|
|
402
|
-
function
|
|
403
|
-
async function s
|
|
404
|
-
let
|
|
405
|
-
for (const
|
|
406
|
-
|
|
407
|
-
const
|
|
408
|
-
for (const
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
const
|
|
412
|
-
Object.keys(
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
const { catchAllCategory: T, colorMapDomain:
|
|
416
|
-
let
|
|
417
|
-
if (g && T &&
|
|
418
|
-
const w = new Set(
|
|
419
|
-
|
|
420
|
-
...
|
|
421
|
-
features:
|
|
422
|
-
const
|
|
423
|
-
return
|
|
517
|
+
], d = [Math.cos(s) * Math.sin(i), Math.cos(s) * Math.cos(i), Math.sin(s)];
|
|
518
|
+
r.resetCamera(d, [n, l, 0], u);
|
|
519
|
+
}
|
|
520
|
+
function we(t, e, o, r) {
|
|
521
|
+
const l = t.layerManager.searchByLayerId(e)?.components;
|
|
522
|
+
return Array.isArray(l) ? l.map((a, s) => {
|
|
523
|
+
const i = Number.isInteger(a?.featureIndex) ? a.featureIndex : s;
|
|
524
|
+
return o[r[i]] ?? "";
|
|
525
|
+
}) : r.map((a) => o[a] ?? "");
|
|
526
|
+
}
|
|
527
|
+
function be(t, e, o, r, n, l) {
|
|
528
|
+
async function a(s, i, u) {
|
|
529
|
+
let d = {};
|
|
530
|
+
for (const f of i.getTablesMetadata())
|
|
531
|
+
f.type !== void 0 && (d[f.name] = f.type);
|
|
532
|
+
const c = [];
|
|
533
|
+
for (const f of u.layerRefs) {
|
|
534
|
+
const m = f.dataRef, h = R(f), y = b(u.workspace, m), p = n?.get(y) ?? d[m], g = f.getFnv, E = o?.get(y) ?? (p === "raster" ? await i.getRaster(m) : await Ct(l, Mt(y, f.osmElements), () => i.getLayer(m, At(f.osmElements)))), _ = E.features ?? [], I = p === "raster" ? [] : _.flatMap((w, v) => w?.geometry != null ? [v] : []), C = p === "raster" ? E : { ...E, features: I.map((w) => _[w]) }, H = p === "raster" ? ye(C, g) : "";
|
|
535
|
+
p === "raster" ? s.loadCollection(h, { collection: C, type: "raster", property: H }) : s.loadCollection(h, { collection: C, type: p }), f.opacity != null && s.updateRenderInfo(h, { opacity: f.opacity });
|
|
536
|
+
const J = le(f, h);
|
|
537
|
+
Object.keys(J).length > 0 && s.updateRenderInfo(h, J);
|
|
538
|
+
const jt = i.getWorkspaceConfiguration().coordinateFormat, q = ie(f.pointSize, p, jt, () => vt(C));
|
|
539
|
+
q !== void 0 && s.updateRenderInfo(h, { pointSize: q }), ue(f, p) && s.updateRenderInfo(h, { isColorMap: !0 }), f.isPick && s.updateRenderInfo(h, { isPick: !0 }), f.isSkip && s.updateRenderInfo(h, { isSkip: !0 });
|
|
540
|
+
const { catchAllCategory: T, colorMapDomain: L } = f;
|
|
541
|
+
let K = C, z = L;
|
|
542
|
+
if (g && T && L?.length) {
|
|
543
|
+
const w = new Set(L);
|
|
544
|
+
K = {
|
|
545
|
+
...C,
|
|
546
|
+
features: C.features.map((v) => {
|
|
547
|
+
const tt = v.properties, U = me(tt, g);
|
|
548
|
+
return U == null || !w.has(String(U)) ? { ...v, properties: he(tt, g, T) } : v;
|
|
424
549
|
})
|
|
425
|
-
},
|
|
550
|
+
}, z = w.has(T) ? L : [...L, T];
|
|
426
551
|
}
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
const
|
|
430
|
-
if (
|
|
552
|
+
const X = p === "raster" && f.transferFunction != null;
|
|
553
|
+
X && s.layerManager.searchByLayerId(h)?.setTransferFunction?.(f.transferFunction);
|
|
554
|
+
const O = f.colorMapRange, Z = p === "raster" && (O != null || f.colorMapCenter != null || f.colorMapReverse === !0);
|
|
555
|
+
if (f.colorMapInterpolator || Z || O) {
|
|
431
556
|
const w = {
|
|
432
557
|
// urban-grammar ColorMapInterpolator values are string-compatible
|
|
433
558
|
// with autk-core ColorMapInterpolator at runtime
|
|
434
|
-
interpolator:
|
|
435
|
-
domainSpec:
|
|
559
|
+
interpolator: f.colorMapInterpolator ?? s.layerManager.searchByLayerId(h)?.layerRenderInfo.colormap.config.interpolator ?? gt.SEQ_REDS,
|
|
560
|
+
domainSpec: Lt(f.normalization, z)
|
|
436
561
|
};
|
|
437
|
-
let
|
|
438
|
-
|
|
439
|
-
} else
|
|
440
|
-
if (g &&
|
|
562
|
+
let v;
|
|
563
|
+
Z ? v = fe(ce(C, H), w, f.colorMapCenter, f.colorMapReverse, O) : p !== "raster" && (v = de(w, O)), v && (w.domainSpec = { type: $.USER, params: v }), s.updateColorMap(h, { colorMap: w });
|
|
564
|
+
} else X && s.updateColorMap(h, { colorMap: {} });
|
|
565
|
+
if (g && p !== "raster") {
|
|
441
566
|
const w = g.startsWith("properties.") ? g : `properties.${g}`;
|
|
442
|
-
|
|
567
|
+
s.updateThematic(h, { collection: K, property: w });
|
|
443
568
|
}
|
|
444
|
-
|
|
569
|
+
c.push(p === "raster" ? [] : we(s, h, _t(_), I));
|
|
445
570
|
}
|
|
446
|
-
return
|
|
571
|
+
return c;
|
|
447
572
|
}
|
|
448
573
|
return {
|
|
449
|
-
async resolveMap(
|
|
450
|
-
if (t && t.map &&
|
|
451
|
-
|
|
452
|
-
for (const
|
|
453
|
-
|
|
574
|
+
async resolveMap(s, i, u = 0) {
|
|
575
|
+
if (t && t.map && s) {
|
|
576
|
+
se(i, u);
|
|
577
|
+
for (const y of i.layerRefs)
|
|
578
|
+
pe(y), re(y.pointSize, R(y));
|
|
579
|
+
const d = i.camera && Nt(i.camera);
|
|
580
|
+
if (d)
|
|
581
|
+
throw new Error(`Map ${u}: ${d}`);
|
|
454
582
|
let c;
|
|
455
583
|
if (Array.isArray(t.map) ? c = document.getElementById(t.map[u]) : c = document.getElementById(t.map), !c)
|
|
456
584
|
throw new Error("Could not find rendering target for map: " + t.map);
|
|
457
585
|
if (!(c instanceof HTMLCanvasElement))
|
|
458
586
|
throw new Error("Target for map is not a canvas: " + t.map);
|
|
459
|
-
const f = new
|
|
460
|
-
let
|
|
587
|
+
const f = new Qt(c);
|
|
588
|
+
let m;
|
|
461
589
|
try {
|
|
462
|
-
|
|
463
|
-
} catch (
|
|
590
|
+
i.style && f.style.setPredefinedStyle(i.style), await f.init(), await P(s, i.workspace), m = await a(f, s, i);
|
|
591
|
+
} catch (y) {
|
|
464
592
|
try {
|
|
465
593
|
f.destroy();
|
|
466
594
|
} catch {
|
|
467
595
|
}
|
|
468
|
-
throw
|
|
596
|
+
throw y;
|
|
469
597
|
}
|
|
470
|
-
const
|
|
471
|
-
|
|
598
|
+
const h = St(i, u);
|
|
599
|
+
i.layerRefs.forEach((y, p) => e?.push({
|
|
472
600
|
map: f,
|
|
473
601
|
mapIndex: u,
|
|
474
|
-
mapId:
|
|
475
|
-
layerId:
|
|
476
|
-
dataRef:
|
|
477
|
-
rows: p
|
|
478
|
-
})),
|
|
602
|
+
mapId: h,
|
|
603
|
+
layerId: R(y),
|
|
604
|
+
dataRef: y.dataRef,
|
|
605
|
+
rows: m[p]
|
|
606
|
+
})), r && (r[u] = f), i.camera && ge(f, i.camera), f.draw();
|
|
479
607
|
}
|
|
480
608
|
}
|
|
481
609
|
};
|
|
482
610
|
}
|
|
483
|
-
function
|
|
611
|
+
function A(t) {
|
|
612
|
+
return t.id ?? t.dataRef;
|
|
613
|
+
}
|
|
614
|
+
const Ee = new Set(Object.values(gt));
|
|
615
|
+
function lt(t, e, o) {
|
|
616
|
+
if (e !== void 0) {
|
|
617
|
+
if (typeof e != "string" || !Ee.has(e)) return `${t} ${JSON.stringify(e)} is not a color scheme.`;
|
|
618
|
+
if (N.isCategorical(e) !== o)
|
|
619
|
+
return o ? `${t} "${e}" is not a categorical scheme: categories take a scheme* scheme, such as schemeTableau10.` : `${t} "${e}" is a categorical scheme: numbers take an interpolate* scheme, and categories take categoricalColorMapInterpolator.`;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
const _e = /^(?:.?[<>=^])?[-+( ]?[$#]?0?\d*,?(?:\.\d+)?~?[a-zA-Z%]?$/;
|
|
623
|
+
function ve(t) {
|
|
624
|
+
if (t === void 0) return;
|
|
625
|
+
if (!Array.isArray(t) || t.length !== 2)
|
|
626
|
+
return "tickFormats must hold two d3-format specifiers, [x, y].";
|
|
627
|
+
const e = t.findIndex((o) => typeof o != "string" || !_e.test(o));
|
|
628
|
+
if (e >= 0)
|
|
629
|
+
return `tickFormats[${e}] ${JSON.stringify(t[e])} is not a d3-format specifier, such as "~s", ",d" or ".0%".`;
|
|
630
|
+
}
|
|
631
|
+
function Me(t, e) {
|
|
632
|
+
if (t === void 0) return;
|
|
633
|
+
if (!Array.isArray(t) || !t.every((r) => typeof r == "string"))
|
|
634
|
+
return "axisLabels must be a list of titles, one for each column of axis.";
|
|
635
|
+
if (t.length > e.length)
|
|
636
|
+
return `axisLabels has ${t.length} titles for the ${e.length} columns of axis.`;
|
|
637
|
+
const o = t.find((r, n) => t.indexOf(r) !== n);
|
|
638
|
+
if (o !== void 0)
|
|
639
|
+
return `axisLabels gives two axes the title ${JSON.stringify(o)}.`;
|
|
640
|
+
}
|
|
641
|
+
function ut(t, e) {
|
|
642
|
+
if (!(e === void 0 || typeof e == "string" && $t.test(e)))
|
|
643
|
+
return `${t} must be a color written #rrggbb, not ${JSON.stringify(e)}.`;
|
|
644
|
+
}
|
|
645
|
+
function Ae(t) {
|
|
646
|
+
if (t !== void 0 && (!Array.isArray(t) || !t.every((e) => Number.isInteger(e) && e >= 0)))
|
|
647
|
+
return "selection must list the positions of rows, whole numbers from 0.";
|
|
648
|
+
}
|
|
649
|
+
function Ce(t) {
|
|
650
|
+
const e = lt("colorMapInterpolator", t.colorMapInterpolator, !1) ?? lt("categoricalColorMapInterpolator", t.categoricalColorMapInterpolator, !0) ?? Pt(t.colorMapRange, t.colorMapDomain) ?? ve(t.tickFormats) ?? Me(t.axisLabels, t.axis) ?? Ae(t.selection) ?? ut("markColor", t.markColor) ?? ut("highlightColor", t.highlightColor);
|
|
651
|
+
if (e) throw new Error(`Plot "${A(t)}": ${e}`);
|
|
652
|
+
}
|
|
653
|
+
function Se(t) {
|
|
654
|
+
const e = {};
|
|
655
|
+
for (const [o, r] of [["markColor", "mark"], ["highlightColor", "highlight"]]) {
|
|
656
|
+
let n;
|
|
657
|
+
for (const l of t) {
|
|
658
|
+
const a = l[o];
|
|
659
|
+
if (a !== void 0) {
|
|
660
|
+
if (n && n[o].toLowerCase() !== a.toLowerCase())
|
|
661
|
+
throw new Error(`Plots "${A(n)}" and "${A(l)}" set different ${o} values, "${n[o]}" and "${a}": autk-plot draws every plot of a page in one ${r} color.`);
|
|
662
|
+
n ??= l;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
n && (e[o] = n[o]);
|
|
666
|
+
}
|
|
667
|
+
return e;
|
|
668
|
+
}
|
|
669
|
+
function Re(t, e) {
|
|
670
|
+
const o = t.selection?.find((r) => r >= e);
|
|
671
|
+
if (o !== void 0)
|
|
672
|
+
throw new Error(`Plot "${A(t)}": selection names row ${o}, but the plot draws ${e === 1 ? "1 row" : `${e} rows`}.`);
|
|
673
|
+
}
|
|
674
|
+
function Ie(t, e) {
|
|
675
|
+
return t === void 0 || t === "@transform" ? !1 : e.some((o) => {
|
|
676
|
+
const r = Yt(o?.properties ?? {}, t);
|
|
677
|
+
return typeof r == "string" && isNaN(Number(r));
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
function $e(t, e) {
|
|
681
|
+
const o = t.colorMapRange;
|
|
682
|
+
if (o !== void 0 && !Ie(t.color, e))
|
|
683
|
+
return { type: $.USER, params: [o[0], o[1]] };
|
|
684
|
+
if (!(t.normalization === void 0 && t.colorMapDomain === void 0))
|
|
685
|
+
return Lt(t.normalization, t.colorMapDomain);
|
|
686
|
+
}
|
|
687
|
+
function Pe(t) {
|
|
688
|
+
return t.axis.map((e, o) => t.axisLabels?.[o] ?? (e === "@transform" ? "value" : e));
|
|
689
|
+
}
|
|
690
|
+
function Le(t, e) {
|
|
691
|
+
const o = $e(t, e);
|
|
692
|
+
return {
|
|
693
|
+
labels: { axis: Pe(t), title: t.title },
|
|
694
|
+
// The grammar's scheme names are autk-core's, as strings.
|
|
695
|
+
...t.colorMapInterpolator !== void 0 && { colorMapInterpolator: t.colorMapInterpolator },
|
|
696
|
+
...t.categoricalColorMapInterpolator !== void 0 && {
|
|
697
|
+
categoricalColorMapInterpolator: t.categoricalColorMapInterpolator
|
|
698
|
+
},
|
|
699
|
+
...o && { domainSpec: o },
|
|
700
|
+
...t.tickFormats !== void 0 && { tickFormats: [...t.tickFormats] }
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
function Ne(t) {
|
|
484
704
|
return {
|
|
485
705
|
scatter: "scatterplot",
|
|
486
706
|
bar: "barchart",
|
|
@@ -491,245 +711,248 @@ function oe(t) {
|
|
|
491
711
|
heatmatrix: "heatmatrix"
|
|
492
712
|
}[t];
|
|
493
713
|
}
|
|
494
|
-
|
|
495
|
-
|
|
714
|
+
let B;
|
|
715
|
+
function ke(t) {
|
|
716
|
+
t.markColor === void 0 && t.highlightColor === void 0 && !B || (B ??= { markColor: F.default, highlightColor: F.highlight }, F.setDefaultColor(t.markColor ?? B.markColor), F.setHighlightColor(t.highlightColor ?? B.highlightColor));
|
|
496
717
|
}
|
|
497
|
-
function
|
|
498
|
-
const { map: n, layerId:
|
|
499
|
-
n.updateRenderInfo(
|
|
500
|
-
|
|
718
|
+
function kt(t, e, o, r) {
|
|
719
|
+
const { map: n, layerId: l } = r;
|
|
720
|
+
n.updateRenderInfo(l, { isPick: !0 }), n.events.on(Y.PICKING, ({ layerId: a, selection: s }) => {
|
|
721
|
+
a === l && t.setSelection(D(s, r.rows, e));
|
|
501
722
|
});
|
|
502
|
-
for (const
|
|
503
|
-
t.events.on(
|
|
504
|
-
n.setHighlightedIds(
|
|
723
|
+
for (const a of o)
|
|
724
|
+
t.events.on(a, ({ selection: s }) => {
|
|
725
|
+
n.setHighlightedIds(l, D(s, e, r.rows));
|
|
505
726
|
});
|
|
506
727
|
}
|
|
507
|
-
async function
|
|
508
|
-
const
|
|
509
|
-
return
|
|
728
|
+
async function Te(t, e, o, r, n) {
|
|
729
|
+
const l = t.getTablesMetadata().find((a) => a.name === e);
|
|
730
|
+
return l && !yt(l) ? { type: "FeatureCollection", features: (await t.getTable(e)).map((s) => ({ type: "Feature", geometry: null, properties: s })) } : Ct(r, Mt(o, n), () => t.getLayer(e, At(n)));
|
|
510
731
|
}
|
|
511
|
-
function
|
|
732
|
+
function Oe(t, e, o, r, n, l, a, s) {
|
|
512
733
|
return {
|
|
513
|
-
async resolvePlot(
|
|
734
|
+
async resolvePlot(i, u, d = 0) {
|
|
514
735
|
if (!t || !t.plot) return;
|
|
515
|
-
const
|
|
516
|
-
if (
|
|
517
|
-
const
|
|
518
|
-
if (!
|
|
519
|
-
const
|
|
520
|
-
if (!
|
|
521
|
-
await
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
736
|
+
const c = Array.isArray(t.plot) ? t.plot[d] : t.plot;
|
|
737
|
+
if (c === void 0) throw new Error(`Plot ${d} has no target: the plot targets name ${t.plot.length} elements.`);
|
|
738
|
+
const f = document.getElementById(c);
|
|
739
|
+
if (!f) throw new Error(`Could not find plot target: ${c}`);
|
|
740
|
+
const m = i;
|
|
741
|
+
if (!m) throw new Error("No data context available for plot.");
|
|
742
|
+
await P(m, u.workspace);
|
|
743
|
+
const h = b(u.workspace, u.dataRef), y = u.osmElements === !0 ? void 0 : n?.get(h), p = l?.get(h) ?? y ?? await Te(m, u.dataRef, h, s, u.osmElements);
|
|
744
|
+
Re(u, p.features?.length ?? 0);
|
|
745
|
+
const g = u.events ?? [], E = new Wt(f, {
|
|
746
|
+
type: Ne(u.mark),
|
|
747
|
+
collection: p,
|
|
525
748
|
attributes: { axis: u.axis, ...u.color && { color: u.color } },
|
|
526
|
-
|
|
527
|
-
|
|
749
|
+
events: g,
|
|
750
|
+
...Le(u, p.features ?? []),
|
|
528
751
|
...u.width && { width: u.width },
|
|
529
752
|
...u.height && { height: u.height },
|
|
530
753
|
...u.margins && { margins: u.margins },
|
|
531
754
|
...u.transform && { transform: u.transform }
|
|
532
755
|
});
|
|
533
|
-
|
|
534
|
-
const _ =
|
|
535
|
-
|
|
536
|
-
for (const
|
|
537
|
-
!u.mapRef ||
|
|
756
|
+
u.mark === "scatter" && u.color !== void 0 && E.setSelection([]), o?.set(A(u), E);
|
|
757
|
+
const _ = _t(p.features ?? []);
|
|
758
|
+
a?.set(A(u), _);
|
|
759
|
+
for (const I of e ?? [])
|
|
760
|
+
!u.mapRef || I.dataRef !== u.mapRef || (kt(E, _, g, I), Rt(r, A(u), I));
|
|
538
761
|
}
|
|
539
762
|
};
|
|
540
763
|
}
|
|
541
|
-
const
|
|
542
|
-
function
|
|
764
|
+
const Tt = 134217728, Fe = 4, xe = 32;
|
|
765
|
+
function Be(t) {
|
|
543
766
|
return Array.isArray(t) ? t.join(`
|
|
544
767
|
`) : t;
|
|
545
768
|
}
|
|
546
|
-
function
|
|
769
|
+
function S(t) {
|
|
547
770
|
return !!t && typeof t == "object" && !Array.isArray(t) && typeof t.fromFeature == "object" && t.fromFeature !== null;
|
|
548
771
|
}
|
|
549
|
-
function
|
|
772
|
+
function k(t, e) {
|
|
550
773
|
return t instanceof Map ? t.get(e) : t[e];
|
|
551
774
|
}
|
|
552
|
-
function
|
|
553
|
-
return e.split(".").reduce((
|
|
554
|
-
if (!(
|
|
555
|
-
return r
|
|
775
|
+
function j(t, e) {
|
|
776
|
+
return e.split(".").reduce((o, r) => {
|
|
777
|
+
if (!(o == null || typeof o != "object"))
|
|
778
|
+
return o[r];
|
|
556
779
|
}, t);
|
|
557
780
|
}
|
|
558
|
-
function
|
|
781
|
+
function Ot(t) {
|
|
559
782
|
const e = [];
|
|
560
|
-
for (const
|
|
561
|
-
for (const
|
|
562
|
-
|
|
783
|
+
for (const o of [t.uniforms, t.uniformMatrices])
|
|
784
|
+
for (const r of Object.values(o ?? {}))
|
|
785
|
+
S(r) && e.push(r);
|
|
563
786
|
return e;
|
|
564
787
|
}
|
|
565
|
-
function
|
|
566
|
-
return [.../* @__PURE__ */ new Set([t.dataRef, ...
|
|
788
|
+
function je(t) {
|
|
789
|
+
return [.../* @__PURE__ */ new Set([t.dataRef, ...Ot(t).map((e) => e.fromFeature.layer)])];
|
|
567
790
|
}
|
|
568
|
-
function
|
|
569
|
-
for (const e of
|
|
570
|
-
const { iterate:
|
|
571
|
-
if (
|
|
791
|
+
function Ft(t) {
|
|
792
|
+
for (const e of Ot(t)) {
|
|
793
|
+
const { iterate: o, layer: r } = e.fromFeature;
|
|
794
|
+
if (o === "all" || o === "batched") return { mode: o, layer: r };
|
|
572
795
|
}
|
|
573
796
|
return null;
|
|
574
797
|
}
|
|
575
|
-
function
|
|
576
|
-
const
|
|
577
|
-
return
|
|
798
|
+
function xt(t, e, o) {
|
|
799
|
+
const r = t.fromFeature, n = o !== void 0 && r.iterate === "all" ? o : r.index ?? 0, l = k(e, r.layer)?.features?.[n];
|
|
800
|
+
return l ? j(l, r.path) : void 0;
|
|
578
801
|
}
|
|
579
|
-
function
|
|
802
|
+
function ct(t, e, o) {
|
|
580
803
|
if (!t) return;
|
|
581
|
-
const
|
|
582
|
-
for (const [n,
|
|
583
|
-
if (!
|
|
584
|
-
|
|
804
|
+
const r = {};
|
|
805
|
+
for (const [n, l] of Object.entries(t)) {
|
|
806
|
+
if (!S(l)) {
|
|
807
|
+
r[n] = l;
|
|
585
808
|
continue;
|
|
586
809
|
}
|
|
587
|
-
const
|
|
588
|
-
Number.isFinite(
|
|
810
|
+
const a = Number(xt(l, e, o) ?? NaN);
|
|
811
|
+
Number.isFinite(a) ? r[n] = a : typeof l.default == "number" && (r[n] = l.default);
|
|
589
812
|
}
|
|
590
|
-
return
|
|
813
|
+
return r;
|
|
591
814
|
}
|
|
592
|
-
function
|
|
815
|
+
function ft(t, e, o) {
|
|
593
816
|
if (!t) return;
|
|
594
|
-
const
|
|
595
|
-
for (const [n,
|
|
596
|
-
if (!
|
|
597
|
-
|
|
817
|
+
const r = {};
|
|
818
|
+
for (const [n, l] of Object.entries(t)) {
|
|
819
|
+
if (!S(l)) {
|
|
820
|
+
r[n] = l;
|
|
598
821
|
continue;
|
|
599
822
|
}
|
|
600
|
-
const
|
|
601
|
-
if (!
|
|
602
|
-
const
|
|
603
|
-
|
|
823
|
+
const a = xt(l, e, o), s = Array.isArray(a) ? a : Array.isArray(l.default) ? l.default : void 0;
|
|
824
|
+
if (!s) continue;
|
|
825
|
+
const i = l.cols ?? (Array.isArray(s[0]) ? s[0].length : 0);
|
|
826
|
+
i > 0 ? r[n] = { data: s, cols: i } : console.warn(`[autk-grammar] uniform matrix "${n}" has no column count; entry dropped`);
|
|
604
827
|
}
|
|
605
|
-
return
|
|
828
|
+
return r;
|
|
606
829
|
}
|
|
607
|
-
function
|
|
830
|
+
function De(t) {
|
|
608
831
|
return t != null && !(typeof t == "number" && !Number.isFinite(t));
|
|
609
832
|
}
|
|
610
|
-
function
|
|
611
|
-
return
|
|
612
|
-
}
|
|
613
|
-
function
|
|
614
|
-
return Object.values(e ?? {}).some(
|
|
615
|
-
}
|
|
616
|
-
function
|
|
617
|
-
const
|
|
618
|
-
return
|
|
619
|
-
}
|
|
620
|
-
function
|
|
621
|
-
const n = {},
|
|
622
|
-
for (const
|
|
623
|
-
for (const u of Object.values(
|
|
624
|
-
|
|
625
|
-
if (
|
|
626
|
-
const
|
|
627
|
-
|
|
833
|
+
function dt(t) {
|
|
834
|
+
return S(t) && t.fromFeature.iterate === "batched";
|
|
835
|
+
}
|
|
836
|
+
function Bt(t, e) {
|
|
837
|
+
return Object.values(e ?? {}).some(dt) ? xe : Object.values(t ?? {}).some(dt) ? Fe : 0;
|
|
838
|
+
}
|
|
839
|
+
function Ge(t, e, o = Tt) {
|
|
840
|
+
const r = Bt(t, e);
|
|
841
|
+
return r > 0 ? Math.floor(o / r) : Number.POSITIVE_INFINITY;
|
|
842
|
+
}
|
|
843
|
+
function Ue(t, e, o, r = Tt) {
|
|
844
|
+
const n = {}, l = {}, a = [];
|
|
845
|
+
for (const i of [t, e])
|
|
846
|
+
for (const u of Object.values(i ?? {}))
|
|
847
|
+
S(u) && u.fromFeature.iterate === "batched" && u.fromFeature.required && a.push(u.fromFeature.path);
|
|
848
|
+
if (a.length > 0) {
|
|
849
|
+
const i = o.length;
|
|
850
|
+
o = o.filter((u) => a.every((d) => De(j(u, d)))), o.length < i && console.info(`[autk-grammar] batched compute dropped ${i - o.length} feature(s) missing ${a.join(", ")}`);
|
|
628
851
|
}
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
`[autk-grammar] batched compute capped at ${
|
|
632
|
-
),
|
|
633
|
-
for (const [
|
|
634
|
-
if (
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
const
|
|
638
|
-
return Number.isFinite(
|
|
852
|
+
const s = Ge(t, e, r);
|
|
853
|
+
o.length > s && (console.warn(
|
|
854
|
+
`[autk-grammar] batched compute capped at ${s} features (got ${o.length}): its largest packed array takes ${Bt(t, e)} B per feature, and a storage buffer binding holds ${r} B`
|
|
855
|
+
), o = o.slice(0, s));
|
|
856
|
+
for (const [i, u] of Object.entries(t ?? {}))
|
|
857
|
+
if (S(u) && u.fromFeature.iterate === "batched") {
|
|
858
|
+
const d = typeof u.default == "number" ? u.default : void 0;
|
|
859
|
+
l[i] = o.map((c) => {
|
|
860
|
+
const f = Number(j(c, u.fromFeature.path) ?? d);
|
|
861
|
+
return Number.isFinite(f) ? f : 0;
|
|
639
862
|
});
|
|
640
|
-
} else typeof u == "number" && (n[
|
|
641
|
-
for (const [
|
|
642
|
-
if (!
|
|
643
|
-
const
|
|
644
|
-
for (const
|
|
645
|
-
const
|
|
646
|
-
let
|
|
647
|
-
if (Array.isArray(
|
|
648
|
-
for (const g of
|
|
863
|
+
} else typeof u == "number" && (n[i] = u);
|
|
864
|
+
for (const [i, u] of Object.entries(e ?? {})) {
|
|
865
|
+
if (!S(u) || u.fromFeature.iterate !== "batched") continue;
|
|
866
|
+
const d = [];
|
|
867
|
+
for (const c of o) {
|
|
868
|
+
const f = j(c, u.fromFeature.path);
|
|
869
|
+
let m = 1 / 0, h = 1 / 0, y = -1 / 0, p = -1 / 0;
|
|
870
|
+
if (Array.isArray(f))
|
|
871
|
+
for (const g of f) {
|
|
649
872
|
if (!Array.isArray(g) || g.length < 2) continue;
|
|
650
|
-
const
|
|
651
|
-
!Number.isFinite(
|
|
873
|
+
const E = Number(g[0]), _ = Number(g[1]);
|
|
874
|
+
!Number.isFinite(E) || !Number.isFinite(_) || (m = Math.min(m, E), h = Math.min(h, _), y = Math.max(y, E), p = Math.max(p, _));
|
|
652
875
|
}
|
|
653
|
-
Number.isFinite(
|
|
876
|
+
Number.isFinite(m) || (m = 0, h = 0, y = 0, p = 0), d.push(m, h, y, h, y, p, m, p);
|
|
654
877
|
}
|
|
655
|
-
|
|
878
|
+
l[i] = d;
|
|
656
879
|
}
|
|
657
|
-
return n.num_features =
|
|
880
|
+
return n.num_features = o.length, { uniforms: n, uniformArrays: l };
|
|
658
881
|
}
|
|
659
|
-
function
|
|
660
|
-
const
|
|
661
|
-
if (!
|
|
882
|
+
function pt(t, e, o) {
|
|
883
|
+
const r = k(e, t.dataRef);
|
|
884
|
+
if (!r) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
|
|
662
885
|
const n = {
|
|
663
|
-
collection:
|
|
886
|
+
collection: r,
|
|
664
887
|
variableMapping: t.attributes,
|
|
665
|
-
wgslBody:
|
|
888
|
+
wgslBody: Be(t.wgslFunction)
|
|
666
889
|
};
|
|
667
890
|
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);
|
|
668
|
-
const
|
|
669
|
-
if (
|
|
670
|
-
const u =
|
|
671
|
-
return n.uniforms = { ...
|
|
891
|
+
const l = Ft(t);
|
|
892
|
+
if (l?.mode === "batched") {
|
|
893
|
+
const u = k(e, l.layer)?.features ?? [], d = Ue(t.uniforms, t.uniformMatrices, u), c = ct(mt(t.uniforms), e) ?? {}, f = ft(mt(t.uniformMatrices), e);
|
|
894
|
+
return n.uniforms = { ...c, ...d.uniforms }, n.uniformArrays = { ...n.uniformArrays ?? {}, ...d.uniformArrays }, f && Object.keys(f).length > 0 && (n.uniformMatrices = f), n;
|
|
672
895
|
}
|
|
673
|
-
const
|
|
674
|
-
return
|
|
896
|
+
const a = l?.mode === "all" ? o : void 0, s = ct(t.uniforms, e, a), i = ft(t.uniformMatrices, e, a);
|
|
897
|
+
return s && (n.uniforms = s), i && (n.uniformMatrices = i), n;
|
|
675
898
|
}
|
|
676
|
-
function
|
|
899
|
+
function mt(t) {
|
|
677
900
|
if (t)
|
|
678
|
-
return Object.fromEntries(Object.entries(t).filter(([, e]) => !(
|
|
901
|
+
return Object.fromEntries(Object.entries(t).filter(([, e]) => !(S(e) && e.fromFeature.iterate === "batched")));
|
|
679
902
|
}
|
|
680
|
-
function
|
|
903
|
+
function Qe(t) {
|
|
681
904
|
return t.outputColumns ?? (t.outputColumnName ? [t.outputColumnName] : []);
|
|
682
905
|
}
|
|
683
|
-
async function
|
|
684
|
-
const
|
|
685
|
-
if (
|
|
686
|
-
const n =
|
|
906
|
+
async function We(t, e, o) {
|
|
907
|
+
const r = Ft(t);
|
|
908
|
+
if (r?.mode !== "all") return o(pt(t, e));
|
|
909
|
+
const n = k(e, t.dataRef);
|
|
687
910
|
if (!n) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
|
|
688
|
-
const
|
|
689
|
-
for (const
|
|
690
|
-
const u =
|
|
691
|
-
for (const
|
|
911
|
+
const l = Qe(t), a = structuredClone(n);
|
|
912
|
+
for (const i of a.features) {
|
|
913
|
+
const u = i.properties ??= {}, d = u.compute ??= {};
|
|
914
|
+
for (const c of l) d[c] = 0;
|
|
692
915
|
}
|
|
693
|
-
const
|
|
694
|
-
for (let
|
|
695
|
-
const u = await
|
|
696
|
-
|
|
697
|
-
const
|
|
698
|
-
if (!(!
|
|
699
|
-
for (const
|
|
700
|
-
const
|
|
701
|
-
Number.isFinite(
|
|
916
|
+
const s = k(e, r.layer)?.features?.length ?? 0;
|
|
917
|
+
for (let i = 0; i < s; i++) {
|
|
918
|
+
const u = await o({ ...pt(t, e, i), collection: a });
|
|
919
|
+
a.features.forEach((d, c) => {
|
|
920
|
+
const f = d.properties?.compute, m = u.features[c]?.properties?.compute;
|
|
921
|
+
if (!(!f || !m))
|
|
922
|
+
for (const h of l) {
|
|
923
|
+
const y = Number(m[h]);
|
|
924
|
+
Number.isFinite(y) && (f[h] += y);
|
|
702
925
|
}
|
|
703
926
|
});
|
|
704
927
|
}
|
|
705
|
-
return
|
|
928
|
+
return a;
|
|
706
929
|
}
|
|
707
|
-
const
|
|
708
|
-
function
|
|
709
|
-
return
|
|
930
|
+
const ht = ["surface", "parks", "water", "roads", "buildings", "polygons", "polylines"];
|
|
931
|
+
function Ye(t, e, o, r) {
|
|
932
|
+
return r?.get(b(o, e)) ?? t.getTablesMetadata().find((n) => n.name === e)?.type;
|
|
710
933
|
}
|
|
711
|
-
function
|
|
712
|
-
async function r(s, i,
|
|
713
|
-
return t?.get(
|
|
934
|
+
function Ve(t, e, o) {
|
|
935
|
+
async function r(s, i, u) {
|
|
936
|
+
return t?.get(b(u, i)) ?? await s.getLayer(i);
|
|
714
937
|
}
|
|
715
|
-
function
|
|
938
|
+
function n(s, i, u, d, c) {
|
|
716
939
|
if (!t) return;
|
|
717
|
-
const f =
|
|
718
|
-
t.set(
|
|
719
|
-
const
|
|
720
|
-
|
|
940
|
+
const f = d.outputTableName ?? u;
|
|
941
|
+
t.set(b(d.workspace, f), i);
|
|
942
|
+
const m = d.layerType ?? c ?? Ye(s, u, d.workspace, e);
|
|
943
|
+
d.outputTableName && m && e?.set(b(d.workspace, f), m);
|
|
721
944
|
}
|
|
722
|
-
async function
|
|
945
|
+
async function l(s, i) {
|
|
723
946
|
for (const c of i.layers)
|
|
724
|
-
if (!
|
|
725
|
-
throw new Error(`Render pass "${i.outputTableName}": layer "${c.id}" has the type "${c.type}", which a render pass cannot draw. A layer's type is one of ${
|
|
726
|
-
const
|
|
947
|
+
if (!ht.includes(c.type))
|
|
948
|
+
throw new Error(`Render pass "${i.outputTableName}": layer "${c.id}" has the type "${c.type}", which a render pass cannot draw. A layer's type is one of ${ht.join(", ")}.`);
|
|
949
|
+
const u = await Promise.all(i.layers.map(async (c) => ({
|
|
727
950
|
id: c.id,
|
|
728
951
|
collection: await r(s, c.dataRef, i.workspace),
|
|
729
952
|
type: c.type,
|
|
730
953
|
objectIdProperty: c.objectIdProperty
|
|
731
|
-
}))),
|
|
732
|
-
layers:
|
|
954
|
+
}))), d = await new et().renderPipeline({
|
|
955
|
+
layers: u,
|
|
733
956
|
viewpoints: {
|
|
734
957
|
collection: await r(s, i.viewpoints.dataRef, i.workspace),
|
|
735
958
|
strategy: i.viewpoints.strategy,
|
|
@@ -739,63 +962,63 @@ function ye(t, e) {
|
|
|
739
962
|
camera: i.camera,
|
|
740
963
|
tileSize: i.tileSize
|
|
741
964
|
});
|
|
742
|
-
|
|
965
|
+
n(s, d, i.viewpoints.dataRef, i, i.viewpoints.strategy?.type === "building-windows" ? "points" : void 0);
|
|
743
966
|
}
|
|
744
967
|
async function a(s, i) {
|
|
745
|
-
const
|
|
746
|
-
for (const
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
749
|
-
else if (
|
|
968
|
+
const u = {}, d = s.getWorkspaceConfiguration().coordinateFormat;
|
|
969
|
+
for (const m of je(i)) {
|
|
970
|
+
const h = b(i.workspace, m), y = t?.get(h) ?? (m === i.dataRef ? void 0 : qt(o?.get(h), d));
|
|
971
|
+
if (y) u[m] = y;
|
|
972
|
+
else if (m === i.dataRef) u[m] = await s.getLayer(m);
|
|
750
973
|
else
|
|
751
974
|
try {
|
|
752
|
-
|
|
975
|
+
u[m] = await s.getLayer(m);
|
|
753
976
|
} catch {
|
|
754
|
-
|
|
977
|
+
u[m] = void 0;
|
|
755
978
|
}
|
|
756
979
|
}
|
|
757
|
-
const
|
|
758
|
-
|
|
980
|
+
const c = new et(), f = await We(i, u, (m) => c.gpgpuPipeline(m));
|
|
981
|
+
n(s, f, i.dataRef, i);
|
|
759
982
|
}
|
|
760
983
|
return {
|
|
761
984
|
async resolveCompute(s, i) {
|
|
762
985
|
if (s)
|
|
763
|
-
return await
|
|
986
|
+
return await P(s, i.workspace), i.type === "render" ? await l(s, i) : await a(s, i), s;
|
|
764
987
|
}
|
|
765
988
|
};
|
|
766
989
|
}
|
|
767
|
-
class
|
|
990
|
+
class He {
|
|
768
991
|
_listeners = /* @__PURE__ */ new Map();
|
|
769
|
-
on(e,
|
|
992
|
+
on(e, o) {
|
|
770
993
|
this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
|
|
771
|
-
const
|
|
772
|
-
return
|
|
994
|
+
const r = this._listeners.get(e);
|
|
995
|
+
return r.add(o), () => r.delete(o);
|
|
773
996
|
}
|
|
774
997
|
/** @internal */
|
|
775
|
-
emit(e,
|
|
776
|
-
this._listeners.get(e)?.forEach((
|
|
998
|
+
emit(e, o) {
|
|
999
|
+
this._listeners.get(e)?.forEach((r) => r(o));
|
|
777
1000
|
}
|
|
778
1001
|
}
|
|
779
|
-
function
|
|
1002
|
+
function M(t) {
|
|
780
1003
|
return t === void 0 ? [] : Array.isArray(t) ? t : [t];
|
|
781
1004
|
}
|
|
782
|
-
function
|
|
1005
|
+
function Je(t) {
|
|
783
1006
|
const e = /* @__PURE__ */ new Set();
|
|
784
|
-
for (const
|
|
785
|
-
if (
|
|
786
|
-
if (
|
|
787
|
-
if (e.has(
|
|
788
|
-
e.add(
|
|
1007
|
+
for (const r of [...M(t.map), ...M(t.plot)])
|
|
1008
|
+
if (r.id !== void 0) {
|
|
1009
|
+
if (r.id === "") throw new Error("A map or plot has an empty id.");
|
|
1010
|
+
if (e.has(r.id)) throw new Error(`Two maps or plots have the id "${r.id}"; an id names one view.`);
|
|
1011
|
+
e.add(r.id);
|
|
789
1012
|
}
|
|
790
|
-
const
|
|
791
|
-
for (const
|
|
792
|
-
const n =
|
|
793
|
-
if (
|
|
794
|
-
throw new Error(
|
|
795
|
-
|
|
1013
|
+
const o = /* @__PURE__ */ new Map();
|
|
1014
|
+
for (const r of M(t.plot)) {
|
|
1015
|
+
const n = A(r), l = o.get(n);
|
|
1016
|
+
if (l)
|
|
1017
|
+
throw new Error(l.id === void 0 && r.id === void 0 ? `Two plots of the table "${n}" have no id; give each plot an id.` : `A plot's id "${n}" is the dataRef of a plot without an id; give each plot an id.`);
|
|
1018
|
+
o.set(n, r);
|
|
796
1019
|
}
|
|
797
1020
|
}
|
|
798
|
-
class
|
|
1021
|
+
class eo {
|
|
799
1022
|
dataAdapter;
|
|
800
1023
|
mapAdapter;
|
|
801
1024
|
plotAdapter;
|
|
@@ -813,12 +1036,13 @@ class Se {
|
|
|
813
1036
|
_exports = /* @__PURE__ */ new Map();
|
|
814
1037
|
/** Each GeoJSON table a run loaded and each table a join wrote, which its plots read before the database. */
|
|
815
1038
|
_geojsonCache = /* @__PURE__ */ new Map();
|
|
816
|
-
interactions = new
|
|
1039
|
+
interactions = new He();
|
|
817
1040
|
constructor(e) {
|
|
818
|
-
this.dataAdapter =
|
|
1041
|
+
this.dataAdapter = oe(e, this._geojsonCache), this.mapAdapter = be(e, this._layers, this._computeCache, this._maps, this._computeTypes, this._exports), this.plotAdapter = Oe(e, this._layers, this._plotRegistry, this._plotLinks, this._geojsonCache, this._computeCache, this._plotRows, this._exports), this.computeAdapter = Ve(this._computeCache, this._computeTypes, this._geojsonCache);
|
|
819
1042
|
}
|
|
820
1043
|
/**
|
|
821
|
-
* The coordinate reference system
|
|
1044
|
+
* The coordinate reference system autk-db stores a workspace's tables in, unless the spec's `workspaces` sets
|
|
1045
|
+
* another for it.
|
|
822
1046
|
*
|
|
823
1047
|
* Input data is expected in EPSG:4326 (WGS84) by default and is transformed
|
|
824
1048
|
* to this CRS on load. Consumers that prepare data for injection (e.g. by
|
|
@@ -826,7 +1050,7 @@ class Se {
|
|
|
826
1050
|
* instead of hard-coding a CRS string.
|
|
827
1051
|
*/
|
|
828
1052
|
get workspaceCrs() {
|
|
829
|
-
return
|
|
1053
|
+
return Ut;
|
|
830
1054
|
}
|
|
831
1055
|
get data() {
|
|
832
1056
|
return this._data;
|
|
@@ -851,8 +1075,8 @@ class Se {
|
|
|
851
1075
|
* @param mapId The map to look in, by its {@link MapId}: a string names a map by its `id`, a number by its index in
|
|
852
1076
|
* the spec's `map` list. Without it, every map.
|
|
853
1077
|
*/
|
|
854
|
-
mapLayers(e,
|
|
855
|
-
return this._layersOf(e,
|
|
1078
|
+
mapLayers(e, o) {
|
|
1079
|
+
return this._layersOf(e, o).map(({ map: r, layerId: n }) => ({ map: r, layerId: n }));
|
|
856
1080
|
}
|
|
857
1081
|
/**
|
|
858
1082
|
* The layer a map of the last {@link run} draws for a table, found by the table's name (a layer's `dataRef`):
|
|
@@ -868,12 +1092,12 @@ class Se {
|
|
|
868
1092
|
* const layer = grammar.mapLayer('buildings');
|
|
869
1093
|
* layer?.map.updateRenderInfo(layer.layerId, { opacity: 0.5 });
|
|
870
1094
|
*/
|
|
871
|
-
mapLayer(e,
|
|
872
|
-
return this.mapLayers(e,
|
|
1095
|
+
mapLayer(e, o) {
|
|
1096
|
+
return this.mapLayers(e, o).pop();
|
|
873
1097
|
}
|
|
874
1098
|
/** The drawn layers of a table, on every map or on the one `mapId` names. */
|
|
875
|
-
_layersOf(e,
|
|
876
|
-
return this._layers.filter((
|
|
1099
|
+
_layersOf(e, o) {
|
|
1100
|
+
return this._layers.filter((r) => r.dataRef === e && W(r, o));
|
|
877
1101
|
}
|
|
878
1102
|
/**
|
|
879
1103
|
* Releases what the last run created: every map (its layers' GPU buffers, its textures, its canvas context, the
|
|
@@ -897,7 +1121,10 @@ class Se {
|
|
|
897
1121
|
throw new Error("Plot adapter not initialized. Please call the constructor first.");
|
|
898
1122
|
if (!this.computeAdapter)
|
|
899
1123
|
throw new Error("Compute adapter not initialized. Please call the constructor first.");
|
|
900
|
-
|
|
1124
|
+
Je(e);
|
|
1125
|
+
for (const l of M(e.plot)) Ce(l);
|
|
1126
|
+
const o = Se(M(e.plot));
|
|
1127
|
+
this.destroy(), M(e.plot).length > 0 && ke(o), this.grammarEngine = Vt({
|
|
901
1128
|
spec: e,
|
|
902
1129
|
adapters: {
|
|
903
1130
|
db: this.dataAdapter,
|
|
@@ -907,27 +1134,27 @@ class Se {
|
|
|
907
1134
|
}
|
|
908
1135
|
}), await this.grammarEngine.run();
|
|
909
1136
|
const r = this.grammarEngine.context;
|
|
910
|
-
if (r && await
|
|
1137
|
+
if (r && await P(r), this._wireLinks(e), this._selectFromTheStart(e), this._rewireInteractions(e), !r) {
|
|
911
1138
|
console.warn("Grammar engine produced no data context."), this._data = {};
|
|
912
1139
|
return;
|
|
913
1140
|
}
|
|
914
|
-
const
|
|
915
|
-
for (const
|
|
916
|
-
Object.defineProperty(
|
|
1141
|
+
const n = {};
|
|
1142
|
+
for (const l of r.getLayersMetadata())
|
|
1143
|
+
Object.defineProperty(n, l.name, {
|
|
917
1144
|
get: () => {
|
|
918
|
-
const a = this._computeCache.get(
|
|
919
|
-
return a ? Promise.resolve(a) : r.getLayer(
|
|
1145
|
+
const a = this._computeCache.get(l.name);
|
|
1146
|
+
return a ? Promise.resolve(a) : r.getLayer(l.name);
|
|
920
1147
|
},
|
|
921
1148
|
enumerable: !0,
|
|
922
1149
|
configurable: !0
|
|
923
1150
|
});
|
|
924
|
-
for (const
|
|
925
|
-
|
|
926
|
-
get: () => Promise.resolve(this._computeCache.get(
|
|
1151
|
+
for (const l of this._computeCache.keys())
|
|
1152
|
+
l in n || Object.defineProperty(n, l, {
|
|
1153
|
+
get: () => Promise.resolve(this._computeCache.get(l)),
|
|
927
1154
|
enumerable: !0,
|
|
928
1155
|
configurable: !0
|
|
929
1156
|
});
|
|
930
|
-
this._data =
|
|
1157
|
+
this._data = n;
|
|
931
1158
|
}
|
|
932
1159
|
/**
|
|
933
1160
|
* Highlights features on every layer that draws the table `dataRef`, in every map (see {@link mapLayers}), or only
|
|
@@ -940,10 +1167,10 @@ class Se {
|
|
|
940
1167
|
* @param mapId The map to highlight on, by its {@link MapId}: a string names a map by its `id`, a number by its
|
|
941
1168
|
* index in the spec's `map` list. Without it, every map that draws the table.
|
|
942
1169
|
*/
|
|
943
|
-
highlightOnMap(e,
|
|
944
|
-
const n = this._layersOf(e,
|
|
945
|
-
for (const { map:
|
|
946
|
-
this._selectInLinkedPlots(n,
|
|
1170
|
+
highlightOnMap(e, o, r) {
|
|
1171
|
+
const n = this._layersOf(e, r);
|
|
1172
|
+
for (const { map: l, layerId: a } of n) l.setHighlightedIds(a, o);
|
|
1173
|
+
this._selectInLinkedPlots(n, o);
|
|
947
1174
|
}
|
|
948
1175
|
/**
|
|
949
1176
|
* Clears highlighted features on every layer that draws the table `dataRef`, in every map (see {@link mapLayers}),
|
|
@@ -954,10 +1181,10 @@ class Se {
|
|
|
954
1181
|
* @param mapId The map to clear, by its {@link MapId}: a string names a map by its `id`, a number by its index in
|
|
955
1182
|
* the spec's `map` list. Without it, every map that draws the table.
|
|
956
1183
|
*/
|
|
957
|
-
clearHighlightOnMap(e,
|
|
958
|
-
const
|
|
959
|
-
for (const { map: n, layerId:
|
|
960
|
-
this._selectInLinkedPlots(
|
|
1184
|
+
clearHighlightOnMap(e, o) {
|
|
1185
|
+
const r = this._layersOf(e, o);
|
|
1186
|
+
for (const { map: n, layerId: l } of r) n.clearHighlightedIds(l);
|
|
1187
|
+
this._selectInLinkedPlots(r, []);
|
|
961
1188
|
}
|
|
962
1189
|
/**
|
|
963
1190
|
* Clears the selection on the plot `plotId` names: its `id`, else its `dataRef`.
|
|
@@ -968,10 +1195,10 @@ class Se {
|
|
|
968
1195
|
* @param mapId The map whose linked layers to clear, by its {@link MapId}: a string names a map by its `id`, a
|
|
969
1196
|
* number by its index in the spec's `map` list. Without it, every linked layer.
|
|
970
1197
|
*/
|
|
971
|
-
clearHighlightOnPlot(e,
|
|
1198
|
+
clearHighlightOnPlot(e, o) {
|
|
972
1199
|
this._plotRegistry.get(e)?.setSelection([]);
|
|
973
|
-
for (const
|
|
974
|
-
|
|
1200
|
+
for (const r of this._plotLinks.get(e) ?? [])
|
|
1201
|
+
W(r, o) && r.map.clearHighlightedIds(r.layerId);
|
|
975
1202
|
}
|
|
976
1203
|
/**
|
|
977
1204
|
* Applies a selection to the plot `plotId` names: its `id`, else its `dataRef`.
|
|
@@ -983,86 +1210,95 @@ class Se {
|
|
|
983
1210
|
* @param mapId The map whose linked layers to highlight, by its {@link MapId}: a string names a map by its `id`, a
|
|
984
1211
|
* number by its index in the spec's `map` list. Without it, every linked layer.
|
|
985
1212
|
*/
|
|
986
|
-
setPlotSelection(e,
|
|
987
|
-
this._plotRegistry.get(e)?.setSelection(
|
|
1213
|
+
setPlotSelection(e, o, r) {
|
|
1214
|
+
this._plotRegistry.get(e)?.setSelection(o);
|
|
988
1215
|
const n = this._plotRows.get(e) ?? [];
|
|
989
|
-
for (const
|
|
990
|
-
|
|
1216
|
+
for (const l of this._plotLinks.get(e) ?? [])
|
|
1217
|
+
W(l, r) && l.map.setHighlightedIds(l.layerId, D(o, n, l.rows));
|
|
991
1218
|
}
|
|
992
1219
|
/**
|
|
993
1220
|
* Applies a selection made on `layers`, by their positions `featureIds`, to every plot linked to one of them, at the
|
|
994
1221
|
* plot's own positions of the selected rows.
|
|
995
1222
|
*/
|
|
996
|
-
_selectInLinkedPlots(e,
|
|
997
|
-
for (const [
|
|
998
|
-
const
|
|
999
|
-
if (
|
|
1000
|
-
const
|
|
1001
|
-
this._plotRegistry.get(
|
|
1223
|
+
_selectInLinkedPlots(e, o) {
|
|
1224
|
+
for (const [r, n] of this._plotLinks) {
|
|
1225
|
+
const l = n.filter((i) => e.includes(i));
|
|
1226
|
+
if (l.length === 0) continue;
|
|
1227
|
+
const a = this._plotRows.get(r) ?? [], s = new Set(l.flatMap((i) => D(o, i.rows, a)));
|
|
1228
|
+
this._plotRegistry.get(r)?.setSelection([...s]);
|
|
1002
1229
|
}
|
|
1003
1230
|
}
|
|
1004
1231
|
/** Wires each entry of `links` between a plot and a layer of a map, both now drawn. */
|
|
1005
1232
|
_wireLinks(e) {
|
|
1006
|
-
const
|
|
1233
|
+
const o = M(e.map), r = M(e.plot);
|
|
1007
1234
|
for (const n of e.links ?? []) {
|
|
1008
|
-
const
|
|
1009
|
-
if (!
|
|
1235
|
+
const l = r.find((c) => A(c) === n.source), a = this._plotRegistry.get(n.source);
|
|
1236
|
+
if (!l || !a)
|
|
1010
1237
|
throw new Error(`Link source "${n.source}" is not the id (or the dataRef) of a plot of this specification.`);
|
|
1011
|
-
const
|
|
1012
|
-
if (
|
|
1238
|
+
const s = o.findIndex((c) => c.id === n.target), i = this._maps[s];
|
|
1239
|
+
if (s < 0 || !i)
|
|
1013
1240
|
throw new Error(`Link target "${n.target}" is not the id of a map of this specification.`);
|
|
1014
|
-
const u =
|
|
1241
|
+
const u = o[s].layerRefs.find((c) => n.layer !== void 0 ? R(c) === n.layer : c.dataRef === l.dataRef);
|
|
1015
1242
|
if (!u)
|
|
1016
|
-
throw new Error(n.layer !== void 0 ? `Link from "${n.source}": map "${n.target}" has no layer "${n.layer}".` : `Link from "${n.source}": map "${n.target}" draws no layer of the table "${
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1243
|
+
throw new Error(n.layer !== void 0 ? `Link from "${n.source}": map "${n.target}" has no layer "${n.layer}".` : `Link from "${n.source}": map "${n.target}" draws no layer of the table "${l.dataRef}"; name the layer.`);
|
|
1244
|
+
const d = this._layers.find((c) => c.mapIndex === s && c.layerId === R(u));
|
|
1245
|
+
d && (kt(a, this._plotRows.get(n.source) ?? [], l.events ?? [], d), Rt(this._plotLinks, n.source, d));
|
|
1019
1246
|
}
|
|
1020
1247
|
}
|
|
1248
|
+
/**
|
|
1249
|
+
* Applies each plot's `selection` once the plots and their links exist, as `setPlotSelection` does: the plot selects
|
|
1250
|
+
* the rows, and the layers it is linked to, by `mapRef` or `links`, highlight them. autk-plot's `setSelection` emits
|
|
1251
|
+
* no event, so no `plot:selection` reports it.
|
|
1252
|
+
*/
|
|
1253
|
+
_selectFromTheStart(e) {
|
|
1254
|
+
for (const o of M(e.plot))
|
|
1255
|
+
o.selection && o.selection.length > 0 && this.setPlotSelection(A(o), o.selection);
|
|
1256
|
+
}
|
|
1021
1257
|
_rewireInteractions(e) {
|
|
1022
|
-
for (const
|
|
1258
|
+
for (const r of this._fwdCleanups) r();
|
|
1023
1259
|
this._fwdCleanups = [];
|
|
1024
|
-
const
|
|
1025
|
-
this._maps.forEach((
|
|
1026
|
-
const
|
|
1027
|
-
this.interactions.emit("map:picking", { mapId:
|
|
1260
|
+
const o = M(e.map);
|
|
1261
|
+
this._maps.forEach((r, n) => {
|
|
1262
|
+
const l = St(o[n], n), a = ({ layerId: s, selection: i }) => {
|
|
1263
|
+
this.interactions.emit("map:picking", { mapId: l, layerId: s, selection: i });
|
|
1028
1264
|
};
|
|
1029
|
-
|
|
1265
|
+
r.events.on(Y.PICKING, a), this._fwdCleanups.push(() => r.events.off(Y.PICKING, a));
|
|
1030
1266
|
});
|
|
1031
|
-
for (const [
|
|
1032
|
-
for (const
|
|
1033
|
-
const
|
|
1267
|
+
for (const [r, n] of this._plotRegistry)
|
|
1268
|
+
for (const l of [x.CLICK, x.BRUSH, x.BRUSH_X, x.BRUSH_Y]) {
|
|
1269
|
+
const a = ({ selection: s }) => {
|
|
1034
1270
|
this.interactions.emit("plot:selection", {
|
|
1035
|
-
plotId:
|
|
1036
|
-
event:
|
|
1037
|
-
selection:
|
|
1271
|
+
plotId: r,
|
|
1272
|
+
event: l,
|
|
1273
|
+
selection: s
|
|
1038
1274
|
});
|
|
1039
1275
|
};
|
|
1040
|
-
n.events.on(
|
|
1276
|
+
n.events.on(l, a), this._fwdCleanups.push(() => n.events.off(l, a));
|
|
1041
1277
|
}
|
|
1042
1278
|
}
|
|
1043
1279
|
}
|
|
1044
1280
|
export {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1281
|
+
eo as AutkGrammar,
|
|
1282
|
+
Ht as ColorMapInterpolator,
|
|
1283
|
+
He as GrammarEventEmitter,
|
|
1284
|
+
wt as NormalizationMode,
|
|
1285
|
+
Tt as STORAGE_BUFFER_BINDING_SIZE,
|
|
1286
|
+
ge as applyCamera,
|
|
1287
|
+
to as arrangeViews,
|
|
1288
|
+
Ue as buildBatchedUniforms,
|
|
1289
|
+
je as computeLayerNames,
|
|
1290
|
+
Ve as createComputeAdapter,
|
|
1291
|
+
oe as createDataAdapter,
|
|
1292
|
+
Vt as createEngine,
|
|
1293
|
+
P as enterWorkspace,
|
|
1294
|
+
Ft as findIterateSource,
|
|
1295
|
+
S as isFromFeature,
|
|
1296
|
+
Be as joinWgsl,
|
|
1297
|
+
Ge as maxBatchedFeatures,
|
|
1298
|
+
pt as resolveComputeParams,
|
|
1299
|
+
ft as resolveUniformMatrices,
|
|
1300
|
+
ct as resolveUniforms,
|
|
1301
|
+
We as runCompute,
|
|
1302
|
+
b as tableKey
|
|
1067
1303
|
};
|
|
1068
1304
|
//# sourceMappingURL=autk-grammar.js.map
|