signalk-livedepth-plugin 0.3.4 → 0.3.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/public/styles.css CHANGED
@@ -45,6 +45,14 @@ h2 {
45
45
  font-weight: 600;
46
46
  }
47
47
 
48
+ h3 {
49
+ margin: 20px 0 12px;
50
+ padding-top: 12px;
51
+ font-size: 14px;
52
+ font-weight: 600;
53
+ border-top: 1px solid var(--line);
54
+ }
55
+
48
56
  .field {
49
57
  display: flex;
50
58
  flex-direction: column;
@@ -105,6 +113,15 @@ input[type="checkbox"] {
105
113
  accent-color: var(--accent);
106
114
  }
107
115
 
116
+ input[type="color"] {
117
+ width: 44px;
118
+ height: 28px;
119
+ padding: 0;
120
+ border: 1px solid var(--line);
121
+ border-radius: 4px;
122
+ background: var(--bg);
123
+ }
124
+
108
125
  .status {
109
126
  color: var(--muted);
110
127
  }
@@ -1,34 +0,0 @@
1
- import { BathymetryData } from "../types.js";
2
- import { TileStore } from "./store.js";
3
- /**
4
- * Folds soundings into the base-level tiles and, on
5
- * {@link TileAccumulator.flush}, writes the changed tiles and min-pools their
6
- * ancestors. Batched so many soundings become one transaction; shared by the
7
- * live writer and any bulk load.
8
- */
9
- export interface TileAccumulator {
10
- add(data: BathymetryData): void;
11
- flush(): void;
12
- /** Tiles touched since the last flush. */
13
- readonly pending: number;
14
- }
15
- export interface AccumulatorOptions {
16
- baseZoom?: number;
17
- /** Rebuild each changed tile's ancestors on flush (the default). Set `false`
18
- * for a bulk load and call {@link rebuildAncestors} once at the end: walking
19
- * the whole pyramid for every changed tile on every batch repeats the same
20
- * work whenever a tile is touched in many batches. */
21
- ancestors?: boolean;
22
- }
23
- export declare function createTileAccumulator(store: TileStore, { baseZoom, ancestors }?: AccumulatorOptions): TileAccumulator;
24
- /**
25
- * Build every level of the pyramid from the base tiles in one bottom-up pass:
26
- * pool each level into the one below, reading each child once. Used after a
27
- * bulk load that ran with `ancestors: false`, so the whole pyramid is built
28
- * once rather than re-walked per changed tile per batch.
29
- */
30
- export declare function rebuildAncestors(store: TileStore, { baseZoom, minZoom, }?: {
31
- baseZoom?: number;
32
- minZoom?: number;
33
- }): void;
34
- //# sourceMappingURL=accumulator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accumulator.d.ts","sourceRoot":"","sources":["../../src/tiles/accumulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAW7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAChC,KAAK,IAAI,IAAI,CAAC;IACd,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;0DAGsD;IACtD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,EAChB,EAAE,QAAoB,EAAE,SAAgB,EAAE,GAAE,kBAAuB,GAClE,eAAe,CAwCjB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,EAChB,EACE,QAAoB,EACpB,OAAkB,GACnB,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC9C,IAAI,CAwBN"}
@@ -1,60 +0,0 @@
1
- import { BASE_ZOOM, MIN_ZOOM, TILE_SIZE, encodeDepth, lngLatToCell, mergeCell, minPoolTile, } from "./grid.js";
2
- export function createTileAccumulator(store, { baseZoom = BASE_ZOOM, ancestors = true } = {}) {
3
- const dirty = new Map();
4
- return {
5
- add(data) {
6
- const { x, y, cx, cy } = lngLatToCell(data.longitude, data.latitude, baseZoom);
7
- const key = `${x},${y}`;
8
- let tile = dirty.get(key);
9
- if (!tile) {
10
- tile = { z: baseZoom, x, y, cells: new Map() };
11
- dirty.set(key, tile);
12
- }
13
- mergeCell(tile.cells, cy * TILE_SIZE + cx, encodeDepth(data.depth));
14
- },
15
- flush() {
16
- if (dirty.size === 0)
17
- return;
18
- const tiles = [...dirty.values()];
19
- dirty.clear();
20
- store.transaction(() => {
21
- for (const tile of tiles) {
22
- store.merge(tile.z, tile.x, tile.y, tile.cells);
23
- if (ancestors) {
24
- store.updateAncestors(tile.z, tile.x, tile.y);
25
- }
26
- }
27
- });
28
- },
29
- get pending() {
30
- return dirty.size;
31
- },
32
- };
33
- }
34
- /**
35
- * Build every level of the pyramid from the base tiles in one bottom-up pass:
36
- * pool each level into the one below, reading each child once. Used after a
37
- * bulk load that ran with `ancestors: false`, so the whole pyramid is built
38
- * once rather than re-walked per changed tile per batch.
39
- */
40
- export function rebuildAncestors(store, { baseZoom = BASE_ZOOM, minZoom = MIN_ZOOM, } = {}) {
41
- for (let z = baseZoom; z > minZoom; z--) {
42
- const parents = new Map();
43
- for (const { x, y } of store.listTiles(z)) {
44
- const px = x >> 1;
45
- const py = y >> 1;
46
- parents.set(`${px},${py}`, { x: px, y: py });
47
- }
48
- store.transaction(() => {
49
- for (const { x, y } of parents.values()) {
50
- store.write(z - 1, x, y, minPoolTile([
51
- store.read(z, x * 2, y * 2),
52
- store.read(z, x * 2 + 1, y * 2),
53
- store.read(z, x * 2, y * 2 + 1),
54
- store.read(z, x * 2 + 1, y * 2 + 1),
55
- ]));
56
- }
57
- });
58
- }
59
- }
60
- //# sourceMappingURL=accumulator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accumulator.js","sourceRoot":"","sources":["../../src/tiles/accumulator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EAET,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,GACZ,MAAM,WAAW,CAAC;AAyBn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AC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;oBAC/B,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBAC/B,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;iBACpC,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -1,59 +0,0 @@
1
- /**
2
- * Fixed-grid geometry for the bathymetry tile store.
3
- *
4
- * A Web-Mercator XYZ quadtree: level `z` splits the world into `2^z` tiles of
5
- * {@link TILE_SIZE} cells each, so a tile's cell grid is square on the ground.
6
- * The base level is chosen so a cell is a fraction of a metre; coarser levels
7
- * are the min-pooled parents (see {@link minPoolTile}), so a shoal is never lost
8
- * when the chart is zoomed out.
9
- *
10
- * A tile is stored sparsely — only cells that have a sounding — because a
11
- * vessel's track is a thin line through a tile and a dense 256x256 array would
12
- * be almost entirely empty. Each occupied cell is a 5-byte record:
13
- * `cx:u8, cy:u8, depthCm:u16le, count:u8`.
14
- */
15
- export declare const TILE_SIZE = 256;
16
- /** Base level: cell ≈ 0.15 m at the equator (156543.03 / 2^20). */
17
- export declare const BASE_ZOOM = 20;
18
- /** Coarsest level built and served (≈ 2.4 km/cell at z4). Low enough that a
19
- * regional zoom-out is covered by a handful of tiles; the min-pool keeps a
20
- * shoal visible however far the chart is zoomed out. */
21
- export declare const MIN_ZOOM = 4;
22
- /** Decoded value for a cell with no sounding. Never stored. */
23
- export declare const NODATA = 65535;
24
- /** Bytes per occupied cell: cx(1) + cy(1) + depth(2) + count(1). */
25
- export declare const RECORD_BYTES = 5;
26
- /** One cell's aggregate: shallowest depth in centimetres and how many soundings. */
27
- export type Cell = {
28
- depth: number;
29
- count: number;
30
- };
31
- /** A tile's occupied cells, keyed by `cy * TILE_SIZE + cx`. */
32
- export type TileCells = Map<number, Cell>;
33
- /** Ground size of one cell, in metres, on the equator. */
34
- export declare function cellSize(z: number): number;
35
- /** The level-z tile and the cell within it that contains a lon/lat. */
36
- export declare function lngLatToCell(lon: number, lat: number, z: number): {
37
- x: number;
38
- y: number;
39
- cx: number;
40
- cy: number;
41
- };
42
- /** Quantise a depth in metres to the store's centimetre resolution. */
43
- export declare function encodeDepth(metres: number): number;
44
- /** Decode a stored depth in centimetres back to metres. */
45
- export declare function decodeDepth(cm: number): number;
46
- /** Merge a sounding into a cell, keeping the shallowest and counting samples. */
47
- export declare function mergeCell(cells: TileCells, key: number, depthCm: number, count?: number): void;
48
- /** Encode a tile's cells to its sparse on-disk/over-the-wire representation. */
49
- export declare function encodeTile(cells: TileCells): Buffer;
50
- /** Decode a sparse tile buffer back to its cells. */
51
- export declare function decodeTile(buf: Buffer | Uint8Array): TileCells;
52
- /**
53
- * Build a parent tile's cells from its four child tiles (level z+1, ordered
54
- * `[southwest, southeast, northwest, northeast]` = `[(0,0),(1,0),(0,1),(1,1)]`
55
- * in child-tile offsets). A parent cell keeps the **minimum** depth of its four
56
- * children and the summed count, so zooming out never deepens a shoal.
57
- */
58
- export declare function minPoolTile(children: (TileCells | undefined)[]): TileCells;
59
- //# sourceMappingURL=grid.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/tiles/grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,SAAS,MAAM,CAAC;AAC7B,mEAAmE;AACnE,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B;;wDAEwD;AACxD,eAAO,MAAM,QAAQ,IAAI,CAAC;AAC1B,+DAA+D;AAC/D,eAAO,MAAM,MAAM,QAAS,CAAC;AAC7B,oEAAoE;AACpE,eAAO,MAAM,YAAY,IAAI,CAAC;AAM9B,oFAAoF;AACpF,MAAM,MAAM,IAAI,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACpD,+DAA+D;AAC/D,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAK1C,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1C;AAYD,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;;;;;EAO/D;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGlD;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,KAAK,SAAI,GACR,IAAI,CAQN;AAED,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAWnD;AAED,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAW9D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,CAAC,SAAS,GAAG,SAAS,CAAC,EAAE,GAAG,SAAS,CAe1E"}
@@ -1,121 +0,0 @@
1
- /**
2
- * Fixed-grid geometry for the bathymetry tile store.
3
- *
4
- * A Web-Mercator XYZ quadtree: level `z` splits the world into `2^z` tiles of
5
- * {@link TILE_SIZE} cells each, so a tile's cell grid is square on the ground.
6
- * The base level is chosen so a cell is a fraction of a metre; coarser levels
7
- * are the min-pooled parents (see {@link minPoolTile}), so a shoal is never lost
8
- * when the chart is zoomed out.
9
- *
10
- * A tile is stored sparsely — only cells that have a sounding — because a
11
- * vessel's track is a thin line through a tile and a dense 256x256 array would
12
- * be almost entirely empty. Each occupied cell is a 5-byte record:
13
- * `cx:u8, cy:u8, depthCm:u16le, count:u8`.
14
- */
15
- export const TILE_SIZE = 256;
16
- /** Base level: cell ≈ 0.15 m at the equator (156543.03 / 2^20). */
17
- export const BASE_ZOOM = 20;
18
- /** Coarsest level built and served (≈ 2.4 km/cell at z4). Low enough that a
19
- * regional zoom-out is covered by a handful of tiles; the min-pool keeps a
20
- * shoal visible however far the chart is zoomed out. */
21
- export const MIN_ZOOM = 4;
22
- /** Decoded value for a cell with no sounding. Never stored. */
23
- export const NODATA = 0xffff;
24
- /** Bytes per occupied cell: cx(1) + cy(1) + depth(2) + count(1). */
25
- export const RECORD_BYTES = 5;
26
- const EARTH_RADIUS = 6378137;
27
- const ORIGIN_SHIFT = Math.PI * EARTH_RADIUS; // 20037508.342789244
28
- const WORLD_WIDTH = 2 * ORIGIN_SHIFT;
29
- const clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
30
- /** Ground size of one cell, in metres, on the equator. */
31
- export function cellSize(z) {
32
- return WORLD_WIDTH / (TILE_SIZE * Math.pow(2, z));
33
- }
34
- /** Fractional tile coordinates of a lon/lat at level z (x east, y south). */
35
- function tileFraction(lon, lat, z) {
36
- const n = Math.pow(2, z);
37
- const latRad = (clamp(lat, -85.05112878, 85.05112878) * Math.PI) / 180;
38
- const x = ((lon + 180) / 360) * n;
39
- const y = ((1 - Math.log(Math.tan(latRad) + 1 / Math.cos(latRad)) / Math.PI) / 2) * n;
40
- return { x, y, n };
41
- }
42
- /** The level-z tile and the cell within it that contains a lon/lat. */
43
- export function lngLatToCell(lon, lat, z) {
44
- const { x: fx, y: fy, n } = tileFraction(lon, lat, z);
45
- const x = clamp(Math.floor(fx), 0, n - 1);
46
- const y = clamp(Math.floor(fy), 0, n - 1);
47
- const cx = clamp(Math.floor((fx - x) * TILE_SIZE), 0, TILE_SIZE - 1);
48
- const cy = clamp(Math.floor((fy - y) * TILE_SIZE), 0, TILE_SIZE - 1);
49
- return { x, y, cx, cy };
50
- }
51
- /** Quantise a depth in metres to the store's centimetre resolution. */
52
- export function encodeDepth(metres) {
53
- if (!Number.isFinite(metres))
54
- return NODATA;
55
- return clamp(Math.round(metres * 100), 0, NODATA - 1);
56
- }
57
- /** Decode a stored depth in centimetres back to metres. */
58
- export function decodeDepth(cm) {
59
- return cm === NODATA ? NaN : cm / 100;
60
- }
61
- /** Merge a sounding into a cell, keeping the shallowest and counting samples. */
62
- export function mergeCell(cells, key, depthCm, count = 1) {
63
- const existing = cells.get(key);
64
- if (!existing) {
65
- cells.set(key, { depth: depthCm, count: Math.min(255, count) });
66
- return;
67
- }
68
- if (depthCm < existing.depth)
69
- existing.depth = depthCm;
70
- existing.count = Math.min(255, existing.count + count);
71
- }
72
- /** Encode a tile's cells to its sparse on-disk/over-the-wire representation. */
73
- export function encodeTile(cells) {
74
- const buf = Buffer.alloc(cells.size * RECORD_BYTES);
75
- let offset = 0;
76
- for (const [key, { depth, count }] of cells) {
77
- buf.writeUInt8(key % TILE_SIZE, offset);
78
- buf.writeUInt8(Math.floor(key / TILE_SIZE), offset + 1);
79
- buf.writeUInt16LE(depth, offset + 2);
80
- buf.writeUInt8(count, offset + 4);
81
- offset += RECORD_BYTES;
82
- }
83
- return buf;
84
- }
85
- /** Decode a sparse tile buffer back to its cells. */
86
- export function decodeTile(buf) {
87
- const cells = new Map();
88
- const view = Buffer.isBuffer(buf) ? buf : Buffer.from(buf);
89
- for (let o = 0; o + RECORD_BYTES <= view.length; o += RECORD_BYTES) {
90
- const cx = view.readUInt8(o);
91
- const cy = view.readUInt8(o + 1);
92
- const depth = view.readUInt16LE(o + 2);
93
- const count = view.readUInt8(o + 4);
94
- cells.set(cy * TILE_SIZE + cx, { depth, count });
95
- }
96
- return cells;
97
- }
98
- /**
99
- * Build a parent tile's cells from its four child tiles (level z+1, ordered
100
- * `[southwest, southeast, northwest, northeast]` = `[(0,0),(1,0),(0,1),(1,1)]`
101
- * in child-tile offsets). A parent cell keeps the **minimum** depth of its four
102
- * children and the summed count, so zooming out never deepens a shoal.
103
- */
104
- export function minPoolTile(children) {
105
- const parent = new Map();
106
- children.forEach((child, index) => {
107
- if (!child)
108
- return;
109
- const dx = index & 1;
110
- const dy = index >> 1;
111
- for (const [key, { depth, count }] of child) {
112
- const cx = key % TILE_SIZE;
113
- const cy = Math.floor(key / TILE_SIZE);
114
- const pcx = (dx * TILE_SIZE + cx) >> 1;
115
- const pcy = (dy * TILE_SIZE + cy) >> 1;
116
- mergeCell(parent, pcy * TILE_SIZE + pcx, depth, count);
117
- }
118
- });
119
- return parent;
120
- }
121
- //# sourceMappingURL=grid.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/tiles/grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAC7B,mEAAmE;AACnE,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAC5B;;wDAEwD;AACxD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAC1B,+DAA+D;AAC/D,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC;AAC7B,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAE9B,MAAM,YAAY,GAAG,OAAO,CAAC;AAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE,GAAG,YAAY,CAAC,CAAC,qBAAqB;AAClE,MAAM,WAAW,GAAG,CAAC,GAAG,YAAY,CAAC;AAOrC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU,EAAE,EAAE,CAClD,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CA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