@metoceanapi/wxtiles-common 0.0.11 → 0.0.12
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/.github/workflows/lint.yml +1 -1
- package/.github/workflows/validate-pull-request-title.yml +17 -0
- package/biome.json +16 -3
- package/controls/WxAPIControl.ts +14 -18
- package/controls/WxStyleEditorControl.ts +6 -1
- package/controls/WxTimeControl.ts +1 -1
- package/fonts/barbs.woff +0 -0
- package/managers/BaseDatasetManager.ts +1 -3
- package/managers/WxAllDatasetsManager.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.json +29 -17
- package/types.ts +1 -1
- package/utils/qtree.ts +2 -1
- package/utils/tests_wxtools.ts +10 -10
- package/utils/wxtools.ts +1 -0
- package/wxapi.ts +3 -4
- package/wxlayer/WxImplementation.ts +6 -4
- package/wxlayer/loadertools.ts +2 -2
- package/wxlayer/painter.ts +7 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: "Validate Pull Request Title"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request_target:
|
|
5
|
+
types: [opened, edited, synchronize]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
pull-requests: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
main:
|
|
12
|
+
name: Validate PR title
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: amannn/action-semantic-pull-request@v5
|
|
16
|
+
env:
|
|
17
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/biome.json
CHANGED
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
"linter": {
|
|
7
7
|
"enabled": true,
|
|
8
8
|
"rules": {
|
|
9
|
-
"recommended": true
|
|
9
|
+
"recommended": true,
|
|
10
|
+
"suspicious": {
|
|
11
|
+
"noExplicitAny": "off"
|
|
12
|
+
},
|
|
13
|
+
"style": {
|
|
14
|
+
"noParameterAssign": "off"
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
17
|
},
|
|
12
18
|
"files": {
|
|
@@ -14,11 +20,18 @@
|
|
|
14
20
|
},
|
|
15
21
|
"javascript": {
|
|
16
22
|
"formatter": {
|
|
17
|
-
"trailingCommas": "
|
|
23
|
+
"trailingCommas": "all",
|
|
18
24
|
"quoteStyle": "single",
|
|
19
25
|
"jsxQuoteStyle": "single",
|
|
20
26
|
"arrowParentheses": "always",
|
|
21
|
-
"lineWidth": 160
|
|
27
|
+
"lineWidth": 160,
|
|
28
|
+
"indentStyle": "space",
|
|
29
|
+
"indentWidth": 2
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"json": {
|
|
33
|
+
"formatter": {
|
|
34
|
+
"indentStyle": "space"
|
|
22
35
|
}
|
|
23
36
|
}
|
|
24
37
|
}
|
package/controls/WxAPIControl.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { WxAPI } from
|
|
2
|
-
import { ControlBusy } from
|
|
3
|
-
import { ControlDataset } from
|
|
4
|
-
import { ControlFilter } from
|
|
1
|
+
import type { WxAPI } from '../wxapi';
|
|
2
|
+
import { ControlBusy } from './WxAPIControl/WxAPIControl-busy';
|
|
3
|
+
import { ControlDataset } from './WxAPIControl/WxAPIControl-datasets';
|
|
4
|
+
import { ControlFilter } from './WxAPIControl/WxAPIControl-filter';
|
|
5
5
|
|
|
6
6
|
export interface ControlElement {
|
|
7
7
|
attachToDom(container: HTMLDivElement): void;
|
|
@@ -9,11 +9,7 @@ export interface ControlElement {
|
|
|
9
9
|
setValue(value: string): void;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export type onChangeControl = (
|
|
13
|
-
dataset: string,
|
|
14
|
-
variable: string,
|
|
15
|
-
resetStyleAndFlyTo?: boolean
|
|
16
|
-
) => Promise<void>;
|
|
12
|
+
export type onChangeControl = (dataset: string, variable: string, resetStyleAndFlyTo?: boolean) => Promise<void>;
|
|
17
13
|
|
|
18
14
|
// // Leaflet
|
|
19
15
|
// const apiControl = new WxAPIControl();
|
|
@@ -47,16 +43,16 @@ export class WxAPIControl {
|
|
|
47
43
|
variable?: string,
|
|
48
44
|
opts: {
|
|
49
45
|
filter?: string;
|
|
50
|
-
} = {}
|
|
46
|
+
} = {},
|
|
51
47
|
) {
|
|
52
|
-
const div = document.createElement(
|
|
53
|
-
div.className =
|
|
54
|
-
div.style.borderStyle =
|
|
55
|
-
div.style.borderColor =
|
|
56
|
-
div.style.backgroundColor =
|
|
57
|
-
div.style.padding =
|
|
58
|
-
div.style.display =
|
|
59
|
-
div.style.flexDirection =
|
|
48
|
+
const div = document.createElement('div');
|
|
49
|
+
div.className = 'mapboxgl-ctrl leaflet-control';
|
|
50
|
+
div.style.borderStyle = 'solid';
|
|
51
|
+
div.style.borderColor = '#000';
|
|
52
|
+
div.style.backgroundColor = '#aaaaaaaa';
|
|
53
|
+
div.style.padding = '5px';
|
|
54
|
+
div.style.display = 'flex';
|
|
55
|
+
div.style.flexDirection = 'column';
|
|
60
56
|
this._div = div;
|
|
61
57
|
|
|
62
58
|
// Add filter input field
|
|
@@ -132,7 +132,7 @@ export class WxStyleEditorControl {
|
|
|
132
132
|
this.parent.onmousemove =
|
|
133
133
|
this.parent.ondblclick =
|
|
134
134
|
this.parent.onclick =
|
|
135
|
-
(e) => e.stopPropagation?.(); // in case of Leaflet
|
|
135
|
+
(e: MouseEvent | PointerEvent) => e.stopPropagation?.(); // in case of Leaflet
|
|
136
136
|
|
|
137
137
|
const { base } = WxGetColorStyles();
|
|
138
138
|
this.styleBase = base;
|
|
@@ -454,6 +454,7 @@ export class WxStyleEditorControl {
|
|
|
454
454
|
protected _getStyleFromDiv(): WxColorStyleWeak {
|
|
455
455
|
const objFromValue = (field: string) => {
|
|
456
456
|
try {
|
|
457
|
+
// @ts-ignore
|
|
457
458
|
return this[field].value ? JSON.parse(this[field].value) : undefined;
|
|
458
459
|
} catch (e) {
|
|
459
460
|
console.log(field, " : parsing error: ", e);
|
|
@@ -604,7 +605,9 @@ export class WxStyleEditorControl {
|
|
|
604
605
|
protected _onDivChange(): void {
|
|
605
606
|
const style = this._getStyleFromDiv();
|
|
606
607
|
for (const key of Object.keys(style)) {
|
|
608
|
+
// @ts-ignore
|
|
607
609
|
if (style[key] === undefined || style[key] === "" || style[key].length === 0) {
|
|
610
|
+
// @ts-ignore
|
|
608
611
|
delete style[key];
|
|
609
612
|
}
|
|
610
613
|
}
|
|
@@ -656,6 +659,7 @@ function createEl<K extends keyof HTMLElementTagNameMap>(
|
|
|
656
659
|
* treated as distinct and sorted alphabetically in a case-insensitive manner.
|
|
657
660
|
*/
|
|
658
661
|
// biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
|
|
662
|
+
// @ts-ignore
|
|
659
663
|
function JSONsort(o: any) {
|
|
660
664
|
if (Array.isArray(o)) {
|
|
661
665
|
return o.map(JSONsort);
|
|
@@ -669,6 +673,7 @@ function JSONsort(o: any) {
|
|
|
669
673
|
return aa === bb ? 0 : aa > bb ? 1 : -1;
|
|
670
674
|
});
|
|
671
675
|
return keys.reduce((a, k) => {
|
|
676
|
+
// @ts-ignore
|
|
672
677
|
a[k] = JSONsort(o[k]);
|
|
673
678
|
return a;
|
|
674
679
|
}, {});
|
|
@@ -94,7 +94,7 @@ declare interface WxTileSource {
|
|
|
94
94
|
*
|
|
95
95
|
* @returns {Promise<void>} A promise that resolves when the coarse level is set.
|
|
96
96
|
*/
|
|
97
|
-
setCoarseLevel(number): Promise<void>;
|
|
97
|
+
setCoarseLevel(level: number): Promise<void>;
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Registers a listener for a specific event type on the tile source.
|
package/fonts/barbs.woff
CHANGED
|
Binary file
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { WXLOG
|
|
1
|
+
import { WXLOG } from "../utils/wxtools";
|
|
2
2
|
import type {
|
|
3
3
|
WxAllBoundariesMeta,
|
|
4
|
-
WxAllDatasetsShortMetas,
|
|
5
4
|
WxDatasetMeta,
|
|
6
5
|
WxVariableMeta,
|
|
7
6
|
WxDate,
|
|
8
7
|
WxLayerVarsNames,
|
|
9
|
-
WxLayerOptions,
|
|
10
8
|
WxDataSetManagerOptions,
|
|
11
9
|
} from "../types";
|
|
12
10
|
import type { WxAPI } from "../wxapi";
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Output configuration
|
|
4
|
+
"outDir": "dist/es",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"emitDeclarationOnly": true,
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
|
|
9
|
+
// Module resolution
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
|
|
15
|
+
// Target and library
|
|
16
|
+
"target": "ES2020",
|
|
17
|
+
"lib": ["ES2020", "DOM"],
|
|
18
|
+
|
|
19
|
+
// Strict type checking (all enabled by "strict")
|
|
20
|
+
"strict": true,
|
|
21
|
+
|
|
22
|
+
// Additional checks
|
|
23
|
+
"noImplicitOverride": true,
|
|
24
|
+
"noImplicitReturns": true,
|
|
25
|
+
"noUnusedLocals": true,
|
|
26
|
+
"noUnusedParameters": true,
|
|
27
|
+
"noFallthroughCasesInSwitch": true,
|
|
28
|
+
"noUncheckedSideEffectImports": true
|
|
29
|
+
},
|
|
30
|
+
"exclude": ["node_modules", "dist"]
|
|
19
31
|
}
|
package/types.ts
CHANGED
|
@@ -326,7 +326,7 @@ export interface WxLngLat {
|
|
|
326
326
|
* Used in {@link WxLayerBaseImplementation} cache of the renderes tiles
|
|
327
327
|
* */
|
|
328
328
|
export class WxRasterDataCache extends Map<string, WxRasterData> {
|
|
329
|
-
clear(): void {
|
|
329
|
+
override clear(): void {
|
|
330
330
|
WXLOG("TilesCache.clear()");
|
|
331
331
|
|
|
332
332
|
for (const v of this.values()) {
|
package/utils/qtree.ts
CHANGED
|
@@ -90,7 +90,8 @@ export class QTree {
|
|
|
90
90
|
const _seamask = await fetchJson<string>(input, requestInit);
|
|
91
91
|
this._qtree = qtreeFromString(_seamask, { pos: 0 });
|
|
92
92
|
} catch (e) {
|
|
93
|
-
|
|
93
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
94
|
+
throw new Error(`Failed to load QTree: ${message}`);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
this._qtreedepth = getTreeDepth(this._qtree);
|
package/utils/tests_wxtools.ts
CHANGED
|
@@ -49,21 +49,21 @@ function ft_printIm(raw: ArrayLike<number>, n: number, comment: string) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function ft_Uint16ArrayRandom() {
|
|
52
|
-
const seed = 1;
|
|
52
|
+
// const seed = 1;
|
|
53
53
|
// const rnd = () => Math.floor(Math.abs(Math.sin(seed++)) * 32000 + 32000);
|
|
54
54
|
const rnd = () => Math.floor(Math.random() * 32000);
|
|
55
55
|
return new Uint16Array(258 * 258).map(rnd);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function ft_Uint16ArrayAscent() {
|
|
59
|
-
return new Uint16Array(258 * 258).map((
|
|
59
|
+
return new Uint16Array(258 * 258).map((_v, i) => (i % 258) + ~~(i / 258));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function ft_Uint16ArrayDescent() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
62
|
+
// function ft_Uint16ArrayDescent() {
|
|
63
|
+
// return new Uint16Array(258 * 258).map(
|
|
64
|
+
// (_v, i) => 514 - ((i % 258) + ~~(i / 258)),
|
|
65
|
+
// );
|
|
66
|
+
// }
|
|
67
67
|
|
|
68
68
|
function ft_Uint32ArrayCompare(a: ArrayLike<number>, b: ArrayLike<number>) {
|
|
69
69
|
if (a.length !== b.length) return false;
|
|
@@ -102,9 +102,9 @@ function ft_buildDataIntegralAscent(): DataIntegral {
|
|
|
102
102
|
return new DataIntegral(ft_Uint16ArrayAscent(), 0, 1, 1);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function ft_buildDataIntegralDescend(): DataIntegral {
|
|
106
|
-
|
|
107
|
-
}
|
|
105
|
+
// function ft_buildDataIntegralDescend(): DataIntegral {
|
|
106
|
+
// return new DataIntegral(ft_Uint16ArrayDescent(), 0, 1, 1);
|
|
107
|
+
// }
|
|
108
108
|
|
|
109
109
|
function ft_buildDataIntegralRandom(): DataIntegral {
|
|
110
110
|
return new DataIntegral(ft_Uint16ArrayRandom(), 0, 1, 1);
|
package/utils/wxtools.ts
CHANGED
package/wxapi.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import "@metoceanapi/wxtiles-common/wxtiles.css";
|
|
2
|
-
|
|
3
|
+
import { WxAllDatasetsManager } from "./managers/WxAllDatasetsManager";
|
|
3
4
|
import { QTree } from "./utils/qtree";
|
|
4
5
|
import {
|
|
5
6
|
WXLOG,
|
|
@@ -10,9 +11,7 @@ import {
|
|
|
10
11
|
loadImageData,
|
|
11
12
|
uriXYZ,
|
|
12
13
|
} from "./utils/wxtools";
|
|
13
|
-
import type { WxAPIOptions,
|
|
14
|
-
import { BaseDatasetManager } from "./managers/BaseDatasetManager";
|
|
15
|
-
import { WxAllDatasetsManager } from "./managers/WxAllDatasetsManager";
|
|
14
|
+
import type { WxAPIOptions, WxDataSetManagerOptions, WxDatasetMeta } from "./types";
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* WxAPI is an initialisation object for the library. See {@link WxAPIOptions} for options.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { BaseDatasetManager } from "../managers/BaseDatasetManager";
|
|
2
|
+
import type { WxDatasetMeta, WxDate, WxEventType, WxLayerVarsNames, WxRasterData, WxRasterDataCache, WxRequestInit, WxVariableMeta } from "../types";
|
|
1
3
|
import {
|
|
2
4
|
WXLOG,
|
|
3
5
|
type WxColorStyleStrict,
|
|
@@ -6,8 +8,6 @@ import {
|
|
|
6
8
|
type XYZ,
|
|
7
9
|
} from "../utils/wxtools";
|
|
8
10
|
import type { WxLayer } from "./wxlayer";
|
|
9
|
-
import type { WxRequestInit, WxDatasetMeta, WxVariableMeta, WxDate, WxLayerVarsNames, WxLngLat, WxRasterDataCache, WxTileInfo, WxLayerBaseAPI, WxRasterData, WxLayerOptions, WxEventType } from "../types";
|
|
10
|
-
import type { BaseDatasetManager } from "../managers/BaseDatasetManager";
|
|
11
11
|
|
|
12
12
|
// biome-ignore lint/suspicious/noExplicitAny: necessary for mixins
|
|
13
13
|
type GenericConstraintConstructor<T> = new (...args: any[]) => T;
|
|
@@ -288,8 +288,8 @@ export function WxLayerBaseImplementationMixin<WxDatasetManagerT extends BaseDat
|
|
|
288
288
|
* A dummy function to be replaced by ancestor classes.
|
|
289
289
|
*/
|
|
290
290
|
async _reloadVisible(
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
_requestInit?: WxRequestInit,
|
|
292
|
+
_redraw?: boolean,
|
|
293
293
|
): Promise<void> {}
|
|
294
294
|
|
|
295
295
|
/**
|
|
@@ -336,12 +336,14 @@ export function WxLayerBaseImplementationMixin<WxDatasetManagerT extends BaseDat
|
|
|
336
336
|
// it's ok if the tile is not found. Just return empty tile, or...
|
|
337
337
|
|
|
338
338
|
// ...or, rethrow 'AbortError' to the framework to handle
|
|
339
|
+
// @ts-ignore
|
|
339
340
|
if (e.name === "AbortError") {
|
|
340
341
|
throw e;
|
|
341
342
|
}
|
|
342
343
|
|
|
343
344
|
// ...or, if the loadTile->loadImage->throw 'reason' is 'instance-not-found', try to update wxdatasetManager, then update the layer
|
|
344
345
|
// if we aren't in the middle of updating wxdatasetManager (others may initiate update as well)
|
|
346
|
+
// @ts-ignore
|
|
345
347
|
if (e.reason === "instance-not-found" && !this._needUpdateDSManager) {
|
|
346
348
|
this._needUpdateDSManager = true;
|
|
347
349
|
WXLOG(
|
package/wxlayer/loadertools.ts
CHANGED
package/wxlayer/painter.ts
CHANGED
|
@@ -221,7 +221,7 @@ function _printIsolineTextWithStroke(
|
|
|
221
221
|
val: string,
|
|
222
222
|
ctx: CanvasRenderingContext2D,
|
|
223
223
|
// biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
|
|
224
|
-
|
|
224
|
+
_z: any,
|
|
225
225
|
): void {
|
|
226
226
|
ctx.strokeText(val, 0, 0);
|
|
227
227
|
} // _printIsolineTextWithStroke
|
|
@@ -293,8 +293,12 @@ function _printVectorsStatic<WxDatasetManagerT extends BaseDatasetManager>(
|
|
|
293
293
|
? style.vectorFactor * 0.5
|
|
294
294
|
: 0.2; /*0.2 to fit font*/
|
|
295
295
|
const vecCode =
|
|
296
|
-
Math.min(
|
|
297
|
-
|
|
296
|
+
Math.min(
|
|
297
|
+
style.vectorType === "barbs"
|
|
298
|
+
? Math.round(CLUT.DataToKnots(vecLen) * sm) // nearest 5 kn
|
|
299
|
+
: ~~(CLUT.DataToKnots(vecLen) * sm),
|
|
300
|
+
25 /* to fit .ttf */,
|
|
301
|
+
) + 65; /* A */
|
|
298
302
|
const vecChar = String.fromCharCode(vecCode);
|
|
299
303
|
switch (style.vectorColor) {
|
|
300
304
|
case "inverted":
|