@metoceanapi/wxtiles-leaflet 2.1.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +10 -32
  3. package/dist/es/controls/WxAPIControl.d.ts +4 -2
  4. package/dist/es/controls/WxTimeControl .d.ts +1 -1
  5. package/dist/es/index.d.ts +13 -17
  6. package/dist/es/index.js +2 -2
  7. package/dist/es/utils/RawCLUT.d.ts +9 -8
  8. package/dist/es/utils/qtree.d.ts +6 -4
  9. package/dist/es/utils/wxtools.d.ts +12 -5
  10. package/dist/es/wxAPI/WxAPI.d.ts +63 -0
  11. package/dist/es/wxAPI/WxAPItypes.d.ts +152 -0
  12. package/dist/es/wxAPI/WxDataSetManager.d.ts +67 -90
  13. package/dist/es/wxlayer/WxImplementation.d.ts +36 -11
  14. package/dist/es/wxlayer/loader.d.ts +3 -3
  15. package/dist/es/wxlayer/loadertools.d.ts +1 -1
  16. package/dist/es/wxlayer/painter.d.ts +1 -1
  17. package/dist/es/wxlayer/wxlayer.d.ts +48 -26
  18. package/dist/es/wxsource/wxsource.d.ts +3 -1
  19. package/dist/es/wxsource/wxsourcetypes.d.ts +2 -1
  20. package/dist/web/index.js +2 -2
  21. package/docs/docs/assets/highlight.css +4 -4
  22. package/docs/docs/assets/search.js +1 -1
  23. package/docs/docs/classes/CustomWxTilesLayer.html +1 -1
  24. package/docs/docs/classes/DataIntegral.html +13 -13
  25. package/docs/docs/classes/Loader.html +17 -17
  26. package/docs/docs/classes/Painter.html +11 -11
  27. package/docs/docs/classes/QTree.html +63 -34
  28. package/docs/docs/classes/RawCLUT.html +8 -8
  29. package/docs/docs/classes/TilesCache.html +108 -0
  30. package/docs/docs/classes/WxAPI.html +31 -104
  31. package/docs/docs/classes/WxDataSetManager.html +115 -181
  32. package/docs/docs/classes/WxLayer.html +78 -60
  33. package/docs/docs/classes/WxLayerBaseImplementation.html +52 -43
  34. package/docs/docs/classes/WxTileSource.html +63 -47
  35. package/docs/docs/enums/TileType.html +4 -4
  36. package/docs/docs/functions/WXLOG.html +9 -7
  37. package/docs/docs/functions/WxCreateLegend.html +11 -9
  38. package/docs/docs/functions/WxGetColorSchemes.html +9 -7
  39. package/docs/docs/functions/WxGetColorStyles.html +9 -7
  40. package/docs/docs/functions/WxTilesLogging.html +9 -7
  41. package/docs/docs/index.html +21 -20
  42. package/docs/docs/interfaces/CachedUriLoaderPromiseFunc.html +106 -0
  43. package/docs/docs/interfaces/ColorStylesIncomplete.html +9 -7
  44. package/docs/docs/interfaces/Converter.html +5 -3
  45. package/docs/docs/interfaces/DataPicture.html +5 -5
  46. package/docs/docs/interfaces/FrameworkOptions.html +5 -4
  47. package/docs/docs/interfaces/IntegralPare.html +3 -3
  48. package/docs/docs/interfaces/SLinePoint.html +3 -3
  49. package/docs/docs/interfaces/Tree.html +2 -2
  50. package/docs/docs/interfaces/WxAPIOptions.html +15 -15
  51. package/docs/docs/interfaces/WxAllBoundariesMeta.html +4 -4
  52. package/docs/docs/interfaces/WxAllDatasetsShortMetas.html +120 -0
  53. package/docs/docs/interfaces/WxBoundaryMeta.html +5 -5
  54. package/docs/docs/interfaces/WxColorSchemes.html +9 -7
  55. package/docs/docs/interfaces/WxColorStyleStrict.html +27 -27
  56. package/docs/docs/interfaces/WxColorStyleWeak.html +27 -27
  57. package/docs/docs/interfaces/WxColorStylesStrict.html +2 -2
  58. package/docs/docs/interfaces/WxColorStylesWeakMixed.html +9 -7
  59. package/docs/docs/interfaces/WxData.html +3 -3
  60. package/docs/docs/interfaces/WxDataSetManagerOptions.html +12 -12
  61. package/docs/docs/interfaces/WxDatasetMeta.html +18 -9
  62. package/docs/docs/interfaces/WxDatasetShortMeta.html +5 -5
  63. package/docs/docs/interfaces/WxLayerAPI.html +92 -26
  64. package/docs/docs/interfaces/WxLayerBaseAPI.html +21 -21
  65. package/docs/docs/interfaces/WxLayerOptions.html +9 -10
  66. package/docs/docs/interfaces/WxLegend.html +7 -7
  67. package/docs/docs/interfaces/WxLngLat.html +3 -3
  68. package/docs/docs/interfaces/WxRasterData.html +6 -6
  69. package/docs/docs/interfaces/WxRequestInit.html +2 -2
  70. package/docs/docs/interfaces/WxSourceLayerOptions.html +8 -5
  71. package/docs/docs/interfaces/WxTick.html +5 -5
  72. package/docs/docs/interfaces/WxTileInfo.html +9 -9
  73. package/docs/docs/interfaces/WxUnits.html +9 -7
  74. package/docs/docs/interfaces/WxVariableMeta.html +6 -6
  75. package/docs/docs/interfaces/WxVariablesMetas.html +9 -7
  76. package/docs/docs/interfaces/XYZ.html +4 -4
  77. package/docs/docs/modules.html +17 -13
  78. package/docs/docs/types/DataIntegrals.html +9 -7
  79. package/docs/docs/types/DataPictures.html +9 -7
  80. package/docs/docs/types/{UriLoaderPromiseFunc.html → ListenerMethod.html} +21 -23
  81. package/docs/docs/types/SLine.html +9 -7
  82. package/docs/docs/types/SubTrees.html +9 -7
  83. package/docs/docs/types/SubTreesN.html +9 -7
  84. package/docs/docs/types/TreeN.html +9 -7
  85. package/docs/docs/types/WxDate.html +17 -8
  86. package/docs/docs/types/WxEventType.html +116 -0
  87. package/docs/docs/types/{WxVars.html → WxInstances.html} +13 -13
  88. package/docs/docs/types/WxLayerVarsNames.html +113 -0
  89. package/docs/docs/types/WxURIs.html +9 -7
  90. package/docs/docs/types/WxUnitTuple.html +9 -7
  91. package/docs/examples/interactive.html +84 -0
  92. package/docs/examples/seaMaskAndAnimatedBlur.html +30 -22
  93. package/docs/examples/simpleDemo.html +32 -21
  94. package/docs/script/script.js +13 -9
  95. package/package.json +1 -1
  96. package/src_example/frwrkdeps.ts +6 -3
  97. package/src_example/index.ts +31 -54
  98. package/src_example/start.ts +39 -21
  99. package/watch-public.mjs +1 -7
  100. package/dist/es/wxAPI/wxAPI.d.ts +0 -192
  101. package/docs/docs/classes/FrameworkParentClass.html +0 -98
  102. package/docs/docs/interfaces/WxDataSetsMetasJSON.html +0 -75
  103. package/docs/docs/interfaces/WxTilesLibOptions.html +0 -92
