isard 1.3.0 → 1.4.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +2 -0
  3. package/dist/basemap/basemaps.js +1 -0
  4. package/dist/basemap/basemaps.js.map +1 -1
  5. package/dist/basemap/vectortiles.d.ts +26 -0
  6. package/dist/basemap/vectortiles.js +125 -1
  7. package/dist/basemap/vectortiles.js.map +1 -1
  8. package/dist/basemap/workerpool.js +9 -0
  9. package/dist/basemap/workerpool.js.map +1 -1
  10. package/dist/basemap.worker.js +2 -2
  11. package/dist/basemap.worker.js.map +7 -4
  12. package/dist/bind/layers.js +10 -0
  13. package/dist/bind/layers.js.map +1 -1
  14. package/dist/decoder.worker.js +3 -3
  15. package/dist/decoder.worker.js.map +3 -3
  16. package/dist/engine-loader.d.ts +4 -1
  17. package/dist/engine-loader.js +9 -0
  18. package/dist/engine-loader.js.map +1 -1
  19. package/dist/grid-module.d.ts +44 -0
  20. package/dist/grid-module.js +63 -0
  21. package/dist/grid-module.js.map +1 -0
  22. package/dist/grids.d.ts +51 -0
  23. package/dist/grids.js +88 -0
  24. package/dist/grids.js.map +1 -0
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.js +2 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/isard_bg.wasm +0 -0
  29. package/dist/isard_core_bg.wasm +0 -0
  30. package/dist/isard_grid_bg.wasm +0 -0
  31. package/dist/layers/flow.d.ts +111 -0
  32. package/dist/layers/flow.js +222 -0
  33. package/dist/layers/flow.js.map +1 -0
  34. package/dist/layers/symbols.d.ts +2 -0
  35. package/dist/layers/symbols.js +2 -1
  36. package/dist/layers/symbols.js.map +1 -1
  37. package/dist/map/layer-spec.d.ts +4 -1
  38. package/dist/map/layer-spec.js +2 -0
  39. package/dist/map/layer-spec.js.map +1 -1
  40. package/dist/map/workers.d.ts +4 -0
  41. package/dist/map/workers.js +35 -0
  42. package/dist/map/workers.js.map +1 -1
  43. package/dist/map.d.ts +14 -0
  44. package/dist/map.js +19 -1
  45. package/dist/map.js.map +1 -1
  46. package/dist/react/Layer.d.ts +2 -0
  47. package/dist/react/Layer.js.map +1 -1
  48. package/dist/types.d.ts +7 -3
  49. package/dist/types.js.map +1 -1
  50. package/dist/wasm/isard.d.ts +42 -0
  51. package/dist/wasm/isard.js +91 -1
  52. package/dist/wasm/isard_core.d.ts +42 -0
  53. package/dist/wasm/isard_core.js +91 -1
  54. package/dist/wasm/isard_grid.d.ts +101 -0
  55. package/dist/wasm/isard_grid.js +375 -0
  56. package/dist/workers/basemap/street.d.ts +19 -0
  57. package/dist/workers/basemap.worker.d.ts +21 -0
  58. package/dist/workers/basemap.worker.js +23 -4
  59. package/dist/workers/basemap.worker.js.map +1 -1
  60. package/package.json +2 -1
  61. package/vite.js +3 -2
