@metoceanapi/wxtiles-leaflet 2.4.0-1 → 2.4.1-3

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 (91) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +214 -92
  3. package/dist/es/index.d.ts +12 -16
  4. package/dist/es/index.js +4 -4
  5. package/dist/es/wxAPI/WxAPI.d.ts +17 -0
  6. package/dist/es/wxAPI/WxDataSetManager.d.ts +14 -4
  7. package/dist/es/wxsource/wxsource.d.ts +24 -20
  8. package/dist/es/wxsource/wxsourcetypes.d.ts +22 -10
  9. package/dist/web/index.js +4 -4
  10. package/docs/docs/assets/highlight.css +12 -19
  11. package/docs/docs/assets/search.js +1 -1
  12. package/docs/docs/classes/WxAPI.html +31 -18
  13. package/docs/docs/classes/WxAPIControl.html +70 -24
  14. package/docs/docs/classes/WxDataSetManager.html +22 -21
  15. package/docs/docs/classes/WxInfoControl.html +37 -10
  16. package/docs/docs/classes/WxLegendControl.html +33 -11
  17. package/docs/docs/classes/WxStyleEditorControl.html +206 -94
  18. package/docs/docs/classes/WxTileSource.html +40 -40
  19. package/docs/docs/classes/WxTimeControl.html +58 -20
  20. package/docs/docs/index.html +188 -101
  21. package/docs/docs/interfaces/FrameworkOptions.html +3 -3
  22. package/docs/docs/interfaces/WxSourceLayerOptions.html +5 -5
  23. package/docs/docs/modules.html +12 -130
  24. package/docs/docs/types/Loader.html +3 -59
  25. package/docs/docs/types/Painter.html +3 -59
  26. package/docs/docs/types/WxLayer.html +3 -59
  27. package/docs/docs/variables/WxLayerBaseImplementation.html +3 -59
  28. package/docs/script/script.css +1 -1
  29. package/docs/script/script.js +6 -6
  30. package/package.json +3 -3
  31. package/src_example/frwrkdeps.ts +131 -80
  32. package/src_example/index.ts +2 -53
  33. package/src_example/start.ts +143 -300
  34. package/dep.dot +0 -33
  35. package/dep.svg +0 -233
  36. package/docs/docs/classes/DataIntegral.html +0 -154
  37. package/docs/docs/classes/QTree.html +0 -185
  38. package/docs/docs/classes/RawCLUT.html +0 -143
  39. package/docs/docs/classes/TilesCache.html +0 -108
  40. package/docs/docs/enums/TileType.html +0 -80
  41. package/docs/docs/functions/WXLOG.html +0 -127
  42. package/docs/docs/functions/WxCreateLegend.html +0 -135
  43. package/docs/docs/functions/WxGetColorSchemes.html +0 -122
  44. package/docs/docs/functions/WxGetColorStyles.html +0 -122
  45. package/docs/docs/functions/WxTilesLogging.html +0 -130
  46. package/docs/docs/interfaces/CachedUriLoaderPromiseFunc.html +0 -108
  47. package/docs/docs/interfaces/ColorStylesIncomplete.html +0 -125
  48. package/docs/docs/interfaces/Converter.html +0 -81
  49. package/docs/docs/interfaces/DataPicture.html +0 -95
  50. package/docs/docs/interfaces/IntegralPare.html +0 -81
  51. package/docs/docs/interfaces/SLinePoint.html +0 -77
  52. package/docs/docs/interfaces/Tree.html +0 -74
  53. package/docs/docs/interfaces/WxAPIOptions.html +0 -173
  54. package/docs/docs/interfaces/WxAllBoundariesMeta.html +0 -90
  55. package/docs/docs/interfaces/WxAllDatasetsShortMetas.html +0 -125
  56. package/docs/docs/interfaces/WxBoundaryMeta.html +0 -99
  57. package/docs/docs/interfaces/WxColorSchemes.html +0 -126
  58. package/docs/docs/interfaces/WxColorStyleStrict.html +0 -359
  59. package/docs/docs/interfaces/WxColorStyleWeak.html +0 -388
  60. package/docs/docs/interfaces/WxColorStylesStrict.html +0 -74
  61. package/docs/docs/interfaces/WxColorStylesWeakMixed.html +0 -125
  62. package/docs/docs/interfaces/WxData.html +0 -85
  63. package/docs/docs/interfaces/WxDataSetManagerOptions.html +0 -117
  64. package/docs/docs/interfaces/WxDatasetMeta.html +0 -144
  65. package/docs/docs/interfaces/WxDatasetShortMeta.html +0 -91
  66. package/docs/docs/interfaces/WxLayerAPI.html +0 -375
  67. package/docs/docs/interfaces/WxLayerBaseAPI.html +0 -242
  68. package/docs/docs/interfaces/WxLayerOptions.html +0 -113
  69. package/docs/docs/interfaces/WxLegend.html +0 -118
  70. package/docs/docs/interfaces/WxLngLat.html +0 -81
  71. package/docs/docs/interfaces/WxRasterData.html +0 -118
  72. package/docs/docs/interfaces/WxRequestInit.html +0 -70
  73. package/docs/docs/interfaces/WxTick.html +0 -100
  74. package/docs/docs/interfaces/WxTileInfo.html +0 -142
  75. package/docs/docs/interfaces/WxUnits.html +0 -125
  76. package/docs/docs/interfaces/WxVariableMeta.html +0 -109
  77. package/docs/docs/interfaces/WxVariablesMetas.html +0 -125
  78. package/docs/docs/interfaces/XYZ.html +0 -84
  79. package/docs/docs/types/DataIntegrals.html +0 -118
  80. package/docs/docs/types/DataPictures.html +0 -118
  81. package/docs/docs/types/ListenerMethod.html +0 -134
  82. package/docs/docs/types/SLine.html +0 -118
  83. package/docs/docs/types/SubTrees.html +0 -118
  84. package/docs/docs/types/SubTreesN.html +0 -118
  85. package/docs/docs/types/TreeN.html +0 -118
  86. package/docs/docs/types/WxDate.html +0 -125
  87. package/docs/docs/types/WxEventType.html +0 -121
  88. package/docs/docs/types/WxInstances.html +0 -118
  89. package/docs/docs/types/WxLayerVarsNames.html +0 -118
  90. package/docs/docs/types/WxURIs.html +0 -118
  91. package/docs/docs/types/WxUnitTuple.html +0 -118
