@metoceanapi/wxtiles-leaflet 2.0.5 → 2.0.7

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 (94) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +132 -305
  3. package/dist/es/controls/WxStyleEditorControl.d.ts +1 -1
  4. package/dist/es/controls/WxTimeControl .d.ts +2 -2
  5. package/dist/es/defaults/styles.d.ts +2 -2
  6. package/dist/es/defaults/uconv.d.ts +2 -2
  7. package/dist/es/index.d.ts +32 -5
  8. package/dist/es/index.js +6 -1
  9. package/dist/es/utils/RawCLUT.d.ts +32 -22
  10. package/dist/es/utils/qtree.d.ts +11 -5
  11. package/dist/es/utils/wxtools.d.ts +243 -33
  12. package/dist/es/wxAPI/WxDataSetManager.d.ts +70 -34
  13. package/dist/es/wxAPI/wxAPI.d.ts +115 -43
  14. package/dist/es/wxlayer/WxImplementation.d.ts +76 -34
  15. package/dist/es/wxlayer/loader.d.ts +27 -3
  16. package/dist/es/wxlayer/loadertools.d.ts +41 -3
  17. package/dist/es/wxlayer/painter.d.ts +39 -0
  18. package/dist/es/wxlayer/wxlayer.d.ts +77 -11
  19. package/dist/es/wxsource/wxsource.d.ts +60 -20
  20. package/dist/es/wxsource/wxsourcetypes.d.ts +16 -0
  21. package/dist/web/index.js +6 -1
  22. package/docs/docs/assets/highlight.css +92 -0
  23. package/docs/docs/assets/main.js +54 -0
  24. package/docs/docs/assets/search.js +1 -0
  25. package/docs/docs/assets/style.css +1257 -0
  26. package/docs/docs/classes/FrameworkParentClass.html +98 -0
  27. package/docs/docs/classes/Loader.html +165 -0
  28. package/docs/docs/classes/Painter.html +161 -0
  29. package/docs/docs/classes/QTree.html +129 -0
  30. package/docs/docs/classes/RawCLUT.html +143 -0
  31. package/docs/docs/classes/WxAPI.html +336 -0
  32. package/docs/docs/classes/WxDataSetManager.html +406 -0
  33. package/docs/docs/classes/WxLayer.html +363 -0
  34. package/docs/docs/classes/WxLayerBaseImplementation.html +371 -0
  35. package/docs/docs/classes/WxTileSource.html +453 -0
  36. package/docs/docs/enums/TileType.html +80 -0
  37. package/docs/docs/functions/WXLOG.html +119 -0
  38. package/docs/docs/functions/WxCreateLegend.html +127 -0
  39. package/docs/docs/functions/WxGetColorSchemes.html +114 -0
  40. package/docs/docs/functions/WxGetColorStyles.html +114 -0
  41. package/docs/docs/functions/WxTilesLogging.html +119 -0
  42. package/docs/docs/index.html +201 -0
  43. package/docs/docs/interfaces/ColorStylesIncomplete.html +117 -0
  44. package/docs/docs/interfaces/Converter.html +81 -0
  45. package/docs/docs/interfaces/DataIntegral.html +112 -0
  46. package/docs/docs/interfaces/DataPicture.html +93 -0
  47. package/docs/docs/interfaces/FrameworkOptions.html +75 -0
  48. package/docs/docs/interfaces/IntegralPare.html +81 -0
  49. package/docs/docs/interfaces/SLinePoint.html +77 -0
  50. package/docs/docs/interfaces/Tree.html +70 -0
  51. package/docs/docs/interfaces/WxAPIOptions.html +164 -0
  52. package/docs/docs/interfaces/WxAllBoundariesMeta.html +85 -0
  53. package/docs/docs/interfaces/WxBoundaryMeta.html +91 -0
  54. package/docs/docs/interfaces/WxColorSchemes.html +118 -0
  55. package/docs/docs/interfaces/WxColorStyleStrict.html +319 -0
  56. package/docs/docs/interfaces/WxColorStyleWeak.html +345 -0
  57. package/docs/docs/interfaces/WxColorStylesStrict.html +74 -0
  58. package/docs/docs/interfaces/WxColorStylesWeakMixed.html +117 -0
  59. package/docs/docs/interfaces/WxData.html +81 -0
  60. package/docs/docs/interfaces/WxDataSetManagerOptions.html +108 -0
  61. package/docs/docs/interfaces/WxDataSetsMetasJSON.html +75 -0
  62. package/docs/docs/interfaces/WxDatasetMeta.html +135 -0
  63. package/docs/docs/interfaces/WxDatasetShortMeta.html +90 -0
  64. package/docs/docs/interfaces/WxLayerAPI.html +313 -0
  65. package/docs/docs/interfaces/WxLayerBaseAPI.html +246 -0
  66. package/docs/docs/interfaces/WxLayerOptions.html +118 -0
  67. package/docs/docs/interfaces/WxLegend.html +117 -0
  68. package/docs/docs/interfaces/WxLngLat.html +81 -0
  69. package/docs/docs/interfaces/WxRasterData.html +99 -0
  70. package/docs/docs/interfaces/WxRequestInit.html +70 -0
  71. package/docs/docs/interfaces/WxSourceLayerOptions.html +109 -0
  72. package/docs/docs/interfaces/WxTick.html +99 -0
  73. package/docs/docs/interfaces/WxTileInfo.html +142 -0
  74. package/docs/docs/interfaces/WxTilesLibOptions.html +92 -0
  75. package/docs/docs/interfaces/WxUnits.html +117 -0
  76. package/docs/docs/interfaces/WxVariableMeta.html +108 -0
  77. package/docs/docs/interfaces/WxVariablesMetas.html +117 -0
  78. package/docs/docs/interfaces/XYZ.html +84 -0
  79. package/docs/docs/modules.html +210 -0
  80. package/docs/docs/types/DataIntegrals.html +110 -0
  81. package/docs/docs/types/DataPictures.html +110 -0
  82. package/docs/docs/types/SLine.html +110 -0
  83. package/docs/docs/types/SubTrees.html +110 -0
  84. package/docs/docs/types/SubTreesN.html +110 -0
  85. package/docs/docs/types/TreeN.html +110 -0
  86. package/docs/docs/types/UriLoaderPromiseFunc.html +130 -0
  87. package/docs/docs/types/WxDate.html +110 -0
  88. package/docs/docs/types/WxURIs.html +110 -0
  89. package/docs/docs/types/WxUnitTuple.html +110 -0
  90. package/docs/docs/types/WxVars.html +110 -0
  91. package/docs/script/script.css +1 -1
  92. package/docs/script/script.js +11 -6
  93. package/package.json +8 -8
  94. package/src_example/index.ts +111 -54
