@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.
- package/CHANGELOG.md +4 -0
- package/README.md +214 -92
- package/dist/es/index.d.ts +12 -16
- package/dist/es/index.js +4 -4
- package/dist/es/wxAPI/WxAPI.d.ts +17 -0
- package/dist/es/wxAPI/WxDataSetManager.d.ts +14 -4
- package/dist/es/wxsource/wxsource.d.ts +24 -20
- package/dist/es/wxsource/wxsourcetypes.d.ts +22 -10
- package/dist/web/index.js +4 -4
- package/docs/docs/assets/highlight.css +12 -19
- package/docs/docs/assets/search.js +1 -1
- package/docs/docs/classes/WxAPI.html +31 -18
- package/docs/docs/classes/WxAPIControl.html +70 -24
- package/docs/docs/classes/WxDataSetManager.html +22 -21
- package/docs/docs/classes/WxInfoControl.html +37 -10
- package/docs/docs/classes/WxLegendControl.html +33 -11
- package/docs/docs/classes/WxStyleEditorControl.html +206 -94
- package/docs/docs/classes/WxTileSource.html +40 -40
- package/docs/docs/classes/WxTimeControl.html +58 -20
- package/docs/docs/index.html +188 -101
- package/docs/docs/interfaces/FrameworkOptions.html +3 -3
- package/docs/docs/interfaces/WxSourceLayerOptions.html +5 -5
- package/docs/docs/modules.html +12 -130
- package/docs/docs/types/Loader.html +3 -59
- package/docs/docs/types/Painter.html +3 -59
- package/docs/docs/types/WxLayer.html +3 -59
- package/docs/docs/variables/WxLayerBaseImplementation.html +3 -59
- package/docs/script/script.css +1 -1
- package/docs/script/script.js +6 -6
- package/package.json +3 -3
- package/src_example/frwrkdeps.ts +131 -80
- package/src_example/index.ts +2 -53
- package/src_example/start.ts +143 -300
- package/dep.dot +0 -33
- package/dep.svg +0 -233
- package/docs/docs/classes/DataIntegral.html +0 -154
- package/docs/docs/classes/QTree.html +0 -185
- package/docs/docs/classes/RawCLUT.html +0 -143
- package/docs/docs/classes/TilesCache.html +0 -108
- package/docs/docs/enums/TileType.html +0 -80
- package/docs/docs/functions/WXLOG.html +0 -127
- package/docs/docs/functions/WxCreateLegend.html +0 -135
- package/docs/docs/functions/WxGetColorSchemes.html +0 -122
- package/docs/docs/functions/WxGetColorStyles.html +0 -122
- package/docs/docs/functions/WxTilesLogging.html +0 -130
- package/docs/docs/interfaces/CachedUriLoaderPromiseFunc.html +0 -108
- package/docs/docs/interfaces/ColorStylesIncomplete.html +0 -125
- package/docs/docs/interfaces/Converter.html +0 -81
- package/docs/docs/interfaces/DataPicture.html +0 -95
- package/docs/docs/interfaces/IntegralPare.html +0 -81
- package/docs/docs/interfaces/SLinePoint.html +0 -77
- package/docs/docs/interfaces/Tree.html +0 -74
- package/docs/docs/interfaces/WxAPIOptions.html +0 -173
- package/docs/docs/interfaces/WxAllBoundariesMeta.html +0 -90
- package/docs/docs/interfaces/WxAllDatasetsShortMetas.html +0 -125
- package/docs/docs/interfaces/WxBoundaryMeta.html +0 -99
- package/docs/docs/interfaces/WxColorSchemes.html +0 -126
- package/docs/docs/interfaces/WxColorStyleStrict.html +0 -359
- package/docs/docs/interfaces/WxColorStyleWeak.html +0 -388
- package/docs/docs/interfaces/WxColorStylesStrict.html +0 -74
- package/docs/docs/interfaces/WxColorStylesWeakMixed.html +0 -125
- package/docs/docs/interfaces/WxData.html +0 -85
- package/docs/docs/interfaces/WxDataSetManagerOptions.html +0 -117
- package/docs/docs/interfaces/WxDatasetMeta.html +0 -144
- package/docs/docs/interfaces/WxDatasetShortMeta.html +0 -91
- package/docs/docs/interfaces/WxLayerAPI.html +0 -375
- package/docs/docs/interfaces/WxLayerBaseAPI.html +0 -242
- package/docs/docs/interfaces/WxLayerOptions.html +0 -113
- package/docs/docs/interfaces/WxLegend.html +0 -118
- package/docs/docs/interfaces/WxLngLat.html +0 -81
- package/docs/docs/interfaces/WxRasterData.html +0 -118
- package/docs/docs/interfaces/WxRequestInit.html +0 -70
- package/docs/docs/interfaces/WxTick.html +0 -100
- package/docs/docs/interfaces/WxTileInfo.html +0 -142
- package/docs/docs/interfaces/WxUnits.html +0 -125
- package/docs/docs/interfaces/WxVariableMeta.html +0 -109
- package/docs/docs/interfaces/WxVariablesMetas.html +0 -125
- package/docs/docs/interfaces/XYZ.html +0 -84
- package/docs/docs/types/DataIntegrals.html +0 -118
- package/docs/docs/types/DataPictures.html +0 -118
- package/docs/docs/types/ListenerMethod.html +0 -134
- package/docs/docs/types/SLine.html +0 -118
- package/docs/docs/types/SubTrees.html +0 -118
- package/docs/docs/types/SubTreesN.html +0 -118
- package/docs/docs/types/TreeN.html +0 -118
- package/docs/docs/types/WxDate.html +0 -125
- package/docs/docs/types/WxEventType.html +0 -121
- package/docs/docs/types/WxInstances.html +0 -118
- package/docs/docs/types/WxLayerVarsNames.html +0 -118
- package/docs/docs/types/WxURIs.html +0 -118
- package/docs/docs/types/WxUnitTuple.html +0 -118
package/src_example/start.ts
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
import { WxAPIControl } from
|
|
2
|
-
import { WxInfoControl } from
|
|
3
|
-
import { WxLegendControl } from
|
|
4
|
-
import { WxStyleEditorControl } from
|
|
5
|
-
import { WxTimeControl } from
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
}
|