@@ -0,0 +1,101 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * The grids of a file
6
+ */
7
+ export class GridSet {
8
+ private constructor();
9
+ free(): void;
10
+ /**
11
+ * How many grids
12
+ */
13
+ count(): number;
14
+ /**
15
+ * Grid `i`'s description: name, standard name, units, level, time, width, height, bounds (JSON)
16
+ */
17
+ meta(i: number): string;
18
+ /**
19
+ * Grid `i`'s values, row after row from the north
20
+ */
21
+ values(i: number): Float32Array;
22
+ }
23
+
24
+ /**
25
+ * The flows of a city's streets for a wind of 1 m/s from the west and one from the south (see `street`): the east and
26
+ * north velocities of each, `width` × `height` cells each
27
+ */
28
+ export class StreetFlow {
29
+ private constructor();
30
+ free(): void;
31
+ /**
32
+ * The flow of a wind towards the east: its east velocities, then its north ones
33
+ */
34
+ eastU(): Float32Array;
35
+ eastV(): Float32Array;
36
+ /**
37
+ * The flow of a wind towards the north: its east velocities, then its north ones
38
+ */
39
+ northU(): Float32Array;
40
+ northV(): Float32Array;
41
+ }
42
+
43
+ /**
44
+ * The grids of a GRIB2 or classic NetCDF file
45
+ *
46
+ * # Errors
47
+ *
48
+ * Throws (to JavaScript) when the file is of neither kind, malformed, or packed in a way not read
49
+ */
50
+ export function readGrids(bytes: Uint8Array): GridSet;
51
+
52
+ /**
53
+ * The flows of the streets of a grid of `width` × `height` cells round the buildings of `points` (their rings in
54
+ * cells, from the north-west corner, interleaved; `ring_start` the first point of each ring and the end,
55
+ * `polygon_start` the first ring of each polygon and the end), after `iterations` sweeps
56
+ */
57
+ export function streetFlow(points: Float64Array, ring_start: Uint32Array, polygon_start: Uint32Array, width: number, height: number, iterations: number): StreetFlow;
58
+
59
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
60
+
61
+ export interface InitOutput {
62
+ readonly memory: WebAssembly.Memory;
63
+ readonly __wbg_gridset_free: (a: number, b: number) => void;
64
+ readonly __wbg_streetflow_free: (a: number, b: number) => void;
65
+ readonly gridset_count: (a: number) => number;
66
+ readonly gridset_meta: (a: number, b: number) => [number, number];
67
+ readonly gridset_values: (a: number, b: number) => any;
68
+ readonly readGrids: (a: number, b: number) => [number, number, number];
69
+ readonly streetFlow: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
70
+ readonly streetflow_eastU: (a: number) => any;
71
+ readonly streetflow_eastV: (a: number) => any;
72
+ readonly streetflow_northU: (a: number) => any;
73
+ readonly streetflow_northV: (a: number) => any;
74
+ readonly __wbindgen_externrefs: WebAssembly.Table;
75
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
76
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
77
+ readonly __externref_table_dealloc: (a: number) => void;
78
+ readonly __wbindgen_start: () => void;
79
+ }
80
+
81
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
82
+
83
+ /**
84
+ * Instantiates the given `module`, which can either be bytes or
85
+ * a precompiled `WebAssembly.Module`.
86
+ *
87
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
88
+ *
89
+ * @returns {InitOutput}
90
+ */
91
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
92
+
93
+ /**
94
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
95
+ * for everything else, calls `WebAssembly.instantiate` directly.
96
+ *
97
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
98
+ *
99
+ * @returns {Promise<InitOutput>}
100
+ */
101
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,375 @@
1
+ /* @ts-self-types="./isard_grid.d.ts" */
2
+
3
+ /**
4
+ * The grids of a file
5
+ */
6
+ export class GridSet {
7
+ static __wrap(ptr) {
8
+ const obj = Object.create(GridSet.prototype);
9
+ obj.__wbg_ptr = ptr;
10
+ GridSetFinalization.register(obj, obj.__wbg_ptr, obj);
11
+ return obj;
12
+ }
13
+ __destroy_into_raw() {
14
+ const ptr = this.__wbg_ptr;
15
+ this.__wbg_ptr = 0;
16
+ GridSetFinalization.unregister(this);
17
+ return ptr;
18
+ }
19
+ free() {
20
+ const ptr = this.__destroy_into_raw();
21
+ wasm.__wbg_gridset_free(ptr, 0);
22
+ }
23
+ /**
24
+ * How many grids
25
+ * @returns {number}
26
+ */
27
+ count() {
28
+ const ret = wasm.gridset_count(this.__wbg_ptr);
29
+ return ret >>> 0;
30
+ }
31
+ /**
32
+ * Grid `i`'s description: name, standard name, units, level, time, width, height, bounds (JSON)
33
+ * @param {number} i
34
+ * @returns {string}
35
+ */
36
+ meta(i) {
37
+ let deferred1_0;
38
+ let deferred1_1;
39
+ try {
40
+ const ret = wasm.gridset_meta(this.__wbg_ptr, i);
41
+ deferred1_0 = ret[0];
42
+ deferred1_1 = ret[1];
43
+ return getStringFromWasm0(ret[0], ret[1]);
44
+ } finally {
45
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
46
+ }
47
+ }
48
+ /**
49
+ * Grid `i`'s values, row after row from the north
50
+ * @param {number} i
51
+ * @returns {Float32Array}
52
+ */
53
+ values(i) {
54
+ const ret = wasm.gridset_values(this.__wbg_ptr, i);
55
+ return ret;
56
+ }
57
+ }
58
+ if (Symbol.dispose) GridSet.prototype[Symbol.dispose] = GridSet.prototype.free;
59
+
60
+ /**
61
+ * The flows of a city's streets for a wind of 1 m/s from the west and one from the south (see `street`): the east and
62
+ * north velocities of each, `width` × `height` cells each
63
+ */
64
+ export class StreetFlow {
65
+ static __wrap(ptr) {
66
+ const obj = Object.create(StreetFlow.prototype);
67
+ obj.__wbg_ptr = ptr;
68
+ StreetFlowFinalization.register(obj, obj.__wbg_ptr, obj);
69
+ return obj;
70
+ }
71
+ __destroy_into_raw() {
72
+ const ptr = this.__wbg_ptr;
73
+ this.__wbg_ptr = 0;
74
+ StreetFlowFinalization.unregister(this);
75
+ return ptr;
76
+ }
77
+ free() {
78
+ const ptr = this.__destroy_into_raw();
79
+ wasm.__wbg_streetflow_free(ptr, 0);
80
+ }
81
+ /**
82
+ * The flow of a wind towards the east: its east velocities, then its north ones
83
+ * @returns {Float32Array}
84
+ */
85
+ eastU() {
86
+ const ret = wasm.streetflow_eastU(this.__wbg_ptr);
87
+ return ret;
88
+ }
89
+ /**
90
+ * @returns {Float32Array}
91
+ */
92
+ eastV() {
93
+ const ret = wasm.streetflow_eastV(this.__wbg_ptr);
94
+ return ret;
95
+ }
96
+ /**
97
+ * The flow of a wind towards the north: its east velocities, then its north ones
98
+ * @returns {Float32Array}
99
+ */
100
+ northU() {
101
+ const ret = wasm.streetflow_northU(this.__wbg_ptr);
102
+ return ret;
103
+ }
104
+ /**
105
+ * @returns {Float32Array}
106
+ */
107
+ northV() {
108
+ const ret = wasm.streetflow_northV(this.__wbg_ptr);
109
+ return ret;
110
+ }
111
+ }
112
+ if (Symbol.dispose) StreetFlow.prototype[Symbol.dispose] = StreetFlow.prototype.free;
113
+
114
+ /**
115
+ * The grids of a GRIB2 or classic NetCDF file
116
+ *
117
+ * # Errors
118
+ *
119
+ * Throws (to JavaScript) when the file is of neither kind, malformed, or packed in a way not read
120
+ * @param {Uint8Array} bytes
121
+ * @returns {GridSet}
122
+ */
123
+ export function readGrids(bytes) {
124
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
125
+ const len0 = WASM_VECTOR_LEN;
126
+ const ret = wasm.readGrids(ptr0, len0);
127
+ if (ret[2]) {
128
+ throw takeFromExternrefTable0(ret[1]);
129
+ }
130
+ return GridSet.__wrap(ret[0]);
131
+ }
132
+
133
+ /**
134
+ * The flows of the streets of a grid of `width` × `height` cells round the buildings of `points` (their rings in
135
+ * cells, from the north-west corner, interleaved; `ring_start` the first point of each ring and the end,
136
+ * `polygon_start` the first ring of each polygon and the end), after `iterations` sweeps
137
+ * @param {Float64Array} points
138
+ * @param {Uint32Array} ring_start
139
+ * @param {Uint32Array} polygon_start
140
+ * @param {number} width
141
+ * @param {number} height
142
+ * @param {number} iterations
143
+ * @returns {StreetFlow}
144
+ */
145
+ export function streetFlow(points, ring_start, polygon_start, width, height, iterations) {
146
+ const ptr0 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
147
+ const len0 = WASM_VECTOR_LEN;
148
+ const ptr1 = passArray32ToWasm0(ring_start, wasm.__wbindgen_malloc);
149
+ const len1 = WASM_VECTOR_LEN;
150
+ const ptr2 = passArray32ToWasm0(polygon_start, wasm.__wbindgen_malloc);
151
+ const len2 = WASM_VECTOR_LEN;
152
+ const ret = wasm.streetFlow(ptr0, len0, ptr1, len1, ptr2, len2, width, height, iterations);
153
+ return StreetFlow.__wrap(ret);
154
+ }
155
+ function __wbg_get_imports() {
156
+ const import0 = {
157
+ __proto__: null,
158
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
159
+ throw new Error(getStringFromWasm0(arg0, arg1));
160
+ },
161
+ __wbg_new_from_slice_ca6ad97db1f4779a: function(arg0, arg1) {
162
+ const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
163
+ return ret;
164
+ },
165
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
166
+ // Cast intrinsic for `Ref(String) -> Externref`.
167
+ const ret = getStringFromWasm0(arg0, arg1);
168
+ return ret;
169
+ },
170
+ __wbindgen_init_externref_table: function() {
171
+ const table = wasm.__wbindgen_externrefs;
172
+ const offset = table.grow(4);
173
+ table.set(0, undefined);
174
+ table.set(offset + 0, undefined);
175
+ table.set(offset + 1, null);
176
+ table.set(offset + 2, true);
177
+ table.set(offset + 3, false);
178
+ },
179
+ };
180
+ return {
181
+ __proto__: null,
182
+ "./isard_grid_bg.js": import0,
183
+ };
184
+ }
185
+
186
+ const GridSetFinalization = (typeof FinalizationRegistry === 'undefined')
187
+ ? { register: () => {}, unregister: () => {} }
188
+ : new FinalizationRegistry(ptr => wasm.__wbg_gridset_free(ptr, 1));
189
+ const StreetFlowFinalization = (typeof FinalizationRegistry === 'undefined')
190
+ ? { register: () => {}, unregister: () => {} }
191
+ : new FinalizationRegistry(ptr => wasm.__wbg_streetflow_free(ptr, 1));
192
+
193
+ function getArrayF32FromWasm0(ptr, len) {
194
+ ptr = ptr >>> 0;
195
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
196
+ }
197
+
198
+ let cachedFloat32ArrayMemory0 = null;
199
+ function getFloat32ArrayMemory0() {
200
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
201
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
202
+ }
203
+ return cachedFloat32ArrayMemory0;
204
+ }
205
+
206
+ let cachedFloat64ArrayMemory0 = null;
207
+ function getFloat64ArrayMemory0() {
208
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
209
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
210
+ }
211
+ return cachedFloat64ArrayMemory0;
212
+ }
213
+
214
+ function getStringFromWasm0(ptr, len) {
215
+ return decodeText(ptr >>> 0, len);
216
+ }
217
+
218
+ let cachedUint32ArrayMemory0 = null;
219
+ function getUint32ArrayMemory0() {
220
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
221
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
222
+ }
223
+ return cachedUint32ArrayMemory0;
224
+ }
225
+
226
+ let cachedUint8ArrayMemory0 = null;
227
+ function getUint8ArrayMemory0() {
228
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
229
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
230
+ }
231
+ return cachedUint8ArrayMemory0;
232
+ }
233
+
234
+ function passArray32ToWasm0(arg, malloc) {
235
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
236
+ getUint32ArrayMemory0().set(arg, ptr / 4);
237
+ WASM_VECTOR_LEN = arg.length;
238
+ return ptr;
239
+ }
240
+
241
+ function passArray8ToWasm0(arg, malloc) {
242
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
243
+ getUint8ArrayMemory0().set(arg, ptr / 1);
244
+ WASM_VECTOR_LEN = arg.length;
245
+ return ptr;
246
+ }
247
+
248
+ function passArrayF64ToWasm0(arg, malloc) {
249
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
250
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
251
+ WASM_VECTOR_LEN = arg.length;
252
+ return ptr;
253
+ }
254
+
255
+ function takeFromExternrefTable0(idx) {
256
+ const value = wasm.__wbindgen_externrefs.get(idx);
257
+ wasm.__externref_table_dealloc(idx);
258
+ return value;
259
+ }
260
+
261
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
262
+ cachedTextDecoder.decode();
263
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
264
+ let numBytesDecoded = 0;
265
+ function decodeText(ptr, len) {
266
+ numBytesDecoded += len;
267
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
268
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
269
+ cachedTextDecoder.decode();
270
+ numBytesDecoded = len;
271
+ }
272
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
273
+ }
274
+
275
+ let WASM_VECTOR_LEN = 0;
276
+
277
+ let wasmModule, wasmInstance, wasm;
278
+ function __wbg_finalize_init(instance, module) {
279
+ wasmInstance = instance;
280
+ wasm = instance.exports;
281
+ wasmModule = module;
282
+ cachedFloat32ArrayMemory0 = null;
283
+ cachedFloat64ArrayMemory0 = null;
284
+ cachedUint32ArrayMemory0 = null;
285
+ cachedUint8ArrayMemory0 = null;
286
+ wasm.__wbindgen_start();
287
+ return wasm;
288
+ }
289
+
290
+ async function __wbg_load(module, imports) {
291
+ if (typeof Response === 'function' && module instanceof Response) {
292
+ if (!module.ok) {
293
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
294
+ }
295
+
296
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
297
+ try {
298
+ return await WebAssembly.instantiateStreaming(module, imports);
299
+ } catch (e) {
300
+ const validResponse = expectedResponseType(module.type);
301
+
302
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
303
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
304
+
305
+ } else { throw e; }
306
+ }
307
+ }
308
+
309
+ const bytes = await module.arrayBuffer();
310
+ return await WebAssembly.instantiate(bytes, imports);
311
+ } else {
312
+ const instance = await WebAssembly.instantiate(module, imports);
313
+
314
+ if (instance instanceof WebAssembly.Instance) {
315
+ return { instance, module };
316
+ } else {
317
+ return instance;
318
+ }
319
+ }
320
+
321
+ function expectedResponseType(type) {
322
+ switch (type) {
323
+ case 'basic': case 'cors': case 'default': return true;
324
+ }
325
+ return false;
326
+ }
327
+ }
328
+
329
+ function initSync(module) {
330
+ if (wasm !== undefined) return wasm;
331
+
332
+
333
+ if (module !== undefined) {
334
+ if (Object.getPrototypeOf(module) === Object.prototype) {
335
+ ({module} = module)
336
+ } else {
337
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
338
+ }
339
+ }
340
+
341
+ const imports = __wbg_get_imports();
342
+ if (!(module instanceof WebAssembly.Module)) {
343
+ module = new WebAssembly.Module(module);
344
+ }
345
+ const instance = new WebAssembly.Instance(module, imports);
346
+ return __wbg_finalize_init(instance, module);
347
+ }
348
+
349
+ async function __wbg_init(module_or_path) {
350
+ if (wasm !== undefined) return wasm;
351
+
352
+
353
+ if (module_or_path !== undefined) {
354
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
355
+ ({module_or_path} = module_or_path)
356
+ } else {
357
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
358
+ }
359
+ }
360
+
361
+ if (module_or_path === undefined) {
362
+ module_or_path = new URL('isard_grid_bg.wasm', import.meta.url);
363
+ }
364
+ const imports = __wbg_get_imports();
365
+
366
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
367
+ module_or_path = fetch(module_or_path);
368
+ }
369
+
370
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
371
+
372
+ return __wbg_finalize_init(instance, module);
373
+ }
374
+
375
+ export { initSync, __wbg_init as default };
@@ -0,0 +1,19 @@
1
+ /** The wind of a city's streets: the buildings of the vector tiles around a square, laid on its grid of cells, and
2
+ * the flow round them for a wind towards the east and one towards the north (the grid module) */
3
+ import { type StreetFlows } from '../../grid-module.ts';
4
+ import type { Priority } from '../basemap.worker.ts';
5
+ import type { Renderer } from './tiles.ts';
6
+ /** What a street flow is asked with: its square (Mercator: west, north, east, south) and grid, the tiles of level `z`
7
+ * over it (x, y pairs), the sweeps, the grid module's URL */
8
+ export interface StreetWork {
9
+ module: string;
10
+ z: number;
11
+ tiles: number[];
12
+ bounds: [x0: number, y0: number, x1: number, y1: number];
13
+ width: number;
14
+ height: number;
15
+ iterations: number;
16
+ priority?: Priority;
17
+ }
18
+ /** The streets' flows of a square: the buildings of its tiles in cells (those away from it left out), then solved */
19
+ export declare const streetFlowOf: (r: Renderer, work: StreetWork, id: number) => Promise<StreetFlows>;
@@ -19,6 +19,8 @@ import { type Job } from '../basemap/resample.ts';
19
19
  import { type PngEncoding } from '../basemap/terrain.ts';