@@ -1,24 +1,11 @@
1
- import { WxAPIControl } from "@metoceanapi/wxtiles-common/controls/WxAPIControl";
2
- import { WxInfoControl } from "@metoceanapi/wxtiles-common/controls/WxInfoControl";
3
- import { WxLegendControl } from "@metoceanapi/wxtiles-common/controls/WxLegendControl";
4
- import { WxStyleEditorControl } from "@metoceanapi/wxtiles-common/controls/WxStyleEditorControl";
5
- import { WxTimeControl } from "@metoceanapi/wxtiles-common/controls/WxTimeControl";
6
- import {
7
- WXLOG,
8
- WxAPI,
9
- type WxColorStyleWeak,
10
- type WxTileSource
11
- } from "../src/index";
12
- import {
13
- addControl,
14
- addLayer,
15
- addRaster,
16
- flyTo,
17
- initFrameWork,
18
- position,
19
- removeLayer,
20
- setURL,
21
- } from "./frwrkdeps";
1
+ import { WxAPIControl } from '@metoceanapi/wxtiles-common/controls/WxAPIControl';
2
+ import { WxInfoControl } from '@metoceanapi/wxtiles-common/controls/WxInfoControl';
3
+ import { WxLegendControl } from '@metoceanapi/wxtiles-common/controls/WxLegendControl';
4
+ import { WxStyleEditorControl } from '@metoceanapi/wxtiles-common/controls/WxStyleEditorControl';
5
+ import { WxTimeControl } from '@metoceanapi/wxtiles-common/controls/WxTimeControl';
6
+ import { WXLOG, type WxColorStyleWeak } from '@metoceanapi/wxtiles-common/utils/wxtools';
7
+ import { WxAPI, type WxTileSource } from '../src/index';
8
+ import { addControl, addLayer, addRaster, flyTo, initFrameWork, position, removeLayer, setURL } from './frwrkdeps';
22
9
 
23
10
  const OPACITY = 0.8;
24
11
 
@@ -26,283 +13,139 @@ const OPACITY = 0.8;
26
13
  // Functions below are just framework specific wrappers for this universal function
27
14
  // start() is the fully interchangable function for Leaflet and Mapbox
