@metoceanapi/wxtiles-common 0.0.8 → 0.0.11-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 (162) hide show
  1. package/.github/workflows/lint.yml +1 -1
  2. package/.github/workflows/validate-pull-request-title.yml +17 -0
  3. package/LICENSE.txt +1 -1
  4. package/biome.json +26 -1
  5. package/controls/WxAPIControl/WxAPIControl-busy.ts +16 -0
  6. package/controls/WxAPIControl/WxAPIControl-datasets.ts +102 -0
  7. package/controls/WxAPIControl/WxAPIControl-filter.ts +66 -0
  8. package/controls/WxAPIControl/WxAPIControl-variables.ts +73 -0
  9. package/controls/WxAPIControl.ts +87 -120
  10. package/controls/WxInfoControl.ts +87 -2
  11. package/controls/WxLegendControl.ts +28 -2
  12. package/controls/WxStyleEditorControl.ts +129 -7
  13. package/controls/WxTimeControl.ts +133 -5
  14. package/docs/docs/.nojekyll +1 -0
  15. package/docs/docs/assets/highlight.css +92 -0
  16. package/docs/docs/assets/icons.svg +1 -0
  17. package/docs/docs/assets/style.css +1610 -0
  18. package/docs/docs/classes/controls_WxAPIControl.WxAPIControl.html +28 -0
  19. package/docs/docs/classes/controls_WxInfoControl.WxInfoControl.html +20 -0
  20. package/docs/docs/classes/controls_WxLegendControl.WxLegendControl.html +19 -0
  21. package/docs/docs/classes/controls_WxStyleEditorControl.WxStyleEditorControl.html +111 -0
  22. package/docs/docs/classes/controls_WxTimeControl.WxTimeControl.html +28 -0
  23. package/docs/docs/classes/managers_BaseDatasetManager.BaseDatasetManager.html +104 -0
  24. package/docs/docs/classes/managers_WxAllDatasetsManager.WxAllDatasetsManager.html +24 -0
  25. package/docs/docs/classes/types.WxRasterDataCache.html +27 -0
  26. package/docs/docs/classes/utils_RawCLUT.RawCLUT.html +18 -0
  27. package/docs/docs/classes/utils_qtree.QTree.html +22 -0
  28. package/docs/docs/classes/utils_wxtools.DataIntegral.html +10 -0
  29. package/docs/docs/classes/wxapi.WxAPI.html +45 -0
  30. package/docs/docs/classes/wxlayer_loader.Loader.html +31 -0
  31. package/docs/docs/classes/wxlayer_painter.Painter.html +20 -0
  32. package/docs/docs/classes/wxlayer_wxlayer.WxLayer.html +57 -0
  33. package/docs/docs/enums/utils_qtree.TileType.html +5 -0
  34. package/docs/docs/functions/utils_RawCLUT.WxCreateLegend.html +5 -0
  35. package/docs/docs/functions/utils_mercator.LatLonToPixels.html +6 -0
  36. package/docs/docs/functions/utils_mercator.PixelsToLatLon.html +6 -0
  37. package/docs/docs/functions/utils_mercator.PixelsToLonLat.html +6 -0
  38. package/docs/docs/functions/utils_mercator.coordToPixel.html +5 -0
  39. package/docs/docs/functions/utils_tests_wxtools.tests.html +1 -0
  40. package/docs/docs/functions/utils_wxtools.HEXtoRGBA.html +3 -0
  41. package/docs/docs/functions/utils_wxtools.HashXYZ.html +4 -0
  42. package/docs/docs/functions/utils_wxtools.RGBAtoHEX.html +3 -0
  43. package/docs/docs/functions/utils_wxtools.RGBtoHEX.html +3 -0
  44. package/docs/docs/functions/utils_wxtools.WXLOG.html +2 -0
  45. package/docs/docs/functions/utils_wxtools.WxGetColorSchemes.html +2 -0
  46. package/docs/docs/functions/utils_wxtools.WxGetColorStyles.html +2 -0
  47. package/docs/docs/functions/utils_wxtools.WxTilesLibSetup.html +3 -0
  48. package/docs/docs/functions/utils_wxtools.WxTilesLogging.html +5 -0
  49. package/docs/docs/functions/utils_wxtools.blurData.html +7 -0
  50. package/docs/docs/functions/utils_wxtools.buildIntegralPare.html +6 -0
  51. package/docs/docs/functions/utils_wxtools.cacheUriPromise.html +2 -0
  52. package/docs/docs/functions/utils_wxtools.create2DContext.html +6 -0
  53. package/docs/docs/functions/utils_wxtools.createEl.html +5 -0
  54. package/docs/docs/functions/utils_wxtools.createLevels.html +6 -0
  55. package/docs/docs/functions/utils_wxtools.fetchJson.html +6 -0
  56. package/docs/docs/functions/utils_wxtools.getClosestTimeString.html +5 -0
  57. package/docs/docs/functions/utils_wxtools.loadDataIntegral.html +5 -0
  58. package/docs/docs/functions/utils_wxtools.loadImage.html +4 -0
  59. package/docs/docs/functions/utils_wxtools.loadImageData.html +5 -0
  60. package/docs/docs/functions/utils_wxtools.makeConverter.html +9 -0
  61. package/docs/docs/functions/utils_wxtools.mixColor.html +3 -0
  62. package/docs/docs/functions/utils_wxtools.refineColor.html +3 -0
  63. package/docs/docs/functions/utils_wxtools.uriXYZ.html +5 -0
  64. package/docs/docs/functions/wxlayer_WxImplementation.WxLayerBaseImplementationMixin.html +4 -0
  65. package/docs/docs/functions/wxlayer_loadertools.applyMask.html +10 -0
  66. package/docs/docs/functions/wxlayer_loadertools.makeBox.html +4 -0
  67. package/docs/docs/functions/wxlayer_loadertools.splitCoords.html +6 -0
  68. package/docs/docs/functions/wxlayer_loadertools.subData.html +5 -0
  69. package/docs/docs/functions/wxlayer_loadertools.subDataDegree.html +5 -0
  70. package/docs/docs/functions/wxlayer_loadertools.subMask.html +5 -0
  71. package/docs/docs/hierarchy.html +1 -0
  72. package/docs/docs/index.html +7 -0
  73. package/docs/docs/interfaces/types.IsoInfo.html +8 -0
  74. package/docs/docs/interfaces/types.SLinePoint.html +4 -0
  75. package/docs/docs/interfaces/types.WxAPIOptions.html +37 -0
  76. package/docs/docs/interfaces/types.WxAllBoundariesMeta.html +8 -0
  77. package/docs/docs/interfaces/types.WxAllDatasetsShortMetas.html +4 -0
  78. package/docs/docs/interfaces/types.WxBoundaryMeta.html +10 -0
  79. package/docs/docs/interfaces/types.WxData.html +10 -0
  80. package/docs/docs/interfaces/types.WxDataSetManagerOptions.html +14 -0
  81. package/docs/docs/interfaces/types.WxDatasetMeta.html +20 -0
  82. package/docs/docs/interfaces/types.WxDatasetShortMeta.html +9 -0
  83. package/docs/docs/interfaces/types.WxLayerAPI.html +24 -0
  84. package/docs/docs/interfaces/types.WxLayerBaseAPI.html +16 -0
  85. package/docs/docs/interfaces/types.WxLayerOptions.html +12 -0
  86. package/docs/docs/interfaces/types.WxLngLat.html +6 -0
  87. package/docs/docs/interfaces/types.WxRasterData.html +13 -0
  88. package/docs/docs/interfaces/types.WxRequestInit.html +3 -0
  89. package/docs/docs/interfaces/types.WxTileInfo.html +18 -0
  90. package/docs/docs/interfaces/types.WxVariableMeta.html +13 -0
  91. package/docs/docs/interfaces/types.WxVariablesMetas.html +4 -0
  92. package/docs/docs/interfaces/utils_RawCLUT.WxLegend.html +14 -0
  93. package/docs/docs/interfaces/utils_RawCLUT.WxTick.html +10 -0
  94. package/docs/docs/interfaces/utils_qtree.Tree.html +7 -0
  95. package/docs/docs/interfaces/utils_wxtools.CachedUriLoaderPromiseFunc.html +2 -0
  96. package/docs/docs/interfaces/utils_wxtools.ColorStylesIncomplete.html +2 -0
  97. package/docs/docs/interfaces/utils_wxtools.Converter.html +5 -0
  98. package/docs/docs/interfaces/utils_wxtools.DataPicture.html +6 -0
  99. package/docs/docs/interfaces/utils_wxtools.IntegralPare.html +6 -0
  100. package/docs/docs/interfaces/utils_wxtools.WxColorSchemes.html +3 -0
  101. package/docs/docs/interfaces/utils_wxtools.WxColorStyleStrict.html +95 -0
  102. package/docs/docs/interfaces/utils_wxtools.WxColorStyleWeak.html +95 -0
  103. package/docs/docs/interfaces/utils_wxtools.WxColorStylesStrict.html +2 -0
  104. package/docs/docs/interfaces/utils_wxtools.WxColorStylesWeakMixed.html +2 -0
  105. package/docs/docs/interfaces/utils_wxtools.WxTilesLibOptions.html +8 -0
  106. package/docs/docs/interfaces/utils_wxtools.WxUnits.html +2 -0
  107. package/docs/docs/interfaces/utils_wxtools.XYZ.html +5 -0
  108. package/docs/docs/modules/controls_WxAPIControl.html +1 -0
  109. package/docs/docs/modules/controls_WxInfoControl.html +1 -0
  110. package/docs/docs/modules/controls_WxLegendControl.html +1 -0
  111. package/docs/docs/modules/controls_WxStyleEditorControl.html +1 -0
  112. package/docs/docs/modules/controls_WxTimeControl.html +1 -0
  113. package/docs/docs/modules/defaults_colorschemes.html +1 -0
  114. package/docs/docs/modules/defaults_styles.html +1 -0
  115. package/docs/docs/modules/defaults_uconv.html +1 -0
  116. package/docs/docs/modules/managers_BaseDatasetManager.html +1 -0
  117. package/docs/docs/modules/managers_WxAllDatasetsManager.html +1 -0
  118. package/docs/docs/modules/types.html +1 -0
  119. package/docs/docs/modules/utils_RawCLUT.html +1 -0
  120. package/docs/docs/modules/utils_mercator.html +1 -0
  121. package/docs/docs/modules/utils_qtree.html +1 -0
  122. package/docs/docs/modules/utils_tests_wxtools.html +1 -0
  123. package/docs/docs/modules/utils_wxtools.html +1 -0
  124. package/docs/docs/modules/wxapi.html +1 -0
  125. package/docs/docs/modules/wxlayer_WxImplementation.html +1 -0
  126. package/docs/docs/modules/wxlayer_loader.html +1 -0
  127. package/docs/docs/modules/wxlayer_loadertools.html +1 -0
  128. package/docs/docs/modules/wxlayer_painter.html +1 -0
  129. package/docs/docs/modules/wxlayer_wxlayer.html +1 -0
  130. package/docs/docs/modules.html +1 -0
  131. package/docs/docs/types/types.ListenerMethod.html +1 -0
  132. package/docs/docs/types/types.SLine.html +2 -0
  133. package/docs/docs/types/types.WxDate.html +9 -0
  134. package/docs/docs/types/types.WxEventType.html +1 -0
  135. package/docs/docs/types/types.WxInstances.html +2 -0
  136. package/docs/docs/types/types.WxLayerVarsNames.html +2 -0
  137. package/docs/docs/types/types.WxURIs.html +2 -0
  138. package/docs/docs/types/utils_qtree.SubTrees.html +2 -0
  139. package/docs/docs/types/utils_qtree.SubTreesN.html +2 -0
  140. package/docs/docs/types/utils_qtree.TreeN.html +2 -0
  141. package/docs/docs/types/utils_wxtools.DataIntegrals.html +2 -0
  142. package/docs/docs/types/utils_wxtools.DataPictures.html +2 -0
  143. package/docs/docs/types/utils_wxtools.WxUnitTuple.html +2 -0
  144. package/docs/docs/types/utils_wxtools.colorMapTuple.html +2 -0
  145. package/docs/docs/variables/defaults_colorschemes.__colorSchemes_default_preset.html +1 -0
  146. package/docs/docs/variables/defaults_styles.__colorStyles_default_preset.html +1 -0
  147. package/docs/docs/variables/defaults_uconv.__units_default_preset.html +1 -0
  148. package/managers/BaseDatasetManager.ts +272 -0
  149. package/managers/WxAllDatasetsManager.ts +60 -0
  150. package/package.json +6 -3
  151. package/tsconfig.json +31 -0
  152. package/typedoc.json +4 -0
  153. package/types.ts +471 -0
  154. package/utils/qtree.ts +2 -1
  155. package/utils/tests_wxtools.ts +10 -10
  156. package/utils/wxtools.ts +1 -0
  157. package/wxapi.ts +222 -0
  158. package/wxlayer/WxImplementation.ts +374 -0
  159. package/wxlayer/loader.ts +305 -0
  160. package/wxlayer/loadertools.ts +380 -0
  161. package/wxlayer/painter.ts +451 -0
  162. package/wxlayer/wxlayer.ts +379 -0
