@metoceanapi/wxtiles-leaflet 2.3.0-0 → 2.4.0-1
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 +2 -0
- package/README.md +16 -3
- package/dep.dot +33 -0
- package/dep.svg +233 -0
- package/dist/es/customlayer/customlayer.d.ts +3 -0
- package/dist/es/index.d.ts +19 -13
- package/dist/es/index.js +6 -2
- package/dist/es/wxAPI/WxAPI.d.ts +3 -61
- package/dist/es/wxAPI/WxDataSetManager.d.ts +35 -123
- package/dist/es/wxsource/wxsource.d.ts +118 -51
- package/dist/es/wxsource/wxsourcetypes.d.ts +70 -10
- package/dist/web/index.js +6 -2
- package/docs/docs/assets/highlight.css +7 -0
- package/docs/docs/assets/search.js +1 -1
- package/docs/docs/classes/CustomWxTilesLayer.html +4 -1
- package/docs/docs/classes/DataIntegral.html +9 -9
- package/docs/docs/classes/QTree.html +41 -14
- package/docs/docs/classes/RawCLUT.html +9 -9
- package/docs/docs/classes/TilesCache.html +5 -5
- package/docs/docs/classes/WxAPI.html +109 -79
- package/docs/docs/classes/WxAPIControl.html +242 -0
- package/docs/docs/classes/WxDataSetManager.html +166 -118
- package/docs/docs/classes/WxInfoControl.html +172 -0
- package/docs/docs/classes/WxLegendControl.html +166 -0
- package/docs/docs/classes/WxStyleEditorControl.html +462 -0
- package/docs/docs/classes/WxTileSource.html +204 -108
- package/docs/docs/classes/WxTimeControl.html +219 -0
- package/docs/docs/enums/TileType.html +4 -4
- package/docs/docs/functions/WXLOG.html +10 -5
- package/docs/docs/functions/WxCreateLegend.html +14 -9
- package/docs/docs/functions/WxGetColorSchemes.html +10 -5
- package/docs/docs/functions/WxGetColorStyles.html +10 -5
- package/docs/docs/functions/WxTilesLogging.html +13 -5
- package/docs/docs/index.html +27 -7
- package/docs/docs/interfaces/CachedUriLoaderPromiseFunc.html +7 -5
- package/docs/docs/interfaces/ColorStylesIncomplete.html +10 -5
- package/docs/docs/interfaces/Converter.html +3 -5
- package/docs/docs/interfaces/DataPicture.html +5 -5
- package/docs/docs/interfaces/FrameworkOptions.html +12 -6
- package/docs/docs/interfaces/IntegralPare.html +3 -3
- package/docs/docs/interfaces/SLinePoint.html +4 -4
- package/docs/docs/interfaces/Tree.html +11 -7
- package/docs/docs/interfaces/WxAPIOptions.html +33 -24
- package/docs/docs/interfaces/WxAllBoundariesMeta.html +14 -9
- package/docs/docs/interfaces/WxAllDatasetsShortMetas.html +11 -6
- package/docs/docs/interfaces/WxBoundaryMeta.html +18 -10
- package/docs/docs/interfaces/WxColorSchemes.html +10 -5
- package/docs/docs/interfaces/WxColorStyleStrict.html +28 -28
- package/docs/docs/interfaces/WxColorStyleWeak.html +28 -28
- package/docs/docs/interfaces/WxColorStylesStrict.html +2 -2
- package/docs/docs/interfaces/WxColorStylesWeakMixed.html +10 -5
- package/docs/docs/interfaces/WxData.html +10 -6
- package/docs/docs/interfaces/WxDataSetManagerOptions.html +15 -15
- package/docs/docs/interfaces/WxDatasetMeta.html +20 -20
- package/docs/docs/interfaces/WxDatasetShortMeta.html +9 -8
- package/docs/docs/interfaces/WxLayerAPI.html +24 -28
- package/docs/docs/interfaces/WxLayerBaseAPI.html +18 -22
- package/docs/docs/interfaces/WxLayerOptions.html +18 -13
- package/docs/docs/interfaces/WxLegend.html +16 -15
- package/docs/docs/interfaces/WxLngLat.html +3 -3
- package/docs/docs/interfaces/WxRasterData.html +11 -8
- package/docs/docs/interfaces/WxRequestInit.html +2 -2
- package/docs/docs/interfaces/WxSourceLayerOptions.html +14 -12
- package/docs/docs/interfaces/WxTick.html +8 -7
- package/docs/docs/interfaces/WxTileInfo.html +10 -10
- package/docs/docs/interfaces/WxUnits.html +10 -5
- package/docs/docs/interfaces/WxVariableMeta.html +13 -12
- package/docs/docs/interfaces/WxVariablesMetas.html +11 -6
- package/docs/docs/interfaces/XYZ.html +4 -4
- package/docs/docs/modules.html +21 -8
- package/docs/docs/types/DataIntegrals.html +10 -5
- package/docs/docs/types/DataPictures.html +10 -5
- package/docs/docs/types/ListenerMethod.html +10 -5
- package/docs/docs/types/Loader.html +116 -0
- package/docs/docs/types/Painter.html +116 -0
- package/docs/docs/types/SLine.html +11 -6
- package/docs/docs/types/SubTrees.html +10 -5
- package/docs/docs/types/SubTreesN.html +12 -7
- package/docs/docs/types/TreeN.html +12 -7
- package/docs/docs/types/WxDate.html +10 -5
- package/docs/docs/types/WxEventType.html +10 -5
- package/docs/docs/types/WxInstances.html +13 -6
- package/docs/docs/types/WxLayer.html +116 -0
- package/docs/docs/types/WxLayerVarsNames.html +11 -6
- package/docs/docs/types/WxURIs.html +10 -5
- package/docs/docs/types/WxUnitTuple.html +10 -5
- package/docs/docs/variables/WxLayerBaseImplementation.html +116 -0
- package/docs/script/script.css +1 -1
- package/docs/script/script.js +8 -8
- package/hooks/pre-commit +29 -0
- package/package.json +9 -2
- package/src_example/frwrkdeps.ts +57 -18
- package/src_example/index.ts +2 -2
- package/src_example/start.ts +100 -46
- package/watch-public.mjs +16 -12
- package/dist/es/controls/WxAPIControl.d.ts +0 -19
- package/dist/es/controls/WxInfoControl.d.ts +0 -16
- package/dist/es/controls/WxLegendControl.d.ts +0 -14
- package/dist/es/controls/WxStyleEditorControl.d.ts +0 -52
- package/dist/es/controls/WxTimeControl .d.ts +0 -18
- package/dist/es/defaults/colorschemes.d.ts +0 -2
- package/dist/es/defaults/styles.d.ts +0 -2
- package/dist/es/defaults/uconv.d.ts +0 -2
- package/dist/es/utils/RawCLUT.d.ts +0 -57
- package/dist/es/utils/mercator.d.ts +0 -4
- package/dist/es/utils/qtree.d.ts +0 -27
- package/dist/es/utils/tests_wxtools.d.ts +0 -1
- package/dist/es/utils/wxtools.d.ts +0 -361
- package/dist/es/wxAPI/WxAPItypes.d.ts +0 -152
- package/dist/es/wxlayer/WxImplementation.d.ts +0 -189
- package/dist/es/wxlayer/loader.d.ts +0 -54
- package/dist/es/wxlayer/loadertools.d.ts +0 -50
- package/dist/es/wxlayer/painter.d.ts +0 -58
- package/dist/es/wxlayer/wxlayer.d.ts +0 -186
- package/docs/docs/classes/Loader.html +0 -165
- package/docs/docs/classes/Painter.html +0 -161
- package/docs/docs/classes/WxLayer.html +0 -419
- package/docs/docs/classes/WxLayerBaseImplementation.html +0 -427
- package/docs/examples/interactive.html +0 -84
- package/docs/examples/res/icon.png +0 -0
- package/docs/examples/res/wxtiles-logo.png +0 -0
- package/docs/examples/seaMaskAndAnimatedBlur.html +0 -76
- package/docs/examples/simpleDemo.html +0 -70
- package/docs/server.py +0 -11
package/hooks/pre-commit
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# Check if Node.js is installed
|
|
4
|
+
node --version > /dev/null 2>&1
|
|
5
|
+
if [[ $? != 0 ]]; then
|
|
6
|
+
echo "Node.js could not be found. Please install Node.js."
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
# Check if Biome is installed
|
|
11
|
+
npx biome --version > /dev/null 2>&1
|
|
12
|
+
if [[ $? != 0 ]]; then
|
|
13
|
+
echo "Biome could not be found. Installing Biome..."
|
|
14
|
+
npm install --save-dev --save-exact @biomejs/biome
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Run Biome linter
|
|
18
|
+
npx biome lint
|
|
19
|
+
|
|
20
|
+
# Capture the exit code of the linter
|
|
21
|
+
LINT_EXIT_CODE=$?
|
|
22
|
+
|
|
23
|
+
# Exit with the linter's exit code
|
|
24
|
+
if [ $LINT_EXIT_CODE -ne 0 ]; then
|
|
25
|
+
echo "Biome linter failed. Please fix the issues before committing."
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
exit 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metoceanapi/wxtiles-leaflet",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-1",
|
|
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",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"preversion": "npm run build",
|
|
13
13
|
"version": "changelogkeeper && git add CHANGELOG.md",
|
|
14
14
|
"npm_reinstall": "rm -rf node_modules package-lock.json && npm i",
|
|
15
|
-
"npm_i": "npm i"
|
|
15
|
+
"npm_i": "npm i",
|
|
16
|
+
"prepare": "husky"
|
|
16
17
|
},
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
@@ -25,12 +26,18 @@
|
|
|
25
26
|
},
|
|
26
27
|
"homepage": "https://github.com/metoceanapi/wxtiles-leaflet#readme",
|
|
27
28
|
"devDependencies": {
|
|
29
|
+
"@biomejs/biome": "1.9.4",
|
|
28
30
|
"@types/leaflet": "^1.9.3",
|
|
29
31
|
"changelogkeeper": "^1.2.0",
|
|
30
32
|
"esbuild": "^0.17.18",
|
|
31
33
|
"esbuild-plugin-external-global": "^1.0.1",
|
|
34
|
+
"git-format-staged": "^3.1.1",
|
|
35
|
+
"husky": "^9.1.6",
|
|
32
36
|
"leaflet": "^1.9.3",
|
|
33
37
|
"typedoc": "^0.23.28",
|
|
34
38
|
"typescript": "^4.9.5"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@metoceanapi/wxtiles-common": "^0.0.10"
|
|
35
42
|
}
|
|
36
43
|
}
|
package/src_example/frwrkdeps.ts
CHANGED
|
@@ -1,34 +1,52 @@
|
|
|
1
|
-
import L from
|
|
2
|
-
import { WxGetColorStyles } from
|
|
1
|
+
import L from "leaflet";
|
|
2
|
+
import { WxGetColorStyles } from "@metoceanapi/wxtiles-common/utils/wxtools";
|
|
3
3
|
|
|
4
|
-
export function flyTo(
|
|
4
|
+
export function flyTo(
|
|
5
|
+
map: L.Map,
|
|
6
|
+
zoom: number,
|
|
7
|
+
lng: number,
|
|
8
|
+
lat: number,
|
|
9
|
+
bearing: number,
|
|
10
|
+
pitch: number,
|
|
11
|
+
) {
|
|
5
12
|
map.flyTo([lat, lng], zoom);
|
|
6
13
|
}
|
|
7
14
|
|
|
8
|
-
export function setURL(
|
|
9
|
-
|
|
15
|
+
export function setURL(
|
|
16
|
+
map: L.Map,
|
|
17
|
+
time: string,
|
|
18
|
+
datasetName: string,
|
|
19
|
+
variable: string,
|
|
20
|
+
// biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
|
|
21
|
+
style: any,
|
|
22
|
+
) {
|
|
23
|
+
let newStyle = style
|
|
24
|
+
const { base } = WxGetColorStyles();
|
|
10
25
|
for (const i in style) style[i] === base[i] && delete style[i]; // remove default values
|
|
11
26
|
if (style.gl) {
|
|
12
|
-
for (const i in style.gl)
|
|
13
|
-
|
|
27
|
+
for (const i in style.gl)
|
|
28
|
+
style.gl[i] === base.gl?.[i] && delete style.gl[i]; // remove default values from gl
|
|
29
|
+
if (Object.keys(style.gl).length === 0) {
|
|
30
|
+
const { gl, ...rest } = style; // Destructure to exclude gl
|
|
31
|
+
newStyle = rest; // Assign the new object back to style
|
|
32
|
+
}
|
|
14
33
|
}
|
|
15
34
|
const center = map.getCenter().wrap();
|
|
16
35
|
const href =
|
|
17
|
-
`##${datasetName}/${variable}/${time}/${map.getZoom().toFixed(2)}/${center.lng.toFixed(2)}/${center.lat.toFixed(2)}/0/0`
|
|
18
|
-
(style ? '/' + JSON.stringify(style) : '');
|
|
36
|
+
`##${datasetName}/${variable}/${time}/${map.getZoom().toFixed(2)}/${center.lng.toFixed(2)}/${center.lat.toFixed(2)}/0/0${newStyle ? `/${JSON.stringify(newStyle)}` : ""}`;
|
|
19
37
|
|
|
20
|
-
history.replaceState(null,
|
|
38
|
+
history.replaceState(null, "", href);
|
|
21
39
|
// location.href = `#${datasetName}/${variables.join(',')}/${time}/${map.getZoom().toFixed(2)}/${center.lng.toFixed(2)}/${center.lat.toFixed(2)}`;
|
|
22
40
|
}
|
|
23
41
|
|
|
24
42
|
export async function initFrameWork() {
|
|
25
|
-
const map = L.map(
|
|
43
|
+
const map = L.map("map", {
|
|
26
44
|
center: [-40.75, 174.5],
|
|
27
45
|
zoom: 7,
|
|
28
46
|
zoomControl: false,
|
|
29
47
|
});
|
|
30
48
|
|
|
31
|
-
L.control.zoom({ position:
|
|
49
|
+
L.control.zoom({ position: "bottomright" }).addTo(map);
|
|
32
50
|
|
|
33
51
|
// class WxDebugLayer extends L.GridLayer {
|
|
34
52
|
// createTile(coords: { x: number; y: number; z: number }) {
|
|
@@ -43,9 +61,17 @@ export async function initFrameWork() {
|
|
|
43
61
|
return map;
|
|
44
62
|
}
|
|
45
63
|
|
|
46
|
-
export function addControl(
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
export function addControl(
|
|
65
|
+
map: L.Map,
|
|
66
|
+
// biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
|
|
67
|
+
control: { extender: () => any },
|
|
68
|
+
position: string,
|
|
69
|
+
) {
|
|
70
|
+
const newPosition = position.replace("-", "");
|
|
71
|
+
map.addControl(
|
|
72
|
+
// biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
|
|
73
|
+
new (L.Control.extend(control.extender()))({ position: newPosition as any }),
|
|
74
|
+
);
|
|
49
75
|
}
|
|
50
76
|
|
|
51
77
|
export function position(e: L.LeafletMouseEvent): L.LatLng {
|
|
@@ -53,6 +79,7 @@ export function position(e: L.LeafletMouseEvent): L.LatLng {
|
|
|
53
79
|
}
|
|
54
80
|
|
|
55
81
|
export function removeLayer(map: L.Map, layerId: string, layer?: L.Layer) {
|
|
82
|
+
// biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
|
|
56
83
|
map.eachLayer((l: any) => {
|
|
57
84
|
if (l.options.id === layerId) {
|
|
58
85
|
map.removeLayer(l);
|
|
@@ -62,10 +89,22 @@ export function removeLayer(map: L.Map, layerId: string, layer?: L.Layer) {
|
|
|
62
89
|
|
|
63
90
|
export async function addLayer(map: L.Map, idL: string, layer: L.Layer) {
|
|
64
91
|
map.addLayer(layer);
|
|
65
|
-
await new Promise((done) => layer.once(
|
|
92
|
+
await new Promise((done) => layer.once("load", done)); // highly recommended to await for the first load
|
|
66
93
|
}
|
|
67
94
|
|
|
68
|
-
export function addRaster(
|
|
69
|
-
|
|
95
|
+
export function addRaster(
|
|
96
|
+
map: L.Map,
|
|
97
|
+
idS: string,
|
|
98
|
+
idL: string,
|
|
99
|
+
URL: string,
|
|
100
|
+
maxZoom: number,
|
|
101
|
+
// biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
|
|
102
|
+
bounds?: any,
|
|
103
|
+
) {
|
|
104
|
+
const layer = L.tileLayer(URL, {
|
|
105
|
+
id: idS,
|
|
106
|
+
maxNativeZoom: maxZoom,
|
|
107
|
+
zIndex: idL === "baseL" ? 1 : 0,
|
|
108
|
+
});
|
|
70
109
|
map.addLayer(layer);
|
|
71
110
|
}
|
package/src_example/index.ts
CHANGED
package/src_example/start.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { WxTimeControl } from
|
|
6
|
-
import {
|
|
7
|
-
|
|
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";
|
|
8
22
|
|
|
9
23
|
const OPACITY = 0.8;
|
|
10
24
|
|
|
@@ -13,8 +27,20 @@ const OPACITY = 0.8;
|
|
|
13
27
|
// start() is the fully interchangable function for Leaflet and Mapbox
|
|
14
28
|
export async function start() {
|
|
15
29
|
const map = await initFrameWork();
|
|
16
|
-
addRaster(
|
|
17
|
-
|
|
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
|
+
);
|
|
18
44
|
// WxTilesLogging(console.trace);
|
|
19
45
|
// const dataServerURL = 'data/'; // different sources manged in 'start' script in package.json
|
|
20
46
|
// const dataServerURL = 'https://tilestest.metoceanapi.com/data/';
|
|
@@ -22,14 +48,14 @@ export async function start() {
|
|
|
22
48
|
// const dataServerURL = 'https://68.171.214.87/data/'; // hihi1
|
|
23
49
|
// const dataServerURL = 'https://68.171.214.81/data/'; // hihi2
|
|
24
50
|
// const dataServerURL = 'https://hihi2.metoceanapi.com/data/';
|
|
25
|
-
const dataServerURL =
|
|
51
|
+
const dataServerURL = "https://tilesdev.metoceanapi.com/data/";
|
|
26
52
|
const myHeaders = new Headers();
|
|
27
53
|
// myHeaders.append('x-api-key', 'SpV3J1RypVrv2qkcJE91gG');
|
|
28
54
|
const wxapi = new WxAPI({
|
|
29
55
|
dataServerURL,
|
|
30
|
-
maskURL:
|
|
31
|
-
maskChannel:
|
|
32
|
-
qtreeURL:
|
|
56
|
+
maskURL: "auto",
|
|
57
|
+
maskChannel: "R",
|
|
58
|
+
qtreeURL: "auto",
|
|
33
59
|
requestInit: { headers: myHeaders },
|
|
34
60
|
});
|
|
35
61
|
|
|
@@ -42,24 +68,24 @@ export async function start() {
|
|
|
42
68
|
// let datasetName = 'ww3-ecmwf.global';
|
|
43
69
|
// let variable = 'wave.direction.mean';
|
|
44
70
|
|
|
45
|
-
let datasetName =
|
|
46
|
-
let variable =
|
|
71
|
+
let datasetName = "obs-radar.rain.nzl.national";
|
|
72
|
+
let variable = "reflectivity";
|
|
47
73
|
|
|
48
74
|
// let datasetName = 'him8_truecolor';
|
|
49
75
|
// let variable = 'h8_rgb';
|
|
50
76
|
|
|
51
77
|
// get datasetName from URL
|
|
52
|
-
const urlParams = window.location.toString().split(
|
|
53
|
-
const params = urlParams?.split(
|
|
78
|
+
const urlParams = window.location.toString().split("##")[1];
|
|
79
|
+
const params = urlParams?.split("/");
|
|
54
80
|
datasetName = params?.[0] || datasetName;
|
|
55
81
|
if (params?.[1]) variable = params[1];
|
|
56
|
-
let time = params?.[2] ||
|
|
57
|
-
const zoom = (params && parseFloat(params[3])) || 0;
|
|
58
|
-
const lng = (params && parseFloat(params[4])) || 0;
|
|
59
|
-
const lat = (params && parseFloat(params[5])) || 0;
|
|
60
|
-
const bearing = (params && parseFloat(params[6])) || 0;
|
|
61
|
-
const pitch = (params && parseFloat(params[7])) || 0;
|
|
62
|
-
if (params?.length > 8) params[8] = params.slice(8).join(
|
|
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("/");
|
|
63
89
|
|
|
64
90
|
const str = params?.[8] && params[8];
|
|
65
91
|
const sth = { style: {} as WxColorStyleWeak };
|
|
@@ -73,54 +99,79 @@ export async function start() {
|
|
|
73
99
|
|
|
74
100
|
params && flyTo(map, zoom, lng, lat, bearing, pitch); // if no params stay at default position set in initFrameWork()
|
|
75
101
|
|
|
76
|
-
map.on(
|
|
77
|
-
map.on(
|
|
78
|
-
map.on(
|
|
79
|
-
map.on(
|
|
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));
|
|
80
106
|
|
|
81
107
|
let wxsourceLayer: WxTileSource | undefined;
|
|
82
108
|
|
|
83
109
|
const legendControl = new WxLegendControl();
|
|
84
|
-
addControl(map, legendControl,
|
|
110
|
+
addControl(map, legendControl, "top-right");
|
|
85
111
|
|
|
86
|
-
const frameworkOptions = {
|
|
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
|
+
};
|
|
87
118
|
const apiControl = new WxAPIControl(wxapi, datasetName, variable);
|
|
88
|
-
addControl(map, apiControl,
|
|
89
|
-
apiControl.onchange = async (
|
|
119
|
+
addControl(map, apiControl, "top-left");
|
|
120
|
+
apiControl.onchange = async (
|
|
121
|
+
_datasetName,
|
|
122
|
+
_variable,
|
|
123
|
+
resetStyleAndFlyTo = true,
|
|
124
|
+
): Promise<void> => {
|
|
90
125
|
datasetName = _datasetName;
|
|
91
126
|
variable = _variable;
|
|
92
|
-
WXLOG(
|
|
127
|
+
WXLOG(
|
|
128
|
+
"apiControl.onchange datasetName=",
|
|
129
|
+
datasetName,
|
|
130
|
+
"variable=",
|
|
131
|
+
variable,
|
|
132
|
+
);
|
|
93
133
|
// remove existing source and layer
|
|
94
134
|
removeLayer(map, frameworkOptions.id, wxsourceLayer);
|
|
95
135
|
//
|
|
96
|
-
|
|
136
|
+
if (resetStyleAndFlyTo) {
|
|
137
|
+
sth.style = {}
|
|
138
|
+
}
|
|
97
139
|
wxsourceLayer = undefined;
|
|
98
140
|
const wxdatasetManager = await wxapi.createDatasetManager(datasetName);
|
|
99
141
|
const boundaries = wxdatasetManager.getBoundaries();
|
|
100
142
|
if (boundaries && resetStyleAndFlyTo) {
|
|
101
143
|
const { east, west, north, south } = boundaries.boundariesnorm;
|
|
102
|
-
const zoom = Math.round(
|
|
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
|
|
103
151
|
flyTo(map, zoom, (east + west) / 2, (north + south) / 2, 0, 0);
|
|
104
152
|
}
|
|
105
153
|
const meta = wxdatasetManager.getVariableCurrentMeta(variable);
|
|
106
|
-
if (meta?.units ===
|
|
154
|
+
if (meta?.units === "RGB") {
|
|
107
155
|
const times = wxdatasetManager.getAllTimes();
|
|
108
156
|
|
|
109
157
|
addRaster(
|
|
110
158
|
map,
|
|
111
159
|
frameworkOptions.id,
|
|
112
|
-
|
|
160
|
+
"wxtiles",
|
|
113
161
|
wxdatasetManager.createURI(variable, times[0]),
|
|
114
162
|
wxdatasetManager.getMaxZoom(),
|
|
115
|
-
wxdatasetManager.getBoundaries()?.boundariesnorm
|
|
163
|
+
wxdatasetManager.getBoundaries()?.boundariesnorm,
|
|
116
164
|
);
|
|
117
165
|
|
|
118
166
|
timeControl.setTimes(times);
|
|
119
167
|
legendControl.clear();
|
|
120
168
|
} else {
|
|
121
|
-
wxsourceLayer = wxdatasetManager.createSourceLayer(
|
|
169
|
+
wxsourceLayer = wxdatasetManager.createSourceLayer(
|
|
170
|
+
{ variable, time, wxstyle: sth.style },
|
|
171
|
+
frameworkOptions,
|
|
172
|
+
);
|
|
122
173
|
wxsourceLayer.setCoarseLevel(0);
|
|
123
|
-
await addLayer(map,
|
|
174
|
+
await addLayer(map, "wxtiles", wxsourceLayer);
|
|
124
175
|
// wxsource.startAnimation();
|
|
125
176
|
const styleCopy = wxsourceLayer.getCurrentStyleObjectCopy();
|
|
126
177
|
legendControl.drawLegend(styleCopy); // first draw legend with current style
|
|
@@ -134,16 +185,17 @@ export async function start() {
|
|
|
134
185
|
};
|
|
135
186
|
|
|
136
187
|
const timeControl = new WxTimeControl(50);
|
|
137
|
-
addControl(map, timeControl,
|
|
188
|
+
addControl(map, timeControl, "top-left");
|
|
138
189
|
timeControl.onchange = (time_) => {
|
|
139
|
-
|
|
190
|
+
time = time_;
|
|
191
|
+
setURL(map, time_, datasetName, variable, sth.style);
|
|
140
192
|
infoControl.update(wxsourceLayer, map);
|
|
141
193
|
};
|
|
142
194
|
|
|
143
195
|
const customStyleEditorControl = new WxStyleEditorControl();
|
|
144
|
-
addControl(map, customStyleEditorControl,
|
|
196
|
+
addControl(map, customStyleEditorControl, "top-right");
|
|
145
197
|
customStyleEditorControl.onchange = async (style, nonnativecall) => {
|
|
146
|
-
WXLOG(
|
|
198
|
+
WXLOG("customStyleEditorControl.onchange");
|
|
147
199
|
if (!wxsourceLayer) return;
|
|
148
200
|
nonnativecall || (await wxsourceLayer.updateCurrentStyleObject(style)); // if called manually, do not update wxsource's style
|
|
149
201
|
const nstyle = wxsourceLayer.getCurrentStyleObjectCopy();
|
|
@@ -156,8 +208,10 @@ export async function start() {
|
|
|
156
208
|
};
|
|
157
209
|
|
|
158
210
|
const infoControl = new WxInfoControl();
|
|
159
|
-
addControl(map, infoControl,
|
|
160
|
-
map.on(
|
|
211
|
+
addControl(map, infoControl, "bottom-left");
|
|
212
|
+
map.on("mousemove", (e) =>
|
|
213
|
+
infoControl.update(wxsourceLayer, map, position(e)),
|
|
214
|
+
);
|
|
161
215
|
|
|
162
216
|
await apiControl.onchange(datasetName, variable, false); // initial load
|
|
163
217
|
|
package/watch-public.mjs
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
// import { type BuildOptions, context } from 'esbuild';
|
|
2
|
-
import * as esbuild from
|
|
3
|
-
import http from
|
|
2
|
+
import * as esbuild from "esbuild";
|
|
3
|
+
import http from "node:http";
|
|
4
4
|
|
|
5
5
|
const PORT = +process.env.PORT || 3000;
|
|
6
6
|
|
|
7
7
|
const buildOptions = {
|
|
8
|
-
entryPoints: [
|
|
8
|
+
entryPoints: ["src_example/index.ts"],
|
|
9
9
|
bundle: true,
|
|
10
10
|
loader: {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
".png": "base64",
|
|
12
|
+
".woff": "base64",
|
|
13
13
|
},
|
|
14
|
-
format:
|
|
15
|
-
outfile:
|
|
14
|
+
format: "iife",
|
|
15
|
+
outfile: "public/script/script.js",
|
|
16
16
|
sourcemap: true,
|
|
17
17
|
minify: false,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const ctx = await esbuild.context(buildOptions);
|
|
21
21
|
await ctx.watch();
|
|
22
|
-
console.log(
|
|
22
|
+
console.log("watching...");
|
|
23
23
|
|
|
24
|
-
const { host, port } = await ctx.serve({
|
|
24
|
+
const { host, port } = await ctx.serve({
|
|
25
|
+
host: "localhost",
|
|
26
|
+
port: PORT + 1000,
|
|
27
|
+
servedir: "public",
|
|
28
|
+
});
|
|
25
29
|
console.log(`Dev is running at ${host}:${PORT}`);
|
|
26
30
|
|
|
27
31
|
// Then start a proxy server on PORT
|
|
@@ -36,9 +40,9 @@ http
|
|
|
36
40
|
headers: req.headers,
|
|
37
41
|
};
|
|
38
42
|
|
|
39
|
-
if (req.url.startsWith(
|
|
43
|
+
if (req.url.startsWith("/data/masks")) {
|
|
40
44
|
options.port = 9191; // all from local 'simple NGINX'
|
|
41
|
-
} else if (req.url.startsWith(
|
|
45
|
+
} else if (req.url.startsWith("/data")) {
|
|
42
46
|
options.port = 8080; // wxtiles-http-server
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { WxAPI } from '../index';
|
|
2
|
-
export declare class WxAPIControl {
|
|
3
|
-
private readonly wxapi;
|
|
4
|
-
private readonly _div;
|
|
5
|
-
readonly datasets: HTMLSelectElement;
|
|
6
|
-
readonly variables: HTMLSelectElement;
|
|
7
|
-
protected _busy: boolean;
|
|
8
|
-
onchange?: (dataset: string, variable: string, resetStyleAndFlyTo?: boolean) => Promise<void>;
|
|
9
|
-
constructor(wxapi: WxAPI, dataset?: string, variable?: string);
|
|
10
|
-
setBusy(b: boolean): void;
|
|
11
|
-
fillDatasets(dataset?: string, variable?: string): Promise<void>;
|
|
12
|
-
fillVariables(variable?: string): Promise<void>;
|
|
13
|
-
onAdd(): HTMLDivElement;
|
|
14
|
-
onRemove(): void;
|
|
15
|
-
extender(): {
|
|
16
|
-
onAdd: () => HTMLDivElement;
|
|
17
|
-
onRemove: () => void;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { WxTileSource } from '../index';
|
|
2
|
-
export declare class WxInfoControl {
|
|
3
|
-
private readonly div;
|
|
4
|
-
private pos;
|
|
5
|
-
constructor();
|
|
6
|
-
onAdd(): HTMLDivElement;
|
|
7
|
-
onRemove(): void;
|
|
8
|
-
update(wxsource: WxTileSource | undefined, map: any, pos_?: {
|
|
9
|
-
lng: number;
|
|
10
|
-
lat: number;
|
|
11
|
-
}): void;
|
|
12
|
-
extender(): {
|
|
13
|
-
onAdd: () => HTMLDivElement;
|
|
14
|
-
onRemove: () => void;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type WxColorStyleStrict } from '../index';
|
|
2
|
-
export declare class WxLegendControl {
|
|
3
|
-
private readonly _div;
|
|
4
|
-
private readonly _canvas;
|
|
5
|
-
constructor();
|
|
6
|
-
onAdd(): HTMLDivElement;
|
|
7
|
-
onRemove(): void;
|
|
8
|
-
drawLegend(style: WxColorStyleStrict): void;
|
|
9
|
-
clear(): void;
|
|
10
|
-
extender(): {
|
|
11
|
-
onAdd: () => HTMLDivElement;
|
|
12
|
-
onRemove: () => void;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { WxColorStyleStrict } from '../index';
|
|
2
|
-
import { WxColorStyleWeak } from '../index';
|
|
3
|
-
export declare class WxStyleEditorControl {
|
|
4
|
-
onchange?: (style: WxColorStyleWeak, nonnative?: boolean) => Promise<void>;
|
|
5
|
-
editorTextAreaEl: HTMLTextAreaElement;
|
|
6
|
-
editorDivEl: HTMLDivElement;
|
|
7
|
-
parentInput: HTMLInputElement;
|
|
8
|
-
nameInput: HTMLInputElement;
|
|
9
|
-
fillSelect: HTMLSelectElement;
|
|
10
|
-
isolineColorSelect: HTMLSelectElement;
|
|
11
|
-
isolineColorInput: HTMLInputElement;
|
|
12
|
-
isolineTextInput: HTMLInputElement;
|
|
13
|
-
vectorTypeSelect: HTMLSelectElement;
|
|
14
|
-
vectorColorSelect: HTMLSelectElement;
|
|
15
|
-
vectorColorInput: HTMLInputElement;
|
|
16
|
-
vectorFactorInput: HTMLInputElement;
|
|
17
|
-
streamLineColorSelect: HTMLSelectElement;
|
|
18
|
-
streamLineColorInput: HTMLInputElement;
|
|
19
|
-
streamLineSpeedFactorInput: HTMLInputElement;
|
|
20
|
-
streamLineStaticInput: HTMLInputElement;
|
|
21
|
-
showBelowMinInput: HTMLInputElement;
|
|
22
|
-
showAboveMaxInput: HTMLInputElement;
|
|
23
|
-
colorSchemeSelect: HTMLSelectElement;
|
|
24
|
-
colorsInput: HTMLInputElement;
|
|
25
|
-
colorMapInput: HTMLInputElement;
|
|
26
|
-
levelsInput: HTMLInputElement;
|
|
27
|
-
blurRadiusInput: HTMLInputElement;
|
|
28
|
-
addDegreesInput: HTMLInputElement;
|
|
29
|
-
unitsInput: HTMLInputElement;
|
|
30
|
-
extraUnitsInput: HTMLInputElement;
|
|
31
|
-
maskSelect: HTMLSelectElement;
|
|
32
|
-
animationSpeed: HTMLInputElement;
|
|
33
|
-
noiseTexturePow: HTMLInputElement;
|
|
34
|
-
vectorFieldFactor: HTMLInputElement;
|
|
35
|
-
animationIntensity: HTMLInputElement;
|
|
36
|
-
wavesCount: HTMLInputElement;
|
|
37
|
-
styleBase: WxColorStyleStrict;
|
|
38
|
-
parent: HTMLDivElement;
|
|
39
|
-
constructor();
|
|
40
|
-
extender(): {
|
|
41
|
-
onAdd: () => HTMLDivElement;
|
|
42
|
-
onRemove: () => void;
|
|
43
|
-
};
|
|
44
|
-
onAdd(): HTMLDivElement;
|
|
45
|
-
onRemove(): void;
|
|
46
|
-
getStyle(): WxColorStyleWeak;
|
|
47
|
-
setStyle(style: WxColorStyleWeak): void;
|
|
48
|
-
protected _getStyleFromDiv(): WxColorStyleWeak;
|
|
49
|
-
protected _setStyleToTextArea(style: WxColorStyleWeak): void;
|
|
50
|
-
protected _setStyleToDiv(style: WxColorStyleWeak): void;
|
|
51
|
-
protected _onDivChange(): void;
|
|
52
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { WxTileSource } from '../index';
|
|
2
|
-
export declare class WxTimeControl {
|
|
3
|
-
readonly delay: number;
|
|
4
|
-
private wxsource?;
|
|
5
|
-
private readonly _div;
|
|
6
|
-
private readonly buttonPlayStop;
|
|
7
|
-
private readonly timesEl;
|
|
8
|
-
onchange: (time: string) => void;
|
|
9
|
-
constructor(delay: number, wxsource?: WxTileSource | undefined);
|
|
10
|
-
setTimes(times: string[]): void;
|
|
11
|
-
updateSource(wxsource?: WxTileSource): void;
|
|
12
|
-
onAdd(): HTMLDivElement;
|
|
13
|
-
onRemove(): void;
|
|
14
|
-
extender(): {
|
|
15
|
-
onAdd: () => HTMLDivElement;
|
|
16
|
-
onRemove: () => void;
|
|
17
|
-
};
|
|
18
|
-
}
|