28
15
  export async function start() {
29
- const map = await initFrameWork();
30
- addRaster(
31
- map,
32
- "baseS",
33
- "baseL",
34
- "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
35
- 3,
36
- );
37
- addRaster(
38
- map,
39
- "baseS",
40
- "baseL",
41
- "https://tiles.metoceanapi.com/base-lines/{z}/{x}/{y}",
42
- 5,
43
- );
44
- // WxTilesLogging(console.trace);
45
- // const dataServerURL = 'data/'; // different sources manged in 'start' script in package.json
46
- // const dataServerURL = 'https://tilestest.metoceanapi.com/data/';
47
- // const dataServerURL = 'http://localhost:9191/data/';
48
- // const dataServerURL = 'https://68.171.214.87/data/'; // hihi1
49
- // const dataServerURL = 'https://68.171.214.81/data/'; // hihi2
50
- // const dataServerURL = 'https://hihi2.metoceanapi.com/data/';
51
- const dataServerURL = "https://tilesdev.metoceanapi.com/data/";
52
- const myHeaders = new Headers();
53
- // myHeaders.append('x-api-key', 'SpV3J1RypVrv2qkcJE91gG');
54
- const wxapi = new WxAPI({
55
- dataServerURL,
56
- maskURL: "auto",
57
- maskChannel: "R",
58
- qtreeURL: "auto",
59
- requestInit: { headers: myHeaders },
60
- });
61
-
62
- // let datasetName = 'ecmwf.global'; /* 'mercator.global/'; */ /* 'gfs.global/'; */ /* 'obs-radar.rain.nzl.national/'; */
63
- // let variable = 'cloud.cover';
64
- // let variable = 'air.temperature.at-2m';
65
- // let variable = 'wind.speed.eastward.at-10m';
66
- // let variable = 'wave.direction.peak';
67
-
68
- // let datasetName = 'ww3-ecmwf.global';
69
- // let variable = 'wave.direction.mean';
70
-
71
- let datasetName = "obs-radar.rain.nzl.national";
72
- let variable = "reflectivity";
73
-
74
- // let datasetName = 'him8_truecolor';
75
- // let variable = 'h8_rgb';
76
-
77
- // get datasetName from URL
78
- const urlParams = window.location.toString().split("##")[1];
79
- const params = urlParams?.split("/");
80
- datasetName = params?.[0] || datasetName;
81
- if (params?.[1]) variable = params[1];
82
- let time = params?.[2] || "";
83
- const zoom = (params && Number.parseFloat(params[3])) || 0;
84
- const lng = (params && Number.parseFloat(params[4])) || 0;
85
- const lat = (params && Number.parseFloat(params[5])) || 0;
86
- const bearing = (params && Number.parseFloat(params[6])) || 0;
87
- const pitch = (params && Number.parseFloat(params[7])) || 0;
88
- if (params?.length > 8) params[8] = params.slice(8).join("/");
89
-
90
- const str = params?.[8] && params[8];
91
- const sth = { style: {} as WxColorStyleWeak };
92
- try {
93
- // get style from URL
94
- sth.style = str && { ...JSON.parse(decodeURI(str)) }; // reset levels if change units
95
- } catch (e) {
96
- /* ignore errors silently */
97
- console.log("Can't parse style from URL");
98
- }
99
-
100
- params && flyTo(map, zoom, lng, lat, bearing, pitch); // if no params stay at default position set in initFrameWork()
101
-
102
- map.on("zoom", () => setURL(map, time, datasetName, variable, sth.style));
103
- map.on("drag", () => setURL(map, time, datasetName, variable, sth.style));
104
- map.on("rotate", () => setURL(map, time, datasetName, variable, sth.style));
105
- map.on("pitch", () => setURL(map, time, datasetName, variable, sth.style));
106
-
107
- let wxsourceLayer: WxTileSource | undefined;
108
-
109
- const legendControl = new WxLegendControl();
110
- addControl(map, legendControl, "top-right");
111
-
112
- const frameworkOptions = {
113
- id: "wxsource",
114
- opacity: OPACITY,
115
- attribution:
116
- '<a href="https://metoceanapi.github.io/wxtiles-leaflet/docs">WxTiles DOCS</a>',
117
- };
118
- const apiControl = new WxAPIControl(wxapi, datasetName, variable);
119
- addControl(map, apiControl, "top-left");
120
- apiControl.onchange = async (
121
- _datasetName,
122
- _variable,
123
- resetStyleAndFlyTo = true,
124
- ): Promise<void> => {
125
- datasetName = _datasetName;
126
- variable = _variable;
127
- WXLOG(
128
- "apiControl.onchange datasetName=",
129
- datasetName,
130
- "variable=",
131
- variable,
132
- );
133
- // remove existing source and layer
134
- removeLayer(map, frameworkOptions.id, wxsourceLayer);
135
- //
136
- if (resetStyleAndFlyTo) {
137
- sth.style = {}
138
- }
139
- wxsourceLayer = undefined;
140
- const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
141
- const boundaries = wxdatasetManager.getBoundaries();
142
- if (boundaries && resetStyleAndFlyTo) {
143
- const { east, west, north, south } = boundaries.boundariesnorm;
144
- const zoom = Math.round(
145
- Math.log(
146
- (360 * 360) /
147
- Math.max((east - west + 360) % 360, north - south) /
148
- 360,
149
- ) / Math.LN2,
150
- ); // from https://stackoverflow.com/questions/6048975/google-maps-v3-how-to-calculate-the-zoom-level-for-a-given-bounds
151
- flyTo(map, zoom, (east + west) / 2, (north + south) / 2, 0, 0);
152
- }
153
- const meta = wxdatasetManager.getVariableCurrentMeta(variable);
154
- if (meta?.units === "RGB") {
155
- const times = wxdatasetManager.getAllTimes();
156
-
157
- addRaster(
158
- map,
159
- frameworkOptions.id,
160
- "wxtiles",
161
- wxdatasetManager.createURI(variable, times[0]),
162
- wxdatasetManager.getMaxZoom(),
163
- wxdatasetManager.getBoundaries()?.boundariesnorm,
164
- );
165
-
166
- timeControl.setTimes(times);
167
- legendControl.clear();
168
- } else {
169
- wxsourceLayer = wxdatasetManager.createSourceLayer(
170
- { variable, time, wxstyle: sth.style },
171
- frameworkOptions,
172
- );
173
- wxsourceLayer.setCoarseLevel(0);
174
- await addLayer(map, "wxtiles", wxsourceLayer);
175
- // wxsource.startAnimation();
176
- const styleCopy = wxsourceLayer.getCurrentStyleObjectCopy();
177
- legendControl.drawLegend(styleCopy); // first draw legend with current style
178
- styleCopy.levels = sth.style?.levels; // no need to show defaults it in the editor and URL
179
- styleCopy.colors = sth.style?.colors; // no need to show defaults it in the editor and URL
180
- await customStyleEditorControl.onchange?.(styleCopy, true);
181
- timeControl.updateSource(wxsourceLayer);
182
- }
183
- // apiControl.datasets.value = datasetName;
184
- // apiControl.variables.value = variable;
185
- };
186
-
187
- const timeControl = new WxTimeControl(50);
188
- addControl(map, timeControl, "top-left");
189
- timeControl.onchange = (time_) => {
190
- time = time_;
191
- setURL(map, time_, datasetName, variable, sth.style);
192
- infoControl.update(wxsourceLayer, map);
193
- };
194
-
195
- const customStyleEditorControl = new WxStyleEditorControl();
196
- addControl(map, customStyleEditorControl, "top-right");
197
- customStyleEditorControl.onchange = async (style, nonnativecall) => {
198
- WXLOG("customStyleEditorControl.onchange");
199
- if (!wxsourceLayer) return;
200
- nonnativecall || (await wxsourceLayer.updateCurrentStyleObject(style)); // if called manually, do not update wxsource's style
201
- const nstyle = wxsourceLayer.getCurrentStyleObjectCopy();
202
- legendControl.drawLegend(nstyle);
203
- nstyle.levels = style?.levels; // keep levels empty if they are not defined
204
- nstyle.colors = style?.colors; // keep colors empty if they are not defined
205
- customStyleEditorControl.setStyle(nstyle); // if called from wxsource, update customStyleEditorControl
206
- sth.style = nstyle;
207
- setURL(map, time, datasetName, variable, sth.style);
208
- };
209
-
210
- const infoControl = new WxInfoControl();
211
- addControl(map, infoControl, "bottom-left");
212
- map.on("mousemove", (e) =>
213
- infoControl.update(wxsourceLayer, map, position(e)),
214
- );
215
-
216
- await apiControl.onchange(datasetName, variable, false); // initial load
217
-
218
- /*/ DEMO: more interactive - additional level and a bit of the red transparentness around the level made from current mouse position
219
- if (wxsource) {
220
- let busy = false;
221
- await wxsource.updateCurrentStyleObject({ levels: undefined }); // await always !!
222
- const levels = wxsource.getCurrentStyleObjectCopy().levels || []; // get current/default/any levels
223
- const colMap: [number, string][] = levels.map((level) => [level, '#' + Math.random().toString(16).slice(2, 8) + 'ff']);
224
- map.on('mousemove', async (e) => {
225
- if (!wxsource || busy) return;
226
- busy = true;
227
- const tileInfo: WxTileInfo | undefined = wxsource.getLayerInfoAtLatLon(position(e), map);
228
- if (tileInfo) {
229
- await customStyleEditorControl.onchange?.({ colorMap: [...colMap, [tileInfo.inStyleUnits[0], '#ff000000']] }); // await always !!
230
- }
231
- busy = false;
232
- });
233
- } //*/
234
-
235
- /*/ DEMO: abort
236
- if (wxsource) {
237
- const abortController = new AbortController();
238
- console.log('setTime(5)');
239
- const prom = wxsource.setTime(5, abortController);
240
- abortController.abort(); // aborts the request
241
- await prom; // await always !! even if aborted
242
- console.log('aborted');
243
- await wxsource.setTime(5); // no abort
244
- console.log('setTime(5) done');
245
- }//*/
246
-
247
- /*/ DEMO: preload a timestep
248
- map.once('click', async () => {
249
- if (!wxsource) return;
250
- console.log('no preload time=5');
251
- const t = Date.now();
252
- await wxsource.setTime(5); // await always !! or abort
253
- console.log(Date.now() - t);
254
- await wxsource.preloadTime(10); // await always !! even if aborted
255
- await wxsource.preloadTime(20); // await always !! even if aborted
256
- console.log('preloaded timesteps 10, 20');
257
- map.once('click', async () => {
258
- if (!wxsource) return;
259
- const t = Date.now();
260
- await wxsource.setTime(10); // await always !! or abort
261
- console.log(Date.now() - t, ' step 10');
262
- map.once('click', async () => {
263
- if (!wxsource) return;
264
- const t = Date.now();
265
- await wxsource.setTime(20); // await always !! or abort
266
- console.log(Date.now() - t, ' step 20');
267
- });
268
- });
269
- }); //*/
270
-
271
- /*/ DEMO: change style's units
272
- let i = 0;
273
- map.on('click', async () => {
274
- if (!wxsource) return;
275
- const u = ['knots', 'm/s', 'km/h', 'miles/h'];
276
- await wxsource.updateCurrentStyleObject({ units: u[i], levels: undefined }); // levels: undefined - to recalculate levels
277
- legendControl.drawLegend(wxsource.getCurrentStyleObjectCopy());
278
- i = (i + 1) % u.length;
279
- }); //*/
280
-
281
- /*/ DEMO : read lon lat data
282
- map.on('mousemove', (e) => {
283
- if (!wxsource) return;
284
- const pos = position(e); //
285
- const tileInfo: WxTileInfo | undefined = wxsource.getLayerInfoAtLatLon(pos.wrap(), map);
286
- if (tileInfo) {
287
- console.log(tileInfo);
288
- }
289
- }); //*/
290
-
291
- /*/ DEMO: timesteps
292
- let t = 0;
293
- const nextTimeStep = async () => {
294
- if (!wxsource) return;
295
- await wxsource.setTime(t++ % wxsource.wxdatasetManager.getTimes().length); // await always !!
296
- setTimeout(nextTimeStep, 0);
297
- };
298
- setTimeout(nextTimeStep, 2000);
299
- //*/
300
-
301
- /*/ DEMO: Dynamic blur effect /
302
- wxsource &&
303
- (async function step(n: number = 0) {
304
- await wxsource.updateCurrentStyleObject({ isolineText: false, blurRadius: ~~(10 * Math.sin(n / 500) + 10) }); // await always !!
305
- requestAnimationFrame(step);
306
- })();
307
- //*/
16
+ const map = await initFrameWork();
17
+ const headers = new Headers({ 'x-api-key': 'YHtP155Q1gxENEeESBsmDF' });
18
+ addRaster(map, 'baseS', 'baseL', 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', 3);
19
+ addRaster(map, 'baseS', 'baseL', 'https://tiles.metoceanapi.com/base-lines/{z}/{x}/{y}', 5, null, headers);
20
+ const dataServerURL = 'https://tilesdev.metoceanapi.com/data/';
21
+ const wxapi = new WxAPI({
22
+ dataServerURL,
23
+ maskURL: 'auto',
24
+ maskChannel: 'R',
25
+ qtreeURL: 'auto',
26
+ requestInit: { headers: headers },
27
+ });
28
+
29
+ const filter = 'global';
30
+ let datasetName = 'gfs.global';
31
+ let variable = 'air.temperature.at-2m';
32
+
33
+ // get datasetName from URL
34
+ const urlParams = window.location.toString().split('##')[1];
35
+ const params = urlParams?.split('/');
36
+ datasetName = params?.[0] || datasetName;
37
+ if (params?.[1]) variable = params[1];
38
+ let time = params?.[2] || '';
39
+ const zoom = (params && Number.parseFloat(params[3])) || 0;
40
+ const lng = (params && Number.parseFloat(params[4])) || 0;
41
+ const lat = (params && Number.parseFloat(params[5])) || 0;
42
+ const bearing = (params && Number.parseFloat(params[6])) || 0;
43
+ const pitch = (params && Number.parseFloat(params[7])) || 0;
44
+ if (params?.length > 8) params[8] = params.slice(8).join('/');
45
+
46
+ const str = params?.[8] && params[8];
47
+ const sth = { style: {} as WxColorStyleWeak };
48
+ try {
49
+ // get style from URL
50
+ sth.style = str && { ...JSON.parse(decodeURI(str)) }; // reset levels if change units
51
+ } catch (e) {
52
+ /* ignore errors silently */
53
+ console.log("Can't parse style from URL");
54
+ }
55
+
56
+ params && flyTo(map, zoom, lng, lat, bearing, pitch); // if no params stay at default position set in initFrameWork()
57
+
58
+ map.on('zoomend', () => setURL(map, time, datasetName, variable, sth.style));
59
+ map.on('moveend', () => setURL(map, time, datasetName, variable, sth.style));
60
+
61
+ let wxsourceLayer: WxTileSource | undefined;
62
+
63
+ const legendControl = new WxLegendControl();
64
+ addControl(map, legendControl, 'top-right');
65
+
66
+ const frameworkOptions = {
67
+ id: 'wxsource',
68
+ opacity: OPACITY,
69
+ attribution: '<a href="https://metoceanapi.github.io/wxtiles-leaflet/docs">WxTiles DOCS</a>',
70
+ };
71
+ const apiControl = new WxAPIControl(wxapi, datasetName, variable, { filter });
72
+ addControl(map, apiControl, 'top-left');
73
+
74
+ apiControl.onchange = async (_datasetName, _variable, resetStyleAndFlyTo = true): Promise<void> => {
75
+ datasetName = _datasetName;
76
+ variable = _variable;
77
+ WXLOG('apiControl.onchange datasetName=', datasetName, 'variable=', variable);
78
+
79
+ // remove existing source and layer
80
+ removeLayer(map, frameworkOptions.id, wxsourceLayer);
81
+ //
82
+ if (resetStyleAndFlyTo) {
83
+ sth.style = {};
84
+ }
85
+ wxsourceLayer = undefined;
86
+ const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
87
+ const boundaries = wxdatasetManager.getBoundaries();
88
+ if (boundaries && resetStyleAndFlyTo) {
89
+ const { east, west, north, south } = boundaries.boundariesnorm;
90
+ const zoom = Math.round(Math.log((360 * 360) / Math.max((east - west + 360) % 360, north - south) / 360) / Math.LN2); // from https://stackoverflow.com/questions/6048975/google-maps-v3-how-to-calculate-the-zoom-level-for-a-given-bounds
91
+ flyTo(map, zoom, (east + west) / 2, (north + south) / 2, 0, 0);
92
+ }
93
+ const meta = wxdatasetManager.getVariableCurrentMeta(variable);
94
+ if (meta?.units === 'RGB') {
95
+ const times = wxdatasetManager.getAllTimes();
96
+
97
+ addRaster(
98
+ map,
99
+ frameworkOptions.id,
100
+ 'wxtiles',
101
+ wxdatasetManager.createURI(variable, times[0]),
102
+ wxdatasetManager.getMaxZoom(),
103
+ wxdatasetManager.getBoundaries()?.boundariesnorm,
104
+ headers,
105
+ );
106
+
107
+ timeControl.setTimes(times);
108
+ legendControl.clear();
109
+ } else {
110
+ wxsourceLayer = wxdatasetManager.createSourceLayer({ variable, time, wxstyle: sth.style }, frameworkOptions);
111
+ wxsourceLayer.setCoarseLevel(0);
112
+ await addLayer(map, 'wxtiles', wxsourceLayer);
113
+ // wxsource.startAnimation();
114
+ const styleCopy = wxsourceLayer.getCurrentStyleObjectCopy();
115
+ legendControl.drawLegend(styleCopy); // first draw legend with current style
116
+ styleCopy.levels = sth.style?.levels; // no need to show defaults it in the editor and URL
117
+ styleCopy.colors = sth.style?.colors; // no need to show defaults it in the editor and URL
118
+ await customStyleEditorControl.onchange?.(styleCopy, true);
119
+ timeControl.updateSource(wxsourceLayer);
120
+ }
121
+ };
122
+
123
+ const timeControl = new WxTimeControl(50);
124
+ addControl(map, timeControl, 'top-left');
125
+ timeControl.onchange = (time_) => {
126
+ time = time_;
127
+ setURL(map, time_, datasetName, variable, sth.style);
128
+ infoControl.update(wxsourceLayer, map);
129
+ };
130
+
131
+ const customStyleEditorControl = new WxStyleEditorControl();
132
+ addControl(map, customStyleEditorControl, 'top-right');
133
+ customStyleEditorControl.onchange = async (style, nonnativecall) => {
134
+ WXLOG('customStyleEditorControl.onchange');
135
+ if (!wxsourceLayer) return;
136
+ nonnativecall || (await wxsourceLayer.updateCurrentStyleObject(style)); // if called manually, do not update wxsource's style
137
+ const nstyle = wxsourceLayer.getCurrentStyleObjectCopy();
138
+ legendControl.drawLegend(nstyle);
139
+ nstyle.levels = style?.levels; // keep levels empty if they are not defined
140
+ nstyle.colors = style?.colors; // keep colors empty if they are not defined
141
+ customStyleEditorControl.setStyle(nstyle); // if called from wxsource, update customStyleEditorControl
142
+ sth.style = nstyle;
143
+ setURL(map, time, datasetName, variable, sth.style);
144
+ };
145
+
146
+ const infoControl = new WxInfoControl();
147
+ addControl(map, infoControl, 'bottom-left');
148
+ map.on('mousemove', (e) => infoControl.update(wxsourceLayer, map, position(e)));
149
+
150
+ await apiControl.onchange(datasetName, variable, false); // initial load
308
151
  }
package/dep.dot DELETED
@@ -1,33 +0,0 @@
1
- strict digraph "dependency-cruiser output"{
2
- rankdir="LR" splines="true" overlap="false" nodesep="0.16" ranksep="0.18" fontname="Helvetica-bold" fontsize="9" style="rounded,bold,filled" fillcolor="#ffffff" compound="true"
3
- node [shape="box" style="rounded, filled" height="0.2" color="black" fillcolor="#ffffcc" fontcolor="black" fontname="Helvetica" fontsize="9"]
4
- edge [arrowhead="normal" arrowsize="0.6" penwidth="2.0" color="#00000033" fontname="Helvetica" fontsize="9"]
5
-
6
- subgraph "cluster_src" {label="src" subgraph "cluster_src/customlayer" {label="customlayer" "src/customlayer/customlayer.ts" [label=<customlayer.ts> tooltip="customlayer.ts" URL="src/customlayer/customlayer.ts" fillcolor="#ddfeff"] } }
7
- subgraph "cluster_src" {label="src" "src/index.ts" [label=<index.ts> tooltip="index.ts" URL="src/index.ts" fillcolor="#ddfeff"] }
8
- "src/index.ts" -> "src/customlayer/customlayer.ts" [arrowhead="inv"]
9
- "src/index.ts" -> "src/wxAPI/WxAPI.ts" [arrowhead="inv"]
10
- "src/index.ts" -> "src/wxAPI/WxDataSetManager.ts" [arrowhead="inv"]
11
- "src/index.ts" -> "src/wxlayer/loader.ts" [arrowhead="inv"]
12
- "src/index.ts" -> "src/wxlayer/painter.ts" [arrowhead="inv"]
13
- "src/index.ts" -> "src/wxlayer/WxImplementation.ts" [arrowhead="inv"]
14
- "src/index.ts" -> "src/wxlayer/wxlayer.ts" [arrowhead="inv"]
15
- "src/index.ts" -> "src/wxsource/wxsource.ts" [arrowhead="inv"]
16
- subgraph "cluster_src" {label="src" subgraph "cluster_src/wxAPI" {label="wxAPI" "src/wxAPI/WxAPI.ts" [label=<WxAPI.ts> tooltip="WxAPI.ts" URL="src/wxAPI/WxAPI.ts" fillcolor="#ddfeff"] } }
17
- "src/wxAPI/WxAPI.ts" -> "src/wxAPI/WxDataSetManager.ts"
18
- subgraph "cluster_src" {label="src" subgraph "cluster_src/wxAPI" {label="wxAPI" "src/wxAPI/WxDataSetManager.ts" [label=<WxDataSetManager.ts> tooltip="WxDataSetManager.ts" URL="src/wxAPI/WxDataSetManager.ts" fillcolor="#ddfeff"] } }
19
- "src/wxAPI/WxDataSetManager.ts" -> "src/wxsource/wxsource.ts"
20
- subgraph "cluster_src" {label="src" subgraph "cluster_src/wxlayer" {label="wxlayer" "src/wxlayer/WxImplementation.ts" [label=<WxImplementation.ts> tooltip="WxImplementation.ts" URL="src/wxlayer/WxImplementation.ts" fillcolor="#ddfeff"] } }
21
- "src/wxlayer/WxImplementation.ts" -> "src/wxsource/wxsourcetypes.ts"
22
- "src/wxlayer/WxImplementation.ts" -> "src/wxlayer/wxlayer.ts"
23
- subgraph "cluster_src" {label="src" subgraph "cluster_src/wxlayer" {label="wxlayer" "src/wxlayer/loader.ts" [label=<loader.ts> tooltip="loader.ts" URL="src/wxlayer/loader.ts" fillcolor="#ddfeff"] } }
24
- "src/wxlayer/loader.ts" -> "src/wxlayer/loadertools.ts"
25
- subgraph "cluster_src" {label="src" subgraph "cluster_src/wxlayer" {label="wxlayer" "src/wxlayer/loadertools.ts" [label=<loadertools.ts> tooltip="loadertools.ts" URL="src/wxlayer/loadertools.ts" fillcolor="#ddfeff"] } }
26
- subgraph "cluster_src" {label="src" subgraph "cluster_src/wxlayer" {label="wxlayer" "src/wxlayer/painter.ts" [label=<painter.ts> tooltip="painter.ts" URL="src/wxlayer/painter.ts" fillcolor="#ddfeff"] } }
27
- subgraph "cluster_src" {label="src" subgraph "cluster_src/wxlayer" {label="wxlayer" "src/wxlayer/wxlayer.ts" [label=<wxlayer.ts> tooltip="wxlayer.ts" URL="src/wxlayer/wxlayer.ts" fillcolor="#ddfeff"] } }
28
- "src/wxlayer/wxlayer.ts" -> "src/wxlayer/loader.ts"
29
- "src/wxlayer/wxlayer.ts" -> "src/wxlayer/painter.ts"
30
- subgraph "cluster_src" {label="src" subgraph "cluster_src/wxsource" {label="wxsource" "src/wxsource/wxsource.ts" [label=<wxsource.ts> tooltip="wxsource.ts" URL="src/wxsource/wxsource.ts" fillcolor="#ddfeff"] } }
31
- "src/wxsource/wxsource.ts" -> "src/wxlayer/WxImplementation.ts"
32
- subgraph "cluster_src" {label="src" subgraph "cluster_src/wxsource" {label="wxsource" "src/wxsource/wxsourcetypes.ts" [label=<wxsourcetypes.ts> tooltip="wxsourcetypes.ts" URL="src/wxsource/wxsourcetypes.ts" fillcolor="#ddfeff"] } }
33
- }