@nika-js/onlymap 0.13.0 → 0.13.2

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +2 -2
  3. package/bin/dem-tiles.mjs +270 -0
  4. package/bin/onlymapjs.mjs +138 -34
  5. package/dist/{basemap-BxqFTBzX.js → basemap-CdSCIWCl.js} +473 -443
  6. package/dist/basemap.d.ts +16 -3
  7. package/dist/{build-D4iI8O9b.js → build-CUx4yR_O.js} +10 -10
  8. package/dist/camera-altitude.d.ts +29 -0
  9. package/dist/{client-BYFePLZV.js → client-DVkMuuPp.js} +2 -2
  10. package/dist/color.d.ts +15 -0
  11. package/dist/credit-chrome.d.ts +11 -0
  12. package/dist/elements/om-map.d.ts +41 -1
  13. package/dist/geodesy.d.ts +2 -0
  14. package/dist/{geoparquet-BV32P0nI.js → geoparquet-DuCEsCOu.js} +3 -3
  15. package/dist/{globe-view-B_X6obse.js → globe-view-BWNfn-Sx.js} +1 -1
  16. package/dist/ground-controller.d.ts +39 -0
  17. package/dist/{hillshade-9VS_t-Ks.js → hillshade-DyfYxqNm.js} +61 -64
  18. package/dist/{hillshade-shader-DI2uLSNU.js → hillshade-shader-BWA0USDQ.js} +12 -11
  19. package/dist/hillshade-shader.d.ts +2 -2
  20. package/dist/hillshade.d.ts +0 -29
  21. package/dist/{index-IDWDfgTC.js → index-BfHaNHyY.js} +20687 -19351
  22. package/dist/{index-JewSBOjJ.js → index-CCj9Z5yt.js} +38 -38
  23. package/dist/{index-D40H3fpl.js → index-Cc3huYsW.js} +62 -62
  24. package/dist/{index-Bct9VWxi.js → index-DRGcZmBm.js} +1 -1
  25. package/dist/{index-eSuCj2Bn.js → index-DYrgHprN.js} +61 -61
  26. package/dist/{index-D3P6Cfbr.js → index-DabUE8w3.js} +38 -38
  27. package/dist/{index-CbFw6P0B.js → index-DfzI_j0D.js} +1 -1
  28. package/dist/{index-Di1LK4JT.js → index-DiDoH_BG.js} +3 -3
  29. package/dist/{index-BR_5FIN1.js → index-dUoVyYIW.js} +18 -18
  30. package/dist/index.d.ts +1 -1
  31. package/dist/{lerc-C42a0ISa.js → lerc-CUV0h9Ci.js} +1 -1
  32. package/dist/onlymap.standalone.js +37891 -36442
  33. package/dist/onlymapjs.js +49 -49
  34. package/dist/plane-gpu/plane-basemap.d.ts +0 -14
  35. package/dist/{post-process-effect-ktcgAjmv.js → post-process-effect-DPrpqybM.js} +1 -1
  36. package/dist/programmatic.d.ts +3 -1
  37. package/dist/{raster-CIxg_M_1.js → raster-CrRQNJE7.js} +4 -4
  38. package/dist/{raster-pipeline-BODPC9vJ.js → raster-pipeline-D9g8RAo4.js} +11 -11
  39. package/dist/runtime-core.d.ts +132 -0
  40. package/dist/sea-surface.d.ts +18 -0
  41. package/dist/terrain-derive.d.ts +39 -0
  42. package/dist/terrain-ground.d.ts +31 -0
  43. package/dist/terrain-heightfield.d.ts +17 -9
  44. package/dist/terrain-inspect-GowNVtMZ.js +96 -0
  45. package/dist/terrain-inspect.d.ts +34 -0
  46. package/dist/terrain-nodata.d.ts +50 -0
  47. package/dist/terrain-priority.d.ts +92 -0
  48. package/dist/terrain-sample.d.ts +6 -0
  49. package/dist/terrain-skirt.d.ts +6140 -0
  50. package/dist/terrain-texture-mask.d.ts +40 -0
  51. package/dist/terrain-tint.d.ts +61 -0
  52. package/dist/terrain.d.ts +132 -8
  53. package/dist/{text-on-path-LZL6NfwZ.js → text-on-path-BoFbm-tl.js} +1 -1
  54. package/dist/version.d.ts +1 -1
  55. package/dist/viewport-filter.d.ts +9 -0
  56. package/dist/volumetrics.d.ts +11 -0
  57. package/dist/{zarr-D19fNIZt.js → zarr-C8CU8LXU.js} +2 -2
  58. package/docs/cartograph.md +2 -2
  59. package/llms.txt +1 -1
  60. package/onlymapjs.html-data.json +162 -2
  61. package/package.json +2 -1
  62. package/skills/onlymapjs/SKILL.md +5 -2
  63. package/skills/onlymapjs/references/syntax.md +3 -3
