@metoceanapi/wxtiles-leaflet 2.1.1 → 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.
- package/CHANGELOG.md +4 -0
- package/README.md +10 -32
- package/dist/es/controls/WxAPIControl.d.ts +4 -2
- package/dist/es/controls/WxStyleEditorControl.d.ts +5 -0
- package/dist/es/controls/WxTimeControl .d.ts +1 -1
- package/dist/es/customlayer/customlayer.d.ts +2 -0
- package/dist/es/index.d.ts +14 -17
- package/dist/es/index.js +2 -2
- package/dist/es/utils/RawCLUT.d.ts +9 -8
- package/dist/es/utils/qtree.d.ts +6 -4
- package/dist/es/utils/tests_wxtools.d.ts +1 -0
- package/dist/es/utils/wxtools.d.ts +32 -5
- package/dist/es/wxAPI/WxAPI.d.ts +63 -0
- package/dist/es/wxAPI/WxAPItypes.d.ts +152 -0
- package/dist/es/wxAPI/WxDataSetManager.d.ts +67 -90
- package/dist/es/wxlayer/WxImplementation.d.ts +36 -16
- package/dist/es/wxlayer/loader.d.ts +3 -5
- package/dist/es/wxlayer/loadertools.d.ts +1 -1
- package/dist/es/wxlayer/painter.d.ts +1 -1
- package/dist/es/wxlayer/wxlayer.d.ts +51 -26
- package/dist/es/wxsource/wxsource.d.ts +3 -1
- package/dist/es/wxsource/wxsourcetypes.d.ts +2 -1
- package/dist/web/index.js +2 -2
- package/docs/docs/assets/highlight.css +4 -4
- package/docs/docs/assets/main.js +56 -52
- package/docs/docs/assets/search.js +1 -1
- package/docs/docs/assets/style.css +27 -5
- package/docs/docs/{interfaces/WxDataSetsMetasJSON.html → classes/CustomWxTilesLayer.html} +16 -23
- package/docs/docs/classes/DataIntegral.html +13 -13
- package/docs/docs/classes/Loader.html +17 -24
- package/docs/docs/classes/Painter.html +11 -11
- package/docs/docs/classes/QTree.html +63 -34
- package/docs/docs/classes/RawCLUT.html +8 -8
- package/docs/docs/classes/TilesCache.html +108 -0
- package/docs/docs/classes/WxAPI.html +33 -106
- package/docs/docs/classes/WxDataSetManager.html +115 -181
- package/docs/docs/classes/WxLayer.html +95 -58
- package/docs/docs/classes/WxLayerBaseImplementation.html +52 -43
- package/docs/docs/classes/WxTileSource.html +63 -47
- package/docs/docs/enums/TileType.html +4 -4
- package/docs/docs/functions/WXLOG.html +11 -8
- package/docs/docs/functions/WxCreateLegend.html +13 -10
- package/docs/docs/functions/WxGetColorSchemes.html +11 -8
- package/docs/docs/functions/WxGetColorStyles.html +11 -8
- package/docs/docs/functions/WxTilesLogging.html +11 -8
- package/docs/docs/index.html +23 -21
- package/docs/docs/interfaces/CachedUriLoaderPromiseFunc.html +106 -0
- package/docs/docs/interfaces/ColorStylesIncomplete.html +11 -8
- package/docs/docs/interfaces/Converter.html +5 -3
- package/docs/docs/interfaces/DataPicture.html +5 -5
- package/docs/docs/interfaces/FrameworkOptions.html +5 -4
- package/docs/docs/interfaces/IntegralPare.html +3 -3
- package/docs/docs/interfaces/SLinePoint.html +3 -3
- package/docs/docs/interfaces/Tree.html +2 -2
- package/docs/docs/interfaces/WxAPIOptions.html +15 -15
- package/docs/docs/interfaces/WxAllBoundariesMeta.html +4 -4
- package/docs/docs/interfaces/WxAllDatasetsShortMetas.html +120 -0
- package/docs/docs/interfaces/WxBoundaryMeta.html +5 -5
- package/docs/docs/interfaces/WxColorSchemes.html +11 -8
- package/docs/docs/interfaces/WxColorStyleStrict.html +47 -25
- package/docs/docs/interfaces/WxColorStyleWeak.html +48 -25
- package/docs/docs/interfaces/WxColorStylesStrict.html +2 -2
- package/docs/docs/interfaces/WxColorStylesWeakMixed.html +11 -8
- package/docs/docs/interfaces/WxData.html +3 -3
- package/docs/docs/interfaces/WxDataSetManagerOptions.html +12 -12
- package/docs/docs/interfaces/WxDatasetMeta.html +18 -9
- package/docs/docs/interfaces/WxDatasetShortMeta.html +5 -5
- package/docs/docs/interfaces/WxLayerAPI.html +92 -26
- package/docs/docs/interfaces/WxLayerBaseAPI.html +21 -21
- package/docs/docs/interfaces/WxLayerOptions.html +9 -10
- package/docs/docs/interfaces/WxLegend.html +7 -7
- package/docs/docs/interfaces/WxLngLat.html +3 -3
- package/docs/docs/interfaces/WxRasterData.html +6 -6
- package/docs/docs/interfaces/WxRequestInit.html +2 -2
- package/docs/docs/interfaces/WxSourceLayerOptions.html +8 -5
- package/docs/docs/interfaces/WxTick.html +5 -5
- package/docs/docs/interfaces/WxTileInfo.html +9 -9
- package/docs/docs/interfaces/WxUnits.html +11 -8
- package/docs/docs/interfaces/WxVariableMeta.html +6 -6
- package/docs/docs/interfaces/WxVariablesMetas.html +11 -8
- package/docs/docs/interfaces/XYZ.html +4 -4
- package/docs/docs/modules.html +20 -14
- package/docs/docs/types/DataIntegrals.html +11 -8
- package/docs/docs/types/DataPictures.html +11 -8
- package/docs/docs/types/ListenerMethod.html +129 -0
- package/docs/docs/types/SLine.html +11 -8
- package/docs/docs/types/SubTrees.html +11 -8
- package/docs/docs/types/SubTreesN.html +11 -8
- package/docs/docs/types/TreeN.html +11 -8
- package/docs/docs/types/WxDate.html +19 -9
- package/docs/docs/types/{UriLoaderPromiseFunc.html → WxEventType.html} +17 -31
- package/docs/docs/types/{WxVars.html → WxInstances.html} +15 -14
- package/docs/docs/types/WxLayerVarsNames.html +113 -0
- package/docs/docs/types/WxURIs.html +11 -8
- package/docs/docs/types/WxUnitTuple.html +11 -8
- package/docs/examples/interactive.html +84 -0
- package/docs/examples/seaMaskAndAnimatedBlur.html +30 -22
- package/docs/examples/simpleDemo.html +32 -21
- package/docs/script/script.js +13 -9
- package/package.json +6 -7
- package/src_example/frwrkdeps.ts +6 -3
- package/src_example/index.ts +31 -54
- package/src_example/start.ts +39 -18
- package/watch-public.mjs +93 -0
- package/dist/es/wxAPI/wxAPI.d.ts +0 -192
- package/docs/docs/classes/FrameworkParentClass.html +0 -98
- package/docs/docs/interfaces/WxTilesLibOptions.html +0 -92
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metoceanapi/wxtiles-leaflet",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "WxTile JS lib to render wxtiles datalayers",
|
|
5
5
|
"main": "dist/es/index.js",
|
|
6
6
|
"types": "dist/es/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build_DEMO_Docs": "npm run build && npm run buildDOCS && node build-for-docs.js",
|
|
9
|
-
"start": "PORT=3002 node watch-public.
|
|
9
|
+
"start": "PORT=3002 node watch-public.mjs",
|
|
10
10
|
"build": "rm -rf dist/ && node build.js && tsc",
|
|
11
11
|
"buildDOCS": "./node_modules/.bin/typedoc --out docs/docs --excludeExternals -gitRevision main src",
|
|
12
12
|
"preversion": "npm run build",
|
|
@@ -25,13 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/metoceanapi/wxtiles-leaflet#readme",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/leaflet": "^1.9.
|
|
28
|
+
"@types/leaflet": "^1.9.3",
|
|
29
29
|
"changelogkeeper": "^1.2.0",
|
|
30
|
-
"esbuild": "^0.
|
|
30
|
+
"esbuild": "^0.17.18",
|
|
31
31
|
"esbuild-plugin-external-global": "^1.0.1",
|
|
32
|
-
"express": "^4.18.2",
|
|
33
32
|
"leaflet": "^1.9.3",
|
|
34
|
-
"typedoc": "^0.23.
|
|
35
|
-
"typescript": "^4.9.
|
|
33
|
+
"typedoc": "^0.23.28",
|
|
34
|
+
"typescript": "^4.9.5"
|
|
36
35
|
}
|
|
37
36
|
}
|
package/src_example/frwrkdeps.ts
CHANGED
|
@@ -8,7 +8,10 @@ export function flyTo(map: L.Map, zoom: number, lng: number, lat: number, bearin
|
|
|
8
8
|
export function setURL(map: L.Map, time: string, datasetName: string, variable: string, style: any) {
|
|
9
9
|
const base = WxGetColorStyles()['base'];
|
|
10
10
|
for (const i in style) style[i] === base[i] && delete style[i]; // remove default values
|
|
11
|
-
|
|
11
|
+
if (style.gl) {
|
|
12
|
+
for (const i in style.gl) style.gl[i] === base.gl?.[i] && delete style.gl[i]; // remove default values from gl
|
|
13
|
+
Object.keys(style.gl).length === 0 && delete style.gl; // remove gl if empty
|
|
14
|
+
}
|
|
12
15
|
const center = map.getCenter().wrap();
|
|
13
16
|
const href =
|
|
14
17
|
`##${datasetName}/${variable}/${time}/${map.getZoom().toFixed(2)}/${center.lng.toFixed(2)}/${center.lat.toFixed(2)}/0/0` +
|
|
@@ -62,7 +65,7 @@ export async function addLayer(map: L.Map, idL: string, layer: L.Layer) {
|
|
|
62
65
|
await new Promise((done) => layer.once('load', done)); // highly recommended to await for the first load
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
export function addRaster(map: L.Map, idS: string, idL: string, URL: string, maxZoom: number) {
|
|
66
|
-
const layer = L.tileLayer(URL, { id: idS, maxNativeZoom: maxZoom, zIndex: idL === 'baseL' ?
|
|
68
|
+
export function addRaster(map: L.Map, idS: string, idL: string, URL: string, maxZoom: number, bounds?: any) {
|
|
69
|
+
const layer = L.tileLayer(URL, { id: idS, maxNativeZoom: maxZoom, zIndex: idL === 'baseL' ? 1 : 0 });
|
|
67
70
|
map.addLayer(layer);
|
|
68
71
|
}
|
package/src_example/index.ts
CHANGED
|
@@ -6,73 +6,50 @@ start();
|
|
|
6
6
|
/*
|
|
7
7
|
import L from 'leaflet'; // goes first always!
|
|
8
8
|
import { WxTileSource, WxAPI, WxTilesLogging, FrameworkOptions } from '../src/index';
|
|
9
|
-
// simpleDemo();
|
|
10
|
-
// twoLayersDemo();
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
start1();
|
|
11
|
+
async function start1() {
|
|
12
|
+
//// Leaflet initialization START
|
|
13
13
|
const map = L.map('map', { center: [0, 0], zoom: 2, zoomControl: true });
|
|
14
|
+
// add navigation controls
|
|
15
|
+
L.control.zoom({ position: 'bottomright' }).addTo(map);
|
|
16
|
+
//// Leaflet initialization END
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}; // add more options if needed such as headers, mode, credentials, etc
|
|
21
|
-
|
|
22
|
-
// Get the API ready - should be ONE per application
|
|
23
|
-
WxTilesLogging(true); // If needed
|
|
24
|
-
const wxapi = new WxAPI({ dataServerURL, maskURL: 'none', qtreeURL: 'none', requestInit });
|
|
25
|
-
|
|
26
|
-
const datasetName = 'gfs.global';
|
|
27
|
-
const variable = 'air.temperature.at-2m'; // Scalar example
|
|
28
|
-
// const variable = 'wind.speed.eastward.at-10m'; // Vector example
|
|
18
|
+
//// Helper
|
|
19
|
+
const addWxLayer = async (wxsource) => {
|
|
20
|
+
map.addLayer(wxsource);
|
|
21
|
+
await new Promise((done) => wxsource.once('load', done)); // highly recommended to await for the first load
|
|
22
|
+
};
|
|
29
23
|
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
const getCoords = (e) => e.latlng.wrap();
|
|
25
|
+
//// Helpers END
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
const
|
|
27
|
+
//// WXTILES START
|
|
28
|
+
// grab the WxTiles API
|
|
29
|
+
// const { WxTilesLogging, WxAPI } = window.wxtilesleaflet;
|
|
36
30
|
|
|
37
|
-
//
|
|
38
|
-
const leafletOptions: FrameworkOptions = { id: 'wxsource', opacity: 1, attribution: 'WxTiles' };
|
|
39
|
-
const wxsource = new WxTileSource({ wxdatasetManager, variables }, leafletOptions);
|
|
40
|
-
|
|
41
|
-
// add the layer to the map
|
|
42
|
-
map.addLayer(wxsource);
|
|
31
|
+
WxTilesLogging(true); // log WxTiles info to console if needed
|
|
43
32
|
|
|
44
|
-
// await for the first load
|
|
45
|
-
await new Promise((done) => wxsource.once('load', done)); // highly recommended to await for the first load
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function twoLayersDemo() {
|
|
49
33
|
const dataServerURL = 'https://tiles.metoceanapi.com/data/';
|
|
50
|
-
const requestInit: RequestInit = {
|
|
51
|
-
// headers: new Headers([['x-api-key', '--proper-key-value--']]),
|
|
52
|
-
}; // add more options if needed such as headers, mode, credentials, etc
|
|
53
|
-
|
|
54
34
|
// Get the API ready - should be ONE per application
|
|
55
|
-
|
|
56
|
-
|
|
35
|
+
const wxapi = new WxAPI({ dataServerURL, maskURL: 'auto', qtreeURL: 'auto' });
|
|
36
|
+
|
|
37
|
+
// Define the dataset and variable
|
|
38
|
+
const datasetName = 'gfs.global';
|
|
39
|
+
// const variable = 'air.temperature.at-2m'; // Scalar example
|
|
40
|
+
const variable = 'wind.speed.eastward.at-10m'; // Vector example
|
|
57
41
|
|
|
58
42
|
// Create a dataset manager (may be used for many layers from this dataset)
|
|
59
|
-
const wxdatasetManager = await wxapi.createDatasetManager(
|
|
43
|
+
const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
|
|
60
44
|
|
|
61
45
|
// create a layer
|
|
62
|
-
const
|
|
63
|
-
const wxsource = wxdatasetManager.createSourceLayer({ variable:
|
|
46
|
+
const layerFrameworkOptions = { id: 'wxsource', opacity: 1, attribution: 'WxTiles' };
|
|
47
|
+
const wxsource = wxdatasetManager.createSourceLayer({ variable, time: 0 }, layerFrameworkOptions);
|
|
64
48
|
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
const wxsource1 = wxdatasetManager.createSourceLayer({ variable: 'air.visibility' }, leafletOptions1);
|
|
49
|
+
// add the layer to the map
|
|
50
|
+
await addWxLayer(wxsource);
|
|
68
51
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
// add leaflet layerGroup to map
|
|
72
|
-
const group = L.layerGroup([wxsource, wxsource1]).addTo(map);
|
|
73
|
-
// create control
|
|
74
|
-
const control = L.control.layers(undefined, { wxsource, wxsource1 }).addTo(map);
|
|
75
|
-
// add the group to the control layer
|
|
76
|
-
control.addOverlay(group, 'wxsources group');
|
|
52
|
+
// extra magic
|
|
53
|
+
await wxsource.updateCurrentStyleObject({ streamLineColor: 'inverted' });
|
|
77
54
|
}
|
|
78
|
-
*/
|
|
55
|
+
// */
|
package/src_example/start.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WxTileSource,
|
|
1
|
+
import { WxTileSource, WxAPI, WxTilesLogging, type WxTileInfo, FrameworkOptions, WxGetColorStyles, WXLOG, WxColorStyleWeak } from '../src/index';
|
|
2
2
|
import { WxLegendControl } from '../src/controls/WxLegendControl';
|
|
3
3
|
import { WxStyleEditorControl } from '../src/controls/WxStyleEditorControl';
|
|
4
4
|
import { WxInfoControl } from '../src/controls/WxInfoControl';
|
|
@@ -6,19 +6,23 @@ import { WxTimeControl } from '../src/controls/WxTimeControl ';
|
|
|
6
6
|
import { WxAPIControl } from '../src/controls/WxAPIControl';
|
|
7
7
|
import { initFrameWork, addRaster, flyTo, setURL, addControl, removeLayer, addLayer, position } from './frwrkdeps';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const OPACITY = 0.8;
|
|
10
10
|
|
|
11
11
|
// this is universal function for Leaflet and Mapbox.
|
|
12
12
|
// Functions below are just framework specific wrappers for this universal function
|
|
13
13
|
// start() is the fully interchangable function for Leaflet and Mapbox
|
|
14
14
|
export async function start() {
|
|
15
15
|
const map = await initFrameWork();
|
|
16
|
-
addRaster(map, 'baseS', 'baseL', 'https://
|
|
16
|
+
addRaster(map, 'baseS', 'baseL', 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', 3);
|
|
17
|
+
// addRaster(map, 'baseS', 'baseL', 'https://tiles.metoceanapi.com/base-lines/{z}/{x}/{y}', 5);
|
|
17
18
|
// WxTilesLogging(console.trace);
|
|
19
|
+
// const dataServerURL = 'data/'; // different sources manged in 'start' script in package.json
|
|
20
|
+
// const dataServerURL = 'https://tilestest.metoceanapi.com/data/';
|
|
18
21
|
// const dataServerURL = 'http://localhost:9191/data/';
|
|
19
|
-
// const dataServerURL = 'https://68.171.214.87/data/'
|
|
20
|
-
const dataServerURL = 'https://
|
|
21
|
-
// const dataServerURL = '
|
|
22
|
+
// const dataServerURL = 'https://68.171.214.87/data/'; // hihi1
|
|
23
|
+
// const dataServerURL = 'https://68.171.214.81/data/'; // hihi2
|
|
24
|
+
// const dataServerURL = 'https://hihi2.metoceanapi.com/data/';
|
|
25
|
+
const dataServerURL = 'https://tilesdev.metoceanapi.com/data/';
|
|
22
26
|
const myHeaders = new Headers();
|
|
23
27
|
// myHeaders.append('x-api-key', 'SpV3J1RypVrv2qkcJE91gG');
|
|
24
28
|
const wxapi = new WxAPI({
|
|
@@ -29,9 +33,11 @@ export async function start() {
|
|
|
29
33
|
requestInit: { headers: myHeaders },
|
|
30
34
|
});
|
|
31
35
|
|
|
32
|
-
// let datasetName = '
|
|
36
|
+
// let datasetName = 'ecmwf.global'; /* 'mercator.global/'; */ /* 'gfs.global/'; */ /* 'obs-radar.rain.nzl.national/'; */
|
|
37
|
+
// let variable = 'cloud.cover';
|
|
33
38
|
// let variable = 'air.temperature.at-2m';
|
|
34
|
-
// let
|
|
39
|
+
// let variable = 'wind.speed.eastward.at-10m';
|
|
40
|
+
// let variable = 'wave.direction.peak';
|
|
35
41
|
|
|
36
42
|
// let datasetName = 'ww3-ecmwf.global';
|
|
37
43
|
// let variable = 'wave.direction.mean';
|
|
@@ -39,6 +45,9 @@ export async function start() {
|
|
|
39
45
|
let datasetName = 'obs-radar.rain.nzl.national';
|
|
40
46
|
let variable = 'reflectivity';
|
|
41
47
|
|
|
48
|
+
// let datasetName = 'him8_truecolor';
|
|
49
|
+
// let variable = 'h8_rgb';
|
|
50
|
+
|
|
42
51
|
// get datasetName from URL
|
|
43
52
|
const urlParams = window.location.toString().split('##')[1];
|
|
44
53
|
const params = urlParams?.split('/');
|
|
@@ -74,18 +83,18 @@ export async function start() {
|
|
|
74
83
|
const legendControl = new WxLegendControl();
|
|
75
84
|
addControl(map, legendControl, 'top-right');
|
|
76
85
|
|
|
77
|
-
const frameworkOptions = { id: 'wxsource', opacity: OPACITY, attribution: 'WxTiles' };
|
|
86
|
+
const frameworkOptions = { id: 'wxsource', opacity: OPACITY, attribution: '<a href="https://metoceanapi.github.io/wxtiles-mbox/docs">WxTiles DOCS</a>' };
|
|
78
87
|
const apiControl = new WxAPIControl(wxapi, datasetName, variable);
|
|
79
88
|
addControl(map, apiControl, 'top-left');
|
|
80
|
-
apiControl.onchange = async (
|
|
81
|
-
|
|
89
|
+
apiControl.onchange = async (_datasetName, _variable, resetStyleAndFlyTo = true): Promise<void> => {
|
|
90
|
+
datasetName = _datasetName;
|
|
91
|
+
variable = _variable;
|
|
92
|
+
WXLOG('apiControl.onchange datasetName=', datasetName, 'variable=', variable);
|
|
82
93
|
// remove existing source and layer
|
|
83
94
|
removeLayer(map, frameworkOptions.id, wxsourceLayer);
|
|
84
95
|
//
|
|
85
96
|
resetStyleAndFlyTo && (sth.style = {}); // reset style if change dataset/variable
|
|
86
97
|
wxsourceLayer = undefined;
|
|
87
|
-
datasetName = datasetName_;
|
|
88
|
-
variable = variable_;
|
|
89
98
|
const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
|
|
90
99
|
const boundaries = wxdatasetManager.getBoundaries();
|
|
91
100
|
if (boundaries && resetStyleAndFlyTo) {
|
|
@@ -93,13 +102,24 @@ export async function start() {
|
|
|
93
102
|
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
|
|
94
103
|
flyTo(map, zoom, (east + west) / 2, (north + south) / 2, 0, 0);
|
|
95
104
|
}
|
|
96
|
-
const meta = wxdatasetManager.
|
|
105
|
+
const meta = wxdatasetManager.getVariableCurrentMeta(variable);
|
|
97
106
|
if (meta?.units === 'RGB') {
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
const times = wxdatasetManager.getAllTimes();
|
|
108
|
+
|
|
109
|
+
addRaster(
|
|
110
|
+
map,
|
|
111
|
+
frameworkOptions.id,
|
|
112
|
+
'wxtiles',
|
|
113
|
+
wxdatasetManager.createURI(variable, times[0]),
|
|
114
|
+
wxdatasetManager.getMaxZoom(),
|
|
115
|
+
wxdatasetManager.getBoundaries()?.boundariesnorm
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
timeControl.setTimes(times);
|
|
100
119
|
legendControl.clear();
|
|
101
120
|
} else {
|
|
102
121
|
wxsourceLayer = wxdatasetManager.createSourceLayer({ variable, time, wxstyle: sth.style }, frameworkOptions);
|
|
122
|
+
wxsourceLayer.setCoarseLevel(0);
|
|
103
123
|
await addLayer(map, 'wxtiles', wxsourceLayer);
|
|
104
124
|
// wxsource.startAnimation();
|
|
105
125
|
const styleCopy = wxsourceLayer.getCurrentStyleObjectCopy();
|
|
@@ -107,9 +127,10 @@ export async function start() {
|
|
|
107
127
|
styleCopy.levels = sth.style?.levels; // no need to show defaults it in the editor and URL
|
|
108
128
|
styleCopy.colors = sth.style?.colors; // no need to show defaults it in the editor and URL
|
|
109
129
|
await customStyleEditorControl.onchange?.(styleCopy, true);
|
|
130
|
+
timeControl.updateSource(wxsourceLayer);
|
|
110
131
|
}
|
|
111
|
-
|
|
112
|
-
|
|
132
|
+
// apiControl.datasets.value = datasetName;
|
|
133
|
+
// apiControl.variables.value = variable;
|
|
113
134
|
};
|
|
114
135
|
|
|
115
136
|
const timeControl = new WxTimeControl(50);
|
package/watch-public.mjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// import { type BuildOptions, context } from 'esbuild';
|
|
2
|
+
import * as esbuild from 'esbuild';
|
|
3
|
+
import http from 'node:http';
|
|
4
|
+
|
|
5
|
+
const PORT = +process.env.PORT || 3000;
|
|
6
|
+
|
|
7
|
+
const buildOptions = {
|
|
8
|
+
entryPoints: ['src_example/index.ts'],
|
|
9
|
+
bundle: true,
|
|
10
|
+
loader: {
|
|
11
|
+
'.png': 'base64',
|
|
12
|
+
'.woff': 'base64',
|
|
13
|
+
},
|
|
14
|
+
format: 'iife',
|
|
15
|
+
outfile: 'public/script/script.js',
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
minify: false,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
let ctx = await esbuild.context(buildOptions);
|
|
21
|
+
await ctx.watch();
|
|
22
|
+
console.log('watching...');
|
|
23
|
+
|
|
24
|
+
const { host, port } = await ctx.serve({ host: 'localhost', port: PORT + 1000, servedir: 'public' });
|
|
25
|
+
console.log(`Dev is running at ${host}:${PORT}`);
|
|
26
|
+
|
|
27
|
+
// Then start a proxy server on PORT
|
|
28
|
+
// https://esbuild.github.io/api/#serve-proxy
|
|
29
|
+
http
|
|
30
|
+
.createServer((req, res) => {
|
|
31
|
+
const options = {
|
|
32
|
+
hostname: host,
|
|
33
|
+
port: port,
|
|
34
|
+
path: req.url,
|
|
35
|
+
method: req.method,
|
|
36
|
+
headers: req.headers,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (req.url.startsWith('/data/masks')) {
|
|
40
|
+
options.port = 9191; // all from local 'simple NGINX'
|
|
41
|
+
} else if (req.url.startsWith('/data')) {
|
|
42
|
+
options.port = 8080; // wxtiles-http-server
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Forward each incoming request to esbuild
|
|
46
|
+
const proxyReq = http.request(options, (proxyRes) => {
|
|
47
|
+
res.writeHead(proxyRes.statusCode, proxyRes.headers);
|
|
48
|
+
proxyRes.pipe(res, { end: true });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Forward the body of the request to esbuild
|
|
52
|
+
req.pipe(proxyReq, { end: true });
|
|
53
|
+
})
|
|
54
|
+
.listen(PORT);
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
// OLD CODE using express. Works with esbuild 0.15, but not with 0.17
|
|
58
|
+
esbuild
|
|
59
|
+
.build({
|
|
60
|
+
entryPoints: ['src_example/index.ts'],
|
|
61
|
+
bundle: true,
|
|
62
|
+
plugins: [],
|
|
63
|
+
loader: {
|
|
64
|
+
'.png': 'base64',
|
|
65
|
+
'.woff': 'base64',
|
|
66
|
+
},
|
|
67
|
+
target: 'es2020',
|
|
68
|
+
format: 'iife',
|
|
69
|
+
outfile: 'public/script/script.js',
|
|
70
|
+
sourcemap: true,
|
|
71
|
+
minify: false,
|
|
72
|
+
watch: {
|
|
73
|
+
onRebuild(error, result) {
|
|
74
|
+
if (error) {
|
|
75
|
+
console.error('watch build failed:', error);
|
|
76
|
+
} else {
|
|
77
|
+
console.log('rebuilded', new Date());
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
.then((result) => {
|
|
83
|
+
const app = express();
|
|
84
|
+
app.use(express.static('public'));
|
|
85
|
+
|
|
86
|
+
const url = `http://localhost:${PORT}`;
|
|
87
|
+
app.listen(PORT, () => {
|
|
88
|
+
console.log(`Dev is running at ${url}`);
|
|
89
|
+
});
|
|
90
|
+
})
|
|
91
|
+
.catch((e) => console.error(e.message));
|
|
92
|
+
|
|
93
|
+
*/
|
package/dist/es/wxAPI/wxAPI.d.ts
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import './wxtiles.css';
|
|
2
|
-
import { XYZ, WxTilesLibOptions } from '../utils/wxtools';
|
|
3
|
-
import { QTree } from '../utils/qtree';
|
|
4
|
-
import { WxDataSetManager } from './WxDataSetManager';
|
|
5
|
-
/**
|
|
6
|
-
* type array of strings - available instances of a dataset */
|
|
7
|
-
export type WxInstances = string[];
|
|
8
|
-
/**
|
|
9
|
-
* Short description of a dataset */
|
|
10
|
-
export interface WxDatasetShortMeta {
|
|
11
|
-
/** represents instances as timesteps for some datasets like NZ Radar */
|
|
12
|
-
instanced?: string[];
|
|
13
|
-
/** last instance of a dataset */
|
|
14
|
-
instance: string;
|
|
15
|
-
/** list of variables in a dataset */
|
|
16
|
-
variables: string[];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Short description of all available datasets */
|
|
20
|
-
export interface WxDataSetsMetasJSON {
|
|
21
|
-
/**
|
|
22
|
-
* a list of datasets */
|
|
23
|
-
allDatasetsList: string[];
|
|
24
|
-
/**
|
|
25
|
-
* a list of datasets with short description */
|
|
26
|
-
[name: string]: WxDatasetShortMeta | string[] | undefined;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Meta data of a variable */
|
|
30
|
-
export interface WxVariableMeta {
|
|
31
|
-
/** units used for the variable */
|
|
32
|
-
units: string;
|
|
33
|
-
/** min value */
|
|
34
|
-
min: number;
|
|
35
|
-
/** max value */
|
|
36
|
-
max: number;
|
|
37
|
-
/** standard name */
|
|
38
|
-
standard_name?: string;
|
|
39
|
-
/** if the variable is a part of vector data, this contains a proper pare */
|
|
40
|
-
vector?: [string, string];
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* interface of an object with variable names as keys and variable meta data as values */
|
|
44
|
-
export interface WxVariablesMetas {
|
|
45
|
-
[name: string]: WxVariableMeta | undefined;
|
|
46
|
-
}
|
|
47
|
-
/** boundaries of a dataset */
|
|
48
|
-
export interface WxBoundaryMeta {
|
|
49
|
-
west: number;
|
|
50
|
-
north: number;
|
|
51
|
-
east: number;
|
|
52
|
-
south: number;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* All possible versions of boundaries for the dataset wrapped (0 -> 360) or (180 -> -180)
|
|
56
|
-
* as well as the original boundaries from the dataset */
|
|
57
|
-
export interface WxAllBoundariesMeta {
|
|
58
|
-
boundariesnorm: WxBoundaryMeta;
|
|
59
|
-
boundaries180: WxBoundaryMeta[];
|
|
60
|
-
boundaries360: WxBoundaryMeta[];
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Meta data of a dataset */
|
|
64
|
-
export interface WxDatasetMeta {
|
|
65
|
-
/**
|
|
66
|
-
* a list of variables in a dataset */
|
|
67
|
-
variables: string[];
|
|
68
|
-
/**
|
|
69
|
-
* metadata of variables */
|
|
70
|
-
variablesMeta: WxVariablesMetas;
|
|
71
|
-
/**
|
|
72
|
-
* max zoom level */
|
|
73
|
-
maxZoom: number;
|
|
74
|
-
/**
|
|
75
|
-
* array of available timesteps */
|
|
76
|
-
times: string[];
|
|
77
|
-
/**
|
|
78
|
-
* boundaries of a dataset */
|
|
79
|
-
boundaries: WxAllBoundariesMeta;
|
|
80
|
-
/**
|
|
81
|
-
* source of the dataset */
|
|
82
|
-
sourceID?: string;
|
|
83
|
-
/**
|
|
84
|
-
* base atmospheric model */
|
|
85
|
-
baseAtmosphericModel?: string;
|
|
86
|
-
/**
|
|
87
|
-
* model used for the dataset*/
|
|
88
|
-
model?: string;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Options to construct {@link WxAPI} object
|
|
92
|
-
* @example
|
|
93
|
-
* ```typescript
|
|
94
|
-
* const requestInit: RequestInit = {
|
|
95
|
-
* headers
|
|
96
|
-
* }; // add more options if needed such as headers, mode, credentials, etc
|
|
97
|
-
* const options = {
|
|
98
|
-
* dataServerURL:'https://tiles.metoceanapi.com/data/',
|
|
99
|
-
* requestInit: { headers: myHeaders },
|
|
100
|
-
* }
|
|
101
|
-
* const wxapi = new WxAPI(options);
|
|
102
|
-
* ```
|
|
103
|
-
* */
|
|
104
|
-
export interface WxAPIOptions extends WxTilesLibOptions {
|
|
105
|
-
/** base URL of the server*/
|
|
106
|
-
dataServerURL: string;
|
|
107
|
-
/** full masks tiles URL, Example: `https://server.com/masks/{z}/{x}/{y}.png`
|
|
108
|
-
* @default 'auto' - will be set to `dataServerURL + 'masks/{z}/{x}/{y}.png'`
|
|
109
|
-
* 'none' - will disable masks */
|
|
110
|
-
maskURL?: 'none' | 'auto' | string;
|
|
111
|
-
/** channel to use for masking from RGBA masks
|
|
112
|
-
* 0 - for the masks from Sarah (current), 3 - for the masks from Mapbox
|
|
113
|
-
* @default 'R' */
|
|
114
|
-
maskChannel?: 'R' | 'G' | 'B' | 'A';
|
|
115
|
-
/** maximum zoom level for mask tiles on the server
|
|
116
|
-
* @default 9 */
|
|
117
|
-
maskDepth?: number;
|
|
118
|
-
/** URL to qtree file.
|
|
119
|
-
* {@link QTree} is a hierarchical structure, that allows to quickly find tile's belonging to the sea/land.
|
|
120
|
-
* @default 'auto' - will be set to `dataServerURL + 'masks/9+1.seamask.qtree'`
|
|
121
|
-
* 'none' - will disable the use of {@link QTree} */
|
|
122
|
-
qtreeURL?: 'none' | 'auto' | string;
|
|
123
|
-
/** parameters to be passed to every fetch() aka _headers, credentials, cors, etc_ for interaction with backend data server */
|
|
124
|
-
requestInit?: RequestInit;
|
|
125
|
-
}
|
|
126
|
-
/** WxAPI is an initialisation object for the library. See {@link WxAPIOptions} for options.
|
|
127
|
-
* @example
|
|
128
|
-
* ```typescript
|
|
129
|
-
* import { WxAPI } from 'wx-tiles';
|
|
130
|
-
* const wxapi = new WxAPI({
|
|
131
|
-
* dataServerURL: 'https://server.com/',
|
|
132
|
-
* // other options
|
|
133
|
-
* });
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
export declare class WxAPI {
|
|
137
|
-
/** @internal see {@link WxAPIOptions}*/
|
|
138
|
-
readonly dataServerURL: string;
|
|
139
|
-
/** @internal see {@link WxAPIOptions}*/
|
|
140
|
-
readonly maskURL: string;
|
|
141
|
-
/** @internal see {@link WxAPIOptions}*/
|
|
142
|
-
readonly maskChannel: number;
|
|
143
|
-
/** @internal see {@link WxAPIOptions}*/
|
|
144
|
-
readonly maskDepth: number;
|
|
145
|
-
/** @internal see {@link WxAPIOptions}*/
|
|
146
|
-
readonly requestInit?: RequestInit;
|
|
147
|
-
/** @internal see {@link WxDataSetsMetasJSON}*/
|
|
148
|
-
readonly datasetsMetas: WxDataSetsMetasJSON;
|
|
149
|
-
/** @internal resolved when {@link WxAPI} is ready to use */
|
|
150
|
-
readonly initDone: Promise<void>;
|
|
151
|
-
/** @internal instance of the qtree object */
|
|
152
|
-
readonly qtree: QTree;
|
|
153
|
-
/** @internal function to load mask tiles */
|
|
154
|
-
readonly loadMaskFunc: ({ x, y, z }: XYZ) => Promise<ImageData>;
|
|
155
|
-
/** @param options - see {@link WxAPIOptions} */
|
|
156
|
-
constructor({ dataServerURL, maskURL, maskChannel, maskDepth, qtreeURL, requestInit, colorStyles, units, colorSchemes, }: WxAPIOptions);
|
|
157
|
-
/**
|
|
158
|
-
* Get short meta for a given dataset name
|
|
159
|
-
* @param datasetName - name of the dataset
|
|
160
|
-
* @returns {WxDatasetShortMeta} - short meta for the dataset */
|
|
161
|
-
protected getDatasetShortMeta(datasetName: 'allDatasetsList' | string): WxDatasetShortMeta | undefined;
|
|
162
|
-
/**
|
|
163
|
-
* Get all variables for the given dataset name.
|
|
164
|
-
* @param datasetName - dataset name
|
|
165
|
-
* @returns {Promise<string[]>} - list of all available variables for the dataset */
|
|
166
|
-
protected getDatasetInatance(datasetName: string): string | undefined;
|
|
167
|
-
/**
|
|
168
|
-
* Get all variables for the given dataset name.
|
|
169
|
-
* @param datasetName - dataset name
|
|
170
|
-
* @returns {Promise<string[]>} - list of all available variables for the dataset */
|
|
171
|
-
getDatasetVariables(datasetName: string): Promise<string[]>;
|
|
172
|
-
/**
|
|
173
|
-
* Create {@link WxDataSetManager} object for the given dataset name.
|
|
174
|
-
* @param datasetName - dataset name
|
|
175
|
-
* @returns {Promise<WxDataSetManager>} - WxDataSetManager object for the given dataset name */
|
|
176
|
-
createDatasetManager(datasetName: string): Promise<WxDataSetManager>;
|
|
177
|
-
/**
|
|
178
|
-
* Creates all possible dataset managers
|
|
179
|
-
* For each dataset in the datasets list, creates WxDataSetManager object.
|
|
180
|
-
* Requests all datasets meta.json in parallel.
|
|
181
|
-
* @returns {Promise<WxDataSetManager[]>} - list of all available dataset managers */
|
|
182
|
-
createAllDatasetsManagers(): Promise<PromiseSettledResult<WxDataSetManager>[]>;
|
|
183
|
-
/**
|
|
184
|
-
* Returns datasets names which have given variable
|
|
185
|
-
* @argument {string} variableName - variable name to search for in datasets
|
|
186
|
-
* @returns {Promise<string[]>} - list of datasets' names */
|
|
187
|
-
filterDatasetsByVariableName(variableName: string): Promise<string[]>;
|
|
188
|
-
/**
|
|
189
|
-
* Get the list of all available datasets' names
|
|
190
|
-
* @returns {Promise<string[]>} - list of all available datasets' names */
|
|
191
|
-
getAllDatasetsNames(): Promise<string[]>;
|
|
192
|
-
}
|