@urban-toolkit/autk-grammar 5.1.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 +89 -1
- package/build/autk-grammar-schema.json +654 -1
- package/dist/autk-grammar.js +737 -617
- 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.js +85 -81
- package/dist/data/autk-grammar-data.js.map +1 -1
- package/dist/index.d.ts +117 -3
- package/package.json +1 -1
package/dist/autk-grammar.js
CHANGED
|
@@ -1,280 +1,288 @@
|
|
|
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.workspaces?.length &&
|
|
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 s
|
|
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
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
|
-
], a =
|
|
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
64
|
...d !== void 0 && { id: d },
|
|
65
65
|
key: c,
|
|
66
66
|
row: Math.floor(f / a),
|
|
67
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
76
|
function b(t, e) {
|
|
77
|
-
return t === void 0 || t ===
|
|
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 a = e[
|
|
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];
|
|
110
118
|
if (a !== void 0)
|
|
111
|
-
for (const
|
|
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((a,
|
|
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,
|
|
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;
|
|
132
140
|
if (Math.abs(n) > 180 || Math.abs(a) > 180)
|
|
133
|
-
throw
|
|
134
|
-
if (Math.abs(
|
|
135
|
-
throw
|
|
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.");
|
|
136
144
|
if (n >= a)
|
|
137
|
-
throw
|
|
138
|
-
if (
|
|
139
|
-
throw
|
|
140
|
-
return { bbox: [n,
|
|
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] };
|
|
141
149
|
}
|
|
142
|
-
function
|
|
143
|
-
const { autoLoadLayers: e, ...
|
|
150
|
+
function te(t) {
|
|
151
|
+
const { autoLoadLayers: e, ...o } = t;
|
|
144
152
|
if (t.pbfFileUrl !== void 0 && (t.tagSets?.length ?? 0) > 0)
|
|
145
153
|
throw new Error(`OSM source "${t.outputTableName}": tagSets are read from the Overpass API only, so a source with pbfFileUrl cannot take them.`);
|
|
146
154
|
return {
|
|
147
|
-
...
|
|
148
|
-
queryArea:
|
|
155
|
+
...o,
|
|
156
|
+
queryArea: Zt(t),
|
|
149
157
|
autoLoadLayers: {
|
|
150
158
|
layers: e?.layers ?? [],
|
|
151
159
|
...e?.coordinateFormat !== void 0 && { coordinateFormat: e.coordinateFormat }
|
|
152
160
|
}
|
|
153
161
|
};
|
|
154
162
|
}
|
|
155
|
-
function
|
|
163
|
+
function nt(t) {
|
|
156
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.`;
|
|
157
165
|
}
|
|
158
|
-
function
|
|
159
|
-
return t === void 0 || t ===
|
|
166
|
+
function Q(t) {
|
|
167
|
+
return t === void 0 || t === G ? "the default workspace" : `the workspace "${t}"`;
|
|
160
168
|
}
|
|
161
|
-
function
|
|
169
|
+
function at(t) {
|
|
162
170
|
if (t != null)
|
|
163
171
|
return typeof t == "string" ? t : JSON.stringify(t);
|
|
164
172
|
}
|
|
165
|
-
async function
|
|
173
|
+
async function ee(t, e, o, r) {
|
|
166
174
|
const n = /* @__PURE__ */ new Map();
|
|
167
|
-
for (const
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
if (
|
|
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)
|
|
171
179
|
throw new Error("its rows have no feature id to update them by.");
|
|
172
|
-
n.set(
|
|
180
|
+
n.set(i, [...n.get(i) ?? [], s.id]);
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
return
|
|
178
|
-
}), a = e.columns.some((
|
|
179
|
-
return { data: { ...
|
|
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 };
|
|
180
188
|
}
|
|
181
|
-
async function
|
|
189
|
+
async function it(t) {
|
|
182
190
|
if (t) return t;
|
|
183
|
-
const e = new
|
|
191
|
+
const e = new Gt();
|
|
184
192
|
return await e.init(), e;
|
|
185
193
|
}
|
|
186
|
-
function
|
|
187
|
-
let e = 1 / 0,
|
|
188
|
-
const
|
|
189
|
-
if (Array.isArray(
|
|
190
|
-
if (typeof
|
|
191
|
-
const [
|
|
192
|
-
|
|
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);
|
|
193
201
|
return;
|
|
194
202
|
}
|
|
195
|
-
for (const
|
|
203
|
+
for (const i of s) l(i);
|
|
196
204
|
}
|
|
197
|
-
}, a = (
|
|
198
|
-
|
|
205
|
+
}, a = (s) => {
|
|
206
|
+
s && (s.type === "GeometryCollection" ? s.geometries.forEach(a) : l(s.coordinates));
|
|
199
207
|
};
|
|
200
|
-
for (const
|
|
201
|
-
return e <=
|
|
208
|
+
for (const s of t.features ?? []) a(s?.geometry);
|
|
209
|
+
return e <= r ? [e, o, r, n] : void 0;
|
|
202
210
|
}
|
|
203
|
-
function
|
|
204
|
-
function
|
|
205
|
-
if (!
|
|
211
|
+
function oe(t, e) {
|
|
212
|
+
function o(n, l) {
|
|
213
|
+
if (!l || !l.db)
|
|
206
214
|
return;
|
|
207
|
-
const a = document.getElementById(
|
|
215
|
+
const a = document.getElementById(l.db);
|
|
208
216
|
if (a) {
|
|
209
|
-
const
|
|
217
|
+
const s = n.getTablesMetadata();
|
|
210
218
|
a.innerHTML += "<ul>";
|
|
211
|
-
for (const
|
|
212
|
-
a.innerHTML += `<li>${
|
|
213
|
-
a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${
|
|
219
|
+
for (const i of s)
|
|
220
|
+
a.innerHTML += `<li>${i.name}: (${i.source}, ${i.type}) </li>`;
|
|
221
|
+
a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${s.length}</p>`;
|
|
214
222
|
}
|
|
215
223
|
}
|
|
216
|
-
async function
|
|
224
|
+
async function r(n, l, a) {
|
|
217
225
|
if (!e) return;
|
|
218
|
-
const
|
|
219
|
-
|
|
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);
|
|
220
228
|
}
|
|
221
229
|
return {
|
|
222
|
-
async resolveWorkspaces(n,
|
|
223
|
-
const a = await
|
|
224
|
-
for (const { name:
|
|
225
|
-
const c =
|
|
226
|
-
if (
|
|
227
|
-
throw new Error(`workspaces sets ${
|
|
228
|
-
|
|
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);
|
|
229
237
|
try {
|
|
230
238
|
await a.setWorkspace(c, { coordinateFormat: u, precisionGrid: d });
|
|
231
239
|
} catch (f) {
|
|
232
|
-
throw new Error(`workspaces, ${
|
|
240
|
+
throw new Error(`workspaces, ${Q(i)}: ${f instanceof Error ? f.message : String(f)}`);
|
|
233
241
|
}
|
|
234
242
|
}
|
|
235
|
-
return await
|
|
243
|
+
return await P(a), a;
|
|
236
244
|
},
|
|
237
|
-
async resolveSource(n,
|
|
238
|
-
const a = await
|
|
239
|
-
await
|
|
240
|
-
let { type:
|
|
241
|
-
switch (
|
|
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;
|
|
249
|
+
switch (i) {
|
|
242
250
|
case "osm":
|
|
243
|
-
return await a.loadOsm(
|
|
251
|
+
return await a.loadOsm(te(d)), o(a, t), a;
|
|
244
252
|
case "csv":
|
|
245
|
-
return await a.loadCsv(d),
|
|
253
|
+
return await a.loadCsv(d), o(a, t), a;
|
|
246
254
|
case "json":
|
|
247
|
-
return await a.loadJson(d),
|
|
255
|
+
return await a.loadJson(d), o(a, t), a;
|
|
248
256
|
case "geojson": {
|
|
249
257
|
const c = d;
|
|
250
258
|
let f;
|
|
251
|
-
c.geojsonFileUrl ? f = await (await fetch(c.geojsonFileUrl)).json() : f = c.geojsonObject, e && f && e.set(b(
|
|
252
|
-
const
|
|
253
|
-
const p = { ...c, geojsonObject:
|
|
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) };
|
|
254
262
|
return delete p.geojsonFileUrl, p;
|
|
255
|
-
})() : c,
|
|
256
|
-
if (
|
|
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))
|
|
257
265
|
throw new Error(
|
|
258
|
-
`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)}`
|
|
259
267
|
);
|
|
260
268
|
try {
|
|
261
|
-
await a.loadGeojson(
|
|
269
|
+
await a.loadGeojson(m);
|
|
262
270
|
} catch (p) {
|
|
263
|
-
throw new Error(`Failed to load GeoJSON layer "${
|
|
271
|
+
throw new Error(`Failed to load GeoJSON layer "${m.outputTableName}": ${p instanceof Error ? p.message : String(p)}`);
|
|
264
272
|
}
|
|
265
273
|
try {
|
|
266
|
-
const p = await a.getBoundingBoxFromLayer(
|
|
267
|
-
if (!isFinite(p.minLon) || !isFinite(p.minLat) || !isFinite(p.maxLon) || !isFinite(p.maxLat) || Math.abs(p.minLon) >
|
|
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)
|
|
268
276
|
throw new Error(
|
|
269
|
-
`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.`
|
|
270
278
|
);
|
|
271
279
|
} catch (p) {
|
|
272
280
|
if (p instanceof Error && p.message.includes("bounding box after transform")) throw p;
|
|
273
281
|
}
|
|
274
|
-
return
|
|
282
|
+
return o(a, t), a;
|
|
275
283
|
}
|
|
276
284
|
case "geotiff":
|
|
277
|
-
return await a.loadGeoTiff(d),
|
|
285
|
+
return await a.loadGeoTiff(d), o(a, t), a;
|
|
278
286
|
case "heatmap": {
|
|
279
287
|
const c = d;
|
|
280
288
|
if (c.groupBy?.some((f) => f.aggregateFn === "collect"))
|
|
@@ -285,7 +293,7 @@ function Vt(t, e) {
|
|
|
285
293
|
outputTableName: c.outputTableName,
|
|
286
294
|
grid: c.grid,
|
|
287
295
|
...c.groupBy && { groupBy: c.groupBy }
|
|
288
|
-
}),
|
|
296
|
+
}), o(a, t), a;
|
|
289
297
|
}
|
|
290
298
|
case "join": {
|
|
291
299
|
const c = d;
|
|
@@ -296,9 +304,9 @@ function Vt(t, e) {
|
|
|
296
304
|
...c.groupBy && { groupBy: c.groupBy }
|
|
297
305
|
}), e) {
|
|
298
306
|
const f = await a.getLayer(c.dataRef);
|
|
299
|
-
e.set(b(
|
|
307
|
+
e.set(b(s, c.dataRef), f);
|
|
300
308
|
}
|
|
301
|
-
return
|
|
309
|
+
return o(a, t), a;
|
|
302
310
|
}
|
|
303
311
|
case "sql": {
|
|
304
312
|
const c = d;
|
|
@@ -315,255 +323,260 @@ function Vt(t, e) {
|
|
|
315
323
|
} catch (f) {
|
|
316
324
|
throw new Error(`SQL source "${c.outputTableName}": ${f instanceof Error ? f.message : String(f)}`);
|
|
317
325
|
}
|
|
318
|
-
return e?.delete(b(
|
|
326
|
+
return e?.delete(b(s, c.outputTableName)), o(a, t), a;
|
|
319
327
|
}
|
|
320
328
|
case "update": {
|
|
321
|
-
const c = d, f = (
|
|
329
|
+
const c = d, f = (y) => new Error(`Update of "${c.dataRef}": ${y}`);
|
|
322
330
|
if (c.geojsonObject === void 0 == (c.jsonObject === void 0))
|
|
323
331
|
throw f("give its rows in geojsonObject or in jsonObject, one of the two.");
|
|
324
332
|
if (c.strategy === "update" && !c.idColumn)
|
|
325
333
|
throw f("the update strategy needs an idColumn, the column that matches a given row to the table's rows.");
|
|
326
|
-
let
|
|
334
|
+
let m = c.geojsonObject ?? c.jsonObject, h = c.idColumn;
|
|
327
335
|
try {
|
|
328
|
-
const
|
|
329
|
-
if (c.strategy === "update" && c.geojsonObject &&
|
|
330
|
-
return
|
|
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;
|
|
331
339
|
await a.updateTable({
|
|
332
340
|
tableName: c.dataRef,
|
|
333
|
-
data:
|
|
341
|
+
data: m,
|
|
334
342
|
strategy: c.strategy,
|
|
335
|
-
...
|
|
343
|
+
...h !== void 0 && { idColumn: h }
|
|
336
344
|
});
|
|
337
|
-
} catch (
|
|
338
|
-
throw f(
|
|
345
|
+
} catch (y) {
|
|
346
|
+
throw f(y instanceof Error ? y.message : String(y));
|
|
339
347
|
}
|
|
340
|
-
return await
|
|
348
|
+
return await r(a, s, c.dataRef), o(a, t), a;
|
|
341
349
|
}
|
|
342
350
|
case "drop": {
|
|
343
351
|
const c = d;
|
|
344
352
|
if (!a.getTablesMetadata().some((f) => f.name === c.dataRef))
|
|
345
|
-
throw new Error(`Drop of "${c.dataRef}": ${
|
|
346
|
-
return await a.removeLayer(c.dataRef), e?.delete(b(
|
|
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;
|
|
347
355
|
}
|
|
348
356
|
default:
|
|
349
|
-
throw new Error(`Unknown data source type "${String(
|
|
357
|
+
throw new Error(`Unknown data source type "${String(i)}".`);
|
|
350
358
|
}
|
|
351
359
|
}
|
|
352
360
|
};
|
|
353
361
|
}
|
|
354
|
-
function
|
|
362
|
+
function Mt(t, e) {
|
|
355
363
|
return e === !0 ? `${t} osm-elements` : t;
|
|
356
364
|
}
|
|
357
|
-
function
|
|
365
|
+
function At(t) {
|
|
358
366
|
return t === !0 ? { osmElements: !0 } : void 0;
|
|
359
367
|
}
|
|
360
|
-
function
|
|
361
|
-
if (!t) return
|
|
362
|
-
let
|
|
363
|
-
return
|
|
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;
|
|
364
372
|
}
|
|
365
|
-
function
|
|
373
|
+
function St(t, e) {
|
|
366
374
|
return t?.id ?? e;
|
|
367
375
|
}
|
|
368
|
-
function
|
|
376
|
+
function W(t, e) {
|
|
369
377
|
return e === void 0 ? !0 : typeof e == "number" ? t.mapIndex === e : t.mapId === e;
|
|
370
378
|
}
|
|
371
|
-
function
|
|
372
|
-
const
|
|
373
|
-
|
|
379
|
+
function Rt(t, e, o) {
|
|
380
|
+
const r = t?.get(e) ?? [];
|
|
381
|
+
r.includes(o) || t?.set(e, [...r, o]);
|
|
374
382
|
}
|
|
375
|
-
const
|
|
376
|
-
function
|
|
383
|
+
const It = 6378137, V = 0.0818191908426215;
|
|
384
|
+
function re(t, e) {
|
|
377
385
|
if (t === void 0 || typeof t == "number" && Number.isFinite(t) && t > 0) return;
|
|
378
|
-
const
|
|
379
|
-
throw new Error(`Layer "${e}": pointSize must be a number of meters greater than 0, not ${
|
|
380
|
-
}
|
|
381
|
-
function
|
|
382
|
-
const e = Math.exp(-t /
|
|
383
|
-
let
|
|
384
|
-
for (let
|
|
385
|
-
const n =
|
|
386
|
-
if (Math.abs(
|
|
387
|
-
|
|
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;
|
|
388
396
|
}
|
|
389
|
-
return
|
|
397
|
+
return o;
|
|
390
398
|
}
|
|
391
|
-
function
|
|
399
|
+
function ae(t, e) {
|
|
392
400
|
if (/^EPSG:3395$/i.test(t)) {
|
|
393
|
-
const
|
|
394
|
-
return Math.sqrt(1 -
|
|
401
|
+
const o = ne(e), r = V * Math.sin(o);
|
|
402
|
+
return Math.sqrt(1 - r * r) / Math.cos(o);
|
|
395
403
|
}
|
|
396
|
-
return /^EPSG:3857$/i.test(t) ? Math.cosh(e /
|
|
404
|
+
return /^EPSG:3857$/i.test(t) ? Math.cosh(e / It) : 1;
|
|
397
405
|
}
|
|
398
|
-
function
|
|
406
|
+
function ie(t, e, o, r) {
|
|
399
407
|
if (t === void 0 || e !== "points") return;
|
|
400
|
-
const n =
|
|
408
|
+
const n = r();
|
|
401
409
|
if (n)
|
|
402
|
-
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 };
|
|
403
428
|
}
|
|
404
429
|
function R(t) {
|
|
405
430
|
return typeof t.title == "string" && t.title !== "" ? t.title : t.dataRef;
|
|
406
431
|
}
|
|
407
|
-
function
|
|
408
|
-
const
|
|
409
|
-
for (const
|
|
410
|
-
const n = R(
|
|
411
|
-
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))
|
|
412
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.`);
|
|
413
|
-
|
|
438
|
+
o.add(n);
|
|
414
439
|
}
|
|
415
440
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
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);
|
|
421
445
|
}
|
|
422
|
-
function
|
|
423
|
-
const
|
|
424
|
-
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;
|
|
425
449
|
}
|
|
426
|
-
function
|
|
450
|
+
function ue(t, e) {
|
|
427
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;
|
|
428
452
|
}
|
|
429
|
-
function
|
|
430
|
-
const
|
|
431
|
-
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;
|
|
432
456
|
}
|
|
433
|
-
function
|
|
434
|
-
if (
|
|
457
|
+
function fe(t, e, o, r, n) {
|
|
458
|
+
if (N.isCategorical(e.interpolator)) return;
|
|
435
459
|
if (n != null) {
|
|
436
|
-
const u =
|
|
437
|
-
return
|
|
460
|
+
const u = o != null ? [n[0], o, n[1]] : [n[0], n[1]];
|
|
461
|
+
return r === !0 ? u.reverse() : u;
|
|
438
462
|
}
|
|
439
463
|
if (!t) return;
|
|
440
|
-
let
|
|
464
|
+
let l = 0, a = 0;
|
|
441
465
|
for (let u = 0; u < t.length; u++) {
|
|
442
466
|
const d = t[u];
|
|
443
|
-
Number.isFinite(d) && (a++,
|
|
467
|
+
Number.isFinite(d) && (a++, o != null && (l = Math.max(l, Math.abs(d - o))));
|
|
444
468
|
}
|
|
445
|
-
const
|
|
446
|
-
if (a === 0 || !
|
|
447
|
-
const
|
|
448
|
-
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;
|
|
449
473
|
}
|
|
450
|
-
function
|
|
451
|
-
if (!(e == null ||
|
|
474
|
+
function de(t, e) {
|
|
475
|
+
if (!(e == null || N.isCategorical(t.interpolator)))
|
|
452
476
|
return [e[0], e[1]];
|
|
453
477
|
}
|
|
454
|
-
function
|
|
478
|
+
function pe(t) {
|
|
455
479
|
const e = t.colorMapRange;
|
|
456
480
|
if (e === void 0) return;
|
|
457
|
-
const
|
|
458
|
-
if (
|
|
459
|
-
throw r
|
|
460
|
-
const [
|
|
461
|
-
if (
|
|
462
|
-
throw
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
function ne(t, e) {
|
|
470
|
-
return e && e.length > 0 ? { type: P.USER, params: e } : t?.mode === pt.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
|
|
471
|
-
type: P.PERCENTILE,
|
|
472
|
-
params: [t.lowerPercentile ?? 0, t.upperPercentile ?? 100]
|
|
473
|
-
} : { type: P.PERCENTILE } : { type: P.MIN_MAX };
|
|
474
|
-
}
|
|
475
|
-
function ae(t, e) {
|
|
476
|
-
return e.split(".").reduce((r, o) => {
|
|
477
|
-
if (!(r == null || typeof r != "object"))
|
|
478
|
-
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];
|
|
479
492
|
}, t);
|
|
480
493
|
}
|
|
481
|
-
function
|
|
482
|
-
const
|
|
483
|
-
let
|
|
484
|
-
for (let a = 0; a <
|
|
485
|
-
|
|
486
|
-
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;
|
|
487
500
|
}
|
|
488
|
-
function
|
|
489
|
-
const
|
|
490
|
-
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 ?? "";
|
|
491
504
|
}
|
|
492
|
-
function
|
|
505
|
+
function Nt(t) {
|
|
493
506
|
const { pitch: e } = t;
|
|
494
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.`;
|
|
495
508
|
}
|
|
496
|
-
function
|
|
497
|
-
const
|
|
498
|
-
if (
|
|
509
|
+
function ge(t, e) {
|
|
510
|
+
const o = Nt(e);
|
|
511
|
+
if (o) throw new Error(o);
|
|
499
512
|
if (e.zoom === void 0 && !e.pitch && !e.bearing) return;
|
|
500
|
-
const
|
|
501
|
-
n - a * Math.sin(
|
|
502
|
-
|
|
503
|
-
a * Math.cos(
|
|
504
|
-
], d = [Math.cos(
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
function
|
|
508
|
-
const
|
|
509
|
-
return Array.isArray(
|
|
510
|
-
const
|
|
511
|
-
return r[
|
|
512
|
-
}) :
|
|
513
|
-
}
|
|
514
|
-
function
|
|
515
|
-
async function a(
|
|
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),
|
|
516
|
+
a * Math.cos(s)
|
|
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) {
|
|
516
529
|
let d = {};
|
|
517
|
-
for (const f of
|
|
530
|
+
for (const f of i.getTablesMetadata())
|
|
518
531
|
f.type !== void 0 && (d[f.name] = f.type);
|
|
519
532
|
const c = [];
|
|
520
533
|
for (const f of u.layerRefs) {
|
|
521
|
-
const
|
|
522
|
-
p === "raster" ?
|
|
523
|
-
const
|
|
524
|
-
Object.keys(
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
const { catchAllCategory:
|
|
528
|
-
let
|
|
529
|
-
if (
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
...
|
|
533
|
-
features:
|
|
534
|
-
const
|
|
535
|
-
return
|
|
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;
|
|
536
549
|
})
|
|
537
|
-
},
|
|
550
|
+
}, z = w.has(T) ? L : [...L, T];
|
|
538
551
|
}
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
const O = f.colorMapRange,
|
|
542
|
-
if (f.colorMapInterpolator ||
|
|
543
|
-
const
|
|
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) {
|
|
556
|
+
const w = {
|
|
544
557
|
// urban-grammar ColorMapInterpolator values are string-compatible
|
|
545
558
|
// with autk-core ColorMapInterpolator at runtime
|
|
546
|
-
interpolator: f.colorMapInterpolator ??
|
|
547
|
-
domainSpec:
|
|
559
|
+
interpolator: f.colorMapInterpolator ?? s.layerManager.searchByLayerId(h)?.layerRenderInfo.colormap.config.interpolator ?? gt.SEQ_REDS,
|
|
560
|
+
domainSpec: Lt(f.normalization, z)
|
|
548
561
|
};
|
|
549
|
-
let
|
|
550
|
-
|
|
551
|
-
} else
|
|
552
|
-
if (
|
|
553
|
-
const
|
|
554
|
-
|
|
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") {
|
|
566
|
+
const w = g.startsWith("properties.") ? g : `properties.${g}`;
|
|
567
|
+
s.updateThematic(h, { collection: K, property: w });
|
|
555
568
|
}
|
|
556
|
-
c.push(p === "raster" ? [] :
|
|
569
|
+
c.push(p === "raster" ? [] : we(s, h, _t(_), I));
|
|
557
570
|
}
|
|
558
571
|
return c;
|
|
559
572
|
}
|
|
560
573
|
return {
|
|
561
|
-
async resolveMap(
|
|
562
|
-
if (t && t.map &&
|
|
563
|
-
|
|
564
|
-
for (const
|
|
565
|
-
|
|
566
|
-
const d =
|
|
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);
|
|
567
580
|
if (d)
|
|
568
581
|
throw new Error(`Map ${u}: ${d}`);
|
|
569
582
|
let c;
|
|
@@ -571,31 +584,123 @@ function ce(t, e, r, o, n, s) {
|
|
|
571
584
|
throw new Error("Could not find rendering target for map: " + t.map);
|
|
572
585
|
if (!(c instanceof HTMLCanvasElement))
|
|
573
586
|
throw new Error("Target for map is not a canvas: " + t.map);
|
|
574
|
-
const f = new
|
|
575
|
-
let
|
|
587
|
+
const f = new Qt(c);
|
|
588
|
+
let m;
|
|
576
589
|
try {
|
|
577
|
-
|
|
578
|
-
} 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) {
|
|
579
592
|
try {
|
|
580
593
|
f.destroy();
|
|
581
594
|
} catch {
|
|
582
595
|
}
|
|
583
|
-
throw
|
|
596
|
+
throw y;
|
|
584
597
|
}
|
|
585
|
-
const
|
|
586
|
-
|
|
598
|
+
const h = St(i, u);
|
|
599
|
+
i.layerRefs.forEach((y, p) => e?.push({
|
|
587
600
|
map: f,
|
|
588
601
|
mapIndex: u,
|
|
589
|
-
mapId:
|
|
590
|
-
layerId: R(
|
|
591
|
-
dataRef:
|
|
592
|
-
rows:
|
|
593
|
-
})),
|
|
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();
|
|
594
607
|
}
|
|
595
608
|
}
|
|
596
609
|
};
|
|
597
610
|
}
|
|
598
|
-
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) {
|
|
599
704
|
return {
|
|
600
705
|
scatter: "scatterplot",
|
|
601
706
|
bar: "barchart",
|
|
@@ -606,247 +711,250 @@ function fe(t) {
|
|
|
606
711
|
heatmatrix: "heatmatrix"
|
|
607
712
|
}[t];
|
|
608
713
|
}
|
|
609
|
-
|
|
610
|
-
|
|
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));
|
|
611
717
|
}
|
|
612
|
-
function
|
|
613
|
-
const { map: n, layerId:
|
|
614
|
-
n.updateRenderInfo(
|
|
615
|
-
a ===
|
|
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));
|
|
616
722
|
});
|
|
617
|
-
for (const a of
|
|
618
|
-
t.events.on(a, ({ selection:
|
|
619
|
-
n.setHighlightedIds(
|
|
723
|
+
for (const a of o)
|
|
724
|
+
t.events.on(a, ({ selection: s }) => {
|
|
725
|
+
n.setHighlightedIds(l, D(s, e, r.rows));
|
|
620
726
|
});
|
|
621
727
|
}
|
|
622
|
-
async function
|
|
623
|
-
const
|
|
624
|
-
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)));
|
|
625
731
|
}
|
|
626
|
-
function
|
|
732
|
+
function Oe(t, e, o, r, n, l, a, s) {
|
|
627
733
|
return {
|
|
628
|
-
async resolvePlot(
|
|
734
|
+
async resolvePlot(i, u, d = 0) {
|
|
629
735
|
if (!t || !t.plot) return;
|
|
630
736
|
const c = Array.isArray(t.plot) ? t.plot[d] : t.plot;
|
|
631
737
|
if (c === void 0) throw new Error(`Plot ${d} has no target: the plot targets name ${t.plot.length} elements.`);
|
|
632
738
|
const f = document.getElementById(c);
|
|
633
739
|
if (!f) throw new Error(`Could not find plot target: ${c}`);
|
|
634
|
-
const
|
|
635
|
-
if (!
|
|
636
|
-
await
|
|
637
|
-
const
|
|
638
|
-
|
|
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),
|
|
639
747
|
collection: p,
|
|
640
748
|
attributes: { axis: u.axis, ...u.color && { color: u.color } },
|
|
641
|
-
|
|
642
|
-
|
|
749
|
+
events: g,
|
|
750
|
+
...Le(u, p.features ?? []),
|
|
643
751
|
...u.width && { width: u.width },
|
|
644
752
|
...u.height && { height: u.height },
|
|
645
753
|
...u.margins && { margins: u.margins },
|
|
646
754
|
...u.transform && { transform: u.transform }
|
|
647
755
|
});
|
|
648
|
-
|
|
649
|
-
const
|
|
650
|
-
a?.set(
|
|
651
|
-
for (const
|
|
652
|
-
!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));
|
|
653
761
|
}
|
|
654
762
|
};
|
|
655
763
|
}
|
|
656
|
-
const
|
|
657
|
-
function
|
|
764
|
+
const Tt = 134217728, Fe = 4, xe = 32;
|
|
765
|
+
function Be(t) {
|
|
658
766
|
return Array.isArray(t) ? t.join(`
|
|
659
767
|
`) : t;
|
|
660
768
|
}
|
|
661
|
-
function
|
|
769
|
+
function S(t) {
|
|
662
770
|
return !!t && typeof t == "object" && !Array.isArray(t) && typeof t.fromFeature == "object" && t.fromFeature !== null;
|
|
663
771
|
}
|
|
664
|
-
function
|
|
772
|
+
function k(t, e) {
|
|
665
773
|
return t instanceof Map ? t.get(e) : t[e];
|
|
666
774
|
}
|
|
667
|
-
function
|
|
668
|
-
return e.split(".").reduce((
|
|
669
|
-
if (!(
|
|
670
|
-
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];
|
|
671
779
|
}, t);
|
|
672
780
|
}
|
|
673
|
-
function
|
|
781
|
+
function Ot(t) {
|
|
674
782
|
const e = [];
|
|
675
|
-
for (const
|
|
676
|
-
for (const
|
|
677
|
-
|
|
783
|
+
for (const o of [t.uniforms, t.uniformMatrices])
|
|
784
|
+
for (const r of Object.values(o ?? {}))
|
|
785
|
+
S(r) && e.push(r);
|
|
678
786
|
return e;
|
|
679
787
|
}
|
|
680
|
-
function
|
|
681
|
-
return [.../* @__PURE__ */ new Set([t.dataRef, ...
|
|
788
|
+
function je(t) {
|
|
789
|
+
return [.../* @__PURE__ */ new Set([t.dataRef, ...Ot(t).map((e) => e.fromFeature.layer)])];
|
|
682
790
|
}
|
|
683
|
-
function
|
|
684
|
-
for (const e of
|
|
685
|
-
const { iterate:
|
|
686
|
-
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 };
|
|
687
795
|
}
|
|
688
796
|
return null;
|
|
689
797
|
}
|
|
690
|
-
function
|
|
691
|
-
const
|
|
692
|
-
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;
|
|
693
801
|
}
|
|
694
|
-
function
|
|
802
|
+
function ct(t, e, o) {
|
|
695
803
|
if (!t) return;
|
|
696
|
-
const
|
|
697
|
-
for (const [n,
|
|
698
|
-
if (!
|
|
699
|
-
|
|
804
|
+
const r = {};
|
|
805
|
+
for (const [n, l] of Object.entries(t)) {
|
|
806
|
+
if (!S(l)) {
|
|
807
|
+
r[n] = l;
|
|
700
808
|
continue;
|
|
701
809
|
}
|
|
702
|
-
const a = Number(
|
|
703
|
-
Number.isFinite(a) ?
|
|
810
|
+
const a = Number(xt(l, e, o) ?? NaN);
|
|
811
|
+
Number.isFinite(a) ? r[n] = a : typeof l.default == "number" && (r[n] = l.default);
|
|
704
812
|
}
|
|
705
|
-
return
|
|
813
|
+
return r;
|
|
706
814
|
}
|
|
707
|
-
function
|
|
815
|
+
function ft(t, e, o) {
|
|
708
816
|
if (!t) return;
|
|
709
|
-
const
|
|
710
|
-
for (const [n,
|
|
711
|
-
if (!
|
|
712
|
-
|
|
817
|
+
const r = {};
|
|
818
|
+
for (const [n, l] of Object.entries(t)) {
|
|
819
|
+
if (!S(l)) {
|
|
820
|
+
r[n] = l;
|
|
713
821
|
continue;
|
|
714
822
|
}
|
|
715
|
-
const a =
|
|
716
|
-
if (!
|
|
717
|
-
const
|
|
718
|
-
|
|
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`);
|
|
719
827
|
}
|
|
720
|
-
return
|
|
828
|
+
return r;
|
|
721
829
|
}
|
|
722
|
-
function
|
|
830
|
+
function De(t) {
|
|
723
831
|
return t != null && !(typeof t == "number" && !Number.isFinite(t));
|
|
724
832
|
}
|
|
725
|
-
function
|
|
726
|
-
return
|
|
833
|
+
function dt(t) {
|
|
834
|
+
return S(t) && t.fromFeature.iterate === "batched";
|
|
727
835
|
}
|
|
728
|
-
function
|
|
729
|
-
return Object.values(e ?? {}).some(
|
|
836
|
+
function Bt(t, e) {
|
|
837
|
+
return Object.values(e ?? {}).some(dt) ? xe : Object.values(t ?? {}).some(dt) ? Fe : 0;
|
|
730
838
|
}
|
|
731
|
-
function
|
|
732
|
-
const
|
|
733
|
-
return
|
|
839
|
+
function Ge(t, e, o = Tt) {
|
|
840
|
+
const r = Bt(t, e);
|
|
841
|
+
return r > 0 ? Math.floor(o / r) : Number.POSITIVE_INFINITY;
|
|
734
842
|
}
|
|
735
|
-
function
|
|
736
|
-
const n = {},
|
|
737
|
-
for (const
|
|
738
|
-
for (const u of Object.values(
|
|
739
|
-
|
|
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);
|
|
740
848
|
if (a.length > 0) {
|
|
741
|
-
const
|
|
742
|
-
|
|
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(", ")}`);
|
|
743
851
|
}
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
`[autk-grammar] batched compute capped at ${
|
|
747
|
-
),
|
|
748
|
-
for (const [
|
|
749
|
-
if (
|
|
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") {
|
|
750
858
|
const d = typeof u.default == "number" ? u.default : void 0;
|
|
751
|
-
|
|
752
|
-
const f = Number(
|
|
859
|
+
l[i] = o.map((c) => {
|
|
860
|
+
const f = Number(j(c, u.fromFeature.path) ?? d);
|
|
753
861
|
return Number.isFinite(f) ? f : 0;
|
|
754
862
|
});
|
|
755
|
-
} else typeof u == "number" && (n[
|
|
756
|
-
for (const [
|
|
757
|
-
if (!
|
|
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;
|
|
758
866
|
const d = [];
|
|
759
|
-
for (const c of
|
|
760
|
-
const f =
|
|
761
|
-
let
|
|
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;
|
|
762
870
|
if (Array.isArray(f))
|
|
763
|
-
for (const
|
|
764
|
-
if (!Array.isArray(
|
|
765
|
-
const
|
|
766
|
-
!Number.isFinite(
|
|
871
|
+
for (const g of f) {
|
|
872
|
+
if (!Array.isArray(g) || g.length < 2) continue;
|
|
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, _));
|
|
767
875
|
}
|
|
768
|
-
Number.isFinite(
|
|
876
|
+
Number.isFinite(m) || (m = 0, h = 0, y = 0, p = 0), d.push(m, h, y, h, y, p, m, p);
|
|
769
877
|
}
|
|
770
|
-
|
|
878
|
+
l[i] = d;
|
|
771
879
|
}
|
|
772
|
-
return n.num_features =
|
|
880
|
+
return n.num_features = o.length, { uniforms: n, uniformArrays: l };
|
|
773
881
|
}
|
|
774
|
-
function
|
|
775
|
-
const
|
|
776
|
-
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`);
|
|
777
885
|
const n = {
|
|
778
|
-
collection:
|
|
886
|
+
collection: r,
|
|
779
887
|
variableMapping: t.attributes,
|
|
780
|
-
wgslBody:
|
|
888
|
+
wgslBody: Be(t.wgslFunction)
|
|
781
889
|
};
|
|
782
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);
|
|
783
|
-
const
|
|
784
|
-
if (
|
|
785
|
-
const u =
|
|
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);
|
|
786
894
|
return n.uniforms = { ...c, ...d.uniforms }, n.uniformArrays = { ...n.uniformArrays ?? {}, ...d.uniformArrays }, f && Object.keys(f).length > 0 && (n.uniformMatrices = f), n;
|
|
787
895
|
}
|
|
788
|
-
const a =
|
|
789
|
-
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;
|
|
790
898
|
}
|
|
791
|
-
function
|
|
899
|
+
function mt(t) {
|
|
792
900
|
if (t)
|
|
793
|
-
return Object.fromEntries(Object.entries(t).filter(([, e]) => !(
|
|
901
|
+
return Object.fromEntries(Object.entries(t).filter(([, e]) => !(S(e) && e.fromFeature.iterate === "batched")));
|
|
794
902
|
}
|
|
795
|
-
function
|
|
903
|
+
function Qe(t) {
|
|
796
904
|
return t.outputColumns ?? (t.outputColumnName ? [t.outputColumnName] : []);
|
|
797
905
|
}
|
|
798
|
-
async function
|
|
799
|
-
const
|
|
800
|
-
if (
|
|
801
|
-
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);
|
|
802
910
|
if (!n) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
|
|
803
|
-
const
|
|
804
|
-
for (const
|
|
805
|
-
const u =
|
|
806
|
-
for (const c of
|
|
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;
|
|
807
915
|
}
|
|
808
|
-
const
|
|
809
|
-
for (let
|
|
810
|
-
const u = await
|
|
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 });
|
|
811
919
|
a.features.forEach((d, c) => {
|
|
812
|
-
const f = d.properties?.compute,
|
|
813
|
-
if (!(!f || !
|
|
814
|
-
for (const
|
|
815
|
-
const
|
|
816
|
-
Number.isFinite(
|
|
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);
|
|
817
925
|
}
|
|
818
926
|
});
|
|
819
927
|
}
|
|
820
928
|
return a;
|
|
821
929
|
}
|
|
822
|
-
const
|
|
823
|
-
function
|
|
824
|
-
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;
|
|
825
933
|
}
|
|
826
|
-
function
|
|
827
|
-
async function r(
|
|
828
|
-
return t?.get(b(
|
|
934
|
+
function Ve(t, e, o) {
|
|
935
|
+
async function r(s, i, u) {
|
|
936
|
+
return t?.get(b(u, i)) ?? await s.getLayer(i);
|
|
829
937
|
}
|
|
830
|
-
function
|
|
938
|
+
function n(s, i, u, d, c) {
|
|
831
939
|
if (!t) return;
|
|
832
|
-
const
|
|
833
|
-
t.set(b(
|
|
834
|
-
const
|
|
835
|
-
|
|
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);
|
|
836
944
|
}
|
|
837
|
-
async function
|
|
838
|
-
for (const
|
|
839
|
-
if (!
|
|
840
|
-
throw new Error(`Render pass "${i.outputTableName}": layer "${
|
|
841
|
-
const
|
|
842
|
-
id:
|
|
843
|
-
collection: await r(
|
|
844
|
-
type:
|
|
845
|
-
objectIdProperty:
|
|
846
|
-
}))),
|
|
847
|
-
layers:
|
|
945
|
+
async function l(s, i) {
|
|
946
|
+
for (const c of i.layers)
|
|
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) => ({
|
|
950
|
+
id: c.id,
|
|
951
|
+
collection: await r(s, c.dataRef, i.workspace),
|
|
952
|
+
type: c.type,
|
|
953
|
+
objectIdProperty: c.objectIdProperty
|
|
954
|
+
}))), d = await new et().renderPipeline({
|
|
955
|
+
layers: u,
|
|
848
956
|
viewpoints: {
|
|
849
|
-
collection: await r(
|
|
957
|
+
collection: await r(s, i.viewpoints.dataRef, i.workspace),
|
|
850
958
|
strategy: i.viewpoints.strategy,
|
|
851
959
|
sampling: i.viewpoints.sampling
|
|
852
960
|
},
|
|
@@ -854,63 +962,63 @@ function ve(t, e) {
|
|
|
854
962
|
camera: i.camera,
|
|
855
963
|
tileSize: i.tileSize
|
|
856
964
|
});
|
|
857
|
-
|
|
965
|
+
n(s, d, i.viewpoints.dataRef, i, i.viewpoints.strategy?.type === "building-windows" ? "points" : void 0);
|
|
858
966
|
}
|
|
859
|
-
async function s
|
|
860
|
-
const
|
|
861
|
-
for (const
|
|
862
|
-
const
|
|
863
|
-
if (
|
|
864
|
-
else if (
|
|
967
|
+
async function a(s, i) {
|
|
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);
|
|
865
973
|
else
|
|
866
974
|
try {
|
|
867
|
-
|
|
975
|
+
u[m] = await s.getLayer(m);
|
|
868
976
|
} catch {
|
|
869
|
-
|
|
977
|
+
u[m] = void 0;
|
|
870
978
|
}
|
|
871
979
|
}
|
|
872
|
-
const
|
|
873
|
-
|
|
980
|
+
const c = new et(), f = await We(i, u, (m) => c.gpgpuPipeline(m));
|
|
981
|
+
n(s, f, i.dataRef, i);
|
|
874
982
|
}
|
|
875
983
|
return {
|
|
876
|
-
async resolveCompute(
|
|
877
|
-
if (
|
|
878
|
-
return await
|
|
984
|
+
async resolveCompute(s, i) {
|
|
985
|
+
if (s)
|
|
986
|
+
return await P(s, i.workspace), i.type === "render" ? await l(s, i) : await a(s, i), s;
|
|
879
987
|
}
|
|
880
988
|
};
|
|
881
989
|
}
|
|
882
|
-
class
|
|
990
|
+
class He {
|
|
883
991
|
_listeners = /* @__PURE__ */ new Map();
|
|
884
|
-
on(e,
|
|
992
|
+
on(e, o) {
|
|
885
993
|
this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
|
|
886
|
-
const
|
|
887
|
-
return
|
|
994
|
+
const r = this._listeners.get(e);
|
|
995
|
+
return r.add(o), () => r.delete(o);
|
|
888
996
|
}
|
|
889
997
|
/** @internal */
|
|
890
|
-
emit(e,
|
|
891
|
-
this._listeners.get(e)?.forEach((
|
|
998
|
+
emit(e, o) {
|
|
999
|
+
this._listeners.get(e)?.forEach((r) => r(o));
|
|
892
1000
|
}
|
|
893
1001
|
}
|
|
894
|
-
function
|
|
1002
|
+
function M(t) {
|
|
895
1003
|
return t === void 0 ? [] : Array.isArray(t) ? t : [t];
|
|
896
1004
|
}
|
|
897
|
-
function
|
|
1005
|
+
function Je(t) {
|
|
898
1006
|
const e = /* @__PURE__ */ new Set();
|
|
899
|
-
for (const
|
|
900
|
-
if (
|
|
901
|
-
if (
|
|
902
|
-
if (e.has(
|
|
903
|
-
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);
|
|
904
1012
|
}
|
|
905
|
-
const
|
|
906
|
-
for (const
|
|
907
|
-
const n =
|
|
908
|
-
if (
|
|
909
|
-
throw new Error(
|
|
910
|
-
|
|
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);
|
|
911
1019
|
}
|
|
912
1020
|
}
|
|
913
|
-
class
|
|
1021
|
+
class eo {
|
|
914
1022
|
dataAdapter;
|
|
915
1023
|
mapAdapter;
|
|
916
1024
|
plotAdapter;
|
|
@@ -928,9 +1036,9 @@ class $e {
|
|
|
928
1036
|
_exports = /* @__PURE__ */ new Map();
|
|
929
1037
|
/** Each GeoJSON table a run loaded and each table a join wrote, which its plots read before the database. */
|
|
930
1038
|
_geojsonCache = /* @__PURE__ */ new Map();
|
|
931
|
-
interactions = new
|
|
1039
|
+
interactions = new He();
|
|
932
1040
|
constructor(e) {
|
|
933
|
-
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);
|
|
934
1042
|
}
|
|
935
1043
|
/**
|
|
936
1044
|
* The coordinate reference system autk-db stores a workspace's tables in, unless the spec's `workspaces` sets
|
|
@@ -942,7 +1050,7 @@ class $e {
|
|
|
942
1050
|
* instead of hard-coding a CRS string.
|
|
943
1051
|
*/
|
|
944
1052
|
get workspaceCrs() {
|
|
945
|
-
return
|
|
1053
|
+
return Ut;
|
|
946
1054
|
}
|
|
947
1055
|
get data() {
|
|
948
1056
|
return this._data;
|
|
@@ -967,8 +1075,8 @@ class $e {
|
|
|
967
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
|
|
968
1076
|
* the spec's `map` list. Without it, every map.
|
|
969
1077
|
*/
|
|
970
|
-
mapLayers(e,
|
|
971
|
-
return this._layersOf(e,
|
|
1078
|
+
mapLayers(e, o) {
|
|
1079
|
+
return this._layersOf(e, o).map(({ map: r, layerId: n }) => ({ map: r, layerId: n }));
|
|
972
1080
|
}
|
|
973
1081
|
/**
|
|
974
1082
|
* The layer a map of the last {@link run} draws for a table, found by the table's name (a layer's `dataRef`):
|
|
@@ -984,12 +1092,12 @@ class $e {
|
|
|
984
1092
|
* const layer = grammar.mapLayer('buildings');
|
|
985
1093
|
* layer?.map.updateRenderInfo(layer.layerId, { opacity: 0.5 });
|
|
986
1094
|
*/
|
|
987
|
-
mapLayer(e,
|
|
988
|
-
return this.mapLayers(e,
|
|
1095
|
+
mapLayer(e, o) {
|
|
1096
|
+
return this.mapLayers(e, o).pop();
|
|
989
1097
|
}
|
|
990
1098
|
/** The drawn layers of a table, on every map or on the one `mapId` names. */
|
|
991
|
-
_layersOf(e,
|
|
992
|
-
return this._layers.filter((
|
|
1099
|
+
_layersOf(e, o) {
|
|
1100
|
+
return this._layers.filter((r) => r.dataRef === e && W(r, o));
|
|
993
1101
|
}
|
|
994
1102
|
/**
|
|
995
1103
|
* Releases what the last run created: every map (its layers' GPU buffers, its textures, its canvas context, the
|
|
@@ -1013,7 +1121,10 @@ class $e {
|
|
|
1013
1121
|
throw new Error("Plot adapter not initialized. Please call the constructor first.");
|
|
1014
1122
|
if (!this.computeAdapter)
|
|
1015
1123
|
throw new Error("Compute adapter not initialized. Please call the constructor first.");
|
|
1016
|
-
|
|
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({
|
|
1017
1128
|
spec: e,
|
|
1018
1129
|
adapters: {
|
|
1019
1130
|
db: this.dataAdapter,
|
|
@@ -1023,27 +1134,27 @@ class $e {
|
|
|
1023
1134
|
}
|
|
1024
1135
|
}), await this.grammarEngine.run();
|
|
1025
1136
|
const r = this.grammarEngine.context;
|
|
1026
|
-
if (r && await
|
|
1137
|
+
if (r && await P(r), this._wireLinks(e), this._selectFromTheStart(e), this._rewireInteractions(e), !r) {
|
|
1027
1138
|
console.warn("Grammar engine produced no data context."), this._data = {};
|
|
1028
1139
|
return;
|
|
1029
1140
|
}
|
|
1030
|
-
const
|
|
1031
|
-
for (const
|
|
1032
|
-
Object.defineProperty(
|
|
1141
|
+
const n = {};
|
|
1142
|
+
for (const l of r.getLayersMetadata())
|
|
1143
|
+
Object.defineProperty(n, l.name, {
|
|
1033
1144
|
get: () => {
|
|
1034
|
-
const
|
|
1035
|
-
return
|
|
1145
|
+
const a = this._computeCache.get(l.name);
|
|
1146
|
+
return a ? Promise.resolve(a) : r.getLayer(l.name);
|
|
1036
1147
|
},
|
|
1037
1148
|
enumerable: !0,
|
|
1038
1149
|
configurable: !0
|
|
1039
1150
|
});
|
|
1040
|
-
for (const
|
|
1041
|
-
|
|
1042
|
-
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)),
|
|
1043
1154
|
enumerable: !0,
|
|
1044
1155
|
configurable: !0
|
|
1045
1156
|
});
|
|
1046
|
-
this._data =
|
|
1157
|
+
this._data = n;
|
|
1047
1158
|
}
|
|
1048
1159
|
/**
|
|
1049
1160
|
* Highlights features on every layer that draws the table `dataRef`, in every map (see {@link mapLayers}), or only
|
|
@@ -1056,10 +1167,10 @@ class $e {
|
|
|
1056
1167
|
* @param mapId The map to highlight on, by its {@link MapId}: a string names a map by its `id`, a number by its
|
|
1057
1168
|
* index in the spec's `map` list. Without it, every map that draws the table.
|
|
1058
1169
|
*/
|
|
1059
|
-
highlightOnMap(e,
|
|
1060
|
-
const n = this._layersOf(e,
|
|
1061
|
-
for (const { map:
|
|
1062
|
-
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);
|
|
1063
1174
|
}
|
|
1064
1175
|
/**
|
|
1065
1176
|
* Clears highlighted features on every layer that draws the table `dataRef`, in every map (see {@link mapLayers}),
|
|
@@ -1070,10 +1181,10 @@ class $e {
|
|
|
1070
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
|
|
1071
1182
|
* the spec's `map` list. Without it, every map that draws the table.
|
|
1072
1183
|
*/
|
|
1073
|
-
clearHighlightOnMap(e,
|
|
1074
|
-
const
|
|
1075
|
-
for (const { map: n, layerId:
|
|
1076
|
-
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, []);
|
|
1077
1188
|
}
|
|
1078
1189
|
/**
|
|
1079
1190
|
* Clears the selection on the plot `plotId` names: its `id`, else its `dataRef`.
|
|
@@ -1084,10 +1195,10 @@ class $e {
|
|
|
1084
1195
|
* @param mapId The map whose linked layers to clear, by its {@link MapId}: a string names a map by its `id`, a
|
|
1085
1196
|
* number by its index in the spec's `map` list. Without it, every linked layer.
|
|
1086
1197
|
*/
|
|
1087
|
-
clearHighlightOnPlot(e,
|
|
1198
|
+
clearHighlightOnPlot(e, o) {
|
|
1088
1199
|
this._plotRegistry.get(e)?.setSelection([]);
|
|
1089
|
-
for (const
|
|
1090
|
-
|
|
1200
|
+
for (const r of this._plotLinks.get(e) ?? [])
|
|
1201
|
+
W(r, o) && r.map.clearHighlightedIds(r.layerId);
|
|
1091
1202
|
}
|
|
1092
1203
|
/**
|
|
1093
1204
|
* Applies a selection to the plot `plotId` names: its `id`, else its `dataRef`.
|
|
@@ -1099,86 +1210,95 @@ class $e {
|
|
|
1099
1210
|
* @param mapId The map whose linked layers to highlight, by its {@link MapId}: a string names a map by its `id`, a
|
|
1100
1211
|
* number by its index in the spec's `map` list. Without it, every linked layer.
|
|
1101
1212
|
*/
|
|
1102
|
-
setPlotSelection(e,
|
|
1103
|
-
this._plotRegistry.get(e)?.setSelection(
|
|
1213
|
+
setPlotSelection(e, o, r) {
|
|
1214
|
+
this._plotRegistry.get(e)?.setSelection(o);
|
|
1104
1215
|
const n = this._plotRows.get(e) ?? [];
|
|
1105
|
-
for (const
|
|
1106
|
-
|
|
1216
|
+
for (const l of this._plotLinks.get(e) ?? [])
|
|
1217
|
+
W(l, r) && l.map.setHighlightedIds(l.layerId, D(o, n, l.rows));
|
|
1107
1218
|
}
|
|
1108
1219
|
/**
|
|
1109
1220
|
* Applies a selection made on `layers`, by their positions `featureIds`, to every plot linked to one of them, at the
|
|
1110
1221
|
* plot's own positions of the selected rows.
|
|
1111
1222
|
*/
|
|
1112
|
-
_selectInLinkedPlots(e,
|
|
1113
|
-
for (const [
|
|
1114
|
-
const
|
|
1115
|
-
if (
|
|
1116
|
-
const a = this._plotRows.get(
|
|
1117
|
-
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]);
|
|
1118
1229
|
}
|
|
1119
1230
|
}
|
|
1120
1231
|
/** Wires each entry of `links` between a plot and a layer of a map, both now drawn. */
|
|
1121
1232
|
_wireLinks(e) {
|
|
1122
|
-
const
|
|
1233
|
+
const o = M(e.map), r = M(e.plot);
|
|
1123
1234
|
for (const n of e.links ?? []) {
|
|
1124
|
-
const
|
|
1125
|
-
if (!
|
|
1235
|
+
const l = r.find((c) => A(c) === n.source), a = this._plotRegistry.get(n.source);
|
|
1236
|
+
if (!l || !a)
|
|
1126
1237
|
throw new Error(`Link source "${n.source}" is not the id (or the dataRef) of a plot of this specification.`);
|
|
1127
|
-
const
|
|
1128
|
-
if (
|
|
1238
|
+
const s = o.findIndex((c) => c.id === n.target), i = this._maps[s];
|
|
1239
|
+
if (s < 0 || !i)
|
|
1129
1240
|
throw new Error(`Link target "${n.target}" is not the id of a map of this specification.`);
|
|
1130
|
-
const u =
|
|
1241
|
+
const u = o[s].layerRefs.find((c) => n.layer !== void 0 ? R(c) === n.layer : c.dataRef === l.dataRef);
|
|
1131
1242
|
if (!u)
|
|
1132
|
-
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 "${
|
|
1133
|
-
const d = this._layers.find((c) => c.mapIndex ===
|
|
1134
|
-
d && (
|
|
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));
|
|
1135
1246
|
}
|
|
1136
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
|
+
}
|
|
1137
1257
|
_rewireInteractions(e) {
|
|
1138
|
-
for (const
|
|
1258
|
+
for (const r of this._fwdCleanups) r();
|
|
1139
1259
|
this._fwdCleanups = [];
|
|
1140
|
-
const
|
|
1141
|
-
this._maps.forEach((
|
|
1142
|
-
const
|
|
1143
|
-
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 });
|
|
1144
1264
|
};
|
|
1145
|
-
|
|
1265
|
+
r.events.on(Y.PICKING, a), this._fwdCleanups.push(() => r.events.off(Y.PICKING, a));
|
|
1146
1266
|
});
|
|
1147
|
-
for (const [
|
|
1148
|
-
for (const
|
|
1149
|
-
const a = ({ selection:
|
|
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 }) => {
|
|
1150
1270
|
this.interactions.emit("plot:selection", {
|
|
1151
|
-
plotId:
|
|
1152
|
-
event:
|
|
1153
|
-
selection:
|
|
1271
|
+
plotId: r,
|
|
1272
|
+
event: l,
|
|
1273
|
+
selection: s
|
|
1154
1274
|
});
|
|
1155
1275
|
};
|
|
1156
|
-
n.events.on(
|
|
1276
|
+
n.events.on(l, a), this._fwdCleanups.push(() => n.events.off(l, a));
|
|
1157
1277
|
}
|
|
1158
1278
|
}
|
|
1159
1279
|
}
|
|
1160
1280
|
export {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
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,
|
|
1182
1302
|
b as tableKey
|
|
1183
1303
|
};
|
|
1184
1304
|
//# sourceMappingURL=autk-grammar.js.map
|