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