@@ -0,0 +1,84 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>WxTiles v2.0</title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <link rel="shortcut icon" href="res/icon.png" type="image/x-icon" />
8
+
9
+ <!-- LEAFLET lib goes first -->
10
+ <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" crossorigin="" />
11
+ <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js" crossorigin=""></script>
12
+
13
+ <!-- WxTile lib goes here -->
14
+ <script src="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.3/dist/web/index.js"></script>
15
+ <link rel="stylesheet" href="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.3/dist/web/index.css" />
16
+ </head>
17
+
18
+ <body style="margin: 0">
19
+ <div id="map" style="height: 100vh; width: 100vw"></div>
20
+ <script>
21
+ ('use strict');
22
+ start();
23
+ async function start() {
24
+ //// Leaflet initialization START
25
+ const map = L.map('map', { center: [0, 0], zoom: 2, zoomControl: true });
26
+ // add navigation controls
27
+ L.control.zoom({ position: 'bottomright' }).addTo(map);
28
+ //// Leaflet initialization END
29
+
30
+ //// Helper
31
+ const addWxLayer = async (wxsource) => {
32
+ map.addLayer(wxsource);
33
+ await new Promise((done) => wxsource.once('load', done)); // highly recommended to await for the first load
34
+ };
35
+
36
+ const getCoords = (e) => e.latlng.wrap();
37
+ //// Helpers END
38
+
39
+ //// WXTILES START
40
+ // grab the WxTiles API
41
+ const { WxTilesLogging, WxAPI } = window.wxtilesleaflet;
42
+
43
+ WxTilesLogging(true); // log WxTiles info to console if needed
44
+
45
+ const dataServerURL = 'https://tiles.metoceanapi.com/data/';
46
+ // Get the API ready - should be ONE per application
47
+ const wxapi = new WxAPI({ dataServerURL, maskURL: 'auto', qtreeURL: 'auto' });
48
+
49
+ // Define the dataset and variable
50
+ const datasetName = 'gfs.global';
51
+ const variable = 'air.temperature.at-2m'; // Scalar example
52
+ // const variable = 'wind.speed.eastward.at-10m'; // Vector example
53
+
54
+ // Create a dataset manager (may be used for many layers from this dataset)
55
+ const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
56
+
57
+ // create a layer
58
+ const layerFrameworkOptions = { id: 'wxsource', opacity: 1, attribution: 'WxTiles' };
59
+ const wxsource = wxdatasetManager.createSourceLayer({ variable }, layerFrameworkOptions);
60
+
61
+ // add the layer to the map
62
+ await addWxLayer(wxsource);
63
+
64
+ // extra magic
65
+ // on mouse movement, add a new color to the color map and re-render the layer
66
+ await wxsource.updateCurrentStyleObject({ levels: undefined, mask: 'land' }); // reset levels if existing in the style
67
+
68
+ const levels = wxsource.getCurrentStyleObjectCopy().levels || []; // get current/default/any levels
69
+ // generate a new color map from the existing levels
70
+ const colMap = levels.map((level) => [level, '#' + Math.random().toString(16).slice(2, 8) + 'ff']);
71
+ let busy = false;
72
+ map.on('mousemove', async (e) => {
73
+ if (!wxsource || busy) return;
74
+ busy = true;
75
+ const tileInfo = wxsource.getLayerInfoAtLatLon(getCoords(e), map);
76
+ if (tileInfo) {
77
+ await wxsource.updateCurrentStyleObject({ colorMap: [...colMap, [tileInfo.inStyleUnits[0], '#ff000000']] });
78
+ }
79
+ busy = false;
80
+ });
81
+ }
82
+ </script>
83
+ </body>
84
+ </html>
@@ -11,8 +11,8 @@
11
11
  <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js" crossorigin=""></script>
