@metoceanapi/wxtiles-leaflet 2.0.4 → 2.0.6
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/CHANGELOG.md +4 -0
- package/README.md +137 -305
- package/dist/es/defaults/styles.d.ts +2 -2
- package/dist/es/defaults/uconv.d.ts +2 -2
- package/dist/es/index.d.ts +31 -4
- package/dist/es/index.js +1 -1
- package/dist/es/utils/RawCLUT.d.ts +32 -22
- package/dist/es/utils/qtree.d.ts +11 -5
- package/dist/es/utils/wxtools.d.ts +226 -60
- package/dist/es/wxAPI/WxDataSetManager.d.ts +65 -35
- package/dist/es/wxAPI/wxAPI.d.ts +115 -43
- package/dist/es/wxlayer/WxImplementation.d.ts +74 -32
- package/dist/es/wxlayer/loader.d.ts +27 -3
- package/dist/es/wxlayer/loadertools.d.ts +41 -3
- package/dist/es/wxlayer/painter.d.ts +39 -0
- package/dist/es/wxlayer/wxlayer.d.ts +77 -9
- package/dist/es/wxsource/wxsource.d.ts +60 -20
- package/dist/es/wxsource/wxsourcetypes.d.ts +13 -0
- package/dist/web/index.js +1 -1
- package/docs/docs/assets/highlight.css +92 -0
- package/docs/docs/assets/main.js +54 -0
- package/docs/docs/assets/search.js +1 -0
- package/docs/docs/assets/style.css +1257 -0
- package/docs/docs/classes/FrameworkParentClass.html +86 -0
- package/docs/docs/classes/Loader.html +165 -0
- package/docs/docs/classes/Painter.html +161 -0
- package/docs/docs/classes/QTree.html +129 -0
- package/docs/docs/classes/RawCLUT.html +143 -0
- package/docs/docs/classes/WxAPI.html +336 -0
- package/docs/docs/classes/WxDataSetManager.html +389 -0
- package/docs/docs/classes/WxLayer.html +363 -0
- package/docs/docs/classes/WxLayerBaseImplementation.html +358 -0
- package/docs/docs/classes/WxTileSource.html +435 -0
- package/docs/docs/enums/TileType.html +80 -0
- package/docs/docs/functions/WXLOG.html +118 -0
- package/docs/docs/functions/WxCreateLegend.html +126 -0
- package/docs/docs/functions/WxGetColorSchemes.html +113 -0
- package/docs/docs/functions/WxGetColorStyles.html +113 -0
- package/docs/docs/functions/WxTilesLogging.html +118 -0
- package/docs/docs/index.html +199 -0
- package/docs/docs/interfaces/ColorStylesIncomplete.html +116 -0
- package/docs/docs/interfaces/Converter.html +81 -0
- package/docs/docs/interfaces/DataIntegral.html +112 -0
- package/docs/docs/interfaces/DataPicture.html +93 -0
- package/docs/docs/interfaces/FrameworkOptions.html +118 -0
- package/docs/docs/interfaces/IntegralPare.html +81 -0
- package/docs/docs/interfaces/SLinePoint.html +77 -0
- package/docs/docs/interfaces/Tree.html +70 -0
- package/docs/docs/interfaces/WxAPIOptions.html +164 -0
- package/docs/docs/interfaces/WxAllBoundariesMeta.html +85 -0
- package/docs/docs/interfaces/WxBoundaryMeta.html +91 -0
- package/docs/docs/interfaces/WxColorSchemes.html +117 -0
- package/docs/docs/interfaces/WxColorStyleStrict.html +299 -0
- package/docs/docs/interfaces/WxColorStyleWeak.html +325 -0
- package/docs/docs/interfaces/WxColorStylesStrict.html +74 -0
- package/docs/docs/interfaces/WxColorStylesWeakMixed.html +116 -0
- package/docs/docs/interfaces/WxData.html +81 -0
- package/docs/docs/interfaces/WxDataSetManagerOptions.html +108 -0
- package/docs/docs/interfaces/WxDataSetsMetasJSON.html +75 -0
- package/docs/docs/interfaces/WxDatasetMeta.html +135 -0
- package/docs/docs/interfaces/WxDatasetShortMeta.html +90 -0
- package/docs/docs/interfaces/WxLayerAPI.html +313 -0
- package/docs/docs/interfaces/WxLayerBaseAPI.html +246 -0
- package/docs/docs/interfaces/WxLayerOptions.html +111 -0
- package/docs/docs/interfaces/WxLegend.html +117 -0
- package/docs/docs/interfaces/WxLngLat.html +81 -0
- package/docs/docs/interfaces/WxRasterData.html +99 -0
- package/docs/docs/interfaces/WxRequestInit.html +70 -0
- package/docs/docs/interfaces/WxTick.html +99 -0
- package/docs/docs/interfaces/WxTileInfo.html +142 -0
- package/docs/docs/interfaces/WxTilesLibOptions.html +92 -0
- package/docs/docs/interfaces/WxUnits.html +116 -0
- package/docs/docs/interfaces/WxVariableMeta.html +108 -0
- package/docs/docs/interfaces/WxVariablesMetas.html +116 -0
- package/docs/docs/interfaces/XYZ.html +84 -0
- package/docs/docs/modules.html +208 -0
- package/docs/docs/types/DataIntegrals.html +109 -0
- package/docs/docs/types/DataPictures.html +109 -0
- package/docs/docs/types/SLine.html +109 -0
- package/docs/docs/types/SubTrees.html +109 -0
- package/docs/docs/types/SubTreesN.html +109 -0
- package/docs/docs/types/TreeN.html +109 -0
- package/docs/docs/types/UriLoaderPromiseFunc.html +129 -0
- package/docs/docs/types/WxDate.html +109 -0
- package/docs/docs/types/WxURIs.html +109 -0
- package/docs/docs/types/WxUnitTuple.html +109 -0
- package/docs/docs/types/WxVars.html +109 -0
- package/docs/script/script.css +1 -1
- package/docs/script/script.js +6 -6
- package/package.json +8 -8
- package/src_example/index.ts +12 -7
|
@@ -1,11 +1,49 @@
|
|
|
1
1
|
import { DataPicture, XYZ } from '../utils/wxtools';
|
|
2
2
|
import { WxBoundaryMeta } from '../wxAPI/wxAPI';
|
|
3
|
+
/**
|
|
4
|
+
* Get sub-tile of a mask via baricemrtric interpolation
|
|
5
|
+
* @param {ImageData} inputData - input data
|
|
6
|
+
* @param {XYZ | undefined} subCoords - subtile coordinates
|
|
7
|
+
* @returns {ImageData} subtile data
|
|
8
|
+
* */
|
|
9
|
+
export declare function subMask(inputData: ImageData, subCoords?: XYZ): ImageData;
|
|
10
|
+
/**
|
|
11
|
+
* Get sub-tile of a regular data via baricemrtric interpolation
|
|
12
|
+
* @param {DataPicture} inputData - input data
|
|
13
|
+
* @param {XYZ | undefined} subCoords - subtile coordinates
|
|
14
|
+
* @returns {DataPicture} subtile data
|
|
15
|
+
* */
|
|
3
16
|
export declare function subData(inputData: DataPicture, subCoords?: XYZ): DataPicture;
|
|
17
|
+
/**
|
|
18
|
+
* Get sub-tile of a degree data tile via bilinear degree interpolation, so middle of 350..10 degree is 0 degree.
|
|
19
|
+
* @param {DataPicture} inputData - input data
|
|
20
|
+
* @param {XYZ | undefined} subCoords - subtile coordinates
|
|
21
|
+
* @returns {DataPicture} subtile data
|
|
22
|
+
* */
|
|
4
23
|
export declare function subDataDegree(inputData: DataPicture, subCoords?: XYZ): DataPicture;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Upply sea/land mask to a data tile
|
|
26
|
+
* 0 - for the masks from Sarah (current), 3 - for the masks from Mapbox
|
|
27
|
+
* @param {DataPicture} dataIn - data tile
|
|
28
|
+
* @param {ImageData} mask - sea/land mask
|
|
29
|
+
* @param {number} mc - mask channel of the mask picture to use (0 - Red, 1 - Green, 2 - Blue, 3 - Alpha)
|
|
30
|
+
* @param {'sea' | 'land'} maskType - sea or land masking to apply
|
|
31
|
+
* @returns {DataPicture} - masked data tile
|
|
32
|
+
* */
|
|
33
|
+
export declare function applyMask(dataIn: DataPicture, { data }: ImageData, mc: number, maskType: 'land' | 'sea'): DataPicture;
|
|
34
|
+
/**
|
|
35
|
+
* Create a bounding box for a tile
|
|
36
|
+
* @param coords - tile coordinates
|
|
37
|
+
* @returns {WxBoundaryMeta} [minLon, minLat, maxLon, maxLat]
|
|
38
|
+
* */
|
|
8
39
|
export declare function makeBox(coords: XYZ): WxBoundaryMeta;
|
|
40
|
+
/**
|
|
41
|
+
* Splits tile coordinates into a tile coords at maximum zoom and a subtile coords.
|
|
42
|
+
* If the tile is below maximum zoom, the subtile coords are undefined.
|
|
43
|
+
* @param coords - tile coordinates
|
|
44
|
+
* @param maxZoom - maximum zoom
|
|
45
|
+
* @returns [tile coords, subtile coords (or undefined)]
|
|
46
|
+
* */
|
|
9
47
|
export declare function splitCoords(coords: XYZ, maxZoom: number): {
|
|
10
48
|
upCoords: XYZ;
|
|
11
49
|
subCoords?: XYZ;
|
|
@@ -1,14 +1,53 @@
|
|
|
1
1
|
import { type WxData } from './loader';
|
|
2
2
|
import { type WxLayer } from './wxlayer';
|
|
3
|
+
/**
|
|
4
|
+
* data object contains raw data, contexts, and other info for fast rendering of a single tile
|
|
5
|
+
* */
|
|
3
6
|
export interface WxRasterData {
|
|
7
|
+
/**
|
|
8
|
+
* Context for drawing back fill and isolines
|
|
9
|
+
*/
|
|
4
10
|
ctxFill: CanvasRenderingContext2D;
|
|
11
|
+
/**
|
|
12
|
+
* Context for rendering vector arrows, and other text
|
|
13
|
+
* */
|
|
5
14
|
ctxText: CanvasRenderingContext2D;
|
|
15
|
+
/**
|
|
16
|
+
* Context for rendering animated streamlines
|
|
17
|
+
* */
|
|
6
18
|
ctxStreamLines: CanvasRenderingContext2D;
|
|
19
|
+
/**
|
|
20
|
+
* {@link WxData} data object for this tile
|
|
21
|
+
* */
|
|
7
22
|
data: WxData;
|
|
8
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Calss for rendering a single tile.
|
|
26
|
+
* Do not create manually
|
|
27
|
+
* */
|
|
9
28
|
export declare class Painter {
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
* {@link WxLayer} - parent layer
|
|
32
|
+
* */
|
|
10
33
|
protected layer: WxLayer;
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
* Do not use constructor directly
|
|
37
|
+
* */
|
|
11
38
|
constructor(layer: WxLayer);
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
* Render data of a single tile into canvases passed in {@link WxRasterData}
|
|
42
|
+
* @param {WxRasterData} data - data object for this tile
|
|
43
|
+
* */
|
|
12
44
|
paint({ data, ctxFill, ctxText, ctxStreamLines }: WxRasterData): void;
|
|
45
|
+
getPaintedCanvas(data: WxRasterData, animation: boolean, seed: number): HTMLCanvasElement;
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
* Render animated streamlines for a single tile with time seed
|
|
49
|
+
* @param {WxRasterData} data - data object for this tile
|
|
50
|
+
* @param {number} seed - time seed
|
|
51
|
+
* */
|
|
13
52
|
imprintVectorAnimationLinesStep({ data, ctxFill, ctxStreamLines }: WxRasterData, seed: number): void;
|
|
14
53
|
}
|
|
@@ -1,73 +1,139 @@
|
|
|
1
1
|
import { RawCLUT } from '../utils/RawCLUT';
|
|
2
|
-
import {
|
|
2
|
+
import type { WxColorStyleStrict, XYZ, DataPictures, WxColorStyleWeak } from '../utils/wxtools';
|
|
3
3
|
import { type WxVariableMeta } from '../wxAPI/wxAPI';
|
|
4
4
|
import { WxDataSetManager } from '../wxAPI/WxDataSetManager';
|
|
5
5
|
import { Loader } from './loader';
|
|
6
6
|
import { Painter, type WxRasterData } from './painter';
|
|
7
|
-
|
|
7
|
+
/** Type used to set a time step for the layer. */
|
|
8
|
+
export type WxDate = string | number | Date;
|
|
9
|
+
/** Used to make an abortable call to the layer update */
|
|
8
10
|
export interface WxRequestInit {
|
|
9
11
|
signal?: AbortSignal;
|
|
10
12
|
}
|
|
13
|
+
/** Information about the current point on map returned by the {@link WxLayer} method. */
|
|
11
14
|
export interface WxTileInfo {
|
|
15
|
+
/** values of all variables in datasets's units */
|
|
12
16
|
data: number[];
|
|
17
|
+
/** RAW values of all variables in internal representation */
|
|
13
18
|
raw: number[];
|
|
19
|
+
/** **uint32** colors defined by curent values {@link WxTileInfo.data} and the style */
|
|
14
20
|
rgba: number[];
|
|
21
|
+
/** web colors defined by curent values {@link WxTileInfo.data} and the style */
|
|
15
22
|
hexColor: string[];
|
|
23
|
+
/** values of all variables in Style's units */
|
|
16
24
|
inStyleUnits: number[];
|
|
25
|
+
/** The current point on map. */
|
|
17
26
|
tilePoint: {
|
|
18
27
|
x: number;
|
|
19
28
|
y: number;
|
|
20
29
|
};
|
|
30
|
+
/** WxUnits defined style */
|
|
21
31
|
styleUnits: string;
|
|
32
|
+
/** WxUnits defined dataset */
|
|
22
33
|
dataUnits: string;
|
|
23
34
|
}
|
|
24
|
-
|
|
25
|
-
export
|
|
35
|
+
/** Array of variable names to be used in {@link WxLayer} */
|
|
36
|
+
export type WxVars = [string] | [string, string];
|
|
37
|
+
/** @internal Array of URIs to request tiles */
|
|
38
|
+
export type WxURIs = [string] | [string, string];
|
|
39
|
+
/** Lon/Lat coordinates */
|
|
26
40
|
export interface WxLngLat {
|
|
41
|
+
/** Longitude */
|
|
27
42
|
lng: number;
|
|
43
|
+
/** Latitude */
|
|
28
44
|
lat: number;
|
|
29
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Options to construct {@link WxTileSource} object
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const variables = wxdatasetManager.checkCombineVariableIfVector('air.temperature.at-2m');
|
|
51
|
+
* const options: WxLayerOptions = { variables, wxdatasetManager, time: Date.now() };
|
|
52
|
+
* ```
|
|
53
|
+
* */
|
|
30
54
|
export interface WxLayerOptions {
|
|
55
|
+
/** Variables of the layer */
|
|
31
56
|
variables: WxVars;
|
|
57
|
+
/** Dataset Manager */
|
|
32
58
|
wxdatasetManager: WxDataSetManager;
|
|
59
|
+
/** initial time step */
|
|
33
60
|
time?: WxDate;
|
|
61
|
+
/** extension of data tiles at the backend */
|
|
34
62
|
ext?: 'png';
|
|
63
|
+
/** initial style name */
|
|
35
64
|
wxstyleName?: string;
|
|
36
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
* Used in {@link WxLayerBaseImplementation} to manipulate the the layer's style, data and time
|
|
69
|
+
* */
|
|
37
70
|
export declare class WxLayer {
|
|
38
|
-
|
|
71
|
+
/** @internal PNG only!*/
|
|
72
|
+
protected readonly ext: 'png';
|
|
73
|
+
/** @internal Variables to be displayed by the layer */
|
|
39
74
|
readonly variables: WxVars;
|
|
75
|
+
/** @internal Data manager created this layer */
|
|
40
76
|
readonly wxdatasetManager: WxDataSetManager;
|
|
77
|
+
/** @internal Current Meta data for the layer*/
|
|
41
78
|
readonly currentMeta: WxVariableMeta;
|
|
79
|
+
/** @internal Current time*/
|
|
42
80
|
protected time: string;
|
|
81
|
+
/** @internal current URIs to fetch tiles */
|
|
43
82
|
tilesURIs: WxURIs;
|
|
83
|
+
/** @internal current Style Object */
|
|
44
84
|
style: WxColorStyleStrict;
|
|
85
|
+
/** @internal Current "Color lookup table" object */
|
|
45
86
|
CLUT: RawCLUT;
|
|
87
|
+
/** @internal cahced URI->data */
|
|
46
88
|
protected tilesCache: Map<string, WxRasterData>;
|
|
89
|
+
/** @internal Painter object to render tiles */
|
|
47
90
|
readonly painter: Painter;
|
|
91
|
+
/** @internal Loader object to load and preprocess tiles */
|
|
48
92
|
protected readonly loader: Loader;
|
|
49
93
|
constructor({ time, variables, wxdatasetManager, ext, wxstyleName }: WxLayerOptions);
|
|
94
|
+
/** Check if the layer is vector and may be animated according to style */
|
|
50
95
|
get nonanimatable(): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* @internal
|
|
98
|
+
* Get the current time step of the layer
|
|
99
|
+
* @returns {string} time step in the dataset meta's format */
|
|
51
100
|
getTime(): string;
|
|
101
|
+
/**
|
|
102
|
+
* @internal
|
|
103
|
+
* Clear the cache of tiles
|
|
104
|
+
* Not to use when loading is in progress. */
|
|
52
105
|
clearCache(): void;
|
|
106
|
+
/** @internal */
|
|
53
107
|
getCurrentStyleObjectCopy(): WxColorStyleStrict;
|
|
108
|
+
/** @internal */
|
|
54
109
|
updateCurrentStyleObject(style?: WxColorStyleWeak): void;
|
|
110
|
+
/** @internal Used by {@link WxTileSource.getLayerInfoAtLatLon} */
|
|
55
111
|
getTileData(tileCoord: XYZ, tilePixel: {
|
|
56
112
|
x: number;
|
|
57
113
|
y: number;
|
|
58
114
|
}): WxTileInfo | undefined;
|
|
115
|
+
/** @internal reassign URIs and a time step with a new given time step */
|
|
59
116
|
setURLsAndTime(time_?: WxDate): void;
|
|
60
|
-
|
|
117
|
+
/** @internal load, cache, draw the tile. Abortable */
|
|
118
|
+
loadTile(tile: XYZ, requestInit?: WxRequestInit): Promise<WxRasterData | null>;
|
|
119
|
+
/** @internal cache given time step for faster access when needed. Resolved when done.
|
|
120
|
+
* @param time_ time step to cache
|
|
121
|
+
* @param requestInit request options
|
|
122
|
+
* @returns {Promise<void>} */
|
|
61
123
|
preloadTime(time_: WxDate, tiles: XYZ[], requestInit?: WxRequestInit): Promise<void>;
|
|
62
124
|
/**
|
|
63
|
-
* @description Load all tiles, draw it on canvas, save to cache and return
|
|
125
|
+
* @description Load all tiles, draw it on canvas, save to cache and return. Resolved when done.
|
|
64
126
|
* @param tiles
|
|
65
127
|
* @param requestInit
|
|
66
|
-
*/
|
|
128
|
+
* @returns {Promise<viod>} */
|
|
67
129
|
reloadTiles(tiles: XYZ[], requestInit?: WxRequestInit): Promise<void>;
|
|
68
|
-
|
|
130
|
+
/** @ignore */
|
|
131
|
+
protected _loadCacheDrawTile(tile: XYZ, tilesCache: Map<string, WxRasterData>, requestInit?: WxRequestInit): Promise<WxRasterData | null>;
|
|
132
|
+
/** @ignore */
|
|
69
133
|
protected _createCurrentStyleObject(style_?: WxColorStyleWeak): [WxColorStyleStrict, RawCLUT];
|
|
134
|
+
/** @ignore creates/calculates meta data for vector layers */
|
|
70
135
|
protected _getCurrentMeta(): WxVariableMeta;
|
|
136
|
+
/** @ignore x, y - pixel on tile, data - data tile */
|
|
71
137
|
protected _getPixelInfo({ x, y }: {
|
|
72
138
|
x: number;
|
|
73
139
|
y: number;
|
|
@@ -75,6 +141,8 @@ export declare class WxLayer {
|
|
|
75
141
|
raw: number[];
|
|
76
142
|
data: number[];
|
|
77
143
|
} | undefined;
|
|
144
|
+
/** @ignore Create a new CLUT for the given style */
|
|
78
145
|
protected _prepareCLUT(style: WxColorStyleStrict): RawCLUT;
|
|
146
|
+
/** @ignore calculate valid timestep and URIs */
|
|
79
147
|
protected _createURLsAndTime(time_?: WxDate): [WxURIs, string];
|
|
80
148
|
}
|
|
@@ -2,40 +2,80 @@ import L from 'leaflet';
|
|
|
2
2
|
import { type XYZ } from '../utils/wxtools';
|
|
3
3
|
import { type WxRequestInit, type WxTileInfo, type WxLngLat, WxLayerOptions } from '../wxlayer/wxlayer';
|
|
4
4
|
import { type WxRasterData } from '../wxlayer/painter';
|
|
5
|
-
import {
|
|
5
|
+
import { WxLayerBaseImplementation, type WxLayerAPI } from '../wxlayer/WxImplementation';
|
|
6
6
|
import { FrameworkOptions } from './wxsourcetypes';
|
|
7
7
|
declare class WxTile {
|
|
8
8
|
coords: XYZ;
|
|
9
9
|
ctx: CanvasRenderingContext2D;
|
|
10
|
-
raster_data: WxRasterData;
|
|
11
|
-
constructor(coords: XYZ, ctx: CanvasRenderingContext2D, raster_data: WxRasterData);
|
|
12
|
-
draw(canvas
|
|
10
|
+
raster_data: WxRasterData | null;
|
|
11
|
+
constructor(coords: XYZ, ctx: CanvasRenderingContext2D, raster_data: WxRasterData | null);
|
|
12
|
+
draw(canvas?: HTMLCanvasElement | null): void;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @description WxTileSource is a custom source for mapbox-gl-js.
|
|
15
|
+
* A custom layer source implementation
|
|
17
16
|
* It is used to load and display weather data from the WxTiles server.
|
|
18
|
-
* @
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
const wxapi = new WxAPI({ 'http://dataserver.com' });
|
|
20
|
+
|
|
21
|
+
const datasetName = 'gfs.global';
|
|
22
|
+
const variable = 'air.temperature.at-2m'; // Scalar example
|
|
23
|
+
|
|
24
|
+
// Create a dataset manager (may be used for many layers from this dataset)
|
|
25
|
+
const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
|
|
26
|
+
|
|
27
|
+
// get proper representation of the variable
|
|
28
|
+
const variables = wxdatasetManager.checkCombineVariableIfVector(variable);
|
|
29
|
+
|
|
30
|
+
// create a layer source
|
|
31
|
+
const wxsource = new WxTileSource({ wxdatasetManager, variables }, { id: 'wxsource', attribution: 'WxTiles' });
|
|
32
|
+
* ```
|
|
24
33
|
*/
|
|
25
|
-
export declare class WxTileSource extends
|
|
26
|
-
constructor(wxlayeroptions: WxLayerOptions, options?: FrameworkOptions);
|
|
34
|
+
export declare class WxTileSource extends WxLayerBaseImplementation implements WxLayerAPI {
|
|
27
35
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {any} anymap - map instance.
|
|
32
|
-
* @returns {WxTileInfo | undefined } Information about the current point on map. Undefined if NODATA
|
|
36
|
+
*
|
|
37
|
+
* @param {WxLayerOptions} wxlayeroptions - The options for the {@link WxLayerBaseImplementation}.
|
|
38
|
+
* @param {FrameworkOptions} frameworkOptions - The options for the framework.
|
|
33
39
|
*/
|
|
40
|
+
constructor(wxlayeroptions: WxLayerOptions, frameworkOptions?: FrameworkOptions);
|
|
41
|
+
/**
|
|
42
|
+
* Get comprehensive information about the current point on map.
|
|
43
|
+
* @param {WxLngLat} lnglat - Coordinates of the point.
|
|
44
|
+
* @param map - map instance.
|
|
45
|
+
* @returns {WxTileInfo | undefined }
|
|
46
|
+
* */
|
|
34
47
|
getLayerInfoAtLatLon(lnglat: WxLngLat, anymap: any): WxTileInfo | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* @ignore
|
|
50
|
+
* Reloads the tiles that are currently visible on the map. Used for time/particles animation.
|
|
51
|
+
**/
|
|
35
52
|
_reloadVisible(requestInit?: WxRequestInit): Promise<void>;
|
|
36
|
-
|
|
53
|
+
/**
|
|
54
|
+
* @ignore
|
|
55
|
+
* Get the tiles that are currently visible on the map.
|
|
56
|
+
* <MBOX API> get assigned by map.addSource *
|
|
57
|
+
* */
|
|
37
58
|
coveringTiles(): XYZ[];
|
|
59
|
+
/**
|
|
60
|
+
* @ignore
|
|
61
|
+
* @description reload tiles that are currently visible on the map.
|
|
62
|
+
* <MBOX API> get assigned by map.addSource
|
|
63
|
+
*/
|
|
64
|
+
update(): void;
|
|
65
|
+
/** @ignore */
|
|
38
66
|
protected _ForEachWxTile<T>(func: (wxtile: WxTile) => T, name: string): T[];
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
* Used by framework. Creates a representation of a tile for the framework.
|
|
70
|
+
* @param tile - The tile coordinates to be loaded.
|
|
71
|
+
* @param requestInit - The request options.
|
|
72
|
+
* @returns {Promise<Picture>} - A picture of the tile.
|
|
73
|
+
*/
|
|
39
74
|
protected createTile(coords: L.Coords, done: L.DoneCallback): HTMLElement;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
* @description Used by framework. Cleans up resources used by the source.
|
|
78
|
+
*/
|
|
79
|
+
onRemove(): this;
|
|
40
80
|
}
|
|
41
81
|
export {};
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import L from 'leaflet';
|
|
2
|
+
/**
|
|
3
|
+
* Framework dependent source type to be inherited by the framework dependent custom source type.
|
|
4
|
+
* Mapbox does not provide a parent type for the custom source.
|
|
5
|
+
* Leaflet provides a parent type for the custom layer to inherit from L.GridLayer.
|
|
6
|
+
* Used as universal type for the custom source parent class. see {@link WxTileSource}
|
|
7
|
+
*/
|
|
2
8
|
export declare class FrameworkParentClass extends L.GridLayer {
|
|
3
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Framework's basic options to construct the layer.
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const leafletOptions: FrameworkOptions = { opacity: 1, attribution: 'WxTiles' };
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
4
17
|
export interface FrameworkOptions extends L.GridLayerOptions {
|
|
5
18
|
}
|
package/dist/web/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var wxtilesleaflet=(()=>{var Ue=Object.create;var U=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames,se=Object.getOwnPropertySymbols,Ze=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable;var ie=(a,e,t)=>e in a?U(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,O=(a,e)=>{for(var t in e||(e={}))le.call(e,t)&&ie(a,t,e[t]);if(se)for(var t of se(e))Ve.call(e,t)&&ie(a,t,e[t]);return a};var Xe=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),Ee=(a,e)=>{for(var t in e)U(a,t,{get:e[t],enumerable:!0})},ce=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Oe(e))!le.call(a,n)&&n!==t&&U(a,n,{get:()=>e[n],enumerable:!(r=Fe(e,n))||r.enumerable});return a};var Ne=(a,e,t)=>(t=a!=null?Ue(Ze(a)):{},ce(e||!a||!a.__esModule?U(t,"default",{value:a,enumerable:!0}):t,a)),Be=a=>ce(U({},"__esModule",{value:!0}),a);var h=(a,e,t)=>new Promise((r,n)=>{var o=c=>{try{i(t.next(c))}catch(l){n(l)}},s=c=>{try{i(t.throw(c))}catch(l){n(l)}},i=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);i((t=t.apply(a,e)).next())});var Ae=Xe((Jt,Re)=>{Re.exports=window.L});var ut={};Ee(ut,{WXLOG:()=>g,WxAPI:()=>$,WxCreateLegend:()=>re,WxDataSetManager:()=>k,WxGetColorSchemes:()=>V,WxGetColorStyles:()=>I,WxTileSource:()=>J,WxTilesLogging:()=>ye});var ue={comment1:["'degC': ['K', 1, 273.15] -> degC = K * 1 + 273.15",0],comment2:["'hPa': ['Pa', 1000]' -> hPa = Pa * 1000 + 0 (0 - could be ommited)",0],K:["K",1],kelvin:["K",1],F:["K",.5555555555,255.372222222],C:["K",1,273.15],degC:["K",1,273.15],"kg/m^2/s":["kg/m^2/s",1],"Kg/m^2/s":["kg/m^2/s",1],"Kg m**-2 s**-1":["kg/m^2/s",1],"Kg m^-2 s^-1":["kg/m^2/s",1],"Kg m^{-2} s^-1":["kg/m^2/s",1],"mm/h":["kg/m^2/s",.00027777777],"mm/hr":["kg/m^2/s",.00027777777],"W/m^2":["W/m^2",1],"W m^-2":["W/m^2",1],"W m^{-2}":["W/m^2",1],"W/m**2":["W/m^2",1],"W m**-2":["W/m^2",1],"m/s":["m/s",1],"m s**-1":["m/s",1],"m s^-1":["m/s",1],"m.s^{-1}":["m/s",1],knot:["m/s",.514444],knots:["m/s",.514444],"km/h":["m/s",.27777777777],"km h^-1":["m/s",.27777777777],"km h**-1":["m/s",.27777777777],mph:["m/s",.44704],"miles/h":["m/s",.44704],s:["s",1],sec:["s",1],h:["s",3600],min:["s",60],m:["m",1],cm:["m",.01],km:["m",1e3],mile:["m",1609.344],miles:["m",1609.344],inch:["m",.0254],Pa:["Pa",1],hPa:["Pa",100],degree:["degree",1],radian:["degree",57.3],"mg/m^3":["mg/m^3",1],"mg m^-3":["mg/m^3",1],"mg.m^-3":["mg/m^3",1],"%":["%",1],"(0 - 1)":["%",100]};var me={none:["#00000000","#00000000"],divergingbluered:["#2166acff","#92c5deff","#f7f7f7ff","#f4a582ff","#b2182bff"],rainbow:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbowzerro:["#ff000000","#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbow2:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff","#ff0000ff"],bluebird:["#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bluebirdzerro:["#0000ff00","#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bw:["#000000ff","#ffffffff"],wb:["#ffffffff","#000000ff"],redish:["#ff00ffff","#ff0000ff","#ffff00ff"],greenish:["#ffff00ff","#00ff00ff","#00ffffff"],blueish:["#ff00ffff","#0000ffff","#00ffffff"],hspastel:["#AC6EA4FF","#8E92BDFF","#ACD4DEFF","#E9DC8EFF","#E7A97DFF","#E59074FF","#BE7E68FF","#A88F86FF"]};var Z={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"},custom:{parent:void 0,name:"custom",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"}};var de,fe,xe;function ge({colorStyles:a={},units:e={},colorSchemes:t={}}={}){g("WxTile lib setup: start"),de=Object.assign({},ue,e),fe=Object.assign({},t,me);let r=Object.assign({},a,Z);xe=$e(r),g("WxTile lib setup: styles unrolled");try{h(this,null,function*(){yield document.fonts.load("32px barbs"),yield document.fonts.load("32px arrows")})}catch(n){g("WxTile lib setup: fonts not loaded")}g("WxTile lib setup is done.")}function I(){return xe}function V(){return fe}function X(a,e,t){g("makeConverter: From=",a," To=",e);let r=m=>m;if(r.trivial=!0,a===e)return g("Trivial converter"),r;let n=Object.assign({},de,t),o=n[a],s=n[e];if(!o||!s)return g("Inconvertible units. Trivial converter"),r;let[i,c,l]=o,[u,d,f]=s;if(i!==u||!c||!d)return g("Inconvertible units. Trivial converter"),r;let b=c/d,x=((l||0)-(f||0))/d;return x?m=>b*m+x:m=>b*m}function $e(a){let e=Object.assign({},Z);for(let o in a){let s=a[o];if(Array.isArray(s))for(let i=0;i<s.length;++i)e[o+"["+i+"]"]=Object.assign({},s[i]);else e[o]=Object.assign({},s)}let t=Object.assign({},Z.base),r=(o,s)=>{if(s==="base")return t;let i=o[s];if(!i)return t;(!i.parent||!(i.parent in o))&&(i.parent="base");let c=r(o,i.parent);return Object.assign(i,Object.assign({},c,i,{parent:"base"}))},n={base:t};for(let o in e)n[o]=r(e,o);return n}function F(a){let e=new Map;return(t,...r)=>{let n=e.get(t);if(n)return n;let o=a(t,...r);return e.set(t,o),o.catch(s=>{s.name==="AbortError"&&e.delete(t)}),o}}function qe(a,e){return h(this,null,function*(){return createImageBitmap(yield(yield fetch(a,e)).blob())})}function P(a,e,t=!0){let r=Object.assign(document.createElement("canvas"),{width:a,height:e,imageSmoothingEnabled:!1}).getContext("2d",{willReadFrequently:t});if(!r)throw new Error("Cannot get canvas context");return r}function Ye(a){let{width:e,height:t}=a,r=P(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}function Q(a,e){return h(this,null,function*(){return Ye(yield qe(a,e))})}function je(a){a.data[34]<1&&g("Warning: image is in too old format. Check the version of the Splitter.");let e=new Uint16Array(a.data.buffer),t=new Uint16Array(e.length/2);for(let l=0;l<t.length;l++)t[l]=e[l*2];let r=new Uint8Array(8);for(let l=0;l<8;++l)r[l]=a.data[l*4+2];let n=new DataView(r.buffer),o=n.getFloat32(0,!0),s=n.getFloat32(4,!0),i=(s-o)/65535,c=Ge(t);return{raw:t,dmin:o,dmax:s,dmul:i,integral:c,radius:0}}function ee(a,e){return h(this,null,function*(){return je(yield Q(a,e))})}function Ge(a){let e=new Uint32Array(66564),t=new Uint32Array(258*258);e[0]=a[0],t[0]=a[0]===0?0:1;for(let r=1;r<258;++r)e[r]=a[r]+e[r-1],e[258*r]=a[258*r]+e[258*r-258],t[r]=(a[r]===0?0:1)+t[r-1],t[258*r]=(a[258*r]===0?0:1)+t[258*r-258];for(let r=1,n=259;r<258;++r,++n)for(let o=1;o<258;++o,++n)e[n]=a[n]+e[n-258]+e[n-1]-e[n-258-1],t[n]=(a[n]===0?0:1)+t[n-258]+t[n-1]-t[n-258-1];return{integral:e,integralNZ:t}}function he(a,e){if(e<0||e===a.radius)return a;a.radius=e;let t=258,{integral:r,integralNZ:n}=a.integral;for(let o=1;o<t;o++)for(let s=1;s<t;s++){if(!a.raw[t*o+s])continue;let i=Math.min(e,s-1,t-1-s),c=Math.min(e,o-1,t-1-o),l=t*(o-c-1)+s,u=t*(o+c)+s,d;if(n){let y=n[l-i-1],W=n[l+i],w=n[u-i-1],C=n[u+i];d=y+C-W-w}else d=(2*i+1)*(2*c+1);let f=r[l-i-1],b=r[l+i],x=r[u-i-1],m=r[u+i],p=f+m-b-x;a.raw[o*t+s]=p/d}return a}function T(a){let e=a>>0&255,t=a>>8&255,r=a>>16&255,n=e.toString(16),o=t.toString(16),s=r.toString(16);return n=n.length===2?n:"0"+n,o=o.length===2?o:"0"+o,s=s.length===2?s:"0"+s,"#"+n+o+s}function M(a){if(a[0]==="#"){if(a.length===4)return+("0xff"+a[3]+a[3]+a[2]+a[2]+a[1]+a[1]);if(a.length===7)return+("0xff"+a[5]+a[6]+a[3]+a[4]+a[1]+a[2]);if(a.length===9)return+("0x"+a[7]+a[8]+a[5]+a[6]+a[3]+a[4]+a[1]+a[2])}return g("wrong color format",a),0}function L(a,e){return h(this,null,function*(){let t=yield fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()})}function te(a,e,t){let r=a>>0&255,n=a>>8&255,o=a>>16&255,s=a>>>24,i=e>>0&255,c=e>>8&255,l=e>>16&255,u=e>>>24,d=r+t*(i-r),f=n+t*(c-n),b=o+t*(l-o),x=s+t*(u-s);return d|f<<8|b<<16|x<<24}function pe(a,e,t){let r=[];for(let n=0;n<t;++n)r.push(n*(e-a)/(t-1)+a);return r}var be=!1;function ye(a){console.log(a?"Logging on":"Logging off"),be=a}function g(...a){be&&console.log(...a)}function We(a){return a[0]==="#"&&a.length===4?"#"+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]:a}function E(a,{x:e,y:t,z:r}){return a.replace("{x}",`${e}`).replace("{y}",`${t}`).replace("{z}",`${r}`)}function N({x:a,y:e,z:t}){return`${t}-${a}-${e}`}var He="A".charCodeAt(0);var B=class{constructor(){this.qtree={nodes:null};this.qtreedepth=0}load(e,t){return h(this,null,function*(){try{let r=yield L(e,t);this.qtree=we(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this.qtreedepth=Se(this.qtree)})}check(e){let t=e.z-this.qtreedepth,r=t>=0,n=r?{x:e.x>>t,y:e.y>>t,z:this.qtreedepth}:O({},e);return De(this.qtree,n,r)}};function we(a,e){let t=a.charCodeAt(e.pos)-He;e.pos++;let r=[1,2,4,8].map(n=>t&n?we(a,e):null);return{nodes:r.some(n=>n)?r:null}}function Se(a){return a!=null&&a.nodes?1+Math.max(...a.nodes.map(Se)):0}function De(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,De(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}var k=class{constructor({datasetName:e,instance:t,instanced:r,meta:n,wxapi:o}){if(!o.datasetsMetas.allDatasetsList.includes(e))throw new Error(`Dataset ${e} not found`);this.datasetName=e,this.instanced=r,this.instance=t,this.meta=n,this.wxapi=o}getValidTime(e=Date()){let t=this.getTimes();if(typeof e=="number"){if(e<=0)return t[0];if(e<t.length)return t[e]}let r=new Date(e).getTime(),n=t.find(o=>new Date(o).getTime()>=r);if(isNaN(r)||!n){let o=t.indexOf(e);return o===-1?t[t.length-1]:t[o]}return n}getTimes(){return this.instanced||this.meta.times}getVariables(){return this.meta.variables}getVariableMeta(e){return this.meta.variablesMeta[e]}getMaxZoom(){return this.meta.maxZoom}getBoundaries180(){var r;let e=(r=this.meta.boundaries)==null?void 0:r.boundaries180;if((e==null?void 0:e.length)!==1)return;let t=e[0];return[t.west,t.south,t.east,t.north]}getBoundaries(){return this.meta.boundaries}createURI(e,t,r="png"){if(!this.checkVariableValid(e))throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);let n=this.getValidTime(t),o=this.instanced?n:this.instance;return`${this.wxapi.dataServerURL+this.datasetName}/${o}/${e}/${n}/{z}/{x}/{y}.${r}`}checkVariableValid(e){return this.getVariableMeta(e)!==void 0}checkCombineVariableIfVector(e){let t=this.getVariableMeta(e);if(!t)throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);return t.vector||[e]}checkDatasetOutdated(){return h(this,null,function*(){return yield this.wxapi.initDone,(yield this.getDatasetInstance())===this.instance})}getDatasetInstance(){return h(this,null,function*(){let e=yield this.getDatasetInstances();return e[e.length-1]})}getDatasetInstances(){return h(this,null,function*(){try{let e=yield L(this.wxapi.dataServerURL+this.datasetName+"/instances.json",this.wxapi.requestInit);if(e.length===0)throw new Error(`No instances found for dataset ${this.datasetName}`);return e}catch(e){throw new Error(`getting dataset instances failure message: ${e.message} datasetName: ${this.datasetName}`)}})}};var $=class{constructor({dataServerURL:e,maskURL:t="auto",qtreeURL:r="auto",requestInit:n,colorStyles:o,units:s,colorSchemes:i}){this.datasetsMetas={allDatasetsList:[]};this.qtree=new B;this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));if(ge({colorStyles:o,units:s,colorSchemes:i}),this.dataServerURL=e,this.requestInit=n,r=r==="auto"?e+"seamask.qtree":r,t!=="none"){let c=F(Q);this.maskURL=t=t==="auto"?e+"mask/":t,this.loadMaskFunc=l=>c(E(t,l),n)}this.initDone=Promise.all([L(e+"datasetsmeta.json",n),r!=="none"?this.qtree.load(r,n):Promise.resolve()]).then(([c,l])=>{c.allDatasetsList||(c.allDatasetsList=Object.keys(c)),this.datasetsMetas=c})}getDatasetShortMeta(e){if(e!=="allDatasetsList")return this.datasetsMetas[e]}getDatasetInatance(e){var t;return(t=this.getDatasetShortMeta(e))==null?void 0:t.instance}getDatasetVariables(e){return h(this,null,function*(){var t;return yield this.initDone,(t=this.datasetsMetas[e])==null?void 0:t.variables})}createDatasetManager(e){return h(this,null,function*(){yield this.initDone;let t=this.getDatasetShortMeta(e),r=t==null?void 0:t.instance;if(!r)throw new Error("Dataset/instance not found:"+e);let n=t.instanced,o=yield L(this.dataServerURL+e+"/"+r+"/meta.json",this.requestInit);return new k({datasetName:e,instanced:n,instance:r,meta:o,wxapi:this})})}createAllDatasetsManagers(){return h(this,null,function*(){return yield this.initDone,Promise.allSettled(this.datasetsMetas.allDatasetsList.map(t=>this.createDatasetManager(t)))})}filterDatasetsByVariableName(e){return h(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList.filter(t=>{var r,n,o;return(o=(n=(r=this.datasetsMetas[t])==null?void 0:r.variables)==null?void 0:n.includes)==null?void 0:o.call(n,e)})})}getAllDatasetsNames(){return h(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList})}};function ze(a,e,t){return a>t?t:a<e?e:a}var q=class{constructor(e,t,[r,n],o){let s=n-r;this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let i=[];this.DataToStyle=X(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),o&&(this.DataToKnots=X(t,"knot"));let c=X(e.units,t,e.extraUnits),l=m=>~~(65535*ze((c(m)-r)/(n-r),0,1));if(Array.isArray(e.colorMap)){e.colorMap.sort((m,p)=>m[0]<p[0]?-1:m[0]>p[0]?1:0);for(let[m]of e.colorMap)i.push(l(m))}else{if(e.levels||(e.levels=pe(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((m,p)=>m<p?-1:m>p?1:0),!e.colors){let m=V();e.colorScheme&&e.colorScheme in m?e.colors=m[e.colorScheme]:e.colors=m.wb}for(let m of e.levels)i.push(l(m))}let u=65536,d=re(u,e);this.ticks=d.ticks;let f=d.ticks[0].data,x=d.ticks[d.ticks.length-1].data-f;for(let m=0;m<65536;++m){let p=s*m/65535+r,y=this.DataToStyle(p),W=Math.round((u-1)*(y-f)/x);W<=0?this.colorsI[m]=e.showBelowMin?d.colors[0]:0:W>=u?this.colorsI[m]=e.showAboveMax?d.colors[u-1]:0:this.colorsI[m]=d.colors[W]}this.colorsI[0]=0;for(let m=0;m<i[0];++m)this.levelIndex[m]=0;for(let m=0;m<i.length-1;m++)for(let p=i[m];p<i[m+1]+1;++p)this.levelIndex[p]=m;for(let m=i[i.length-1];m<65536;++m)this.levelIndex[m]=i.length-1}};function Te(a){var t;if(a!==0&&-.1<a&&a<.1)return a.toExponential(2);let e=a.toString();return((t=e.split(".")[1])==null?void 0:t.length)>2?a.toFixed(2):e}function re(a,e){let t={size:a,showBelowMin:e.showBelowMin,showAboveMax:e.showAboveMax,units:e.units,colors:new Uint32Array(a),ticks:[]},{colorMap:r,levels:n,colors:o}=e,s=e.fill!=="solid";if(r){let f=r[0][0],b=r[r.length-1][0]-f;for(let[x,m]of r){let p=~~((x-f)/b*(a-1)),y={data:x,dataString:Te(x),color:m,pos:p};t.ticks.push(y)}for(let x=0;x<r.length-1;x++){let m=t.ticks[x].pos,p=t.ticks[x+1].pos,y=M(r[x][1]),W=s?M(r[x+1][1]):0;for(let w=m;w<p;++w)t.colors[w]=s?te(y,W,(w-m)/(p-m)):y}return t.colors[a-1]=M(r[r.length-1][1]),t}if(!o||!n)return t;let i=0,c=0,l=-1;for(let f=0;f<a;++f){let b=f*(o.length-1)/a;l!==~~b&&(l=~~b,i=M(o[l]),c=o.length>l+1?M(o[l+1]):i),t.colors[f]=s?te(i,c,b-l):i}t.colors[a-1]=M(o[o.length-1]);let u=n[0],d=(a-1)/(n[n.length-1]-u);for(let f of n){let b=~~((f-u)*d),x={data:f,dataString:Te(f),color:T(t.colors[b]),pos:b};t.ticks.push(x)}return t}var Ke=2*Math.PI*6378137/256,Y=2*Math.PI*6378137/2;function Je(a,e){let t=a/Y*180,r=e/Y*180;return r=180/Math.PI*(2*Math.atan(Math.exp(r*Math.PI/180))-Math.PI/2),[r,t]}function Qe(a,e,t){let r=et(t),n=a*r-Y,o=e*r-Y;return[n,o]}function et(a){return Ke/Math.pow(2,a)}function ae(a,e,t){let[r,n]=Je(...Qe(a,e,t));return[n,-r]}function Ce(a,e){return[a*256,e*256]}function ne(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function tt(a,e,t,r,n,o,s,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 0:return 0;case 1:return a;case 2:return e;case 3:t=a,r=e;break;case 4:return t;case 5:e=a,r=t;break;case 6:r=e+t>>1,a=r;break;case 7:r=e+t>>1;break;case 8:return r;case 9:e=a+r>>1,t=e;break;case 10:a=e,t=r;break;case 11:t=a+r>>1;break;case 12:a=t,e=r;break;case 13:e=a+r>>1;break;case 14:a=e+t>>1;break}a=s+i*a,e=s+i*e,t=s+i*t,r=s+i*r;let l=ne(a,e,n),u=ne(t,r,n);return(ne(l,u,o)-s)/i||1}function rt(a,e,t,r,n,o,s,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 7:return n+o<1?n*(e-a)+o*(t-a)+a:0;case 14:return n+o<1?0:n*(r-t)+o*(r-e)+e+t-r;case 11:return o<n?(1-n)*(a-e)+o*(r-e)+e:0;case 13:return o<n?0:(1-n)*(t-r)+o*(t-a)+a+r-t;case 15:return n+o<1?n*(e-a)+o*(t-a)+a:n*(r-t)+o*(r-e)+e+t-r;default:return 0}}function Me(a,e,t){if(!t)return e;let r=.9999999/Math.pow(2,t.z),n=t.x*256*r,o=t.y*256*r,{raw:s,dmin:i,dmax:c,dmul:l}=e,u={raw:new Uint16Array(258*258),dmin:i,dmax:c,dmul:l},{raw:d}=u;for(let f=-1,b=0;f<=256;f++){let x=o+f*r,m=Math.floor(x),p=x-m;for(let y=-1;y<=256;y++,b++){let W=n+y*r,w=Math.floor(W),C=W-w,S=w+1+(m+1)*258,D=s[S],v=s[S+1],R=s[S+258],A=s[S+258+1];d[b]=a(D,v,R,A,C,p,i,l)}}return u}function ve(a,e){return Me(rt,a,e)}function Le(a,e){return Me(tt,a,e)}function Ie(a,e,t){let r=t==="sea";for(let n=3,o=0;o<256;o++)for(let s=0,i=(o+1)*258+1;s<256;s++,i++,n+=4)r===!e.data[n]&&(a.raw[i]=0);return a}function Pe(a){let[e,t]=Ce(a.x,a.y),[r,n]=ae(e,t,a.z),[o,s]=ae(e+256,t+256,a.z);return{west:r,north:n,east:o,south:s}}function ke(a,e){let t=a.z-e;if(t<=0)return{upCoords:a};let r={x:a.x>>>t,y:a.y>>>t,z:e},n={x:a.x&(1<<t)-1,y:a.y&(1<<t)-1,z:t};return{upCoords:r,subCoords:n}}var j=class{constructor(e){this.loadDataFunc=F(ee);this.layer=e}load(e,t){return h(this,null,function*(){let r=yield this.cacheLoad(e,this.layer.tilesURIs,t);if(!r)return null;let{rawdata:n,subCoords:o,tileType:s}=r,{units:i}=this.layer.currentMeta,c=i==="degree"?Le:ve,l=d=>c(he(d,this.layer.style.blurRadius),o),u=n.map(l);return this._vectorMagnitudesPrepare(u),yield this._applyMask(u,e,s,!o&&n.length===1),{data:u,slines:this._createStreamLines(u)}})}cacheLoad(e,t,r){return h(this,null,function*(){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:o,subCoords:s}=ke(e,this.layer.wxdatasetManager.getMaxZoom()),i=t.map(u=>E(u,o)),c=Object.assign({},this.layer.wxdatasetManager.wxapi.requestInit,{signal:r==null?void 0:r.signal});return{rawdata:yield Promise.all(i.map(u=>this.loadDataFunc(u,c))),subCoords:s,tileType:n}})}clearCache(){this.loadDataFunc=F(ee)}_applyMask(e,t,r,n){return h(this,null,function*(){let{style:o}=this.layer;if((o.mask==="land"||o.mask==="sea")&&r==="mixed"){if(n){let{raw:i,dmin:c,dmax:l,dmul:u}=e[0];e[0]={raw:new Uint16Array(i),dmin:c,dmax:l,dmul:u}}let s;try{s=yield this.layer.wxdatasetManager.wxapi.loadMaskFunc(t)}catch(i){o.mask=void 0,g("Can't load Mask. Masking is Turned OFF");return}Ie(e[0],s,o.mask)}})}_vectorMagnitudesPrepare(e){if(e.length===1)return;e.unshift({raw:new Uint16Array(258*258),dmin:0,dmax:0,dmul:0});let[t,r,n]=e;t.dmax=1.42*Math.max(-r.dmin,r.dmax,-n.dmin,n.dmax),t.dmul=(t.dmax-t.dmin)/65535;for(let o=0;o<258*258;++o){if(!r.raw[o]||!n.raw[o])continue;let s=r.dmin+r.dmul*r.raw[o],i=n.dmin+n.dmul*n.raw[o];t.raw[o]=Math.sqrt(i*i+s*s)/t.dmul}}_checkTypeAndMask(e){let{mask:t}=this.layer.style;var r="mixed";if(!((t==="land"||t==="sea")&&(r=this.layer.wxdatasetManager.wxapi.qtree.check(e),t===r)))return r}_checkInsideBoundaries(e){let t=this.layer.wxdatasetManager.getBoundaries();if(t!=null&&t.boundaries180){let r=Pe(e),n=o=>!(r.west>o.east||o.west>r.east||r.south>o.north||o.south>r.north);if(!t.boundaries180.some(n))return!1}return!0}_createStreamLines(e){if(e.length!==3)return[];let{style:t}=this.layer;if(t.streamLineColor==="none")return[];let r=[],[n,o,s]=e,i=(t.streamLineSpeedFactor||1)/n.dmax,c=t.addDegrees?.017453292519943*t.addDegrees:0,l=t.streamLineGridStep||64,u=t.streamLineSteps||300;for(let d=0;d<=256;d+=l)for(let f=0;f<=256;f+=l){if(!n.raw[1+f+(1+d)*258])continue;let b=[],x=f,m=d,p=-1,y=0,W=0;for(let S=0;S<=u&&x>=0&&x<=256&&m>=0&&m<=256;S++){S%(u/10)||b.push({x:~~x,y:~~m});let D=~~x+1+(~~m+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,R=o.dmin+o.raw[D]*o.dmul,A=s.dmin+s.raw[D]*s.dmul,_=Math.atan2(R,A)+c;y=i*v*Math.sin(_),W=i*v*Math.cos(_)}x+=y,m-=W}let w=f,C=d;p=-1;for(let S=1;S<=u&&w>=0&&w<=256&&C>=0&&C<=256;S++){S%(u/10)||b.unshift({x:~~w,y:~~C});let D=~~w+1+(~~C+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,R=o.dmin+o.raw[D]*o.dmul,A=s.dmin+s.raw[D]*s.dmul,_=Math.atan2(R,A)+c;y=i*v*Math.sin(_),W=i*v*Math.cos(_)}w-=y,C+=W}b.length>2&&r.push(b)}return r}};var G=class{constructor(e){this.layer=e}paint({data:e,ctxFill:t,ctxText:r,ctxStreamLines:n}){let{layer:o}=this,{units:s}=o.currentMeta,i=new ImageData(256,256),c=new Uint32Array(i.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),at(e.data[0],c,o);let l=nt(c,e.data[0],o);t.putImageData(i,0,0),ot(l,r,o),st(e.data,r,o),it(e.data[0],r,s,o),lt(e,r,o)}imprintVectorAnimationLinesStep({data:e,ctxFill:t,ctxStreamLines:r},n){let{layer:o}=this;r.clearRect(0,0,256,256),r.drawImage(t.canvas,0,0),!(e.slines.length===0||o.style.streamLineStatic||o.style.streamLineColor==="none")&&ct(e,r,o,n)}};function at(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:o}=t;if(r.fill!=="none")for(let s=0,i=0,c=259;s<256;++s,c+=2)for(let l=0;l<256;++l,++i,++c)e[i]=o[n[c]];else e.fill(0)}function nt(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:o,colorsI:s}=t,i=[];if(r.isolineColor!=="none"){let c=r.isolineColor[0]==="#"?M(r.isolineColor):0;for(let l=0,u=0;l<256;l+=1)for(let d=0;d<256;d+=1){let f=(l+1)*258+(d+1),b=n[f],x=n[f+1],m=n[f+258];if(!b||!x||!m)continue;let p=o[b],y=o[x],W=o[m];if(p!==y||p!==W){let w=Math.max(p,y,W),C=Math.max(b,x,m),S=l*256+d;switch(r.isolineColor){case"inverted":a[S]=~s[C]|4278190080;break;case"fill":a[S]=s[C]|4278190080;break;default:a[S]=c;break}r.isolineText&&!(++u%255)&&d>20&&d<235&&l>20&&l<235&&i.push({x:d,y:l,d:b,dr:x,db:m,mli:w})}}}return i}function ot(a,e,{CLUT:t}){if(a.length){e.font="1.1em Sans-serif",e.lineWidth=2,e.strokeStyle="white",e.fillStyle="black",e.textAlign="center",e.textBaseline="middle";for(let{x:r,y:n,d:o,dr:s,db:i,mli:c}of a){let l=t.ticks[c].dataString,u=Math.atan2(o-s,i-o);e.save(),e.translate(r,n),e.rotate(u<-1.57||u>1.57?u+3.14:u),e.strokeText(l,0,0),e.fillText(l,0,0),e.restore()}}}function st(a,e,{CLUT:t,style:r}){if(!t.DataToKnots||r.vectorColor==="none"||r.vectorType==="none")return;if(a.length!==3)throw new Error("data.length !== 3");let[n,o,s]=a;switch(r.vectorType){case"barbs":e.font="40px barbs";break;case"arrows":e.font="50px arrows";break;default:e.font=r.vectorType}e.textAlign="center",e.textBaseline="middle",e.fillStyle=r.vectorColor;let i=r.addDegrees?.017453292519943*r.addDegrees:0,c=32;for(let l=c/2;l<256;l+=c)for(let u=c/2;u<256;u+=c){let d=u+1+(l+1)*258;if(!n.raw[d])continue;let f=Math.atan2(o.dmin+o.raw[d]*o.dmul,s.dmin+s.raw[d]*s.dmul),b=n.dmin+n.raw[d]*n.dmul,x=r.vectorType!=="barbs"?r.vectorFactor*.2:.2,m=Math.min(t.DataToKnots(b)*x,25)+65,p=String.fromCharCode(m);switch(r.vectorColor){case"inverted":e.fillStyle=T(~t.colorsI[n.raw[d]]);break;case"fill":e.fillStyle=T(t.colorsI[n.raw[d]]);break}e.save(),e.translate(u,l),e.rotate(f+i),e.fillText(p,0,0),e.restore()}}function it(a,e,t,{CLUT:r,style:n}){if(t!=="degree")return;let o=.017453292519943*n.addDegrees;e.font="50px arrows",e.textAlign="center",e.textBaseline="middle",e.fillStyle=n.vectorColor;let s="L",i=32;for(let c=i/2;c<256;c+=i)for(let l=i/2;l<256;l+=i){let u=l+1+(c+1)*258;if(!a.raw[u])continue;let f=(a.dmin+a.raw[u]*a.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=T(~r.colorsI[a.raw[u]]);break;case"fill":e.fillStyle=T(r.colorsI[a.raw[u]]);break}e.save(),e.translate(l,c),e.rotate(f+o),e.fillText(s,0,0),e.restore()}}function lt(a,e,{CLUT:t,style:r}){let{data:n,slines:o}=a;if(!o.length||!r.streamLineStatic||r.streamLineColor==="none")return;let s=n[0];e.lineWidth=1,e.strokeStyle=r.streamLineColor;for(let i=o.length;i--;){let c=o[i];for(let l=0;l<c.length-1;++l){let u=c[l],d=c[l+1],f=u.x+1+(u.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=T(~t.colorsI[s.raw[f]]);break;case"fill":e.strokeStyle=T(t.colorsI[s.raw[f]]);break}e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(d.x,d.y),e.stroke()}}}function ct(a,e,{CLUT:t,style:r},n){let{data:o,slines:s}=a,i=o[0],c=r.streamLineColor.substring(0,7);n=n>>5;for(let l=0;l<s.length;++l){let u=s[l],d=u.length-1,f=(n+(1+u[0].x)*(1+u[0].y))%30;for(let b=0;b<d;++b){let x=u[b],m=u[b+1],p=1-(f-b)/d;(p<0||p>1)&&(p=0);let y=(~~(p*255)).toString(16).padStart(2,"0"),W=1+~~((1.2-p)*5);e.lineWidth=W;let w=x.x+1+(x.y+1)*258;switch(r.streamLineColor){case"inverted":c=T(~t.colorsI[i.raw[w]]);break;case"fill":c=T(t.colorsI[i.raw[w]]);break}e.strokeStyle=c+y,e.beginPath(),e.moveTo(x.x,x.y),e.lineTo(m.x,m.y),e.stroke()}}}var H=class{constructor({time:e,variables:t,wxdatasetManager:r,ext:n="png",wxstyleName:o="base"}){this.tilesCache=new Map;this.painter=new G(this);this.loader=new j(this);if(!(t!=null&&t.length)||t.length>2)throw new Error(`WxTileSource ${r.datasetName}: only 1 or 2 variables are supported but ${t.length} were given`);t.forEach(s=>{if(!r.checkVariableValid(s))throw new Error(`WxTileSource ${r.datasetName}: variable ${s} is not valid`)}),this.variables=t,this.wxdatasetManager=r,this.ext=n,this.currentMeta=this._getCurrentMeta(),[this.tilesURIs,this.time]=this._createURLsAndTime(e),[this.style,this.CLUT]=this._createCurrentStyleObject(I()[o]),g(`WxTileSource created ${r.datasetName}, ${t.join(", ")}, ${o}`)}get nonanimatable(){return this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getTime(){return this.time}clearCache(){this.tilesCache.clear(),this.loader.clearCache()}getCurrentStyleObjectCopy(){return Object.assign({},this.style)}updateCurrentStyleObject(e){[this.style,this.CLUT]=this._createCurrentStyleObject(e)}getTileData(e,t){let r=this.tilesCache.get(N(e));if(!r)return;let n=this._getPixelInfo(t,r.data.data);if(!n)return;let{raw:o,data:s}=n,i=o.map(u=>this.CLUT.colorsI[u]),c=i.map(T),l=s.map(u=>this.CLUT.DataToStyle(u));return{data:s,raw:o,rgba:i,hexColor:c,inStyleUnits:l,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentMeta.units}}setURLsAndTime(e){[this.tilesURIs,this.time]=this._createURLsAndTime(e)}loadTile(e,t){return h(this,null,function*(){return this._loadCacheDrawTile(e,this.tilesCache,t)})}preloadTime(e,t,r){return h(this,null,function*(){let[n]=this._createURLsAndTime(e);yield Promise.allSettled(t.map(o=>this.loader.cacheLoad(o,n,r)))})}reloadTiles(e,t){return h(this,null,function*(){var n;let r=new Map;yield Promise.allSettled(e.map(o=>this._loadCacheDrawTile(o,r,t))),(n=t==null?void 0:t.signal)!=null&&n.aborted||(this.tilesCache=r)})}_loadCacheDrawTile(e,t,r){return h(this,null,function*(){let n=t.get(N(e));if(n)return n;let o=null;try{o=yield this.loader.load(e,r)}catch(u){throw{status:404}}if(!o)throw{status:404};let s=P(256,256),i=s,c=this.variables.length===2?P(256,256):s,l={ctxFill:s,ctxText:i,ctxStreamLines:c,data:o};return this.painter.paint(l),t.set(N(e),l),l})}_createCurrentStyleObject(e){let t=Object.assign(this.getCurrentStyleObjectCopy(),e);t.streamLineColor=We(t.streamLineColor);let r=this._prepareCLUT(t);return[t,r]}_getCurrentMeta(){let e=this.variables.map(s=>{let i=this.wxdatasetManager.getVariableMeta(s);if(!i)throw new Error(`WxTileSource ${this.wxdatasetManager.datasetName}: variable ${s} is not valid`);return i}),{min:t,max:r,units:n,vector:o}=e[0];return this.variables.length>1&&(t=0,r=1.42*Math.max(-e[0].min,e[0].max,-e[1].min,e[1].max)),{min:t,max:r,units:n,vector:o}}_getPixelInfo({x:e,y:t},r){var o,s;let n=(t+1)*258+(e+1);if(!!((s=(o=r==null?void 0:r[0])==null?void 0:o.raw)!=null&&s[n]))return{raw:r.map(i=>i.raw[n]),data:r.map(i=>i.raw[n]*i.dmul+i.dmin)}}_prepareCLUT(e){let{min:t,max:r,units:n}=this.currentMeta;return new q(e,n,[t,r],this.variables.length===2)}_createURLsAndTime(e){let t=this.wxdatasetManager.getValidTime(e);return[this.variables.map(n=>this.wxdatasetManager.createURI(n,t,this.ext)),t]}};var _e=Ne(Ae()),z=class extends _e.default.GridLayer{};var K=class extends z{constructor(t,r){super(r);this.animation=!1;this.animationSeed=0;this.layer=new H(t)}get wxdatasetManager(){return this.layer.wxdatasetManager}getMetadata(){return g(`WxTileSource getMetadata (${this.layer.wxdatasetManager.datasetName})`),O({},this.layer.currentMeta)}getVariables(){return g(`WxTileSource getVariables (${this.layer.wxdatasetManager.datasetName})`),[...this.layer.variables]}clearCache(){g(`WxTileSource clearCache (${this.layer.wxdatasetManager.datasetName})`),this.layer.clearCache()}getCurrentStyleObjectCopy(){return g(`WxTileSource getCurrentStyleObjectCopy (${this.layer.wxdatasetManager.datasetName})`),this.layer.getCurrentStyleObjectCopy()}getTime(){return g(`WxTileSource getTime (${this.layer.wxdatasetManager.datasetName})`),this.layer.getTime()}setTime(t,r){return h(this,null,function*(){var o;g(`WxTileSource setTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t});let n=this.getTime();return this.layer.setURLsAndTime(t),yield this._reloadVisible(r),(o=r==null?void 0:r.signal)!=null&&o.aborted&&this.layer.setURLsAndTime(n),this.getTime()})}preloadTime(t,r){return h(this,null,function*(){return g(`WxTileSource preloadTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t}),this.layer.preloadTime(t,this.coveringTiles(),r)})}startAnimation(){if(this.animation){g(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) already started`);return}if(this.layer.nonanimatable){g(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) nonanimatable`);return}g(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!0;let t=r=>h(this,null,function*(){if(g(`WxTileSource animationStep (${this.layer.wxdatasetManager.datasetName})`),!this.animation||this.layer.nonanimatable){this.animation=!1;return}this.animationSeed=r,yield this._redrawTiles(),requestAnimationFrame(t)});requestAnimationFrame(t)}stopAnimation(){return h(this,null,function*(){return g(`WxTileSource stopAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this._redrawTiles()})}setCoarseLevel(t=2){return h(this,null,function*(){return g(`WxTileSource setCoarseLevel (${this.layer.wxdatasetManager.datasetName})`,{level:t}),this.oldMaxZoom=this.layer.wxdatasetManager.getMaxZoom(),this.layer.wxdatasetManager.meta.maxZoom=Math.max(this.oldMaxZoom-t,1),this._reloadVisible()})}unsetCoarseLevel(){return h(this,null,function*(){if(g(`WxTileSource unsetCoarseLevel (${this.layer.wxdatasetManager.datasetName})`),this.oldMaxZoom)return this.layer.wxdatasetManager.meta.maxZoom=this.oldMaxZoom,this._reloadVisible()})}setStyleByName(t,r=!0){return h(this,null,function*(){return g(`WxTileSource setStyleByName (${this.layer.wxdatasetManager.datasetName})`),this.updateCurrentStyleObject(I()[t],r)})}updateCurrentStyleObject(t,r=!0,n){return h(this,null,function*(){if(g(`WxTileSource updateCurrentStyleObject (${this.layer.wxdatasetManager.datasetName})`,{style:t}),this.layer.updateCurrentStyleObject(t),this.startAnimation(),r)return this._reloadVisible(n)})}_redrawTiles(){return this.redrawRequested?this.redrawRequested:(this.redrawRequested=new Promise(t=>{requestAnimationFrame(()=>{g(`WxTileSource _redrawTiles (${this.layer.wxdatasetManager.datasetName})`),this.update(),t(),this.redrawRequested=void 0})}),this.redrawRequested)}_reloadVisible(t){return h(this,null,function*(){})}coveringTiles(){return[]}update(){}};var oe=class{constructor(e,t,r){this.coords=e;this.ctx=t;this.raster_data=r;this.draw(r.ctxFill.canvas)}draw(e){this.ctx.clearRect(0,0,256,256),this.ctx.drawImage(e,0,0)}},J=class extends K{constructor(e,t){super(e,t),g("WxTileSource constructor: ",e)}getLayerInfoAtLatLon(e,t){if(g(`WxTileSource getLayerInfoAtLatLon (${this.layer.wxdatasetManager.datasetName})`,e),!this._map)return;let r=this._map.getZoom(),n=this._map.project(e,r),o=n.divideBy(256).floor(),s=n.subtract(o.multiplyBy(256)).floor();return this.layer.getTileData({x:o.x,y:o.y,z:r},s)}_reloadVisible(e){return h(this,null,function*(){var t;if(g(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName})`),yield this.layer.reloadTiles(this.coveringTiles(),e),(t=e==null?void 0:e.signal)!=null&&t.aborted){g(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName}) aborted`);return}return yield Promise.allSettled(this._ForEachWxTile(r=>h(this,null,function*(){r.raster_data=yield this.layer.loadTile(r.coords)}),"_reloadVisible")),this._redrawTiles()})}update(){this._ForEachWxTile(e=>{this.animation?(this.layer.painter.imprintVectorAnimationLinesStep(e.raster_data,this.animationSeed),e.draw(e.raster_data.ctxStreamLines.canvas)):e.draw(e.raster_data.ctxFill.canvas)},"_redrawTiles")}coveringTiles(){var t;g(`WxTileSource coveringTiles (${this.layer.wxdatasetManager.datasetName})`);let e=[];for(let r in this._tiles){let n=(t=this._tiles[r].el)==null?void 0:t.wxtile;n&&e.push(n.coords)}return e}_ForEachWxTile(e,t){var n;g(`WxTileSource _ForEachWxTile (${this.layer.wxdatasetManager.datasetName}) func=${t}`);let r=[];for(let o in this._tiles){let s=(n=this._tiles[o].el)==null?void 0:n.wxtile;s&&r.push(e(s))}return r}createTile(e,t){let r=P(256,256),n=r.canvas;return this.layer.loadTile(e).then(o=>{n.wxtile=new oe({x:e.x,y:e.y,z:e.z},r,o),t()}).catch(o=>{t(o)}),n}};return Be(ut);})();
|
|
1
|
+
var wxtilesleaflet=(()=>{var Oe=Object.create;var B=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames,ie=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable;var le=(a,e,t)=>e in a?B(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,$=(a,e)=>{for(var t in e||(e={}))ce.call(e,t)&&le(a,t,e[t]);if(ie)for(var t of ie(e))Ve.call(e,t)&&le(a,t,e[t]);return a};var Be=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),Xe=(a,e)=>{for(var t in e)B(a,t,{get:e[t],enumerable:!0})},ue=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ze(e))!ce.call(a,n)&&n!==t&&B(a,n,{get:()=>e[n],enumerable:!(r=Ne(e,n))||r.enumerable});return a};var $e=(a,e,t)=>(t=a!=null?Oe(Fe(a)):{},ue(e||!a||!a.__esModule?B(t,"default",{value:a,enumerable:!0}):t,a)),Ee=a=>ue(B({},"__esModule",{value:!0}),a);var y=(a,e,t)=>new Promise((r,n)=>{var s=c=>{try{i(t.next(c))}catch(l){n(l)}},o=c=>{try{i(t.throw(c))}catch(l){n(l)}},i=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,o);i((t=t.apply(a,e)).next())});var _e=Be((sr,Ae)=>{Ae.exports=window.L});var mt={};Xe(mt,{FrameworkParentClass:()=>N,Loader:()=>_,Painter:()=>U,QTree:()=>k,RawCLUT:()=>A,WXLOG:()=>g,WxAPI:()=>z,WxCreateLegend:()=>ae,WxDataSetManager:()=>R,WxGetColorSchemes:()=>q,WxGetColorStyles:()=>I,WxLayer:()=>O,WxTileSource:()=>Q,WxTilesLogging:()=>We});var me={comment1:["'degC': ['K', 1, 273.15] -> degC = K * 1 + 273.15",0],comment2:["'hPa': ['Pa', 1000]' -> hPa = Pa * 1000 + 0 (0 - could be ommited)",0],K:["K",1],kelvin:["K",1],F:["K",.5555555555,255.372222222],C:["K",1,273.15],degC:["K",1,273.15],"kg/m^2/s":["kg/m^2/s",1],"Kg/m^2/s":["kg/m^2/s",1],"Kg m**-2 s**-1":["kg/m^2/s",1],"Kg m^-2 s^-1":["kg/m^2/s",1],"Kg m^{-2} s^-1":["kg/m^2/s",1],"mm/h":["kg/m^2/s",.00027777777],"mm/hr":["kg/m^2/s",.00027777777],"W/m^2":["W/m^2",1],"W m^-2":["W/m^2",1],"W m^{-2}":["W/m^2",1],"W/m**2":["W/m^2",1],"W m**-2":["W/m^2",1],"m/s":["m/s",1],"m s**-1":["m/s",1],"m s^-1":["m/s",1],"m.s^{-1}":["m/s",1],knot:["m/s",.514444],knots:["m/s",.514444],"km/h":["m/s",.27777777777],"km h^-1":["m/s",.27777777777],"km h**-1":["m/s",.27777777777],mph:["m/s",.44704],"miles/h":["m/s",.44704],s:["s",1],sec:["s",1],h:["s",3600],min:["s",60],m:["m",1],cm:["m",.01],km:["m",1e3],mile:["m",1609.344],miles:["m",1609.344],inch:["m",.0254],Pa:["Pa",1],hPa:["Pa",100],degree:["degree",1],radian:["degree",57.3],"mg/m^3":["mg/m^3",1],"mg m^-3":["mg/m^3",1],"mg.m^-3":["mg/m^3",1],"%":["%",1],"(0 - 1)":["%",100]};var fe={none:["#00000000","#00000000"],divergingbluered:["#2166acff","#92c5deff","#f7f7f7ff","#f4a582ff","#b2182bff"],rainbow:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbowzerro:["#ff000000","#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbow2:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff","#ff0000ff"],bluebird:["#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bluebirdzerro:["#0000ff00","#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bw:["#000000ff","#ffffffff"],wb:["#ffffffff","#000000ff"],redish:["#ff00ffff","#ff0000ff","#ffff00ff"],greenish:["#ffff00ff","#00ff00ff","#00ffffff"],blueish:["#ff00ffff","#0000ffff","#00ffffff"],hspastel:["#AC6EA4FF","#8E92BDFF","#ACD4DEFF","#E9DC8EFF","#E7A97DFF","#E59074FF","#BE7E68FF","#A88F86FF"]};var E={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"divergingbluered",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"},custom:{parent:void 0,name:"custom",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"}};var de,xe,pe;function ge({colorStyles:a={},units:e={},colorSchemes:t={}}={}){g("WxTile lib setup: start"),de=Object.assign({},me,e),xe=Object.assign({},t,fe);let r=Object.assign({},a,E);pe=qe(r),g("WxTile lib setup: styles unrolled");try{y(this,null,function*(){yield document.fonts.load("32px barbs"),yield document.fonts.load("32px arrows")})}catch(n){g("WxTile lib setup: fonts not loaded")}g("WxTile lib setup is done.")}function I(){return pe}function q(){return xe}function Y(a,e,t){g("makeConverter: From=",a," To=",e);let r=m=>m;if(r.trivial=!0,a===e)return g("Trivial converter"),r;let n=Object.assign({},de,t),s=n[a],o=n[e];if(!s||!o)return g("Inconvertible units. Trivial converter"),r;let[i,c,l]=s,[u,f,d]=o;if(i!==u||!c||!f)return g("Inconvertible units. Trivial converter"),r;let h=c/f,x=((l||0)-(d||0))/f;return x?m=>h*m+x:m=>h*m}function qe(a){let e=Object.assign({},E);for(let s in a){let o=a[s];if(Array.isArray(o))for(let i=0;i<o.length;++i)e[s+"["+i+"]"]=Object.assign({},o[i]);else e[s]=Object.assign({},o)}let t=Object.assign({},E.base),r=(s,o)=>{if(o==="base")return t;let i=s[o];if(!i)return t;(!i.parent||!(i.parent in s))&&(i.parent="base");let c=r(s,i.parent);return Object.assign(i,Object.assign({},c,i,{parent:"base"}))},n={base:t};for(let s in e)n[s]=r(e,s);return n}function X(a){let e=new Map;return(t,...r)=>{let n=e.get(t);if(n)return n;let s=a(t,...r);return e.set(t,s),s.catch(o=>{o.name==="AbortError"&&e.delete(t)}),s}}function Ye(a,e){return y(this,null,function*(){return createImageBitmap(yield(yield fetch(a,e)).blob())})}function P(a,e,t=!0){let r=Object.assign(document.createElement("canvas"),{width:a,height:e,imageSmoothingEnabled:!1}).getContext("2d",{willReadFrequently:t});if(!r)throw new Error("Cannot get canvas context");return r}function je(a){let{width:e,height:t}=a,r=P(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}function ee(a,e){return y(this,null,function*(){return je(yield Ye(a,e))})}function Ge(a){a.data[34]<1&&g("Warning: image is in too old format. Check the version of the Splitter.");let e=new Uint16Array(a.data.buffer),t=new Uint16Array(e.length/2);for(let l=0;l<t.length;l++)t[l]=e[l*2];let r=new Uint8Array(8);for(let l=0;l<8;++l)r[l]=a.data[l*4+2];let n=new DataView(r.buffer),s=n.getFloat32(0,!0),o=n.getFloat32(4,!0),i=(o-s)/65535,c=ze(t);return{raw:t,dmin:s,dmax:o,dmul:i,integral:c,radius:0}}function te(a,e){return y(this,null,function*(){return Ge(yield ee(a,e))})}function ze(a){let e=new Uint32Array(66564),t=new Uint32Array(258*258);e[0]=a[0],t[0]=a[0]===0?0:1;for(let r=1;r<258;++r)e[r]=a[r]+e[r-1],e[258*r]=a[258*r]+e[258*r-258],t[r]=(a[r]===0?0:1)+t[r-1],t[258*r]=(a[258*r]===0?0:1)+t[258*r-258];for(let r=1,n=259;r<258;++r,++n)for(let s=1;s<258;++s,++n)e[n]=a[n]+e[n-258]+e[n-1]-e[n-258-1],t[n]=(a[n]===0?0:1)+t[n-258]+t[n-1]-t[n-258-1];return{integral:e,integralNZ:t}}function he(a,e){if(e<0||e===a.radius)return a;a.radius=e;let t=258,{integral:r,integralNZ:n}=a.integral;for(let s=1;s<t;s++)for(let o=1;o<t;o++){if(!a.raw[t*s+o])continue;let i=Math.min(e,o-1,t-1-o),c=Math.min(e,s-1,t-1-s),l=t*(s-c-1)+o,u=t*(s+c)+o,f;if(n){let b=n[l-i-1],W=n[l+i],w=n[u-i-1],T=n[u+i];f=b+T-W-w}else f=(2*i+1)*(2*c+1);let d=r[l-i-1],h=r[l+i],x=r[u-i-1],m=r[u+i],p=d+m-h-x;a.raw[s*t+o]=p/f}return a}function M(a){let e=a>>0&255,t=a>>8&255,r=a>>16&255,n=e.toString(16),s=t.toString(16),o=r.toString(16);return n=n.length===2?n:"0"+n,s=s.length===2?s:"0"+s,o=o.length===2?o:"0"+o,"#"+n+s+o}function C(a){if(a[0]==="#"){if(a.length===4)return+("0xff"+a[3]+a[3]+a[2]+a[2]+a[1]+a[1]);if(a.length===7)return+("0xff"+a[5]+a[6]+a[3]+a[4]+a[1]+a[2]);if(a.length===9)return+("0x"+a[7]+a[8]+a[5]+a[6]+a[3]+a[4]+a[1]+a[2])}return g("wrong color format",a),0}function L(a,e){return y(this,null,function*(){let t=yield fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()})}function re(a,e,t){let r=a>>0&255,n=a>>8&255,s=a>>16&255,o=a>>>24,i=e>>0&255,c=e>>8&255,l=e>>16&255,u=e>>>24,f=r+t*(i-r),d=n+t*(c-n),h=s+t*(l-s),x=o+t*(u-o);return f|d<<8|h<<16|x<<24}function ye(a,e,t){let r=[];for(let n=0;n<t;++n)r.push(n*(e-a)/(t-1)+a);return r}var be=!1;function We(a){console.log(a?"Logging on":"Logging off"),be=a}function g(...a){be&&console.log(...a)}function we(a){return a[0]==="#"&&a.length===4?"#"+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]:a}function j(a,{x:e,y:t,z:r}){return a.replace("{x}",`${e}`).replace("{y}",`${t}`).replace("{z}",`${r}`)}function G({x:a,y:e,z:t}){return`${t}-${a}-${e}`}var Ke="A".charCodeAt(0);var k=class{constructor(){this.qtree={nodes:null};this.qtreedepth=0}load(e,t){return y(this,null,function*(){try{let r=yield L(e,t);this.qtree=Se(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this.qtreedepth=De(this.qtree)})}check(e){let t=e.z-this.qtreedepth,r=t>=0,n=r?{x:e.x>>t,y:e.y>>t,z:this.qtreedepth}:$({},e);return Te(this.qtree,n,r)}};function Se(a,e){let t=a.charCodeAt(e.pos)-Ke;e.pos++;let r=[1,2,4,8].map(n=>t&n?Se(a,e):null);return{nodes:r.some(n=>n)?r:null}}function De(a){return a!=null&&a.nodes?1+Math.max(...a.nodes.map(De)):0}function Te(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,Te(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}var R=class{constructor({datasetName:e,instance:t,instanced:r,meta:n,wxapi:s}){if(!s.datasetsMetas.allDatasetsList.includes(e))throw new Error(`Dataset ${e} not found`);this.datasetName=e,this.instanced=r,this.instance=t,this.meta=n,this.wxapi=s}getValidTime(e=Date()){let t=this.getTimes();if(typeof e=="number"){if(e<=0)return t[0];if(e<t.length)return t[e]}let r=new Date(e).getTime(),n=t.find(s=>new Date(s).getTime()>=r);if(isNaN(r)||!n){let s=t.indexOf(e);return s===-1?t[t.length-1]:t[s]}return n}getTimes(){return this.instanced||this.meta.times}getVariables(){return this.meta.variables}getVariableMeta(e){return this.meta.variablesMeta[e]}getMaxZoom(){return this.meta.maxZoom}getBoundaries180(){var r;let e=(r=this.meta.boundaries)==null?void 0:r.boundaries180;if((e==null?void 0:e.length)!==1)return;let t=e[0];return[t.west,t.south,t.east,t.north]}getBoundaries(){return this.meta.boundaries}createURI(e,t,r="png"){if(!this.checkVariableValid(e))throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);let n=this.getValidTime(t),s=this.instanced?n:this.instance;return`${this.wxapi.dataServerURL+this.datasetName}/${s}/${e}/${n}/{z}/{x}/{y}.${r}`}checkVariableValid(e){return this.getVariableMeta(e)!==void 0}checkCombineVariableIfVector(e){let t=this.getVariableMeta(e);if(!t)throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);return t.vector||[e]}checkDatasetOutdated(){return y(this,null,function*(){return yield this.wxapi.initDone,(yield this.getDatasetInstance())===this.instance})}getDatasetInstance(){return y(this,null,function*(){let e=yield this.getDatasetInstances();return e[e.length-1]})}getDatasetInstances(){return y(this,null,function*(){try{let e=yield L(this.wxapi.dataServerURL+this.datasetName+"/instances.json",this.wxapi.requestInit);if(e.length===0)throw new Error(`No instances found for dataset ${this.datasetName}`);return e}catch(e){throw new Error(`getting dataset instances failure message: ${e.message} datasetName: ${this.datasetName}`)}})}};var z=class{constructor({dataServerURL:e,maskURL:t="auto",maskChannel:r="R",maskDepth:n=9,qtreeURL:s="auto",requestInit:o,colorStyles:i,units:c,colorSchemes:l}){this.maskURL="auto";this.datasetsMetas={allDatasetsList:[]};this.qtree=new k;this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));if(ge({colorStyles:i,units:c,colorSchemes:l}),this.dataServerURL=e,this.requestInit=o,s=s==="auto"?e+"masks/9+1.seamask.qtree":s,t!=="none"){let u=X(ee);this.maskURL=t=t==="auto"?e+"masks/{z}/{x}/{y}.png":t,this.loadMaskFunc=f=>u(j(t,f),o)}this.maskChannel=r==="R"?0:r==="G"?1:r==="B"?2:r==="A"?3:0,this.maskDepth=n,this.initDone=Promise.all([L(e+"datasetsmeta.json",o),s!=="none"?this.qtree.load(s,o):Promise.resolve()]).then(([u,f])=>{u.allDatasetsList||(u.allDatasetsList=Object.keys(u)),this.datasetsMetas=u})}getDatasetShortMeta(e){if(e!=="allDatasetsList")return this.datasetsMetas[e]}getDatasetInatance(e){var t;return(t=this.getDatasetShortMeta(e))==null?void 0:t.instance}getDatasetVariables(e){return y(this,null,function*(){var t;return yield this.initDone,(t=this.datasetsMetas[e])==null?void 0:t.variables})}createDatasetManager(e){return y(this,null,function*(){yield this.initDone;let t=this.getDatasetShortMeta(e),r=t==null?void 0:t.instance;if(!r)throw new Error("Dataset/instance not found:"+e);let n=t.instanced,s=yield L(this.dataServerURL+e+"/"+r+"/meta.json",this.requestInit);return new R({datasetName:e,instanced:n,instance:r,meta:s,wxapi:this})})}createAllDatasetsManagers(){return y(this,null,function*(){return yield this.initDone,Promise.allSettled(this.datasetsMetas.allDatasetsList.map(t=>this.createDatasetManager(t)))})}filterDatasetsByVariableName(e){return y(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList.filter(t=>{var r,n,s;return(s=(n=(r=this.datasetsMetas[t])==null?void 0:r.variables)==null?void 0:n.includes)==null?void 0:s.call(n,e)})})}getAllDatasetsNames(){return y(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList})}};function He(a,e,t){return a>t?t:a<e?e:a}var A=class{constructor(e,t,[r,n],s){let o=n-r;this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let i=[];this.DataToStyle=Y(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),s&&(this.DataToKnots=Y(t,"knot"));let c=Y(e.units,t,e.extraUnits),l=m=>~~(65535*He((c(m)-r)/(n-r),0,1));if(Array.isArray(e.colorMap)){e.colorMap.sort((m,p)=>m[0]<p[0]?-1:m[0]>p[0]?1:0);for(let[m]of e.colorMap)i.push(l(m))}else{if(e.levels||(e.levels=ye(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((m,p)=>m<p?-1:m>p?1:0),!e.colors){let m=q();e.colorScheme&&e.colorScheme in m?e.colors=m[e.colorScheme]:e.colors=m.wb}for(let m of e.levels)i.push(l(m))}let u=65536,f=ae(u,e);this.ticks=f.ticks;let d=f.ticks[0].data,x=f.ticks[f.ticks.length-1].data-d;for(let m=0;m<65536;++m){let p=o*m/65535+r,b=this.DataToStyle(p),W=Math.round((u-1)*(b-d)/x);W<=0?this.colorsI[m]=e.showBelowMin?f.colors[0]:0:W>=u?this.colorsI[m]=e.showAboveMax?f.colors[u-1]:0:this.colorsI[m]=f.colors[W]}this.colorsI[0]=0;for(let m=0;m<i[0];++m)this.levelIndex[m]=0;for(let m=0;m<i.length-1;m++)for(let p=i[m];p<i[m+1]+1;++p)this.levelIndex[p]=m;for(let m=i[i.length-1];m<65536;++m)this.levelIndex[m]=i.length-1}};function Me(a){var t;if(a!==0&&-.1<a&&a<.1)return a.toExponential(2);let e=a.toString();return((t=e.split(".")[1])==null?void 0:t.length)>2?a.toFixed(2):e}function ae(a,e){let t={size:a,showBelowMin:e.showBelowMin,showAboveMax:e.showAboveMax,units:e.units,colors:new Uint32Array(a),ticks:[]},{colorMap:r,levels:n,colors:s}=e,o=e.fill!=="solid";if(r){let d=r[0][0],h=r[r.length-1][0]-d;for(let[x,m]of r){let p=~~((x-d)/h*(a-1)),b={data:x,dataString:Me(x),color:m,pos:p};t.ticks.push(b)}for(let x=0;x<r.length-1;x++){let m=t.ticks[x].pos,p=t.ticks[x+1].pos,b=C(r[x][1]),W=o?C(r[x+1][1]):0;for(let w=m;w<p;++w)t.colors[w]=o?re(b,W,(w-m)/(p-m)):b}return t.colors[a-1]=C(r[r.length-1][1]),t}if(!s||!n)return t;let i=0,c=0,l=-1;for(let d=0;d<a;++d){let h=d*(s.length-1)/a;l!==~~h&&(l=~~h,i=C(s[l]),c=s.length>l+1?C(s[l+1]):i),t.colors[d]=o?re(i,c,h-l):i}t.colors[a-1]=C(s[s.length-1]);let u=n[0],f=(a-1)/(n[n.length-1]-u);for(let d of n){let h=~~((d-u)*f),x={data:d,dataString:Me(d),color:M(t.colors[h]),pos:h};t.ticks.push(x)}return t}var Je=2*Math.PI*6378137/256,K=2*Math.PI*6378137/2;function Qe(a,e){let t=a/K*180,r=e/K*180;return r=180/Math.PI*(2*Math.atan(Math.exp(r*Math.PI/180))-Math.PI/2),[r,t]}function et(a,e,t){let r=tt(t),n=a*r-K,s=e*r-K;return[n,s]}function tt(a){return Je/Math.pow(2,a)}function ne(a,e,t){let[r,n]=Qe(...et(a,e,t));return[n,-r]}function Ce(a,e){return[a*256,e*256]}function se(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function rt(a,e,t,r,n,s,o,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 0:return 0;case 1:return a;case 2:return e;case 3:t=a,r=e;break;case 4:return t;case 5:e=a,r=t;break;case 6:r=e+t>>1,a=r;break;case 7:r=e+t>>1;break;case 8:return r;case 9:e=a+r>>1,t=e;break;case 10:a=e,t=r;break;case 11:t=a+r>>1;break;case 12:a=t,e=r;break;case 13:e=a+r>>1;break;case 14:a=e+t>>1;break}a=o+i*a,e=o+i*e,t=o+i*t,r=o+i*r;let l=se(a,e,n),u=se(t,r,n);return(se(l,u,s)-o)/i||1}function at(a,e,t,r,n,s,o,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 7:return n+s<1?n*(e-a)+s*(t-a)+a:0;case 14:return n+s<1?0:n*(r-t)+s*(r-e)+e+t-r;case 11:return s<n?(1-n)*(a-e)+s*(r-e)+e:0;case 13:return s<n?0:(1-n)*(t-r)+s*(t-a)+a+r-t;case 15:return n+s<1?n*(e-a)+s*(t-a)+a:n*(r-t)+s*(r-e)+e+t-r;default:return 0}}function ve(a,e,t){let r=.9999999/Math.pow(2,t.z),n=t.x*256*r,s=t.y*256*r,{raw:o,dmin:i,dmax:c,dmul:l}=e,u={raw:new Uint16Array(258*258),dmin:i,dmax:c,dmul:l},{raw:f}=u;for(let d=-1,h=0;d<=256;d++){let x=s+d*r,m=Math.floor(x),p=x-m;for(let b=-1;b<=256;b++,h++){let W=n+b*r,w=Math.floor(W),T=W-w,S=w+1+(m+1)*258,D=o[S],v=o[S+1],Z=o[S+258],F=o[S+258+1];f[h]=a(D,v,Z,F,T,p,i,l)}}return u}function Le(a,e){if(!e)return a;let t=1/Math.pow(2,e.z),r=e.x*256*t,n=e.y*256*t,{data:s}=a,o=new ImageData(256,256),{data:i}=o;for(let c=0,l=0;c<256;c++){let u=n+c*t,f=Math.floor(u);f===255&&(f=254);let d=u-f;for(let h=0;h<256;h++,l++){let x=r+h*t,m=Math.floor(x);m===255&&(m=254);let p=x-m,b=(m+f*256)*4+0,W=s[b],w=s[b+4],T=s[b+4*256],S=s[b+4*256+4],D=p+d<1?p*(w-W)+d*(T-W)+W:p*(S-T)+d*(S-w)+w+T-S;i[l*4]=D>127?255:0}}return o}function Ie(a,e){return e?ve(at,a,e):a}function Pe(a,e){return e?ve(rt,a,e):a}function ke(a,{data:e},t,r){let n=r==="sea",{raw:s}=a;for(let o=t,i=259,c=0;c<256;i+=2,c++)for(let l=0;l<256;l++,i++,o+=4)n===!e[o]&&(s[i]=0);return a}function Re(a){let[e,t]=Ce(a.x,a.y),[r,n]=ne(e,t,a.z),[s,o]=ne(e+256,t+256,a.z);return{west:r,north:n,east:s,south:o}}function oe(a,e){let t=a.z-e;if(t<=0)return{upCoords:a};let r={x:a.x>>>t,y:a.y>>>t,z:e},n={x:a.x&(1<<t)-1,y:a.y&(1<<t)-1,z:t};return{upCoords:r,subCoords:n}}var _=class{constructor(e){this.loadDataFunc=X(te);this.layer=e}load(e,t){return y(this,null,function*(){let r=yield this.cacheLoad(e,this.layer.tilesURIs,t);if(!r)return null;let{rawdata:n,subCoords:s,tileType:o}=r,{units:i}=this.layer.currentMeta,c=i==="degree"?Pe:Ie,l=f=>c(he(f,this.layer.style.blurRadius),s),u=n.map(l);return this._vectorMagnitudesPrepare(u),yield this._applyMask(u,e,o,!s&&n.length===1),{data:u,slines:this._createStreamLines(u)}})}cacheLoad(e,t,r){return y(this,null,function*(){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:s,subCoords:o}=oe(e,this.layer.wxdatasetManager.getMaxZoom()),i=t.map(u=>j(u,s)),c=Object.assign({},this.layer.wxdatasetManager.wxapi.requestInit,{signal:r==null?void 0:r.signal});return{rawdata:yield Promise.all(i.map(u=>this.loadDataFunc(u,c))),subCoords:o,tileType:n}})}clearCache(){this.loadDataFunc=X(te)}_applyMask(e,t,r,n){return y(this,null,function*(){let{style:s}=this.layer;if((s.mask==="land"||s.mask==="sea")&&r==="mixed"){if(n){let{raw:i,dmin:c,dmax:l,dmul:u}=e[0];e[0]={raw:new Uint16Array(i),dmin:c,dmax:l,dmul:u}}let o;try{let{upCoords:i,subCoords:c}=oe(t,this.layer.wxdatasetManager.wxapi.maskDepth);o=yield this.layer.wxdatasetManager.wxapi.loadMaskFunc(i),o=Le(o,c)}catch(i){s.mask=void 0,g("Can't load Mask. Masking is disabled");return}ke(e[0],o,this.layer.wxdatasetManager.wxapi.maskChannel,s.mask)}})}_vectorMagnitudesPrepare(e){if(e.length===1)return;e.unshift({raw:new Uint16Array(258*258),dmin:0,dmax:0,dmul:0});let[t,r,n]=e;t.dmax=1.42*Math.max(-r.dmin,r.dmax,-n.dmin,n.dmax),t.dmul=(t.dmax-t.dmin)/65535;for(let s=0;s<258*258;++s){if(!r.raw[s]||!n.raw[s])continue;let o=r.dmin+r.dmul*r.raw[s],i=n.dmin+n.dmul*n.raw[s];t.raw[s]=Math.sqrt(i*i+o*o)/t.dmul}}_checkTypeAndMask(e){let{mask:t}=this.layer.style;var r="mixed";if(!((t==="land"||t==="sea")&&(r=this.layer.wxdatasetManager.wxapi.qtree.check(e),t===r)))return r}_checkInsideBoundaries(e){let t=this.layer.wxdatasetManager.getBoundaries();if(t!=null&&t.boundaries180){let r=Re(e),n=s=>!(r.west>s.east||s.west>r.east||r.south>s.north||s.south>r.north);if(!t.boundaries180.some(n))return!1}return!0}_createStreamLines(e){if(e.length!==3)return[];let{style:t}=this.layer;if(t.streamLineColor==="none")return[];let r=[],[n,s,o]=e,i=(t.streamLineSpeedFactor||1)/n.dmax,c=t.addDegrees?.017453292519943*t.addDegrees:0,l=t.streamLineGridStep||64,u=t.streamLineSteps||300;for(let f=0;f<=256;f+=l)for(let d=0;d<=256;d+=l){if(!n.raw[1+d+(1+f)*258])continue;let h=[],x=d,m=f,p=-1,b=0,W=0;for(let S=0;S<=u&&x>=0&&x<=256&&m>=0&&m<=256;S++){S%(u/10)||h.push({x:~~x,y:~~m});let D=~~x+1+(~~m+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,Z=s.dmin+s.raw[D]*s.dmul,F=o.dmin+o.raw[D]*o.dmul,V=Math.atan2(Z,F)+c;b=i*v*Math.sin(V),W=i*v*Math.cos(V)}x+=b,m-=W}let w=d,T=f;p=-1;for(let S=1;S<=u&&w>=0&&w<=256&&T>=0&&T<=256;S++){S%(u/10)||h.unshift({x:~~w,y:~~T});let D=~~w+1+(~~T+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,Z=s.dmin+s.raw[D]*s.dmul,F=o.dmin+o.raw[D]*o.dmul,V=Math.atan2(Z,F)+c;b=i*v*Math.sin(V),W=i*v*Math.cos(V)}w-=b,T+=W}h.length>2&&r.push(h)}return r}};var U=class{constructor(e){this.layer=e}paint({data:e,ctxFill:t,ctxText:r,ctxStreamLines:n}){let{layer:s}=this,{units:o}=s.currentMeta,i=new ImageData(256,256),c=new Uint32Array(i.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),nt(e.data[0],c,s);let l=st(c,e.data[0],s);t.putImageData(i,0,0),ot(l,r,s),it(e.data,r,s),lt(e.data[0],r,o,s),ct(e,r,s)}getPaintedCanvas(e,t,r){return t?(this.imprintVectorAnimationLinesStep(e,r),e.ctxStreamLines.canvas):e.ctxFill.canvas}imprintVectorAnimationLinesStep({data:e,ctxFill:t,ctxStreamLines:r},n){let{layer:s}=this;r.clearRect(0,0,256,256),r.drawImage(t.canvas,0,0),!(e.slines.length===0||s.style.streamLineStatic||s.style.streamLineColor==="none")&&ut(e,r,s,n)}};function nt(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:s}=t;if(r.fill!=="none")for(let o=0,i=0,c=259;o<256;++o,c+=2)for(let l=0;l<256;++l,++i,++c)e[i]=s[n[c]];else e.fill(0)}function st(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:s,colorsI:o}=t,i=[];if(r.isolineColor!=="none"){let c=r.isolineColor[0]==="#"?C(r.isolineColor):0;for(let l=0,u=0;l<256;l+=1)for(let f=0;f<256;f+=1){let d=(l+1)*258+(f+1),h=n[d],x=n[d+1],m=n[d+258];if(!h||!x||!m)continue;let p=s[h],b=s[x],W=s[m];if(p!==b||p!==W){let w=Math.max(p,b,W),T=Math.max(h,x,m),S=l*256+f;switch(r.isolineColor){case"inverted":a[S]=~o[T]|4278190080;break;case"fill":a[S]=o[T]|4278190080;break;default:a[S]=c;break}r.isolineText&&!(++u%255)&&f>20&&f<235&&l>20&&l<235&&i.push({x:f,y:l,d:h,dr:x,db:m,mli:w})}}}return i}function ot(a,e,{CLUT:t}){if(a.length){e.font="1.1em Sans-serif",e.lineWidth=2,e.strokeStyle="white",e.fillStyle="black",e.textAlign="center",e.textBaseline="middle";for(let{x:r,y:n,d:s,dr:o,db:i,mli:c}of a){let l=t.ticks[c].dataString,u=Math.atan2(s-o,i-s);e.save(),e.translate(r,n),e.rotate(u<-1.57||u>1.57?u+3.14:u),e.strokeText(l,0,0),e.fillText(l,0,0),e.restore()}}}function it(a,e,{CLUT:t,style:r}){if(!t.DataToKnots||r.vectorColor==="none"||r.vectorType==="none")return;if(a.length!==3)throw new Error("data.length !== 3");let[n,s,o]=a;switch(r.vectorType){case"barbs":e.font="40px barbs";break;case"arrows":e.font="50px arrows";break;default:e.font=r.vectorType}e.textAlign="center",e.textBaseline="middle",e.fillStyle=r.vectorColor;let i=r.addDegrees?.017453292519943*r.addDegrees:0,c=32;for(let l=c/2;l<256;l+=c)for(let u=c/2;u<256;u+=c){let f=u+1+(l+1)*258;if(!n.raw[f])continue;let d=Math.atan2(s.dmin+s.raw[f]*s.dmul,o.dmin+o.raw[f]*o.dmul),h=n.dmin+n.raw[f]*n.dmul,x=r.vectorType!=="barbs"?r.vectorFactor*.2:.2,m=Math.min(t.DataToKnots(h)*x,25)+65,p=String.fromCharCode(m);switch(r.vectorColor){case"inverted":e.fillStyle=M(~t.colorsI[n.raw[f]]);break;case"fill":e.fillStyle=M(t.colorsI[n.raw[f]]);break}e.save(),e.translate(u,l),e.rotate(d+i),e.fillText(p,0,0),e.restore()}}function lt(a,e,t,{CLUT:r,style:n}){if(t!=="degree")return;let s=.017453292519943*n.addDegrees;e.font="50px arrows",e.textAlign="center",e.textBaseline="middle",e.fillStyle=n.vectorColor;let o="L",i=32;for(let c=i/2;c<256;c+=i)for(let l=i/2;l<256;l+=i){let u=l+1+(c+1)*258;if(!a.raw[u])continue;let d=(a.dmin+a.raw[u]*a.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=M(~r.colorsI[a.raw[u]]);break;case"fill":e.fillStyle=M(r.colorsI[a.raw[u]]);break}e.save(),e.translate(l,c),e.rotate(d+s),e.fillText(o,0,0),e.restore()}}function ct(a,e,{CLUT:t,style:r}){let{data:n,slines:s}=a;if(!s.length||!r.streamLineStatic||r.streamLineColor==="none")return;let o=n[0];e.lineWidth=1,e.strokeStyle=r.streamLineColor;for(let i=s.length;i--;){let c=s[i];for(let l=0;l<c.length-1;++l){let u=c[l],f=c[l+1],d=u.x+1+(u.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=M(~t.colorsI[o.raw[d]]);break;case"fill":e.strokeStyle=M(t.colorsI[o.raw[d]]);break}e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(f.x,f.y),e.stroke()}}}function ut(a,e,{CLUT:t,style:r},n){let{data:s,slines:o}=a,i=s[0],c=r.streamLineColor.substring(0,7);n=n>>5;for(let l=0;l<o.length;++l){let u=o[l],f=u.length-1,d=(n+(1+u[0].x)*(1+u[0].y))%30;for(let h=0;h<f;++h){let x=u[h],m=u[h+1],p=1-(d-h)/f;(p<0||p>1)&&(p=0);let b=(~~(p*255)).toString(16).padStart(2,"0"),W=1+~~((1.2-p)*5);e.lineWidth=W;let w=x.x+1+(x.y+1)*258;switch(r.streamLineColor){case"inverted":c=M(~t.colorsI[i.raw[w]]);break;case"fill":c=M(t.colorsI[i.raw[w]]);break}e.strokeStyle=c+b,e.beginPath(),e.moveTo(x.x,x.y),e.lineTo(m.x,m.y),e.stroke()}}}var O=class{constructor({time:e,variables:t,wxdatasetManager:r,ext:n="png",wxstyleName:s="base"}){this.tilesCache=new Map;this.painter=new U(this);this.loader=new _(this);if(!(t!=null&&t.length)||t.length>2)throw new Error(`WxTileSource ${r.datasetName}: only 1 or 2 variables are supported but ${t.length} were given`);t.forEach(o=>{if(!r.checkVariableValid(o))throw new Error(`WxTileSource ${r.datasetName}: variable ${o} is not valid`)}),this.variables=t,this.wxdatasetManager=r,this.ext=n,this.currentMeta=this._getCurrentMeta(),[this.tilesURIs,this.time]=this._createURLsAndTime(e),[this.style,this.CLUT]=this._createCurrentStyleObject(I()[s]),g(`WxTileSource created ${r.datasetName}, ${t.join(", ")}, ${s}`)}get nonanimatable(){return this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getTime(){return this.time}clearCache(){this.tilesCache.clear(),this.loader.clearCache()}getCurrentStyleObjectCopy(){return Object.assign({},this.style)}updateCurrentStyleObject(e){[this.style,this.CLUT]=this._createCurrentStyleObject(e)}getTileData(e,t){let r=this.tilesCache.get(G(e));if(!r)return;let n=this._getPixelInfo(t,r.data.data);if(!n)return;let{raw:s,data:o}=n,i=s.map(u=>this.CLUT.colorsI[u]),c=i.map(M),l=o.map(u=>this.CLUT.DataToStyle(u));return{data:o,raw:s,rgba:i,hexColor:c,inStyleUnits:l,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentMeta.units}}setURLsAndTime(e){[this.tilesURIs,this.time]=this._createURLsAndTime(e)}loadTile(e,t){return y(this,null,function*(){return this._loadCacheDrawTile(e,this.tilesCache,t)})}preloadTime(e,t,r){return y(this,null,function*(){let[n]=this._createURLsAndTime(e);yield Promise.allSettled(t.map(s=>this.loader.cacheLoad(s,n,r)))})}reloadTiles(e,t){return y(this,null,function*(){var n;let r=new Map;yield Promise.allSettled(e.map(s=>this._loadCacheDrawTile(s,r,t))),(n=t==null?void 0:t.signal)!=null&&n.aborted||(this.tilesCache=r)})}_loadCacheDrawTile(e,t,r){return y(this,null,function*(){let n=t.get(G(e));if(n)return n;let s=yield this.loader.load(e,r);if(!s)return null;let o=P(256,256),i=o,c=this.variables.length===2?P(256,256):o,l={ctxFill:o,ctxText:i,ctxStreamLines:c,data:s};return this.painter.paint(l),t.set(G(e),l),l})}_createCurrentStyleObject(e){let t=Object.assign(this.getCurrentStyleObjectCopy(),e);t.streamLineColor=we(t.streamLineColor);let r=this._prepareCLUT(t);return[t,r]}_getCurrentMeta(){let e=this.variables.map(o=>{let i=this.wxdatasetManager.getVariableMeta(o);if(!i)throw new Error(`WxTileSource ${this.wxdatasetManager.datasetName}: variable ${o} is not valid`);return i}),{min:t,max:r,units:n,vector:s}=e[0];return this.variables.length>1&&(t=0,r=1.42*Math.max(-e[0].min,e[0].max,-e[1].min,e[1].max)),{min:t,max:r,units:n,vector:s}}_getPixelInfo({x:e,y:t},r){var s,o;let n=(t+1)*258+(e+1);if(!!((o=(s=r==null?void 0:r[0])==null?void 0:s.raw)!=null&&o[n]))return{raw:r.map(i=>i.raw[n]),data:r.map(i=>i.raw[n]*i.dmul+i.dmin)}}_prepareCLUT(e){let{min:t,max:r,units:n}=this.currentMeta;return new A(e,n,[t,r],this.variables.length===2)}_createURLsAndTime(e){let t=this.wxdatasetManager.getValidTime(e);return[this.variables.map(n=>this.wxdatasetManager.createURI(n,t,this.ext)),t]}};var Ue=$e(_e()),N=class extends Ue.default.GridLayer{};var H=class extends N{constructor(t,r){super(r);this.animation=!1;this.animationSeed=0;this.layer=new O(t)}get wxdatasetManager(){return this.layer.wxdatasetManager}getMetadata(){return g(`WxTileSource getMetadata (${this.layer.wxdatasetManager.datasetName})`),$({},this.layer.currentMeta)}getVariables(){return g(`WxTileSource getVariables (${this.layer.wxdatasetManager.datasetName})`),[...this.layer.variables]}clearCache(){g(`WxTileSource clearCache (${this.layer.wxdatasetManager.datasetName})`),this.layer.clearCache()}getCurrentStyleObjectCopy(){return g(`WxTileSource getCurrentStyleObjectCopy (${this.layer.wxdatasetManager.datasetName})`),this.layer.getCurrentStyleObjectCopy()}getTime(){return g(`WxTileSource getTime (${this.layer.wxdatasetManager.datasetName})`),this.layer.getTime()}setTime(t,r){return y(this,null,function*(){var s;g(`WxTileSource setTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t});let n=this.getTime();return this.layer.setURLsAndTime(t),yield this._reloadVisible(r),(s=r==null?void 0:r.signal)!=null&&s.aborted&&this.layer.setURLsAndTime(n),this.getTime()})}preloadTime(t,r){return y(this,null,function*(){return g(`WxTileSource preloadTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t}),this.layer.preloadTime(t,this.coveringTiles(),r)})}startAnimation(){if(this.animation){g(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) already started`);return}if(this.layer.nonanimatable){g(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) nonanimatable`);return}g(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!0;let t=r=>y(this,null,function*(){if(g(`WxTileSource animationStep (${this.layer.wxdatasetManager.datasetName})`),!this.animation||this.layer.nonanimatable){this.animation=!1;return}this.animationSeed=r,yield this._redrawTiles(),requestAnimationFrame(t)});requestAnimationFrame(t)}stopAnimation(){return y(this,null,function*(){return g(`WxTileSource stopAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this._redrawTiles()})}setCoarseLevel(t=2){return y(this,null,function*(){return g(`WxTileSource setCoarseLevel (${this.layer.wxdatasetManager.datasetName})`,{level:t}),this.oldMaxZoom=this.layer.wxdatasetManager.getMaxZoom(),this.layer.wxdatasetManager.meta.maxZoom=Math.max(this.oldMaxZoom-t,1),this._reloadVisible()})}unsetCoarseLevel(){return y(this,null,function*(){if(g(`WxTileSource unsetCoarseLevel (${this.layer.wxdatasetManager.datasetName})`),this.oldMaxZoom)return this.layer.wxdatasetManager.meta.maxZoom=this.oldMaxZoom,this._reloadVisible()})}setStyleByName(t,r=!0){return y(this,null,function*(){return g(`WxTileSource setStyleByName (${this.layer.wxdatasetManager.datasetName})`),this.updateCurrentStyleObject(I()[t],r)})}updateCurrentStyleObject(t,r=!0,n){return y(this,null,function*(){if(g(`WxTileSource updateCurrentStyleObject (${this.layer.wxdatasetManager.datasetName})`,{style:t}),this.layer.updateCurrentStyleObject(t),this.startAnimation(),r)return this._reloadVisible(n)})}_redrawTiles(){return this.redrawRequested?this.redrawRequested:(this.redrawRequested=new Promise(t=>{requestAnimationFrame(()=>{g(`WxTileSource _redrawTiles (${this.layer.wxdatasetManager.datasetName})`),this.update(),t(),this.redrawRequested=void 0})}),this.redrawRequested)}_reloadVisible(t){return y(this,null,function*(){})}coveringTiles(){return[]}update(){}};var J=class{constructor(e,t,r){this.coords=e;this.ctx=t;this.raster_data=r;this.draw(r==null?void 0:r.ctxFill.canvas)}draw(e){this.ctx.clearRect(0,0,256,256),e&&this.ctx.drawImage(e,0,0)}},Q=class extends H{constructor(e,t){super(e,t),g("WxTileSource constructor: ",e)}getLayerInfoAtLatLon(e,t){if(g(`WxTileSource getLayerInfoAtLatLon (${this.layer.wxdatasetManager.datasetName})`,e),!this._map)return;let r=this._map.getZoom(),n=this._map.project(e,r),s=n.divideBy(256).floor(),o=n.subtract(s.multiplyBy(256)).floor();return this.layer.getTileData({x:s.x,y:s.y,z:r},o)}_reloadVisible(e){return y(this,null,function*(){var t;if(g(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName})`),yield this.layer.reloadTiles(this.coveringTiles(),e),(t=e==null?void 0:e.signal)!=null&&t.aborted){g(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName}) aborted`);return}return yield Promise.allSettled(this._ForEachWxTile(r=>y(this,null,function*(){r.raster_data=yield this.layer.loadTile(r.coords)}),"_reloadVisible")),this._redrawTiles()})}coveringTiles(){var t;g(`WxTileSource coveringTiles (${this.layer.wxdatasetManager.datasetName})`);let e=[];for(let r in this._tiles){let n=(t=this._tiles[r].el)==null?void 0:t.wxtile;n&&e.push(n.coords)}return e}update(){this._ForEachWxTile(e=>{e.draw(e.raster_data&&this.layer.painter.getPaintedCanvas(e.raster_data,this.animation,this.animationSeed))},"_redrawTiles")}_ForEachWxTile(e,t){var n;g(`WxTileSource _ForEachWxTile (${this.layer.wxdatasetManager.datasetName}) func=${t}`);let r=[];for(let s in this._tiles){let o=(n=this._tiles[s].el)==null?void 0:n.wxtile;o&&r.push(e(o))}return r}createTile(e,t){let r=P(256,256),n=r.canvas;return this.layer.loadTile(e).then(s=>{n.wxtile=new J(e,r,s)}).catch(()=>{n.wxtile=new J(e,r,null)}).finally(t),n}onRemove(){return g(`WxTileSource onRemove (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this.clearCache(),this}};return Ee(mt);})();
|