@fxi/zartigl 0.1.4 → 0.2.14
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 +250 -70
- package/dist/catalog.d.ts +103 -0
- package/dist/catalog.js +28 -0
- package/dist/zartigl.d.ts +1444 -0
- package/dist/zartigl.js +4563 -1875
- package/package.json +36 -10
- package/dist/data/catalog.json +0 -351
- package/dist/index.d.ts +0 -416
package/dist/index.d.ts
DELETED
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
import { CustomLayerInterface } from 'maplibre-gl';
|
|
2
|
-
import { CustomRenderMethodInput } from 'maplibre-gl';
|
|
3
|
-
import { Map as Map_2 } from 'maplibre-gl';
|
|
4
|
-
|
|
5
|
-
export declare type ColorRampInput = string | string[] | Record<number, string>;
|
|
6
|
-
|
|
7
|
-
declare interface CoordArrays {
|
|
8
|
-
time: Float64Array | Float32Array;
|
|
9
|
-
vertical: Float32Array;
|
|
10
|
-
latitude: Float32Array;
|
|
11
|
-
longitude: Float32Array;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export declare interface FieldMeta {
|
|
15
|
-
min: number;
|
|
16
|
-
max: number;
|
|
17
|
-
unit: string;
|
|
18
|
-
time: string;
|
|
19
|
-
depth?: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export declare function getPalettes(): PaletteMeta[];
|
|
23
|
-
|
|
24
|
-
declare type LayerEventMap = {
|
|
25
|
-
loading: () => void;
|
|
26
|
-
loaded: (meta: FieldMeta) => void;
|
|
27
|
-
error: (err: Error) => void;
|
|
28
|
-
/** Fired when a time step has been pre-fetched and is ready for instant swap. */
|
|
29
|
-
frameBuffered: (ms: number) => void;
|
|
30
|
-
/** Fired when the frame cache is wiped (viewport changed). */
|
|
31
|
-
cacheInvalidated: () => void;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export declare interface PaletteMeta {
|
|
35
|
-
id: string;
|
|
36
|
-
label: string;
|
|
37
|
-
tags: string[];
|
|
38
|
-
colors: string[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export declare class ParticleLayer implements CustomLayerInterface {
|
|
42
|
-
readonly id: string;
|
|
43
|
-
readonly type: "custom";
|
|
44
|
-
readonly renderingMode: "3d";
|
|
45
|
-
private map;
|
|
46
|
-
private gl;
|
|
47
|
-
private simulation;
|
|
48
|
-
private velocityField;
|
|
49
|
-
private zarrSource;
|
|
50
|
-
private speedFactorParam;
|
|
51
|
-
private fadeOpacityParam;
|
|
52
|
-
private zoomRange;
|
|
53
|
-
private variableU;
|
|
54
|
-
private variableV;
|
|
55
|
-
private time;
|
|
56
|
-
private depth;
|
|
57
|
-
private scalarMode;
|
|
58
|
-
private scalarUnit;
|
|
59
|
-
private initialized;
|
|
60
|
-
private loading;
|
|
61
|
-
private velocityTexUnit;
|
|
62
|
-
private moveStartHandler;
|
|
63
|
-
private moveEndHandler;
|
|
64
|
-
/** Pre-fetched frames keyed by time-ms. Cleared when the viewport changes. */
|
|
65
|
-
private frameCache;
|
|
66
|
-
/** Time-ms values currently being fetched in the background. */
|
|
67
|
-
private inflight;
|
|
68
|
-
private listeners;
|
|
69
|
-
constructor(options: ParticleLayerOptions);
|
|
70
|
-
onAdd(map: Map_2, gl: WebGLRenderingContext): Promise<void>;
|
|
71
|
-
private initAsync;
|
|
72
|
-
private timeToMs;
|
|
73
|
-
private computeFieldMeta;
|
|
74
|
-
/**
|
|
75
|
-
* Fetch and stitch velocity data for the given time without touching GL state.
|
|
76
|
-
* The map's current viewport is used to determine the lat bounds of the request.
|
|
77
|
-
*/
|
|
78
|
-
private fetchVelocityData;
|
|
79
|
-
private loadViewportVelocity;
|
|
80
|
-
render(gl: WebGLRenderingContext, options: CustomRenderMethodInput | number[]): void;
|
|
81
|
-
onRemove(): void;
|
|
82
|
-
/**
|
|
83
|
-
* Interpolate speed and fade per render frame (cheap uniform uploads).
|
|
84
|
-
* t=0 at low zoom (global), t=1 at high zoom (local).
|
|
85
|
-
* For each range [min, max]: min applies at high zoom, max at low zoom.
|
|
86
|
-
*/
|
|
87
|
-
private applyZoomWeighting;
|
|
88
|
-
setTime(time: string | number): void;
|
|
89
|
-
/**
|
|
90
|
-
* Pre-fetch velocity data for a future time step without swapping the active
|
|
91
|
-
* field. Fires `frameBuffered(ms)` when ready so playback can advance
|
|
92
|
-
* immediately without a loading gap.
|
|
93
|
-
*/
|
|
94
|
-
prefetchTime(ms: number): Promise<void>;
|
|
95
|
-
/** True when the frame for the given time (ms) is already in the cache. */
|
|
96
|
-
isFrameCached(ms: number): boolean;
|
|
97
|
-
/** Abort all pending Zarr prefetch fetches and clear the inflight set. */
|
|
98
|
-
cancelPrefetches(): void;
|
|
99
|
-
setDepth(depth: number): void;
|
|
100
|
-
setSpeedFactor(v: ZoomWeighted): void;
|
|
101
|
-
setFadeOpacity(v: ZoomWeighted): void;
|
|
102
|
-
setDropRate(v: number): void;
|
|
103
|
-
setDropRateBump(v: number): void;
|
|
104
|
-
setParticleDensity(density: number): void;
|
|
105
|
-
setZoomRange(range: [number, number]): void;
|
|
106
|
-
setColorRamp(ramp: ColorRampInput): void;
|
|
107
|
-
setRenderMode(mode: RenderMode): void;
|
|
108
|
-
setOpacity(v: number): void;
|
|
109
|
-
setLogScale(v: boolean): void;
|
|
110
|
-
setVibrance(v: number): void;
|
|
111
|
-
setScalarVariable(varName: string): void;
|
|
112
|
-
on<K extends keyof LayerEventMap>(event: K, handler: LayerEventMap[K]): this;
|
|
113
|
-
off<K extends keyof LayerEventMap>(event: K, handler: LayerEventMap[K]): this;
|
|
114
|
-
private emit;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export declare interface ParticleLayerOptions {
|
|
118
|
-
id: string;
|
|
119
|
-
source: string;
|
|
120
|
-
variableU?: string;
|
|
121
|
-
variableV?: string;
|
|
122
|
-
/** Particles per screen pixel. Count = clamp(w × h × density, 1, 262144). Default 0.05. */
|
|
123
|
-
particleDensity?: number;
|
|
124
|
-
/** Fixed speed or [atHighZoom, atLowZoom]. */
|
|
125
|
-
speedFactor?: ZoomWeighted;
|
|
126
|
-
/** Fixed fade or [atHighZoom, atLowZoom]. */
|
|
127
|
-
fadeOpacity?: ZoomWeighted;
|
|
128
|
-
dropRate?: number;
|
|
129
|
-
dropRateBump?: number;
|
|
130
|
-
colorRamp?: Record<number, string>;
|
|
131
|
-
time?: string | number;
|
|
132
|
-
depth?: number;
|
|
133
|
-
/** [lowZoom, highZoom] breakpoints for zoom-weighted params. Default [2, 12]. */
|
|
134
|
-
zoomRange?: [number, number];
|
|
135
|
-
/** Global layer opacity [0, 1]. Default 1.0. */
|
|
136
|
-
opacity?: number;
|
|
137
|
-
/** Logarithmic speed normalization. Default false. */
|
|
138
|
-
logScale?: boolean;
|
|
139
|
-
/** Vibrance adjustment [-1, 1]. Default 0.0. */
|
|
140
|
-
vibrance?: number;
|
|
141
|
-
scalarMode?: boolean;
|
|
142
|
-
scalarUnit?: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export declare class ParticleSimulation {
|
|
146
|
-
private gl;
|
|
147
|
-
private params;
|
|
148
|
-
private updateProgram;
|
|
149
|
-
private drawProgram;
|
|
150
|
-
private fadeProgram;
|
|
151
|
-
private gridProgram;
|
|
152
|
-
private particleStateTextures;
|
|
153
|
-
private particleFramebuffers;
|
|
154
|
-
private particleIndexBuffer;
|
|
155
|
-
private particleIsCurrBuffer;
|
|
156
|
-
/** Active draw count — changes with canvas size / density, no realloc. */
|
|
157
|
-
private numParticles;
|
|
158
|
-
private screenTextures;
|
|
159
|
-
private screenFramebuffers;
|
|
160
|
-
private screenWidth;
|
|
161
|
-
private screenHeight;
|
|
162
|
-
private quadBuffer;
|
|
163
|
-
private colorRampTexture;
|
|
164
|
-
renderMode: RenderMode;
|
|
165
|
-
private updateLocs;
|
|
166
|
-
private drawLocs;
|
|
167
|
-
private fadeLocs;
|
|
168
|
-
private gridLocs;
|
|
169
|
-
constructor(params?: Partial<SimulationParams>);
|
|
170
|
-
init(gl: WebGLRenderingContext): void;
|
|
171
|
-
private getUniforms;
|
|
172
|
-
private initParticleState;
|
|
173
|
-
/**
|
|
174
|
-
* Ensure screen textures match the current canvas size and recompute
|
|
175
|
-
* the active particle count from density × canvas area.
|
|
176
|
-
*/
|
|
177
|
-
resize(width: number, height: number): void;
|
|
178
|
-
/**
|
|
179
|
-
* Run one simulation step: update positions, fade trails, draw particles.
|
|
180
|
-
* Must be called within the MapLibre render callback.
|
|
181
|
-
*/
|
|
182
|
-
render(velocityTexUnit: number, velocityMin: [number, number], velocityMax: [number, number], matrix: Iterable<number>, bounds: {
|
|
183
|
-
minX: number;
|
|
184
|
-
minY: number;
|
|
185
|
-
maxX: number;
|
|
186
|
-
maxY: number;
|
|
187
|
-
}, worldSize: number, worldCopyOffsets: number[], geoBounds?: {
|
|
188
|
-
west: number;
|
|
189
|
-
south: number;
|
|
190
|
-
east: number;
|
|
191
|
-
north: number;
|
|
192
|
-
}, isGlobe?: boolean): void;
|
|
193
|
-
private drawQuad;
|
|
194
|
-
setSpeedFactor(v: number): void;
|
|
195
|
-
setFadeOpacity(v: number): void;
|
|
196
|
-
setDropRate(v: number): void;
|
|
197
|
-
setDropRateBump(v: number): void;
|
|
198
|
-
setParticleDensity(density: number): void;
|
|
199
|
-
setColorRamp(ramp: Record<number, string>): void;
|
|
200
|
-
setRenderMode(mode: RenderMode): void;
|
|
201
|
-
setOpacity(v: number): void;
|
|
202
|
-
setLogScale(v: boolean): void;
|
|
203
|
-
setVibrance(v: number): void;
|
|
204
|
-
setScalarMode(v: boolean): void;
|
|
205
|
-
/**
|
|
206
|
-
* Reset all particles to random positions. Call after time/depth change
|
|
207
|
-
* or map move. Randomises the full state texture and clears trail FBOs.
|
|
208
|
-
*/
|
|
209
|
-
resetParticles(): void;
|
|
210
|
-
/**
|
|
211
|
-
* Clear screen framebuffers to transparent black.
|
|
212
|
-
* Eliminates ghost trails when the viewport shifts.
|
|
213
|
-
*/
|
|
214
|
-
clearState(): void;
|
|
215
|
-
destroy(): void;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
declare type RenderMode = 'raster' | 'particles' | 'raster+particles';
|
|
219
|
-
|
|
220
|
-
declare interface SimulationParams {
|
|
221
|
-
/** Particles per screen pixel. Active count = clamp(w * h * density, 1, MAX). */
|
|
222
|
-
particleDensity: number;
|
|
223
|
-
speedFactor: number;
|
|
224
|
-
fadeOpacity: number;
|
|
225
|
-
dropRate: number;
|
|
226
|
-
dropRateBump: number;
|
|
227
|
-
colorRamp?: Record<number, string>;
|
|
228
|
-
opacity: number;
|
|
229
|
-
logScale: boolean;
|
|
230
|
-
vibrance: number;
|
|
231
|
-
scalarMode: boolean;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Stitch multiple decoded chunks into a single global velocity grid.
|
|
236
|
-
* The result covers [0,360) longitude x [-90,90] latitude.
|
|
237
|
-
* Grid resolution matches the source data.
|
|
238
|
-
*/
|
|
239
|
-
export declare function stitchVelocityChunks(uChunks: Array<{
|
|
240
|
-
data: Float32Array;
|
|
241
|
-
latStart: number;
|
|
242
|
-
lonStart: number;
|
|
243
|
-
latSize: number;
|
|
244
|
-
lonSize: number;
|
|
245
|
-
lonChunkSize: number;
|
|
246
|
-
}>, vChunks: Array<{
|
|
247
|
-
data: Float32Array;
|
|
248
|
-
latStart: number;
|
|
249
|
-
lonStart: number;
|
|
250
|
-
latSize: number;
|
|
251
|
-
lonSize: number;
|
|
252
|
-
lonChunkSize: number;
|
|
253
|
-
}>, totalLat: number, totalLon: number, geoBounds?: {
|
|
254
|
-
west: number;
|
|
255
|
-
south: number;
|
|
256
|
-
east: number;
|
|
257
|
-
north: number;
|
|
258
|
-
}, latDescending?: boolean, scalarMode?: boolean): VelocityData;
|
|
259
|
-
|
|
260
|
-
export declare interface VelocityData {
|
|
261
|
-
u: Float32Array;
|
|
262
|
-
v: Float32Array;
|
|
263
|
-
width: number;
|
|
264
|
-
height: number;
|
|
265
|
-
uMin: number;
|
|
266
|
-
uMax: number;
|
|
267
|
-
vMin: number;
|
|
268
|
-
vMax: number;
|
|
269
|
-
bounds: {
|
|
270
|
-
west: number;
|
|
271
|
-
south: number;
|
|
272
|
-
east: number;
|
|
273
|
-
north: number;
|
|
274
|
-
};
|
|
275
|
-
/** True when latitude rows are stored north-to-south (needs GL Y-flip). */
|
|
276
|
-
latDescending?: boolean;
|
|
277
|
-
/** When true: R=scalar_norm, G=128(neutral), V loop skipped. */
|
|
278
|
-
scalarMode?: boolean;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Manages a WebGL texture that holds stitched U/V velocity data
|
|
283
|
-
* in geographic space [0,1]x[0,1], with R=u, G=v normalized to [0,1].
|
|
284
|
-
*/
|
|
285
|
-
export declare class VelocityField {
|
|
286
|
-
private gl;
|
|
287
|
-
private texture;
|
|
288
|
-
private width;
|
|
289
|
-
private height;
|
|
290
|
-
uMin: number;
|
|
291
|
-
uMax: number;
|
|
292
|
-
vMin: number;
|
|
293
|
-
vMax: number;
|
|
294
|
-
geoBounds: {
|
|
295
|
-
west: number;
|
|
296
|
-
south: number;
|
|
297
|
-
east: number;
|
|
298
|
-
north: number;
|
|
299
|
-
};
|
|
300
|
-
scalarMode: boolean;
|
|
301
|
-
private linearFilter;
|
|
302
|
-
init(gl: WebGLRenderingContext): void;
|
|
303
|
-
/**
|
|
304
|
-
* Upload velocity data as a 2-channel (RG) texture.
|
|
305
|
-
* Input: u/v Float32Arrays with real physical values.
|
|
306
|
-
* Stored normalized to [0,1] using uMin/uMax/vMin/vMax.
|
|
307
|
-
*/
|
|
308
|
-
update(data: VelocityData): void;
|
|
309
|
-
/** Switch between bilinear (particles) and nearest-neighbour (raster) sampling. */
|
|
310
|
-
setFilter(linear: boolean): void;
|
|
311
|
-
bind(unit: number): void;
|
|
312
|
-
hasData(): boolean;
|
|
313
|
-
destroy(): void;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export declare interface ZarrArrayMeta {
|
|
317
|
-
zarr_format: number;
|
|
318
|
-
shape: number[];
|
|
319
|
-
chunks: number[];
|
|
320
|
-
dtype: string;
|
|
321
|
-
compressor: {
|
|
322
|
-
id: string;
|
|
323
|
-
level?: number;
|
|
324
|
-
clevel?: number;
|
|
325
|
-
cname?: string;
|
|
326
|
-
shuffle?: number;
|
|
327
|
-
blocksize?: number;
|
|
328
|
-
} | null;
|
|
329
|
-
fill_value: number | string | null;
|
|
330
|
-
order: string;
|
|
331
|
-
filters: unknown[] | null;
|
|
332
|
-
dimension_separator?: string;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
declare interface ZarrAttrs {
|
|
336
|
-
_ARRAY_DIMENSIONS?: string[];
|
|
337
|
-
units?: string;
|
|
338
|
-
standard_name?: string;
|
|
339
|
-
long_name?: string;
|
|
340
|
-
calendar?: string;
|
|
341
|
-
[key: string]: unknown;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
export declare interface ZarrConsolidatedMeta {
|
|
345
|
-
zarr_consolidated_format: number;
|
|
346
|
-
metadata: Record<string, ZarrArrayMeta | ZarrAttrs | {
|
|
347
|
-
zarr_format: number;
|
|
348
|
-
}>;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
export declare class ZarrSource {
|
|
352
|
-
private root;
|
|
353
|
-
private meta;
|
|
354
|
-
private coords;
|
|
355
|
-
private verticalName;
|
|
356
|
-
private timeUnits;
|
|
357
|
-
private cache;
|
|
358
|
-
private maxCacheSize;
|
|
359
|
-
private abortControllers;
|
|
360
|
-
private bloscCodecCache;
|
|
361
|
-
constructor(root: string, maxCacheSize?: number);
|
|
362
|
-
init(): Promise<void>;
|
|
363
|
-
private getArrayMeta;
|
|
364
|
-
private getAttrs;
|
|
365
|
-
getDimensionSeparator(variable: string): string;
|
|
366
|
-
getShape(variable: string): number[];
|
|
367
|
-
getChunkShape(variable: string): number[];
|
|
368
|
-
getCoords(): CoordArrays;
|
|
369
|
-
getDimensions(variable: string): string[];
|
|
370
|
-
findNearestIndex(array: Float32Array | Float64Array, value: number): number;
|
|
371
|
-
findTimeIndex(time: string | number): number;
|
|
372
|
-
/**
|
|
373
|
-
* Convert a Unix-ms timestamp to the native time units used by this zarr
|
|
374
|
-
* (read from the time variable's .zattrs "units" field).
|
|
375
|
-
* Falls back to a magnitude heuristic when units are absent or unparseable.
|
|
376
|
-
*/
|
|
377
|
-
private msToZarrTime;
|
|
378
|
-
findDepthIndex(depth: number): number;
|
|
379
|
-
/** Return the actual name of the vertical dimension ("depth" or "elevation"). */
|
|
380
|
-
getVerticalDimName(): string;
|
|
381
|
-
/**
|
|
382
|
-
* Get chunk indices that intersect a geographic bounding box.
|
|
383
|
-
*/
|
|
384
|
-
getChunksForBounds(variable: string, timeIdx: number, depthIdx: number, bounds: {
|
|
385
|
-
west: number;
|
|
386
|
-
south: number;
|
|
387
|
-
east: number;
|
|
388
|
-
north: number;
|
|
389
|
-
}): Array<{
|
|
390
|
-
timeIdx: number;
|
|
391
|
-
depthIdx: number;
|
|
392
|
-
latIdx: number;
|
|
393
|
-
lonIdx: number;
|
|
394
|
-
latRange: [number, number];
|
|
395
|
-
lonRange: [number, number];
|
|
396
|
-
latSize: number;
|
|
397
|
-
lonSize: number;
|
|
398
|
-
}>;
|
|
399
|
-
fetchChunk(variable: string, indices: number[]): Promise<Float32Array>;
|
|
400
|
-
cancelAll(): void;
|
|
401
|
-
private getBloscCodec;
|
|
402
|
-
private decompress;
|
|
403
|
-
private loadCoordinates;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* A param that is either a fixed scalar or a zoom-weighted range.
|
|
408
|
-
* When a range [min, max] is given:
|
|
409
|
-
* - min is the value at high zoom (local / detail view)
|
|
410
|
-
* - max is the value at low zoom (global / overview)
|
|
411
|
-
* The layer interpolates between them based on the current map zoom
|
|
412
|
-
* and the configured zoomRange.
|
|
413
|
-
*/
|
|
414
|
-
export declare type ZoomWeighted = number | [min: number, max: number];
|
|
415
|
-
|
|
416
|
-
export { }
|