20
20
  import { type LabelCandidate, type RasterSource, type StyleLayer } from '../basemap/vectorstyle.ts';
21
21
  import { type HeaderRules } from '../engine/requests.ts';
22
+ import { type GridDescription, type StreetFlows } from '../grid-module.ts';
23
+ import { type StreetWork } from './basemap/street.ts';
22
24
  import { type Sprite } from './basemap/tiles.ts';
23
25
  export type { LabelCandidate, RasterSource, Sprite };
24
26
  /** Fetch priority of a request (`fetch`'s `priority`, a hint to the browser) */
@@ -85,6 +87,18 @@ export type BasemapWork = {
85
87
  url: string;
86
88
  encoding: PngEncoding;
87
89
  floor?: number;
90
+ }
91
+ /** The wind of a city's streets round the buildings of the renderer's layers (see `StreetWork`) */
92
+ | ({
93
+ type: 'street';
94
+ key: string;
95
+ } & StreetWork)
96
+ /** A GRIB2 or NetCDF file (fetched from `url`, or its `bytes`) read into grids by the grid module (`module`) */
97
+ | {
98
+ type: 'grids';
99
+ module: string;
100
+ url?: string;
101
+ bytes?: ArrayBuffer;
88
102
  } | {
89
103
  type: 'reproject';
90
104
  job: Job;
@@ -151,6 +165,13 @@ export type BasemapResponse = {
151
165
  } | {
152
166
  id: number;
153
167
  heights: Float32Array;
168
+ } | {
169
+ id: number;
170
+ grids: GridDescription[];
171
+ values: Float32Array[];
172
+ } | {
173
+ id: number;
174
+ street: StreetFlows;
154
175
  };
155
176
  /** The polygons of a tile in Mercator [0, 1], as the extrusions take them (`PolygonArrays`), and their properties */
156
177
  export interface TilePolygons {
@@ -17,10 +17,12 @@
17
17
  import { resampler } from "../basemap/resample.js";
18
18
  import { fetchHeights } from "../basemap/terrain.js";
19
19
  import { vectorKind } from "../basemap/vectorstyle.js";
20
- import { setHeaderRules } from "../engine/requests.js";
20
+ import { setHeaderRules, withHeaders } from "../engine/requests.js";
21
+ import { decodeGrids } from "../grid-module.js";
21
22
  import { polygons, tess, tessellate, tessellator, vectors } from "./basemap/geometry.js";
22
23
  import { labels } from "./basemap/labels.js";
23
24
  import { render } from "./basemap/raster.js";
25
+ import { streetFlowOf } from "./basemap/street.js";
24
26
  import { aborted, active, cache, cacheShare, renderers } from "./basemap/tiles.js";
25
27
  import { trees } from "./basemap/trees.js";
26
28
  /** The signals of the relief and reprojection requests in progress, aborted with them */
@@ -67,7 +69,7 @@ self.onmessage = async ({ data }) => {
67
69
  controllers.get(data.id)?.abort();
68
70
  return;
69
71
  }
70
- if (data.type === 'heights' || data.type === 'reproject') {
72
+ if (data.type === 'heights' || data.type === 'reproject' || data.type === 'grids') {
71
73
  await decodeTile(data);
72
74
  return;
73
75
  }
@@ -90,6 +92,10 @@ self.onmessage = async ({ data }) => {
90
92
  else
91
93
  post({ id: data.id, trees: out }, [out.buffer]);
92
94
  }
95
+ else if (data.type === 'street') {
96
+ const street = await streetFlowOf(r, data, data.id);
97
+ post({ id: data.id, street }, [street.eastU, street.eastV, street.northU, street.northV].map((a) => a.buffer));
98
+ }
93
99
  else if (data.type === 'polygons') {
94
100
  const tilePolygons = await polygons(r, data.z, data.x, data.y, data.id, data.priority);
95
101
  if (!tilePolygons)
@@ -148,12 +154,25 @@ self.onmessage = async ({ data }) => {
148
154
  aborted.delete(data.id);
149
155
  }
150
156
  };
151
- /** A tile of another layer: the altitudes of a relief tile, or a reprojected raster tile */
157
+ /** A file's bytes, with the page's request headers */
158
+ const fetchBytes = async (url, signal) => {
159
+ const response = await fetch(url, withHeaders(url, { signal }));
160
+ if (!response.ok)
161
+ throw new Error(`${url}: ${response.status}`);
162
+ return response.arrayBuffer();
163
+ };
164
+ /** A tile of another layer: the altitudes of a relief tile, or a reprojected raster tile; or a file's grids */
152
165
  const decodeTile = async (data) => {
153
166
  const controller = new AbortController();
154
167
  controllers.set(data.id, controller);
155
168
  try {
156
- if (data.type === 'heights') {
169
+ if (data.type === 'grids') {
170
+ const { module, url, bytes } = data;
171
+ const file = bytes ?? (url ? await fetchBytes(url, controller.signal) : new ArrayBuffer(0));
172
+ const { grids, values } = await decodeGrids(new Uint8Array(file), module);
173
+ post({ id: data.id, grids, values }, values.map((v) => v.buffer));
174
+ }
175
+ else if (data.type === 'heights') {
157
176
  const heights = await fetchHeights(data.url, data.encoding, data.floor, controller.signal, heightsSurface);
158
177
  if (heights)
159
178
  post({ id: data.id, heights }, [heights.buffer]);