package/types.ts ADDED
@@ -0,0 +1,471 @@
1
+ /**
2
+ * type array of strings - available instances of a dataset */
3
+
4
+ import type { WxTilesLibOptions, WxColorStyleStrict, WxColorStyleWeak, XYZ, DataPictures } from "./utils/wxtools";
5
+ import type { BaseDatasetManager } from "./managers/BaseDatasetManager";
6
+ import type { WxAPI } from "./wxapi";
7
+ import { WXLOG } from "./utils/wxtools";
8
+
9
+ /**
10
+ * Type alias for an array of strings representing available instances of a dataset
11
+ */
12
+ export type WxInstances = string[];
13
+
14
+ /**
15
+ * Short metadata describing a dataset */
16
+ export interface WxDatasetShortMeta {
17
+ /**
18
+ * Represents instances as timesteps for datasets that support instancing, such as NZ Radar.
19
+ * Each entry corresponds to a specific time step. */
20
+ instanced?: WxInstances;
21
+
22
+ /** The latest available instance of the dataset. */
23
+ instance: string;
24
+
25
+ /** List of all variables available in the dataset. */
26
+ variables: string[];
27
+ }
28
+
29
+ /**
30
+ * Metadata structure for all available datasets with their short descriptions.
31
+ */
32
+ export interface WxAllDatasetsShortMetas {
33
+ /**
34
+ * An object where the keys are dataset names and the values are their corresponding short metadata.
35
+ * If no metadata is available for a dataset, the value will be `undefined`.
36
+ */
37
+ [name: string]: WxDatasetShortMeta | undefined;
38
+ }
39
+
40
+ /**
41
+ * Metadata for a specific variable in a dataset.
42
+ */
43
+ export interface WxVariableMeta {
44
+ /**
45
+ * Units of measurement for the variable.
46
+ */
47
+ units: string;
48
+
49
+ /**
50
+ * Minimum value for the variable.
51
+ */
52
+ min: number;
53
+
54
+ /**
55
+ * Maximum value for the variable.
56
+ */
57
+ max: number;
58
+
59
+ /**
60
+ * Standardized name for the variable, if available.
61
+ */
62
+ standard_name?: string;
63
+
64
+ /**
65
+ * If the variable is part of a vector data pair (e.g., u, v components of wind),
66
+ * this contains the associated pair.
67
+ */
68
+ vector?: [string, string];
69
+ }
70
+
71
+ /**
72
+ * Interface representing a collection of variables and their metadata.
73
+ */
74
+ export interface WxVariablesMetas {
75
+ /**
76
+ * An object where keys are variable names and values are their corresponding metadata.
77
+ * If metadata for a variable is unavailable, the value will be `undefined`.
78
+ */
79
+ [name: string]: WxVariableMeta | undefined;
80
+ }
81
+
82
+ /**
83
+ * Geographic boundaries of a dataset.
84
+ */
85
+ export interface WxBoundaryMeta {
86
+ /** Westernmost longitude. */
87
+ west: number;
88
+
89
+ /** Northernmost latitude. */
90
+ north: number;
91
+
92
+ /** Easternmost longitude. */
93
+ east: number;
94
+
95
+ /** Southernmost latitude. */
96
+ south: number;
97
+ }
98
+
99
+ /** Used to make an abortable call to the layer update */
100
+ export interface WxRequestInit {
101
+ signal?: AbortSignal;
102
+ }
103
+
104
+ /**
105
+ * All possible boundary representations for a dataset, including normalized and wrapped formats.
106
+ */
107
+ export interface WxAllBoundariesMeta {
108
+ /**
109
+ * Original boundaries of the dataset in normalized format.
110
+ */
111
+ boundariesnorm: WxBoundaryMeta;
112
+
113
+ /**
114
+ * Array of boundaries wrapped to the [-180, 180] longitude range.
115
+ */
116
+ boundaries180: WxBoundaryMeta[];
117
+
118
+ /**
119
+ * Array of boundaries wrapped to the [0, 360] longitude range.
120
+ */
121
+ boundaries360: WxBoundaryMeta[];
122
+ }
123
+
124
+ /**
125
+ * Comprehensive metadata for a dataset.
126
+ */
127
+ export interface WxDatasetMeta {
128
+ /**
129
+ * List of all variables in the dataset.
130
+ */
131
+ variables: string[];
132
+
133
+ /**
134
+ * Metadata for each variable.
135
+ */
136
+ variablesMeta: WxVariablesMetas;
137
+
138
+ /**
139
+ * Maximum zoom level supported by the dataset.
140
+ */
141
+ maxZoom: number;
142
+
143
+ /**
144
+ * The latest available instance of the dataset.
145
+ */
146
+ instance: string;
147
+
148
+ /** Array of all available timesteps (instances) for the dataset. */
149
+ times: string[];
150
+
151
+ /** Geographic boundaries of the dataset. */
152
+ boundaries: WxAllBoundariesMeta;
153
+
154
+ /** Identifier for the dataset's source. */
155
+ sourceID?: string;
156
+
157
+ /** Base atmospheric model used for the dataset, if applicable. */
158
+ baseAtmosphericModel?: string;
159
+
160
+ /** Name of the model used to generate the dataset, if applicable. */
161
+ model?: string;
162
+ }
163
+
164
+ /**
165
+ * Configuration options for constructing a {@link WxAPI} object.
166
+ * @example
167
+ * ```typescript
168
+ * const requestInit: RequestInit = {
169
+ * headers: {
170
+ * Authorization: "Bearer <token>",
171
+ * },
172
+ * }; // Add more options if needed, such as mode or credentials.
173
+ * const options: WxAPIOptions = {
174
+ * dataServerURL: "https://tiles.metoceanapi.com/data/",
175
+ * requestInit,
176
+ * };
177
+ * const wxapi = new WxAPI(options);
178
+ * ```
179
+ */
180
+ export interface WxAPIOptions extends WxTilesLibOptions {
181
+ /**
182
+ * Base URL of the data server.
183
+ */
184
+ dataServerURL: string;
185
+
186
+ /** extension of the tiles*/
187
+ ext?: string;
188
+
189
+ /**
190
+ * Full URL for mask tiles. Example: `https://server.com/masks/{z}/{x}/{y}.webp`.
191
+ * @default 'auto' - Automatically set to `dataServerURL + 'masks/{z}/{x}/{y}.webp'`.
192
+ * 'none' - Masks are disabled.
193
+ */
194
+ maskURL?: "none" | "auto" | string;
195
+
196
+ /**
197
+ * RGBA channel to use for masking.
198
+ * 0 - Masks from Sarah (current),
199
+ * 3 - Masks from Mapbox.
200
+ * @default 'R'
201
+ */
202
+ maskChannel?: "R" | "G" | "B" | "A";
203
+
204
+ /**
205
+ * Maximum zoom level for mask tiles on the server.
206
+ * @default 9
207
+ */
208
+ maskDepth?: number;
209
+
210
+ /**
211
+ * URL for the QTree file. QTree is a hierarchical structure that enables efficient spatial queries for sea/land detection.
212
+ * @default 'auto' - Automatically set to `dataServerURL + 'masks/9+1.seamask.qtree'`.
213
+ * 'none' - Disables QTree usage.
214
+ */
215
+ qtreeURL?: "none" | "auto" | string;
216
+
217
+ /**
218
+ * Options for HTTP requests made to the backend data server, such as headers, credentials, and CORS settings.
219
+ */
220
+ requestInit?: RequestInit;
221
+ }
222
+
223
+ /**
224
+ * Mandatory Interface to be implemented by a {@link WxLayerBaseImplementation}
225
+ */
226
+ export interface WxLayerBaseAPI {
227
+ wxdatasetManager: BaseDatasetManager;
228
+ getCurrentVariableMeta(): WxVariableMeta;
229
+ getVariablesNames(): WxLayerVarsNames;
230
+ clearCache(): void;
231
+ getCurrentStyleObjectCopy(): WxColorStyleStrict;
232
+ getTime(): string;
233
+ setTime(time?: WxDate, requestInit?: WxRequestInit): Promise<string>;
234
+ preloadTime(time: WxDate, requestInit?: WxRequestInit): Promise<void>;
235
+ startAnimation(): void;
236
+ stopAnimation(): Promise<void>;
237
+ setCoarseLevel(level: number): Promise<void>;
238
+ unsetCoarseLevel(): Promise<void>;
239
+ setStyleByName(wxstyleName: string, reload: boolean): Promise<void>;
240
+ updateCurrentStyleObject(
241
+ style?: WxColorStyleWeak,
242
+ reload?: boolean,
243
+ requestInit?: WxRequestInit,
244
+ ): Promise<void>;
245
+ }
246
+
247
+ export type ListenerMethod = <T extends keyof WxEventType>(
248
+ arg?: WxEventType[T],
249
+ ) => void;
250
+
251
+ export type WxEventType = {
252
+ // biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
253
+ changed: any;
254
+ };
255
+
256
+ /**
257
+ * Mandatory Interface to be implemented by a {@link WxTileSource} implementation
258
+ * These methods *Requires* framework specific implementation
259
+ * */
260
+ export interface WxLayerAPI extends WxLayerBaseAPI {
261
+ // biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
262
+ getLayerInfoAtLatLon(lnglat: WxLngLat, anymap: any): WxTileInfo | undefined;
263
+ _reloadVisible(requestInit?: WxRequestInit): Promise<void>;
264
+ update(): void;
265
+ coveringTiles(): XYZ[];
266
+ on<T extends keyof WxEventType>(type: T, listener: ListenerMethod): void;
267
+ off<T extends keyof WxEventType>(type: T, listener: ListenerMethod): void;
268
+ once<T extends keyof WxEventType>(type: T, listener: ListenerMethod): void;
269
+ }
270
+
271
+ /**
272
+ * Type used to set a time step for the layer.
273
+ * Can be
274
+ * 1. a string in the dataset's format,
275
+ * 2. a number of a time step in the dataset's meta data,
276
+ * 3. a number of milliseconds since 1970-01-01T00:00:00Z
277
+ * 4. a Date object.
278
+ * */
279
+ export type WxDate = string | number | Date;
280
+
281
+
282
+ /** Information about the current point on map returned by the {@link WxLayer} method. */
283
+ export interface WxTileInfo {
284
+ /** values of all variables in datasets's units */
285
+ data: number[];
286
+
287
+ /** RAW values of all variables in internal representation */
288
+ raw: number[];
289
+
290
+ /** **uint32** colors defined by curent values {@link WxTileInfo.data} and the style */
291
+ rgba: number[];
292
+
293
+ /** web colors defined by curent values {@link WxTileInfo.data} and the style */
294
+ hexColor: string[];
295
+
296
+ /** values of all variables in Style's units */
297
+ inStyleUnits: number[];
298
+
299
+ /** The current point on map. */
300
+ tilePoint: { x: number; y: number };
301
+
302
+ /** WxUnits defined style */
303
+ styleUnits: string;
304
+
305
+ /** WxUnits defined dataset */
306
+ dataUnits: string;
307
+ }
308
+
309
+ /** Array of variable names to be used in {@link WxLayer} */
310
+ export type WxLayerVarsNames = [string] | [string, string];
311
+
312
+ /** @internal Array of URIs to request tiles */
313
+ export type WxURIs = [string] | [string, string];
314
+
315
+ /** Lon/Lat coordinates */
316
+ export interface WxLngLat {
317
+ /** Longitude */
318
+ lng: number;
319
+
320
+ /** Latitude */
321
+ lat: number;
322
+ }
323
+
324
+ /**
325
+ * @internal
326
+ * Used in {@link WxLayerBaseImplementation} cache of the renderes tiles
327
+ * */
328
+ export class WxRasterDataCache extends Map<string, WxRasterData> {
329
+ override clear(): void {
330
+ WXLOG("TilesCache.clear()");
331
+
332
+ for (const v of this.values()) {
333
+ if (!v.rd) return;
334
+ v.rd.gl.deleteTexture(v.rd.vectorTextureU);
335
+ v.rd.gl.deleteTexture(v.rd.vectorTextureV);
336
+ }
337
+
338
+ super.clear();
339
+ }
340
+ }
341
+
342
+ /**
343
+ * Interface to represent information related to isolines
344
+ */
345
+ export interface IsoInfo {
346
+ x: number;
347
+ y: number;
348
+ d: number;
349
+ dr: number;
350
+ db: number;
351
+ mli: number;
352
+ }
353
+
354
+ /**
355
+ * Interface representing raster data required for rendering a single tile.
356
+ * Contains necessary contexts and raw data for rendering.
357
+ */
358
+ export interface WxRasterData {
359
+ /**
360
+ * Context for rendering background fill and isolines.
361
+ */
362
+ ctxFill: CanvasRenderingContext2D;
363
+
364
+ /**
365
+ * Context for rendering vector arrows, and other text
366
+ * */
367
+ ctxText: CanvasRenderingContext2D;
368
+
369
+ /**
370
+ * Context for rendering animated streamlines
371
+ * */
372
+ ctxStreamLines: CanvasRenderingContext2D;
373
+
374
+ /**
375
+ * {@link WxData} data object for this tile
376
+ * */
377
+ data: WxData;
378
+
379
+ /**
380
+ * Optional WebGL textures for vector field representations.
381
+ */
382
+ rd?: {
383
+ vectorTextureU: WebGLTexture;
384
+ vectorTextureV: WebGLTexture;
385
+ gl: WebGLRenderingContext;
386
+ };
387
+ }
388
+
389
+ /** Represents a point on a pixel grid */
390
+ export interface SLinePoint {
391
+ x: number;
392
+ y: number;
393
+ }
394
+
395
+ /** Represents a line on a pixel grid */
396
+ export type SLine = SLinePoint[];
397
+
398
+ /** Data structure for a single tile */
399
+ export interface WxData {
400
+ /**
401
+ * Tile data array.
402
+ * - Contains one element for scalar data.
403
+ * - Contains three elements for vector data (U, V components, and vector lengths).
404
+ */
405
+ data: DataPictures;
406
+
407
+ /** Streamlines for visualizing vector fields */
408
+ slines: SLine[];
409
+ }
410
+
411
+ /**
412
+ * @internal
413
+ * Do not use this type directly, use {@link WxSourceLayerOptions} instead
414
+ * */
415
+ export interface WxLayerOptions<WxDatasetManagerT> {
416
+ /** Variables of the layer */
417
+ variables: WxLayerVarsNames;
418
+
419
+ /** Dataset Manager */
420
+ wxdatasetManager: WxDatasetManagerT;
421
+
422
+ /** initial time step */
423
+ time?: WxDate;
424
+
425
+ /** initial style name */
426
+ wxstyleName?: string;
427
+
428
+ /** initial style, applyed on top of style passed by name {@link wxstyleName} */
429
+ wxstyle?: WxColorStyleWeak;
430
+ }
431
+
432
+ /**
433
+ * Options for constructing a {@link WxDataSetManager} instance.
434
+ */
435
+ export interface WxDataSetManagerOptions {
436
+ /**
437
+ * @internal
438
+ * The name of the dataset to manage.
439
+ */
440
+ datasetName: string;
441
+
442
+ /**
443
+ * @internal
444
+ * Current instance of the dataset
445
+ * */
446
+ datasetCurrentInstance: string;
447
+
448
+ /**
449
+ * @internal
450
+ * Array of time steps for instanced datasets.
451
+ * */
452
+ instanced?: WxInstances;
453
+
454
+ /**
455
+ * @internal
456
+ * Metadata for the current instance of the dataset.
457
+ * */
458
+ datasetCurrentMeta: WxDatasetMeta;
459
+
460
+ /**
461
+ * @internal
462
+ * Metadata for all instances of the dataset, if instanced.
463
+ * */
464
+ metas?: Map<string, WxDatasetMeta>;
465
+
466
+ /**
467
+ * @internal
468
+ * Reference to the {@link WxAPI} instance used to interact with the WxTiles API.
469
+ * */
470
+ wxAPI: WxAPI;
471
+ }
package/utils/qtree.ts CHANGED
@@ -90,7 +90,8 @@ export class QTree {
90
90
  const _seamask = await fetchJson<string>(input, requestInit);
91
91
  this._qtree = qtreeFromString(_seamask, { pos: 0 });
92
92
  } catch (e) {
93
- throw new Error(`Failed to load QTree: ${e.message}`);
93
+ const message = e instanceof Error ? e.message : String(e);
94
+ throw new Error(`Failed to load QTree: ${message}`);
94
95
  }