12
12
 
13
13
  <!-- WxTile lib goes here -->
14
- <script src="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.1/dist/web/index.js"></script>
15
- <link rel="stylesheet" href="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.1/dist/web/index.css" />
14
+ <script src="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.3/dist/web/index.js"></script>
15
+ <link rel="stylesheet" href="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.3/dist/web/index.css" />
16
16
  </head>
17
17
 
18
18
  <body style="margin: 0">
@@ -20,23 +20,34 @@
20
20
 
21
21
  <script>
22
22
  ('use strict');
23
- simpleDemo();
24
- async function simpleDemo() {
25
- const { WxTilesLogging, WxAPI } = window.wxtilesleaflet;
26
-
23
+ start();
24
+ async function start() {
25
+ //// Leaflet initialization START
27
26
  const map = L.map('map', { center: [0, 0], zoom: 2, zoomControl: true });
27
+ // add navigation controls
28
+ L.control.zoom({ position: 'bottomright' }).addTo(map);
29
+ //// Leaflet initialization END
30
+
31
+ //// Helper
32
+ const addWxLayer = async (wxsource) => {
33
+ map.addLayer(wxsource);
34
+ await new Promise((done) => wxsource.once('load', done)); // highly recommended to await for the first load
35
+ };
36
+
37
+ const getCoords = (e) => e.latlng.wrap();
38
+ //// Helpers END
28
39
 
29
- const dataServerURL = 'https://tilestest.metoceanapi.com/data/';
30
- // const headers = new Headers();
31
- // headers.append('x-api-key', '--proper-key-value--'); // If needed in the future
32
- const requestInit = {
33
- /* headers */
34
- }; // add more options if needed such as headers, mode, credentials, etc
40
+ //// WXTILES START
41
+ // grab the WxTiles API
42
+ const { WxTilesLogging, WxAPI } = window.wxtilesleaflet;
43
+
44
+ WxTilesLogging(true); // log WxTiles info to console if needed
35
45
 
46
+ const dataServerURL = 'https://tiles.metoceanapi.com/data/';
36
47
  // Get the API ready - should be ONE per application
37
- WxTilesLogging(true); // If needed
38
- const wxapi = new WxAPI({ dataServerURL, maskURL: 'auto', qtreeURL: 'auto', requestInit });
48
+ const wxapi = new WxAPI({ dataServerURL, maskURL: 'auto', qtreeURL: 'auto' });
39
49
 
50
+ // Define the dataset and variable
40
51
  const datasetName = 'gfs.global';
41
52
  const variable = 'air.temperature.at-2m'; // Scalar example
42
53
  // const variable = 'wind.speed.eastward.at-10m'; // Vector example
@@ -45,18 +56,15 @@
45
56
  const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
46
57
 
47
58
  // create a layer
48
- const leafletOptions = { id: 'wxsource', opacity: 1, attribution: 'WxTiles' };
49
- const wxsource = wxdatasetManager.createSourceLayer({ variable }, leafletOptions);
59
+ const layerFrameworkOptions = { id: 'wxsource', opacity: 1, attribution: 'WxTiles' };
60
+ const wxsource = wxdatasetManager.createSourceLayer({ variable }, layerFrameworkOptions);
50
61
 
51
62
  // add the layer to the map
52
- map.addLayer(wxsource);
53
-
54
- // await for the first load
55
- await new Promise((done) => wxsource.once('load', done)); // highly recommended to await for the first load
63
+ await addWxLayer(wxsource);
56
64
 
65
+ // extra magic
57
66
  // update the style: mask sea
58
- await wxsource.updateCurrentStyleObject({ mask: 'sea' });
59
-
67
+ await wxsource.updateCurrentStyleObject({ mask: 'land' });
60
68
  // start the blur animation
61
69
  (async function step(n = 0) {
62
70
  await wxsource.updateCurrentStyleObject({ isolineText: false, blurRadius: ~~(10 * Math.sin(n / 500) + 10) });
@@ -11,8 +11,8 @@
11
11
  <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js" crossorigin=""></script>
12
12
 
13
13
  <!-- WxTile lib goes here -->
14
- <script src="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.1/dist/web/index.js"></script>
15
- <link rel="stylesheet" href="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.1/dist/web/index.css" />
14
+ <script src="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.3/dist/web/index.js"></script>
15
+ <link rel="stylesheet" href="https://unpkg.com/@metoceanapi/wxtiles-leaflet@2.1.3/dist/web/index.css" />
16
16
  </head>
17
17
 
18
18
  <body style="margin: 0">
@@ -20,39 +20,50 @@
20
20
 
21
21
  <script>
22
22
  ('use strict');
23
- simpleDemo();
24
- async function simpleDemo() {
25
- const { WxTilesLogging, WxAPI } = window.wxtilesleaflet;
26
-
23
+ start();
24
+ async function start() {
25
+ //// Leaflet initialization START
27
26
  const map = L.map('map', { center: [0, 0], zoom: 2, zoomControl: true });
27
+ // add navigation controls
28
+ L.control.zoom({ position: 'bottomright' }).addTo(map);
29
+ //// Leaflet initialization END
30
+
31
+ //// Helper
32
+ const addWxLayer = async (wxsource) => {
33
+ map.addLayer(wxsource);
34
+ await new Promise((done) => wxsource.once('load', done)); // highly recommended to await for the first load
35
+ };
36
+
37
+ const getCoords = (e) => e.latlng.wrap();
38
+ //// Helpers END
39
+
40
+ //// WXTILES START
41
+ // grab the WxTiles API
42
+ const { WxTilesLogging, WxAPI } = window.wxtilesleaflet;
28
43
 
29
- const dataServerURL = 'https://tilestest.metoceanapi.com/data/';
30
- // const headers = new Headers();
31
- // headers.append('x-api-key', '--proper-key-value--'); // If needed in the future
32
- const requestInit = {
33
- /* headers */
34
- }; // add more options if needed such as headers, mode, credentials, etc
44
+ WxTilesLogging(true); // log WxTiles info to console if needed
35
45
 
46
+ const dataServerURL = 'https://tiles.metoceanapi.com/data/';
36
47
  // Get the API ready - should be ONE per application
37
- WxTilesLogging(true); // If needed
38
- const wxapi = new WxAPI({ dataServerURL, maskURL: 'auto', qtreeURL: 'auto', requestInit });
48
+ const wxapi = new WxAPI({ dataServerURL, maskURL: 'auto', qtreeURL: 'auto' });
39
49
 
50
+ // Define the dataset and variable
40
51
  const datasetName = 'gfs.global';
41
- const variable = 'air.temperature.at-2m'; // Scalar example
42
- // const variable = 'wind.speed.eastward.at-10m'; // Vector example
52
+ // const variable = 'air.temperature.at-2m'; // Scalar example
53
+ const variable = 'wind.speed.eastward.at-10m'; // Vector example
43
54
 
44
55
  // Create a dataset manager (may be used for many layers from this dataset)
45
56
  const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
46
57
 
47
58
  // create a layer
48
- const leafletOptions = { id: 'wxsource', opacity: 1, attribution: 'WxTiles' };
49
- const wxsource = wxdatasetManager.createSourceLayer({ variable }, leafletOptions);
59
+ const layerFrameworkOptions = { id: 'wxsource', opacity: 1, attribution: 'WxTiles' };
60
+ const wxsource = wxdatasetManager.createSourceLayer({ variable }, layerFrameworkOptions);
50
61
 
51
62
  // add the layer to the map
52
- map.addLayer(wxsource);
63
+ await addWxLayer(wxsource);
53
64
 
54
- // await for the first load
55
- await new Promise((done) => wxsource.once('load', done)); // highly recommended to await for the first load
65
+ // extra magic
66
+ await wxsource.updateCurrentStyleObject({ streamLineColor: 'inverted' });
56
67
  }
57
68
  </script>
58
69
  </body>