package/CHANGELOG.md CHANGED
@@ -9,6 +9,10 @@ Write your changes below this section. `npm version [major|minor|patch]` will au
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [2.0.7] - 2022-11-30
13
+
14
+ ## [2.0.6] - 2022-11-27
15
+
12
16
  ## [2.0.5] - 2022-11-24
13
17
 
14
18
  ## [2.0.4] - 2022-11-18
package/README.md CHANGED
@@ -1,357 +1,184 @@
1
- # Wxtiles-leaflet lib
1
+ # wxtiles
2
2
 
3
- JS lib based on Leaflet https://leafletjs.com
4
- Data tiles are from https://tiles.metoceanapi.com
3
+ This is a project for weather data visualization.
4
+ There are three main parts of the project:
5
5
 
6
- # demo and examples
6
+ 1. [Splitter](https://github.com/metocean/wxtile-splitter) - a service that splits the datasets into tiles (PNG) and some metadata (JSON) served by a fileserver backend aka NGINX.
7
+ 2. [WxTiles-mbox source code](https://github.com/metoceanapi/wxtiles-mbox), npm [@metoceanapi/wxtiles-mbox](https://www.npmjs.com/package/@metoceanapi/wxtiles-mbox) - a JS API providing work with metadata, dataset manager and an implementation of a Custom MapBox-gl-gs Layer for visualizing the tiles using [Mapbox-gl-gs](https://www.mapbox.com/).
8
+ 3. [WxTiles-leaflet source code](https://github.com/metoceanapi/wxtiles-leaflet), npm [@metoceanapi/wxtiles-leaflet](https://www.npmjs.com/package/@metoceanapi/wxtiles-leaflet) - a JS API providing work with metadata, dataset manager and an implementation of a Custom Leaflet Layer for visualizing the tiles using [Leaflet](https://leafletjs.com/).
7
9
 
8
- To see a demo running:
10
+ ## API
9
11
 
10
- ```
11
- npm install
12
- npm run start
13
- ```
14
-
15
- Demo code is found in
16
-
17
- ```
18
- public/index.html
19
- public/index.js
20
- ```
21
-
22
- Folder Examples contains standalone workable html examples.
12
+ APIs for Leaflet and Mapbox-gl-gs are similar in many ways. The difference is in framework-specific implementations of the Custom Source/Layer.
23
13
 
24
- # API. Functions
14
+ Usage and API documentation is mainly equal for both frameworks.
25
15
 
26
- ## WxTileLibSetup({ colorStyles, units, colorSchemes } = {})
16
+ ## DOCS
27
17
 
28
- Wxtile lib must be initialized before use.
18
+ - Mapbox-gl: https://metoceanapi.github.io/wxtiles-mbox/docs/
19
+ - Leaflet: https://metoceanapi.github.io/wxtiles-leaflet/docs/
29
20
 
30
- ## WxGetColorStyles()
21
+ ## Examples
31
22
 
32
- Get all style objects. See 'styles'
23
+ ### MapBox-gl-js
33
24
 
34
- ## WxTileLayer(settings)
25
+ ```ts
26
+ import 'mapbox-gl/dist/mapbox-gl.css';
27
+ import mapboxgl from 'mapbox-gl';
28
+ import { WxAPI } from '@metoceanapi/wxtiles-mbox';
35
29
 
36
- See Layer.initialize
30
+ async func(){
31
+ // Get the API ready - should be ONE per application
32
+ // requestInit is used in every request to the server. Add your keys, credentials, mode, etc.
33
+ const wxapi = new WxAPI({ dataServerURL: 'https://tiles.metoceanapi.com/data/',
34
+ requestInit: { /* headers: new Headers([['x-api-key', 'key']]), */ } });
37
35
 
38
- ## WxTileLogging(bool:on = false)
36
+ // Create a dataset manager (may be used for many variables-layers from this dataset)
37
+ const wxdatasetManager = await wxapi.createDatasetManager('gfs.global');
39
38
 
40
- Print vast logs to consol.
39
+ // Automatically gets a proper set of variable(s) from the dataset and composes northward or eastward components if needed
40
+ const variables = wxdatasetManager.checkCombineVariableIfVector('air.temperature.at-2m'); // 'wind.speed.eastward.at-10m' - Vector example
41
41
 
42
- ## WxGetInternalLeafletCopy()
42
+ // create a Mapbox layer source
43
+ const mboxSourceOptions = { id: 'wxsource', attribution: 'WxTiles' };
44
+ const wxsource = new WxTileSource({ wxdatasetManager, variables }, mboxSourceOptions);
43
45
 
44
- Get the Leaflet library bundled with Wxtiles.
46
+ // add the layer to the map
47
+ const map = new mapboxgl.Map({ container: 'map', accessToken:'token', style: { version: 8, name: 'Empty', sources: {}, layers: [] } });
48
+ await map.once('load');
49
+ map.addSource(wxsource.id, wxsource);
50
+ map.addLayer({ id: 'wxlayer', type: 'raster', source: wxsource.id, paint: { 'raster-fade-duration': 0 /*NEDDED for animation*/ } });
51
+ }()
45
52
 
46
- ## WxTileWatermark(params)
47
-
48
- params - Leaflet control's parameters
49
-
50
- # API. Layer Objects
51
-
52
- ## constructor: initialize({ dataSource, options = {}, lazy = true })
53
-
54
- ```js
55
- dataSource = {
56
- serverURI: string, // server to fetch data from
57
- ext: string, // png / webp (default) - wxtilesplitter output format
58
- dataset: string, // dataset of the dataset
59
- variables: [string, string] // variable(s) to be used for the layer rendering
60
- name: string, // attribute of the dataSource to be used externally
61
- styleName: string, // The name of the style (from styles.json) to apply for the layer
62
- }
63
- // Lazy setup
64
- // 'true': perform setup and data loading on 'addTo(map)'.
65
- // 'false': start loading immediately, but loading is not finished when layer is created.
66
- // the signal 'setupcomplete' is fired when loading is finished.
67
- // useful when a big bunch of layers is used, so layers are not wasting memory and bandwidth.
68
- lazy: bool
69
-
70
- options = { // Lealet's options for the layer
71
- opacity: 1,
72
- }
73
53
  ```
74
54
 
75
- ## getSetupCompletePromise() : Promise<void>
76
-
77
- As setup process is async, this function returns the promise which is resolved upon setup complete.
55
+ ### Leaflet
78
56
 
79
- ## once('setupcomplete', func(){})
57
+ ```ts
58
+ import 'leaflet/dist/leaflet.css';
59
+ import L from 'leaflet';
60
+ import { WxAPI } from '@metoceanapi/wxtiles-leaflet';
80
61
 
81
- It is a Leaflet's feature.
82
- _func_ - a callback called upon setup complete.
62
+ async func(){
63
+ // Get the API ready - should be ONE per application
64
+ // requestInit is used in every request to the server. Add your keys, credentials, mode, etc.
65
+ const wxapi = new WxAPI({ dataServerURL: 'https://tiles.metoceanapi.com/data/',
66
+ requestInit: { /* headers: new Headers([['x-api-key', 'key']]), */ } });
83
67
 
84
- ## createTile(coords: obj, done: function)
68
+ // Create a dataset manager (may be used for many variables-layers from this dataset)
69
+ const wxdatasetManager = await wxapi.createDatasetManager('gfs.global');
85
70
 
86
- Leaflet calls this function to create tiles.
71
+ // Automatically gets a proper set of variable(s) from the dataset and composes northward or eastward components if needed
72
+ const variables = wxdatasetManager.checkCombineVariableIfVector('air.temperature.at-2m'); // 'wind.speed.eastward.at-10m' - Vector example
87
73
 
88
- ## getTile(latlng) : obj
74
+ // create a layer
75
+ const leafletOptions: L.GridLayerOptions = { opacity: 1, attribution: 'WxTiles' };
76
+ const wxsource = new WxTileSource({ wxdatasetManager, variables }, leafletOptions);
89
77
 
90
- ```js
91
- latlng = { lat: num, lon: num };
92
- obj = { tile: obj, data: num, raw: uint16, rgba: Uint32, hexColor: string, inStyleUnits: num, tilePoint: { x, y }, units: string };
78
+ // add the layer to the map
79
+ const map = L.map('map', { center: [0, 0], zoom: 2, zoomControl: true });
80
+ map.addLayer(wxsource);
81
+ await new Promise((done) => wxsource.once('load', done)); // highly recommended to await for the first load
82
+ }()
93
83
  ```
94
84
 
95
- **tile** - internal wxtile-js lib object.
96
- **raw** - raw representation of data at latlng
97
- **data** - data at latlng
98
- **inStyleUnits** - data at latlng converted into style units.
99
- **rgba** - uint32 representation of the color at latlng
100
- **hexColor** - web format of the color reprensentation at latlng
101
- **tilePoint** - {x, y} (0-256) projection of the latlng on the tile.
102
- **units** - style units
103
-
104
- ## setStyle(name: string)
105
-
106
- **name** - a name of a style object in _styles.json_. (Warning! it is not an internal 'name' _in_ the style)
107
-
108
- ## getStyle() : string
109
-
110
- Get the 'name' of the layer's style object used for rendering.
111
-
112
- ## getStyleName() : string
113
-
114
- Get an internal 'name' of the layer's style.
115
-
116
- ## setTime(unixTime: number) : Promise<void>
117
-
118
- _unixTime_ - milliseconds since Jan 1, 1970, 00:00:00.000 GMT
119
- _Promise_ is resolved when new data is loaded and rendered. _Undefined_ if error ocured.
120
-
121
- ## getTime() : string
122
-
123
- Get current layer's _time step_ used for rendering.
124
-
125
- ## getTimes()
126
-
127
- Get all layer's _time steps_.
128
-
129
- ## checkDataChanged() : Promise<bool>
130
-
131
- resolved as _true_ if there is a new instance of data.
85
+ ### Change the time step
132
86
 
133
- ## reloadData() : Promise<void>
134
-
135
- Forces layer to reload data
136
-
137
- ## getLegendData(legendSize: number): obj
138
-
139
- Returns style's metadata usefull for legend rendering
140
- _legendSize_ - width of a legend.
141
-
142
- ```js
143
- obj = { size: number, showBelowMin: bool, showAboveMax: bool, units: string, colors: Uint32Array(size), ticks: [tickobj] };
144
- tickobj = { data: number, dataString: string, color: string, pos: number };
87
+ ```ts
88
+ await wxsource.setTimeStep(1); // 1 - index of the time step in the dataset
145
89
  ```
146
90
 
147
- _size_ = legendSize
148
- _showBelowMin_ - usefull to show somehow on a legend that data is shown (or not) below the legend's minimum
149
- _showAboveMax_ - usefull to show somehow on a legend that data is shown (or not) above the legend's maximum
150
- _units_ - style's units
151
- _colors_ - array of RGBA.
152
-
153
- _tick_ - metadata for ticks on the legend
154
- _data_ - data in style's units
155
- _dataString_ - string representation of a data (formated).
156
- _color_ - web color at the tick
157
- _pos_ - legend's X coord for the tick (0, legendSize)
158
-
159
- ## setCoarseLevel(l = 2)
160
-
161
- Prepares layer to be time-animated. Reduces level of detalization, so dramaticaly reduces downloaded data during animation.
162
-
163
- ## unsetCoarseLevel()
164
-
165
- Restores level of detalization to the level's maximum.
166
-
167
- # WxTile Data structure
168
-
169
- See https://github.com/metocean/wxtile-splitter
170
-
171
- ## Styles, unrolling and inheritance
172
-
173
- 'styles.json' contains a set of styles. It is processsed in order to aplly 'unrolling' and 'inheritance'
174
-
175
- 'unrolling' and 'inheritance' example:
91
+ or
176
92
 
177
- ```js
178
- {
179
- "variableName": [ // style can be arrays of styles. Usefull when many styles are set for one variable.
180
- {
181
- "name": "super 0",
182
- "....": "..."
183
- },
184
- {
185
- "name": "super 1",
186
- "....": "..."
187
- },
188
- {
189
- "name": "super 2",
190
- "parent": "variablName[1]",
191
- "....": "..."
192
- }
193
- ]
194
- }
93
+ ```ts
94
+ await wxsource.setTimeStep('2020-01-01T00:00:00Z'); // '2020-01-01T00:00:00Z' - time step in the dataset
195
95
  ```
196
96
 
197
- unrolled to
198
-
199
- ```json
200
- {
201
- // NOTE: order number in array is added to the arrayed-style, so each style becomes independent
202
- "variableName[0]": {
203
- "name": "super 0",
204
- "....": "..."
205
- },
206
- // So, as an example of inheritance, 'variableName[1]' could be used as a parent for variableName[2]
207
- "variableName[1]": {
208
- "name": "super 1",
209
- "....": "..."
210
- },
211
- // So, as an example of inheritance, 'variableName[1]' could be used as a parent for variableName[2]
212
- "variableName[2]": {
213
- "name": "super 2",
214
- "parent": "variableName[1]",
215
- "....": "..."
216
- }
217
- }
218
- ```
97
+ or
219
98
 
220
- ## fields of a style
221
-
222
- ```js
223
- {
224
- "parent": "base", /* parent the style. Usefull within the inharitance system.
225
- If presented in 'styles.json', to fullfill this style the parentstyle is ammended with fields of this style.
226
- multi-inheritance is acceptable, so parent style can have its own parent etc
227
- if no parent specified parent="base" is used. "base" style must be in 'styles.json'
228
- NOTE: useless for hot 'custom' style - dirty hack acccepted by wxtile-js lib.*/
229
- "name": "Style name to be showed on legend",
230
- "fill": "gradient(default)/solid/none",
231
- "isolineColor": "inverted(default)/fill/none",
232
- "isolineText": true, // make text on isolines visible (default: true)
233
- "showBelowMin": true, // make invisible(if false) data below minimud level data.
234
- "showAboveMax": true, // make invisible(if false) data above minimud level data.
235
- "blurRadius": 0, // apply BoxBlur to fetched data
236
- "addDegrees": 0, // rotation of arrows. Usefull for currents and winds in some cases with data units 'degree' to coorect rotation of original data if needed.
237
- "vectorColor": "inverted/fill/none(default)/#xxxxxxxx", /* color of vectors:
238
- "none" - (default) don't render vectors,
239
- "inverted" - inverted color for current data,
240
- "fill" - color for current data,
241
- "#ffffffff" - const color (web format) for all vectors.*/
242
- "vectorType": "arrows(default)/barbs", /*the name of the font used for vector rendering.
243
- "none" - (default) don't render vectors,
244
- "vector" - arrows
245
- "barbs" - barbs*/
246
- "streamLineColor": "none/#888", // in web color scheme "#rgb" or "#rrggbb" "#rrggbbaa". "none" - no particle animation
247
- "streamLineSpeedFactor": 3, // factor to make stream lines longer (particles faster).
248
- "streamLineStatic": false, // don't animate streamlines, draw a 'curve' instead.
249
- "levels": [0, 0.25, 0.75, 1, 1.5, 2], /* levels of data for legend and isolines.
250
- if "levels" is null, then 10 levels in [min, max] are autocreated.
251
- Ignored if 'colorMap' is not null*/
252
- "colorScheme": "rainbow", /*predefined colorsceme in 'colorschemes.json' (ignored if 'colors' or 'colorMap' is not null):
253
- "rainbow" (default), used if there is no colorscheme in a style)
254
- "rainbow2"
255
- "bluebird"
256
- "bw"
257
- "wb"
258
- "redish"
259
- "greenish"
260
- "blueish"*/
261
- "colors": ["#5E6472FF", "#AED9E0FF", "#B3E6E3FF", "#B8F2E6FF", "#FAF3DDFF", "#FFA69EFF"], // legend's linear colorscheme. Ignored if 'colorMap' is not null)
262
- "colorMap": [ // array of levels and corresponding colors. Non-linear representation of a colorscheme
263
- [0, "#323200ff"], // level value (in style's units), color
264
- [16, "#ffff00ff"],[20, "#ffff00ff"],[20, "#0032a0ff"],[30, "#0050ffff"],[30, "#006496ff"],[40, "#00ffffff"],...
265
- ],
266
- "units": "speedOfLight", // representation of the layer's data (data is converted if necessary)
267
- "extraUnits": {"speedOfLight": ["m/s", 299792458, 0]} // append default unit converter system with new units: "speedOfLight" = "m/s" * 299792458 + 0;
268
- }
99
+ ```ts
100
+ await wxsource.setTimeStep(2345323454); // time in seconds since 1970-01-01T00:00:00Z
269
101
  ```
270
102
 
271
- ## Colors defined as a string (web format)
103
+ or
272
104
 
273
- The basic information could be found here: https://en.wikipedia.org/wiki/Web_colors#Hex_triplet
274
- In addition to 'standard' triplets, in 'wxtile-js' lib four bytes could be used to represent RGBA (transparancy).
275
- Color defenition is "case insensitive".
276
-
277
- #ffd700 = #FFD700 = #FFD700FF (opaque, "case insensitive")
278
- #FFD7007F (semi transparent)
105
+ ```ts
106
+ await wxsource.setTimeStep(new Date('2020-01-01T00:00:00Z')); // Date object
107
+ ```
279
108
 
280
- #f6e = #ff66EE = #ff66eeff (opaque)
281
- #0aF = #00AAff = #00AAFFFF (opaque)
109
+ ### Update the style
282
110
 
283
- # Color schemes
111
+ ```ts
112
+ await wxsource.updateCurrentStyleObject({ units: 'm/s', levels: undefined }); // set levels to undefined - to automatically calculate the levels from the dataset
113
+ ```
284
114
 
285
- colorschemes.json
115
+ ### Preload the time steps
286
116
 
287
- ```js
288
- {
289
- "rainbow": [ // Name of a colorscheme
290
- "#ff0000ff", // string representation of RGBA color,
291
- "#ffff00ff",
292
- "#00ff00ff",
293
- "#00ffffff",
294
- "#0000ffff",
295
- "#ff00ffff"
296
- ],
297
- ...
298
- }
117
+ ```ts
118
+ // load the time step 10 to the cache but do not not render it
119
+ const prom = wxsource.preloadTime(10);
120
+ // do stuff asyncronously
121
+ // ...
122
+ await prom; // wait for the time step to finish loading
123
+ // now set the time step to 10
124
+ await wxsource.setTime(10); // will be fast rendered from the cache
299
125
  ```
300
126
 
301
- # Units convertion
302
-
303
- Units converter works ONLY with units from this file.
304
- It considers "m/s" and "m s\*\*-1" as different units.
305
- NOTE!!! Units in the first column are taken from dataset data files.
306
- NOTE!!! Units int the `uconv.json` are case-sensitive.
127
+ ### Abort loading
307
128
 
308
- ## Example:
129
+ ```ts
130
+ const abortController = new AbortController();
131
+ console.log('setTime(5)');
132
+ const prom = wxsource.setTime(5, abortController);
133
+ abortController.abort(); // aborts the request
134
+ await prom; // await always !! even if aborted
135
+ console.log('aborted');
136
+ ```
309
137
 
310
- Base units for "knot" is "m/s",
311
- Base units for "km/h" is "m/s", so "knot" and "km/h" are convertible.
312
- Convertion is always two-staged, forward - units-1 to its base units, backward - from base units to units-2.
313
- to convert 5 "knot" to "km/h":
138
+ ### Get the current time step
314
139
 
140
+ ```ts
141
+ const timeStep = wxsource.getTime();
315
142
  ```
316
- "knot": ["m/s", 0.514444],
317
- "km/h": ["m/s", 0.27777777777],
318
143
 
319
- ```
144
+ ### read lon lat data
320
145
 
321
- 1. 5 knot = 5 \* 0.514444 = 2,57222 m/s -- forward
322
- 2. 2,57222 / 0.277777777 = 9.26 km/h -- backward
323
-
324
- ## 'uconv.json' example
325
-
326
- ```json
327
- {
328
- "K": ["K", 1],
329
- "F": ["K", 0.5555555555, 255.372222222],
330
- "C": ["K", 1, 273.15],
331
- "degC": ["K", 1, 273.15],
332
- "kg/m^2/s": ["kg/m^2/s", 1],
333
- "Kg m**-2 s**-1": ["kg/m^2/s", 1],
334
- "W/m^2": ["W/m^2", 1],
335
- "W m**2": ["W/m^2", 1],
336
- "m/s": ["m/s", 1],
337
- "m s**-1": ["m/s", 1],
338
- "knot": ["m/s", 0.514444],
339
- "km/h": ["m/s", 0.27777777777],
340
- "s": ["s", 1],
341
- "sec": ["s", 1],
342
- "h": ["s", 3600],
343
- "min": ["s", 60],
344
- "m": ["m", 1],
345
- "cm": ["m", 0.01],
346
- "inch": ["m", 0.0254]
347
- }
146
+ ```ts
147
+ map.on('mousemove', (e) => {
148
+ if (!wxsource) return;
149
+ const pos = position(e); //
150
+ const tileInfo: WxTileInfo | undefined = wxsource.getLayerInfoAtLatLon(pos.wrap(), map);
151
+ if (tileInfo) {
152
+ console.log(tileInfo);
153
+ }
154
+ });
348
155
  ```
349
156
 
350
- # ToDos:
351
-
352
- 1. animated `degrees` like wave direction (minor)
157
+ ### animated blur effect
353
158
 
354
- # browsers compatibility
159
+ ```ts
160
+ (async function step(n: number = 0) {
161
+ await wxsource.updateCurrentStyleObject({ isolineText: false, blurRadius: ~~(10 * Math.sin(n / 500) + 10) }); // await always !!
162
+ requestAnimationFrame(step);
163
+ })();
164
+ ```
355
165
 
356
- See https://leafletjs.com/ section 'Browser Support'
357
- In addition, if 'webp' as compression format is used see compatibility: https://caniuse.com/webp
166
+ ### more interactive - additional level and a bit of the red transparentness around the level made from current mouse position
167
+
168
+ ```ts
169
+ await wxsource.updateCurrentStyleObject({ levels: undefined }); // reset levels if existed in the style
170
+ const levels = wxsource.getCurrentStyleObjectCopy().levels || []; // get current/default/any levels
171
+ // generate a new color map from the levels
172
+ const colMap: [number, string][] = levels.map((level) => [level, '#' + Math.random().toString(16).slice(2, 8) + 'ff']);
173
+ let busy = false;
174
+ map.on('mousemove', async (e) => {
175
+ if (!wxsource || busy) return;
176
+ busy = true;
177
+ const tileInfo: WxTileInfo | undefined = wxsource.getLayerInfoAtLatLon(position(e), map);
178
+ if (tileInfo) {
179
+ await wxsource.updateCurrentStyleObject({ colorMap: [...colMap, [tileInfo.inStyleUnits[0], '#ff000000']] });
180
+ onsole.log(tileInfo);
181
+ }
182
+ busy = false;
183
+ });
184
+ ```
@@ -1,7 +1,7 @@
1
1
  import { WxColorStyleStrict } from '../index';
2
2
  import { WxColorStyleWeak } from '../index';
3
3
  export declare class WxStyleEditorControl {
4
- onchange?: (style: WxColorStyleWeak) => Promise<void>;
4
+ onchange?: (style: WxColorStyleWeak, nonnative?: boolean) => Promise<void>;
5
5
  editorTextAreaEl: HTMLTextAreaElement;
6
6
  editorDivEl: HTMLDivElement;
7
7
  parentInput: HTMLInputElement;
@@ -1,6 +1,6 @@
1
1
  import { WxTileSource } from '../index';
2
2
  export declare class WxTimeControl {
3
- private readonly delay;
3
+ readonly delay: number;
4
4
  private wxsource?;
5
5
  private readonly _div;
6
6
  private readonly button;
@@ -8,7 +8,7 @@ export declare class WxTimeControl {
8
8
  onchange: (time: string) => void;
9
9
  constructor(delay: number, wxsource?: WxTileSource | undefined);
10
10
  setTimes(times: string[]): void;
11
- updateSource(wxsource: WxTileSource): void;
11
+ updateSource(wxsource?: WxTileSource): void;
12
12
  onAdd(): HTMLDivElement;
13
13
  onRemove(): void;
14
14
  extender(): {
@@ -1,2 +1,2 @@
1
- import { ColorStylesStrict } from '../utils/wxtools';
2
- export declare const __colorStyles_default_preset: ColorStylesStrict;
1
+ import { WxColorStylesStrict } from '../utils/wxtools';
2
+ export declare const __colorStyles_default_preset: WxColorStylesStrict;
@@ -1,2 +1,2 @@
1
- import { Units } from '../utils/wxtools';
2
- export declare const __units_default_preset: Units;
1
+ import { WxUnits } from '../utils/wxtools';
2
+ export declare const __units_default_preset: WxUnits;
@@ -1,8 +1,35 @@
1
+ /**
2
+ * Main classes and interfaces to use in your application are:
3
+ * - {@link WxAPIOptions} options to pass to the constructor of {@link WxAPI}.
4
+ * - {@link WxAPI} the main class to use to interact with the *WxTiles* API and to create {@link WxDataSetManager} instances
5
+ * - {@link WxDataSetManager} class for managing WX datasets and create {@link WxTileSource}.
6
+ * * {@link FrameworkOptions} framework specific options to pass to the constructor of {@link WxTileSource}.
7
+ * - {@link WxLayerOptions} options to pass to the constructor of {@link WxTileSource}.
8
+ * - {@link WxTileSource} class for managing WX tiles sources.
9
+ * - {@link WxColorStyleWeak} interface for color styles.
10
+ * - {@link WxDate} type for dates.
11
+ * - {@link WxVars} type for variables.
12
+ * - {@link WxDatasetMeta} interface for dataset's meta data.
13
+ * - {@link WxVariableMeta} interface for variable's meta data.
14
+ * - {@link WxAllBoundariesMeta} interface for boundaries of a dataset.
15
+ * - {@link WxTileInfo} interface for tile's information.
16
+ *
17
+ * ### Note
18
+ * In case of use **async** member functions, you must use the **await** syntax.
19
+ * @module
20
+ */
1
21
  export { WxAPI } from './wxAPI/wxAPI';
2
- export type { WxAPIOptions, WxVariableMeta, WxVariablesMetas, WxBoundaryMeta, WxAllBoundariesMeta, WxDatasetMeta } from './wxAPI/wxAPI';
3
- export { WxDataSetManager } from './wxAPI/WxDataSetManager';
22
+ export type { WxAPIOptions, WxDatasetMeta, WxDatasetShortMeta, WxDataSetsMetasJSON, WxVariableMeta, WxVariablesMetas, WxBoundaryMeta, WxAllBoundariesMeta, } from './wxAPI/wxAPI';
23
+ export { WxDataSetManager, type WxDataSetManagerOptions, type WxSourceLayerOptions } from './wxAPI/WxDataSetManager';
4
24
  export { WxTileSource } from './wxsource/wxsource';
5
- export type { WxLayerOptions, WxDate, WxRequestInit, WxTileInfo, WxVars, WxLngLat } from './wxlayer/wxlayer';
6
- export { WxCreateLegend, type WxLegend, type WxTick } from './utils/RawCLUT';
25
+ export { type FrameworkOptions, FrameworkParentClass } from './wxsource/wxsourcetypes';
26
+ export type { WxLayerOptions, WxDate, WxRequestInit, WxTileInfo, WxVars, WxLngLat, WxURIs } from './wxlayer/wxlayer';
27
+ export { WxLayer } from './wxlayer/wxlayer';
28
+ export type { WxLayerBaseAPI, WxLayerBaseImplementation, WxLayerAPI } from './wxlayer/WxImplementation';
29
+ export { WxCreateLegend, RawCLUT, type WxLegend, type WxTick } from './utils/RawCLUT';
7
30
  export { WxGetColorStyles, WxGetColorSchemes, WxTilesLogging, WXLOG } from './utils/wxtools';
8
- export type { XYZ, WxColorSchemes, WxColorStyleWeak, WxColorStyleStrict, WxTilesLibOptions } from './utils/wxtools';
31
+ export type { XYZ, WxUnits, WxUnitTuple, WxColorSchemes, WxColorStyleWeak, WxColorStyleStrict, WxColorStylesStrict, WxColorStylesWeakMixed, WxTilesLibOptions, ColorStylesIncomplete, Converter, IntegralPare, DataIntegral, DataIntegrals, DataPicture, DataPictures, UriLoaderPromiseFunc, } from './utils/wxtools';
32
+ export { Painter, type WxRasterData } from './wxlayer/painter';
33
+ export { Loader, type WxData, type SLine, type SLinePoint } from './wxlayer/loader';
34
+ export { QTree } from './utils/qtree';
35
+ export type { TileType, Tree, SubTrees, SubTreesN, TreeN } from './utils/qtree';