95
96
 
96
97
  this._qtreedepth = getTreeDepth(this._qtree);
@@ -49,21 +49,21 @@ function ft_printIm(raw: ArrayLike<number>, n: number, comment: string) {
49
49
  }
50
50
 
51
51
  function ft_Uint16ArrayRandom() {
52
- const seed = 1;
52
+ // const seed = 1;
53
53
  // const rnd = () => Math.floor(Math.abs(Math.sin(seed++)) * 32000 + 32000);
54
54
  const rnd = () => Math.floor(Math.random() * 32000);
55
55
  return new Uint16Array(258 * 258).map(rnd);
56
56
  }
57
57
 
58
58
  function ft_Uint16ArrayAscent() {
59
- return new Uint16Array(258 * 258).map((v, i) => (i % 258) + ~~(i / 258));
59
+ return new Uint16Array(258 * 258).map((_v, i) => (i % 258) + ~~(i / 258));
60
60
  }
61
61
 
62
- function ft_Uint16ArrayDescent() {
63
- return new Uint16Array(258 * 258).map(
64
- (v, i) => 514 - ((i % 258) + ~~(i / 258)),
65
- );
66
- }
62
+ // function ft_Uint16ArrayDescent() {
63
+ // return new Uint16Array(258 * 258).map(
64
+ // (_v, i) => 514 - ((i % 258) + ~~(i / 258)),
65
+ // );
66
+ // }
67
67
 