@@ -0,0 +1,96 @@
1
+ import { a3 as p, a4 as w, a5 as E, a6 as P, a7 as D, a8 as T, a9 as b, aa as k } from "./index-BfHaNHyY.js";
2
+ const v = [-11e3, 9e3], A = 126, x = 24, R = 32, S = 1;
3
+ async function H(e, i) {
4
+ const a = p(e), o = a.flatMap((t, n) => t.extent ? a.slice(n + 1).map((h) => [t, h]) : []), [r, s] = await Promise.all([
5
+ Promise.all(a.map((t) => L(t, i(t)))),
6
+ Promise.all(o.map(async ([t, n]) => {
7
+ const h = await z(t, n);
8
+ return h ? [I(t, n, h, i(t))] : [];
9
+ }))
10
+ ]);
11
+ return [...r.flat(), ...s.flat()];
12
+ }
13
+ function _(e) {
14
+ if (e.length < 10) return null;
15
+ const i = [...e].sort((t, n) => t - n), a = (t, n) => n[Math.min(n.length - 1, Math.floor(t * n.length))], o = a(0.5, i), r = a(0.9, [...e].map(Math.abs).sort((t, n) => t - n)), s = a(0.9, e.map((t) => Math.abs(t - o)).sort((t, n) => t - n));
16
+ return { median: o, p90: r, spread: s, count: e.length };
17
+ }
18
+ function I(e, i, a, o) {
19
+ const r = (n) => `${Math.abs(n) < 10 ? n.toFixed(1) : Math.round(n)} m`, s = a.spread <= Math.max(1, Math.abs(a.median)), t = (e.verticalOffset ?? 0) - a.median;
20
+ return {
21
+ severity: "warning",
22
+ element: o,
23
+ attribute: s ? "vertical-offset" : "extent",
24
+ message: `Along its extent's edge, "${e.id ?? "this source"}" sits ${r(Math.abs(a.median))} ${a.median > 0 ? "above" : "below"} "${i.id ?? "the next source"}" (median of ${a.count} points; 90 % within ${r(a.p90)}${s ? ", consistently" : `, unevenly — ${r(a.spread)} either side of the median`}).`,
25
+ fix: s ? `A steady step is a vertical datum difference: set vertical-offset="${Number(t.toFixed(2))}" on "${e.id}" (or the opposite on "${i.id}").` : "An uneven step is the datasets disagreeing, not a datum: check both are on the same vertical datum, then feather one into the other where they meet when you tile them."
26
+ };
27
+ }
28
+ async function z(e, i) {
29
+ const [a, o, r, s] = e.extent, t = 0.01, n = N([a + (r - a) * t, o + (s - o) * t, r - (r - a) * t, s - (s - o) * t], A).filter((l) => D(i, l));
30
+ if (n.length < 10) return null;
31
+ const [h, d] = await Promise.all([M(e, n), M(i, n)]), c = [];
32
+ n.forEach((l) => {
33
+ const m = h.elevationAt(l), g = d.elevationAt(l);
34
+ m !== null && g !== null && c.push(m - g);
35
+ });
36
+ const f = _(c);
37
+ return f && Math.abs(f.median) >= S ? f : null;
38
+ }
39
+ function N([e, i, a, o], r) {
40
+ const s = [[[e, i], [a, i]], [[a, i], [a, o]], [[a, o], [e, o]], [[e, o], [e, i]]], t = s.map(([d, c]) => Math.hypot(c[0] - d[0], c[1] - d[1])), n = t.reduce((d, c) => d + c, 0), h = [];
41
+ for (let d = 0; d < r; d++) {
42
+ let c = d / r * n, f = 0;
43
+ for (; f < 3 && c > t[f]; ) c -= t[f++];
44
+ const [l, m] = s[f], g = t[f] ? c / t[f] : 0;
45
+ h.push([l[0] + (m[0] - l[0]) * g, l[1] + (m[1] - l[1]) * g]);
46
+ }
47
+ return h;
48
+ }
49
+ function M(e, i, a = !1) {
50
+ return T(i, a ? { ...e, nodata: void 0 } : e, G(e, i));
51
+ }
52
+ function G(e, i) {
53
+ const a = Math.max(0, e.minZoom ?? 0);
54
+ for (let o = e.maxZoom; o > a; o--)
55
+ if (new Set(i.map((s) => {
56
+ const t = b(s, o);
57
+ return `${t.x}/${t.y}`;
58
+ })).size <= R) return o;
59
+ return a;
60
+ }
61
+ async function L(e, i) {
62
+ if (!e.extent) return [];
63
+ const [a, o, r, s] = e.extent, t = [];
64
+ for (let $ = 0; $ < x; $++) for (let u = 0; u < x; u++) t.push([a + ($ + 0.5) / x * (r - a), o + (u + 0.5) / x * (s - o)]);
65
+ const { tiles: n } = await M(e, t, !0), h = w(n), d = E(e), c = /* @__PURE__ */ new Map();
66
+ let f = 0;
67
+ for (const $ of t) {
68
+ const u = O(n, h, $);
69
+ if (u === null || (f++, u >= v[0] && u <= v[1]) || P(u, d)) continue;
70
+ const y = Math.round(u);
71
+ c.set(y, (c.get(y) ?? 0) + 1);
72
+ }
73
+ const [l, m] = [...c.entries()].sort(($, u) => u[1] - $[1])[0] ?? [];
74
+ if (l === void 0 || m < 3) return [];
75
+ const g = l - (e.verticalOffset ?? 0);
76
+ return [
77
+ {
78
+ severity: "warning",
79
+ element: i,
80
+ attribute: "nodata",
81
+ message: `${m} of ${f} points read ${l} m — no real ground is that ${l > 0 ? "high" : "deep"}: it looks like the value these tiles use where they have no data, drawn as a cliff.`,
82
+ fix: `Set nodata="${g}" on "${e.id ?? "the terrain"}" (terrain-nodata on the map for a single DEM).`
83
+ }
84
+ ];
85
+ }
86
+ function O(e, i, a) {
87
+ const { x: o, y: r, px: s, py: t } = b(a, e.zoom), n = i.get(`${o}/${r}`);
88
+ if (!n) return null;
89
+ const h = Math.min(n.width - 1, Math.floor(s * n.width / 256)), c = (Math.min(n.height - 1, Math.floor(t * n.height / 256)) * n.width + h) * 4;
90
+ return k(e.decoder, n.data[c], n.data[c + 1], n.data[c + 2]);
91
+ }
92
+ export {
93
+ N as edgePoints,
94
+ H as inspectTerrain,
95
+ _ as summarizeSteps
96
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A terrain's data, read (docs/design/underwater-terrain.md, Phase I, piece
3
+ * 3): `map.inspectTerrain()` and `onlymapjs inspect-terrain`. Opt-in because
4
+ * it fetches tiles; warnings only, because the map draws either way. It
5
+ * answers the two questions a user's own survey raises that markup alone
6
+ * cannot:
7
+ *
8
+ * - **A step where two sources meet.** For each source with an extent and
9
+ * each lower-ranked source under that extent, both are read at points just
10
+ * inside the extent's edge (where the partition switches from one to the
11
+ * other). A consistent step is a vertical datum difference — the fix is
12
+ * `vertical-offset` — an uneven one is the data disagreeing.
13
+ * - **A value that is not ground.** Each source is read on a grid at the
14
+ * nearest pixel; heights beyond any real relief, repeated, are the value
15
+ * its tiles use for "no data" — the fix is `nodata`.
16
+ *
17
+ * Tile budgets keep it cheap: each read drops to a zoom where it touches at
18
+ * most a few dozen tiles (never below the source's own min-zoom).
19
+ */
20
+ import type { LngLat } from "./geodesy";
21
+ import type { ValidationEntry } from "./validation";
22
+ import { type TerrainIR, type TerrainSourceIR } from "./terrain";
23
+ export declare function inspectTerrain(ir: TerrainIR, elementOf: (source: TerrainSourceIR) => string): Promise<ValidationEntry[]>;
24
+ export interface Step {
25
+ median: number;
26
+ p90: number;
27
+ /** p90 of the distance from the median — how uneven the step is. */
28
+ spread: number;
29
+ count: number;
30
+ }
31
+ /** The step's statistics, or null when too few points read on both sides. */
32
+ export declare function summarizeSteps(steps: number[]): Step | null;
33
+ /** Points evenly round a box's perimeter. */
34
+ export declare function edgePoints([w, s, e, n]: [number, number, number, number], count: number): LngLat[];
@@ -0,0 +1,50 @@
1
+ /**
2
+ * No-data in a terrain source (docs/design/underwater-terrain.md, Phase I,
3
+ * piece 1): `nodata="-32768"` on an `<om-terrain>` (or `terrain-nodata` on
4
+ * the map) says which height means "not measured here", and the mesh ends
5
+ * at the last measured cell instead of plunging to the sentinel.
6
+ *
7
+ * deck's terrain loader adds a skirt (a wall down from every outer edge)
8
+ * inside its worker, before the runtime sees the mesh — so dropping the
9
+ * triangles on a no-data vertex afterwards would keep half of every skirt
10
+ * quad hanging from one: a slab 32 km deep. A source with nodata therefore
11
+ * loads with NO skirt, and the skirt is added here, after the cut, along the
12
+ * outer edges of what is left — which includes every hole's edge, so a hole
13
+ * is walled down to whatever shows through it like a tile edge is.
14
+ *
15
+ * `addSkirt` below is loaders.gl's own (src/lib/helpers/skirt.ts, MIT), not
16
+ * exported by the package; same geometry, same vertex order.
17
+ */
18
+ export interface TerrainMesh {
19
+ header: {
20
+ vertexCount: number;
21
+ boundingBox: number[][];
22
+ };
23
+ indices: {
24
+ value: Uint32Array;
25
+ size: number;
26
+ };
27
+ attributes: {
28
+ POSITION: {
29
+ value: Float32Array;
30
+ size: number;
31
+ };
32
+ TEXCOORD_0: {
33
+ value: Float32Array;
34
+ size: number;
35
+ };
36
+ };
37
+ [key: string]: unknown;
38
+ }
39
+ /**
40
+ * Drop every triangle with a vertex at `noDataZ` (± `tolerance`, the mesh's
41
+ * units), measure the bounding box over what remains, and skirt the result.
42
+ * The vertex buffers are kept as they are (a dropped vertex is simply no
43
+ * longer indexed); a tile that is all no-data comes back with no triangles.
44
+ */
45
+ export declare function cutNoData(mesh: TerrainMesh, noDataZ: number, tolerance: number, skirtHeight: number): TerrainMesh;
46
+ /** loaders.gl's addSkirt: a wall `skirtHeight` down from every edge that belongs to one triangle only. */
47
+ export declare function addSkirt(attributes: TerrainMesh["attributes"], triangles: Uint32Array, skirtHeight: number): {
48
+ attributes: TerrainMesh["attributes"];
49
+ triangles: Uint32Array;
50
+ };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Several terrain sources, one surface (docs/design/underwater-terrain.md,
3
+ * Phase B). Each source is its own TerrainLayer; where their extents overlap
4
+ * deck would draw both meshes (z-fighting) and write both into the height
5
+ * map (whose max blend keeps the higher, not the better). This extension
6
+ * partitions the ground instead: a source draws only INSIDE its own extent
7
+ * and never inside the extent of any source ranked above it.
8
+ *
9
+ * The test has to run before deck's terrain module, which in the height-map
10
+ * pass writes the fragment's height and RETURNS at `fs:#main-start` — ahead
11
+ * of every DECKGL_FILTER_COLOR hook, where deck's own ClipExtension
12
+ * discards. So the discard is a shader-module injection at `fs:#main-start`
13
+ * with a negative order (luma sorts each hook's injections by order; deck's
14
+ * terrain module injects there at 0). A module, not the extension's
15
+ * `inject`: deck merges extension injections as plain strings, which drops
16
+ * the order. The same discard runs in the colour and picking passes, so a
17
+ * hidden part of a mesh is neither drawn nor picked.
18
+ *
19
+ * `extent` alone would not do: it only limits which TILES load, and a tile
20
+ * on the edge overhangs the extent.
21
+ *
22
+ * The partition leaves a step where two datasets disagree at an extent's
23
+ * edge, and a step with no wall is a see-through line along the extent.
24
+ * `TerrainBackfillExtension` closes it (Phase H): a second copy of each
25
+ * lower-ranked source, drawn only UNDER the higher-ranked extents, with its
26
+ * depth squeezed into the last thousandth before the far plane — so every
27
+ * real surface in front of it wins, it still hides its own valleys behind
28
+ * its own hills, and it shows only where nothing else drew. The lower-ranked
29
+ * source is one continuous sheet, so any ray through the step crosses it.
30
+ * The copy is a plain drawn layer, not a terrain: no height map, no drape
31
+ * covers, no picking. It is a separate layer, not a mode of this one,
32
+ * because a shader that writes gl_FragDepth anywhere must write it on every
33
+ * path — and doing that in the real terrain drops deck's per-layer polygon
34
+ * offset (measured: an offset marker behind a raised survey's far edge
35
+ * vanished).
36
+ */
37
+ import { LayerExtension } from "@deck.gl/core";
38
+ import type { Layer } from "@deck.gl/core";
39
+ /** [west, south, east, north] in degrees. */
40
+ export type Extent = [number, number, number, number];
41
+ /** Sources ranked above another, at most — a shader takes a fixed number. */
42
+ export declare const MAX_TERRAIN_SOURCES = 4;
43
+ /**
44
+ * The height map, by rank (Phase I, piece 1). It is max-blended, so with a
45
+ * hole in a higher-ranked source the next source must still be able to
46
+ * write there — but must never outrank the higher one where both have
47
+ * ground. Each source writes its height shifted into its own band,
48
+ * `r = z − rank·BAND`, with the band in `g = −rank·BAND`: max picks the
49
+ * highest-ranked source present at a texel (and within it the highest
50
+ * surface, as before — a skirt never wins), and the read (deck-patch
51
+ * terrain-shader-module.js) is `(r − g) / a`, exact even at linearly
52
+ * filtered coverage edges, where the clear `[−32, −32]` cancels itself. A
53
+ * single source writes rank 0 through deck's own shader (`g = 0`). Bands 8
54
+ * common units apart stay disjoint for any relief under ~600 km (× the
55
+ * exaggeration) at the equator.
56
+ */
57
+ export declare const TERRAIN_BAND = 8;
58
+ type PriorityProps = {
59
+ terrainKeep?: Extent | null;
60
+ terrainHide?: Extent[];
61
+ terrainBackfillSea?: number[] | null;
62
+ terrainRank?: number;
63
+ };
64
+ /** Draw this terrain source only inside `terrainKeep` and outside every `terrainHide`. */
65
+ export declare class TerrainPriorityExtension extends LayerExtension {
66
+ static extensionName: string;
67
+ static defaultProps: {
68
+ terrainKeep: null;
69
+ terrainHide: never[];
70
+ terrainRank: number;
71
+ };
72
+ getShaders(): unknown;
73
+ draw(this: Layer<PriorityProps>, opts: {
74
+ shaderModuleProps?: {
75
+ terrain?: {
76
+ drawToTerrainHeightMap?: boolean;
77
+ };
78
+ };
79
+ }): void;
80
+ }
81
+ /** Draw this source only under `terrainHide` (inside `terrainKeep`), behind every real surface — a backfill for the partition's steps. */
82
+ export declare class TerrainBackfillExtension extends LayerExtension {
83
+ static extensionName: string;
84
+ static defaultProps: {
85
+ terrainKeep: null;
86
+ terrainHide: never[];
87
+ terrainBackfillSea: null;
88
+ };
89
+ getShaders(): unknown;
90
+ draw(this: Layer<PriorityProps>): void;
91
+ }
92
+ export {};
@@ -1,5 +1,11 @@
1
1
  import type { LngLat } from "./geodesy";
2
2
  import type { TerrainIR } from "./terrain";
3
+ /**
4
+ * A tile's URL from a `{z}/{x}/{y}` template — deck's own filler, so `{-y}`
5
+ * and a list of mirrors work as they do for deck's tiles (the same mirror
6
+ * for the same tile). Every DEM/texture fetch outside deck goes through here.
7
+ */
8
+ export declare function tileUrl(template: string | string[], x: number, y: number, z: number): string;
3
9
  /** Slippy-map tile + fractional pixel covering `lngLat` at `zoom` (256px tiles). Exported for `terrain-heightfield.ts`'s bulk loader — same tile math, no reason to duplicate it. */
4
10
  export declare function tilePixel(lngLat: LngLat, zoom: number): {
5
11
  x: number;