@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
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,357 +1,189 @@
|
|
|
1
|
-
#
|
|
1
|
+
# wxtiles
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
This is a project for weather data visualization.
|
|
4
|
+
There are three main parts of the project:
|
|
5
5
|
|
|
6
|
-
|
|
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
|
-
|
|
10
|
+
## DOCS
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
- Mapbox-gl: https://metoceanapi.github.io/wxtiles-mbox/docs/
|
|
13
|
+
- Leaflet: https://metoceanapi.github.io/wxtiles-leaflet/docs/
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
## API
|
|
25
16
|
|
|
26
|
-
|
|
17
|
+
APIs for Leaflet and Mapbox-gl-gs are similar, but they have different implementations of the Custom Source/Layer.
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
## Examples
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
### MapBox-gl-js
|
|
31
22
|
|
|
32
|
-
|
|
23
|
+
```ts
|
|
24
|
+
import 'mapbox-gl/dist/mapbox-gl.css';
|
|
25
|
+
import mapboxgl from 'mapbox-gl';
|
|
26
|
+
import { WxAPI } from '@metoceanapi/wxtiles-mbox';
|
|
33
27
|
|
|
34
|
-
|
|
28
|
+
async func(){
|
|
29
|
+
// Get the API ready - should be ONE per application
|
|
30
|
+
// requestInit is used in every request to the server. Add your keys, credentials, mode, etc.
|
|
31
|
+
const wxapi = new WxAPI({ dataServerURL: 'https://tiles.metoceanapi.com/data/',
|
|
32
|
+
requestInit: { /* headers: new Headers([['x-api-key', 'key']]), */ } });
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
// Create a dataset manager (may be used for many variables-layers from this dataset)
|
|
35
|
+
const wxdatasetManager = await wxapi.createDatasetManager('gfs.global');
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
// Automatically gets a proper set of variable(s) from the dataset and composes northward or eastward components if needed
|
|
38
|
+
const variables = wxdatasetManager.checkCombineVariableIfVector('air.temperature.at-2m'); // 'wind.speed.eastward.at-10m' - Vector example
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// create a Mapbox layer source
|
|
41
|
+
const mboxSourceOptions = { id: 'wxsource', attribution: 'WxTiles' };
|
|
42
|
+
const wxsource = new WxTileSource({ wxdatasetManager, variables }, mboxSourceOptions);
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
// add the layer to the map
|
|
45
|
+
const map = new mapboxgl.Map({ container: 'map', accessToken:'token', style: { version: 8, name: 'Empty', sources: {}, layers: [] } });
|
|
46
|
+
await map.once('load');
|
|
47
|
+
map.addSource(wxsource.id, wxsource);
|
|
48
|
+
map.addLayer({ id: 'wxlayer', type: 'raster', source: wxsource.id, paint: { 'raster-fade-duration': 0 /*NEDDED for animation*/ } });
|
|
49
|
+
}()
|
|
43
50
|
|
|
44
|
-
Get the Leaflet library bundled with Wxtiles.
|
|
45
|
-
|
|
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
51
|
```
|
|
74
52
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
As setup process is async, this function returns the promise which is resolved upon setup complete.
|
|
53
|
+
### Leaflet
|
|
78
54
|
|
|
79
|
-
|
|
55
|
+
```ts
|
|
56
|
+
import 'leaflet/dist/leaflet.css';
|
|
57
|
+
import L from 'leaflet';
|
|
58
|
+
import { WxAPI } from '@metoceanapi/wxtiles-leaflet';
|
|
80
59
|
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
async func(){
|
|
61
|
+
// Get the API ready - should be ONE per application
|
|
62
|
+
// requestInit is used in every request to the server. Add your keys, credentials, mode, etc.
|
|
63
|
+
const wxapi = new WxAPI({ dataServerURL: 'https://tiles.metoceanapi.com/data/',
|
|
64
|
+
requestInit: { /* headers: new Headers([['x-api-key', 'key']]), */ } });
|
|
83
65
|
|
|
84
|
-
|
|
66
|
+
// Create a dataset manager (may be used for many variables-layers from this dataset)
|
|
67
|
+
const wxdatasetManager = await wxapi.createDatasetManager('gfs.global');
|
|
85
68
|
|
|
86
|
-
|
|
69
|
+
// Automatically gets a proper set of variable(s) from the dataset and composes northward or eastward components if needed
|
|
70
|
+
const variables = wxdatasetManager.checkCombineVariableIfVector('air.temperature.at-2m'); // 'wind.speed.eastward.at-10m' - Vector example
|
|
87
71
|
|
|
88
|
-
|
|
72
|
+
// create a layer
|
|
73
|
+
const leafletOptions: L.GridLayerOptions = { opacity: 1, attribution: 'WxTiles' };
|
|
74
|
+
const wxsource = new WxTileSource({ wxdatasetManager, variables }, leafletOptions);
|
|
89
75
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
// add the layer to the map
|
|
77
|
+
const map = L.map('map', { center: [0, 0], zoom: 2, zoomControl: true });
|
|
78
|
+
map.addLayer(wxsource);
|
|
79
|
+
await new Promise((done) => wxsource.once('load', done)); // highly recommended to await for the first load
|
|
80
|
+
}()
|
|
93
81
|
```
|
|
94
82
|
|
|
95
|
-
|
|
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>
|
|
83
|
+
### Change the time step
|
|
130
84
|
|
|
131
|
-
|
|
132
|
-
|
|
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 };
|
|
85
|
+
```ts
|
|
86
|
+
await wxsource.setTimeStep(1); // 1 - index of the time step in the dataset
|
|
145
87
|
```
|
|
146
88
|
|
|
147
|
-
|
|
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'
|
|
89
|
+
or
|
|
174
90
|
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
}
|
|
91
|
+
```ts
|
|
92
|
+
await wxsource.setTimeStep('2020-01-01T00:00:00Z'); // '2020-01-01T00:00:00Z' - time step in the dataset
|
|
195
93
|
```
|
|
196
94
|
|
|
197
|
-
|
|
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
|
-
```
|
|
95
|
+
or
|
|
219
96
|
|
|
220
|
-
|
|
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
|
-
}
|
|
97
|
+
```ts
|
|
98
|
+
await wxsource.setTimeStep(2345323454); // time in seconds since 1970-01-01T00:00:00Z
|
|
269
99
|
```
|
|
270
100
|
|
|
271
|
-
|
|
272
|
-
|
|
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".
|
|
101
|
+
or
|
|
276
102
|
|
|
277
|
-
|
|
278
|
-
|
|
103
|
+
```ts
|
|
104
|
+
await wxsource.setTimeStep(new Date('2020-01-01T00:00:00Z')); // Date object
|
|
105
|
+
```
|
|
279
106
|
|
|
280
|
-
|
|
281
|
-
#0aF = #00AAff = #00AAFFFF (opaque)
|
|
107
|
+
### Update the style
|
|
282
108
|
|
|
283
|
-
|
|
109
|
+
```ts
|
|
110
|
+
await wxsource.updateCurrentStyleObject({ units: 'm/s', levels: undefined }); // levels: undefined - to recalculate levels
|
|
111
|
+
```
|
|
284
112
|
|
|
285
|
-
|
|
113
|
+
### Preload the time steps
|
|
286
114
|
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
"#ff00ffff"
|
|
296
|
-
],
|
|
297
|
-
...
|
|
298
|
-
}
|
|
115
|
+
```ts
|
|
116
|
+
// load to the cache the time steps 10 but not render it
|
|
117
|
+
const prom = wxsource.preloadTime(10);
|
|
118
|
+
// do stuff asyncronously
|
|
119
|
+
// ...
|
|
120
|
+
await prom; // wait for the time step to finish loading
|
|
121
|
+
// now set the time step to 10
|
|
122
|
+
await wxsource.setTime(10); // will be rendered from the cache
|
|
299
123
|
```
|
|
300
124
|
|
|
301
|
-
|
|
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.
|
|
125
|
+
### Abort loading
|
|
307
126
|
|
|
308
|
-
|
|
127
|
+
```ts
|
|
128
|
+
const abortController = new AbortController();
|
|
129
|
+
console.log('setTime(5)');
|
|
130
|
+
const prom = wxsource.setTime(5, abortController);
|
|
131
|
+
abortController.abort(); // aborts the request
|
|
132
|
+
await prom; // await always !! even if aborted
|
|
133
|
+
console.log('aborted');
|
|
134
|
+
```
|
|
309
135
|
|
|
310
|
-
|
|
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":
|
|
136
|
+
### Get the current time step
|
|
314
137
|
|
|
138
|
+
```ts
|
|
139
|
+
const timeStep = wxsource.getTime();
|
|
315
140
|
```
|
|
316
|
-
"knot": ["m/s", 0.514444],
|
|
317
|
-
"km/h": ["m/s", 0.27777777777],
|
|
318
141
|
|
|
319
|
-
|
|
142
|
+
### read lon lat data
|
|
320
143
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
-
}
|
|
144
|
+
```ts
|
|
145
|
+
map.on('mousemove', (e) => {
|
|
146
|
+
if (!wxsource) return;
|
|
147
|
+
const pos = position(e); //
|
|
148
|
+
const tileInfo: WxTileInfo | undefined = wxsource.getLayerInfoAtLatLon(pos.wrap(), map);
|
|
149
|
+
if (tileInfo) {
|
|
150
|
+
console.log(tileInfo);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
348
153
|
```
|
|
349
154
|
|
|
350
|
-
|
|
155
|
+
### animated blur effect
|
|
351
156
|
|
|
352
|
-
|
|
157
|
+
```ts
|
|
158
|
+
let b = 0;
|
|
159
|
+
let db = 1;
|
|
160
|
+
const nextAnim = async () => {
|
|
161
|
+
if (!wxsource) return;
|
|
162
|
+
await wxsource.updateCurrentStyleObject({ blurRadius: b }); // await always !!
|
|
353
163
|
|
|
354
|
-
|
|
164
|
+
b += db;
|
|
165
|
+
if (b > 16 || b < 0) db = -db;
|
|
166
|
+
setTimeout(nextAnim, 1);
|
|
167
|
+
};
|
|
168
|
+
setTimeout(nextAnim, 2000);
|
|
169
|
+
```
|
|
355
170
|
|
|
356
|
-
|
|
357
|
-
|
|
171
|
+
### more interactive - additional level and a bit of the red transparentness around the level made from current mouse position
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
await wxsource.updateCurrentStyleObject({ levels: undefined }); // reset levels if existed in the style
|
|
175
|
+
const levels = wxsource.getCurrentStyleObjectCopy().levels || []; // get current/default/any levels
|
|
176
|
+
// generate a new color map from the levels
|
|
177
|
+
const colMap: [number, string][] = levels.map((level) => [level, '#' + Math.random().toString(16).slice(2, 8) + 'ff']);
|
|
178
|
+
let busy = false;
|
|
179
|
+
map.on('mousemove', async (e) => {
|
|
180
|
+
if (!wxsource || busy) return;
|
|
181
|
+
busy = true;
|
|
182
|
+
const tileInfo: WxTileInfo | undefined = wxsource.getLayerInfoAtLatLon(position(e), map);
|
|
183
|
+
if (tileInfo) {
|
|
184
|
+
await wxsource.updateCurrentStyleObject({ colorMap: [...colMap, [tileInfo.inStyleUnits[0], '#ff000000']] });
|
|
185
|
+
onsole.log(tileInfo);
|
|
186
|
+
}
|
|
187
|
+
busy = false;
|
|
188
|
+
});
|
|
189
|
+
```
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const __colorStyles_default_preset:
|
|
1
|
+
import { WxColorStylesStrict } from '../utils/wxtools';
|
|
2
|
+
export declare const __colorStyles_default_preset: WxColorStylesStrict;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const __units_default_preset:
|
|
1
|
+
import { WxUnits } from '../utils/wxtools';
|
|
2
|
+
export declare const __units_default_preset: WxUnits;
|
package/dist/es/index.d.ts
CHANGED
|
@@ -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,
|
|
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 } from './wxAPI/WxDataSetManager';
|
|
4
24
|
export { WxTileSource } from './wxsource/wxsource';
|
|
5
|
-
export
|
|
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';
|
|
6
29
|
export { WxCreateLegend, 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, WxRasterData } from './wxlayer/painter';
|
|
33
|
+
export { Loader, WxData, SLine, SLinePoint } from './wxlayer/loader';
|
|
34
|
+
export { type TileType, QTree, Tree, SubTrees, SubTreesN, TreeN } from './utils/qtree';
|
|
35
|
+
export { RawCLUT } from './utils/RawCLUT';
|