68
68
  function ft_Uint32ArrayCompare(a: ArrayLike<number>, b: ArrayLike<number>) {
69
69
  if (a.length !== b.length) return false;
@@ -102,9 +102,9 @@ function ft_buildDataIntegralAscent(): DataIntegral {
102
102
  return new DataIntegral(ft_Uint16ArrayAscent(), 0, 1, 1);
103
103
  }
104
104
 
105
- function ft_buildDataIntegralDescend(): DataIntegral {
106
- return new DataIntegral(ft_Uint16ArrayDescent(), 0, 1, 1);
107
- }
105
+ // function ft_buildDataIntegralDescend(): DataIntegral {
106
+ // return new DataIntegral(ft_Uint16ArrayDescent(), 0, 1, 1);
107
+ // }
108
108
 
109
109
  function ft_buildDataIntegralRandom(): DataIntegral {
110
110
  return new DataIntegral(ft_Uint16ArrayRandom(), 0, 1, 1);
package/utils/wxtools.ts CHANGED
@@ -1053,6 +1053,7 @@ export function getClosestTimeString(
1053
1053
  * Logging helper
1054
1054
  * */
1055
1055
  // biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
1056
+ // @ts-ignore
1056
1057
  export let WXLOG = (...args: any[]) => {};
1057
1058
 
1058
1059
  /**