@nika-js/onlymap 0.9.0 → 0.10.0

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 (93) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +50 -3
  3. package/dist/{LercDecode.es-BMcxSLhD.js → LercDecode.es-IEPCRZOv.js} +1 -1
  4. package/dist/{basemap-m98j2wxG.js → basemap-9lXclX9H.js} +3882 -3980
  5. package/dist/cartograph/elements/om-frame.d.ts +67 -1
  6. package/dist/cartograph/georef.d.ts +18 -4
  7. package/dist/cartograph/schema.d.ts +11 -0
  8. package/dist/cartograph.js +1480 -1311
  9. package/dist/cartograph.standalone.js +1808 -1615
  10. package/dist/{cityjson-D_V5GY8b.js → cityjson-k-z1r6c0.js} +1 -1
  11. package/dist/{crs-DsDQ4Q4i.js → crs-BzE_KP4M.js} +25 -2
  12. package/dist/{crs-Ciu7Xs7a.js → crs-ChglCB3O.js} +39 -16
  13. package/dist/dem-decode.d.ts +58 -0
  14. package/dist/elements/om-map.d.ts +12 -0
  15. package/dist/{geoparquet-XOwOmChh.js → geoparquet-DFDZDBun.js} +10 -10
  16. package/dist/globe-view-D9wjfL0T.js +104 -0
  17. package/dist/hillshade-C2BQr6pd.js +298 -0
  18. package/dist/hillshade-apron-Bem3DWyJ.js +40 -0
  19. package/dist/hillshade-apron.d.ts +54 -0
  20. package/dist/hillshade-shader-DI2uLSNU.js +165 -0
  21. package/dist/hillshade-shader.d.ts +168 -0
  22. package/dist/hillshade.d.ts +163 -0
  23. package/dist/html-data.d.ts +1 -1
  24. package/dist/{ifc-Dc-TdSJr.js → ifc-DXwePQRv.js} +131 -131
  25. package/dist/{index-DzOvV-O7.js → index-4Tvlt0iO.js} +57 -57
  26. package/dist/{index-HZWdgtm4.js → index-Bn66l3KG.js} +1 -1
  27. package/dist/index-BuXrMq5D.js +322 -0
  28. package/dist/index-CNRbZHkK.js +459 -0
  29. package/dist/{index-DDNElBTs.js → index-CkovmN47.js} +1 -1
  30. package/dist/index-CmuOizAF.js +641 -0
  31. package/dist/index-CvT5QHBS.js +65 -0
  32. package/dist/{index-BMbpftvm.js → index-DnVHKI61.js} +1 -1
  33. package/dist/{index-BSAY6CWm.js → index-JjyDEqAS.js} +18911 -17456
  34. package/dist/index.d.ts +4 -0
  35. package/dist/layer-registry.d.ts +27 -0
  36. package/dist/lerc-C1mQ_Kqq.js +22 -0
  37. package/dist/onlymap.standalone.js +49075 -45717
  38. package/dist/onlymapjs.js +73 -70
  39. package/dist/parse-manifest.d.ts +6 -0
  40. package/dist/plane-camera.d.ts +59 -0
  41. package/dist/plane-layers.d.ts +56 -0
  42. package/dist/plane-tiles.d.ts +99 -0
  43. package/dist/plane-tileset.d.ts +31 -0
  44. package/dist/plane-warp.d.ts +91 -0
  45. package/dist/post-process-effect-DfslKPM6.js +197 -0
  46. package/dist/programmatic.d.ts +16 -1
  47. package/dist/projection.d.ts +118 -0
  48. package/dist/{raster-Dg5p_99H.js → raster-D2NzdjZE.js} +609 -499
  49. package/dist/raster-hillshade.d.ts +119 -0
  50. package/dist/{raster-pipeline-DhjkqDYd.js → raster-pipeline-qnD1icOv.js} +511 -484
  51. package/dist/raster-pipeline.d.ts +10 -0
  52. package/dist/raster.d.ts +5 -0
  53. package/dist/runtime-core.d.ts +140 -1
  54. package/dist/serialize/clip.d.ts +50 -0
  55. package/dist/serialize/declutter.d.ts +44 -0
  56. package/dist/serialize/emit.d.ts +60 -0
  57. package/dist/serialize/index.d.ts +64 -0
  58. package/dist/serialize/strategy.d.ts +30 -0
  59. package/dist/serialize/style.d.ts +77 -0
  60. package/dist/snapshot.d.ts +46 -0
  61. package/dist/surface-anchor.d.ts +6 -0
  62. package/dist/terrain-heightfield.d.ts +0 -16
  63. package/dist/terrain-sample.d.ts +0 -13
  64. package/dist/text-on-path-Dm7vtNqt.js +146 -0
  65. package/dist/text-on-path.d.ts +157 -0
  66. package/dist/transform/buffer.d.ts +63 -0
  67. package/dist/transform/contour.d.ts +37 -0
  68. package/dist/transform/dot-density.d.ts +19 -0
  69. package/dist/transform/field.d.ts +80 -0
  70. package/dist/transform/geometry.d.ts +20 -0
  71. package/dist/transform/index.d.ts +29 -0
  72. package/dist/transform/simplify.d.ts +10 -0
  73. package/dist/transform/smooth.d.ts +12 -0
  74. package/dist/transform-stage.d.ts +92 -0
  75. package/dist/version.d.ts +1 -1
  76. package/dist/volumetrics.d.ts +7 -0
  77. package/dist/{zarr-D3CzK1Zm.js → zarr-D5e5agMG.js} +2 -2
  78. package/docs/cartograph.md +12 -4
  79. package/docs/cartography.md +328 -0
  80. package/docs/design/arrows.md +182 -0
  81. package/docs/design/carto-substrate.md +1055 -0
  82. package/docs/design/extensions.md +250 -0
  83. package/docs/design/hillshade.md +290 -0
  84. package/docs/effects.md +11 -0
  85. package/docs/hillshade.md +203 -0
  86. package/llms.txt +4 -2
  87. package/onlymapjs.attributes.json +45 -2
  88. package/onlymapjs.html-data.json +213 -25
  89. package/package.json +13 -9
  90. package/skills/onlymapjs/SKILL.md +7 -2
  91. package/skills/onlymapjs/references/syntax.md +31 -3
  92. package/dist/index-CfPbQUqO.js +0 -511
  93. package/dist/lerc-qK-nhCaB.js +0 -30
@@ -0,0 +1,40 @@
1
+ const _ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2
+ __proto__: null
3
+ }, Symbol.toStringTag, { value: "Module" }));
4
+ function i(c, r, t) {
5
+ return (t + 1) * (c + 2) + (r + 1);
6
+ }
7
+ function g(c, r) {
8
+ const { width: t, height: e } = c, f = new Float32Array((t + 2) * (e + 2));
9
+ for (let o = 0; o < e; o++)
10
+ for (let n = 0; n < t; n++) f[i(t, n, o)] = c.at(n, o);
11
+ for (let o = -1; o <= e; o++)
12
+ for (let n = -1; n <= t; n++) {
13
+ if (n >= 0 && n < t && o >= 0 && o < e) continue;
14
+ const s = Math.min(t - 1, Math.max(0, n)), u = Math.min(e - 1, Math.max(0, o));
15
+ f[i(t, n, o)] = f[i(t, s, u)];
16
+ }
17
+ for (let o = -1; o <= 1; o++)
18
+ for (let n = -1; n <= 1; n++) {
19
+ if (n === 0 && o === 0) continue;
20
+ const s = r(n, o);
21
+ if (!s || s.width !== t || s.height !== e) continue;
22
+ const u = n === 0 ? null : [n === -1 ? t - 1 : 0], x = o === 0 ? null : [o === -1 ? e - 1 : 0], y = u ?? Array.from({ length: t }, (l, a) => a), d = x ?? Array.from({ length: e }, (l, a) => a);
23
+ for (const l of d)
24
+ for (const a of y) {
25
+ const h = n === 0 ? a : n === -1 ? -1 : t, p = o === 0 ? l : o === -1 ? -1 : e;
26
+ f[i(t, h, p)] = s.at(a, l);
27
+ }
28
+ }
29
+ return { width: t, height: e, data: f };
30
+ }
31
+ const m = (() => {
32
+ const c = [];
33
+ for (let r = -1; r <= 1; r++) for (let t = -1; t <= 1; t++) (t !== 0 || r !== 0) && c.push({ dx: t, dy: r });
34
+ return c;
35
+ })();
36
+ export {
37
+ m as N,
38
+ _,
39
+ g as c
40
+ };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The one-pixel apron — shared by both hillshade entry points.
3
+ *
4
+ * A hillshade is a DERIVATIVE, so a fragment at a tile's edge needs heights
5
+ * that live in the next tile. Sampling with clamp-to-edge instead makes the
6
+ * gradient collapse along every boundary and draws a pale grid over the whole
7
+ * world: the single most recognisable way a hand-rolled hillshade looks
8
+ * broken, and invisible to any test that only asks "did something render".
9
+ *
10
+ * So every tile is composed into a heightfield one pixel larger on each side,
11
+ * with that border taken from its eight neighbours. The shader then samples
12
+ * ONE texture with no edge case at all — it never learns that tiles exist.
13
+ *
14
+ * This module is deliberately ignorant of WHERE heights come from. The tiled
15
+ * DEM path decodes RGB-encoded bytes; the raster path reads a float band out
16
+ * of a retained decode. Both hand this a `HeightSource`, which is the only
17
+ * thing the apron logic has ever needed.
18
+ */
19
+ /** A tile's heights, addressed in its own pixel grid. */
20
+ export interface HeightSource {
21
+ width: number;
22
+ height: number;
23
+ at(px: number, py: number): number;
24
+ }
25
+ /** A tile's heights with a one-pixel apron: `(width + 2) * (height + 2)` floats. */
26
+ export interface PaddedHeights {
27
+ /** The INTERIOR size — the apron is one pixel outside this on every side. */
28
+ width: number;
29
+ height: number;
30
+ data: Float32Array;
31
+ }
32
+ /** Index into the padded grid from INTERIOR coordinates, which may be -1 or width/height (the apron). */
33
+ export declare function paddedIndex(width: number, px: number, py: number): number;
34
+ /**
35
+ * Composes `own` plus its eight neighbours into a padded heightfield.
36
+ *
37
+ * `neighbour(dx, dy)` returns the tile at that offset, or null when there
38
+ * genuinely isn't one — off the edge of the world or of the source's extent,
39
+ * a failed fetch, or a tile whose dimensions don't line up with this one
40
+ * (which happens at a raster's clipped edge, where a strip could only be
41
+ * copied into the wrong rows).
42
+ *
43
+ * A missing neighbour falls back to CLAMPING that border — the artifact this
44
+ * whole module exists to avoid, but confined to the one edge that has no
45
+ * honest answer. The clamp is seeded BEFORE the neighbour pass on purpose: a
46
+ * zero left there would decode as a sea-level cliff and draw a HARD black
47
+ * line, which is worse than the pale one.
48
+ */
49
+ export declare function composeApron(own: HeightSource, neighbour: (dx: number, dy: number) => HeightSource | null): PaddedHeights;
50
+ /** The eight neighbour offsets, in a stable order. */
51
+ export declare const NEIGHBOUR_OFFSETS: readonly {
52
+ dx: number;
53
+ dy: number;
54
+ }[];
@@ -0,0 +1,165 @@
1
+ const d = 40075016686e-3, u = 110574, m = 111320, o = Math.PI / 180, f = { none: 0, mercator: 1, geographic: 2 };
2
+ function p(e, a, s = "HillshadeLayer") {
3
+ const h = (l) => l == null || l === "" ? [] : typeof l == "number" ? Number.isFinite(l) ? [l] : [] : String(l).split(/[\s,]+/).filter(Boolean).map(Number).filter((r) => Number.isFinite(r));
4
+ let t = h(e);
5
+ t.length === 0 && (t = [315]), t.length > 4 && (console.warn(`[onlymapjs] ${s}: sun-azimuth takes at most 4 azimuths — using the first 4 of ${t.length}.`), t = t.slice(0, 4));
6
+ let i = h(a);
7
+ (i.length !== t.length || i.some((l) => l < 0)) && (i.length > 0 && console.warn(`[onlymapjs] ${s}: sun-weight must give one non-negative number per sun-azimuth (${t.length}) — using equal weights.`), i = t.map(() => 1));
8
+ const n = i.reduce((l, r) => l + r, 0);
9
+ return i = n > 0 ? i.map((l) => l / n) : t.map(() => 1 / t.length), { azimuths: t, weights: i };
10
+ }
11
+ const g = `uniform hillshadeUniforms {
12
+ vec4 azimuths;
13
+ vec4 weights;
14
+ vec2 interiorOffset;
15
+ vec2 interiorScale;
16
+ vec2 texel;
17
+ vec2 metresPerTexel;
18
+ vec2 latBounds;
19
+ float latMode;
20
+ float sunElevation;
21
+ float zFactor;
22
+ float composite;
23
+ } hillshade;
24
+ `, z = (
25
+ /* glsl */
26
+ `
27
+ uniform sampler2D hillshadeHeights;
28
+
29
+ float hillshade_light(vec3 normal, float azimuth, float elevation) {
30
+ float ce = cos(elevation);
31
+ vec3 sun = vec3(sin(azimuth) * ce, cos(azimuth) * ce, sin(elevation));
32
+ return max(dot(normal, sun), 0.0);
33
+ }
34
+ `
35
+ ), v = (
36
+ /* glsl */
37
+ `
38
+ vec2 hsUV = hillshade.interiorOffset + geometry.uv * hillshade.interiorScale;
39
+ vec2 hsT = hillshade.texel;
40
+ float z00 = texture(hillshadeHeights, hsUV + vec2(-hsT.x, -hsT.y)).r;
41
+ float z01 = texture(hillshadeHeights, hsUV + vec2(0.0, -hsT.y)).r;
42
+ float z02 = texture(hillshadeHeights, hsUV + vec2(hsT.x, -hsT.y)).r;
43
+ float z10 = texture(hillshadeHeights, hsUV + vec2(-hsT.x, 0.0)).r;
44
+ float z12 = texture(hillshadeHeights, hsUV + vec2(hsT.x, 0.0)).r;
45
+ float z20 = texture(hillshadeHeights, hsUV + vec2(-hsT.x, hsT.y)).r;
46
+ float z21 = texture(hillshadeHeights, hsUV + vec2(0.0, hsT.y)).r;
47
+ float z22 = texture(hillshadeHeights, hsUV + vec2(hsT.x, hsT.y)).r;
48
+
49
+ float dzdu = ((z02 + 2.0 * z12 + z22) - (z00 + 2.0 * z10 + z20)) / 8.0;
50
+ float dzdv = ((z20 + 2.0 * z21 + z22) - (z00 + 2.0 * z01 + z02)) / 8.0;
51
+
52
+ // Ground scale per texel, corrected for latitude where the CRS requires it.
53
+ vec2 mpt = hillshade.metresPerTexel;
54
+ if (hillshade.latMode > 0.5) {
55
+ float t = mix(hillshade.latBounds.x, hillshade.latBounds.y, geometry.uv.y);
56
+ if (hillshade.latMode < 1.5) {
57
+ // Mercator: conformal, so the same factor applies to both axes.
58
+ float cosLat = 1.0 / cosh(t);
59
+ mpt *= cosLat;
60
+ } else {
61
+ // Geographic: only longitude degrees shrink toward the poles.
62
+ mpt.x *= cos(t);
63
+ }
64
+ }
65
+
66
+ float gradEast = dzdu / mpt.x;
67
+ float gradNorth = -dzdv / mpt.y; // v increases southward
68
+ vec3 normal = normalize(vec3(-gradEast * hillshade.zFactor, -gradNorth * hillshade.zFactor, 1.0));
69
+
70
+ float shade =
71
+ hillshade.weights.x * hillshade_light(normal, hillshade.azimuths.x, hillshade.sunElevation)
72
+ + hillshade.weights.y * hillshade_light(normal, hillshade.azimuths.y, hillshade.sunElevation)
73
+ + hillshade.weights.z * hillshade_light(normal, hillshade.azimuths.z, hillshade.sunElevation)
74
+ + hillshade.weights.w * hillshade_light(normal, hillshade.azimuths.w, hillshade.sunElevation);
75
+ shade = clamp(shade, 0.0, 1.0);
76
+
77
+ if (hillshade.composite > 1.5) {
78
+ // The layer's own texture is the HEIGHTFIELD, not a picture: emit the
79
+ // shade and let the multiply blend put it into the framebuffer. White is
80
+ // that blend's identity, so opacity fades toward white rather than toward
81
+ // transparent. Alpha stays 1 because the blend takes alpha from the
82
+ // destination.
83
+ color = vec4(vec3(mix(1.0, shade, layer.opacity)), 1.0);
84
+ } else if (hillshade.composite > 0.5) {
85
+ // Multiply into a real sampled colour — the raster path's colormap.
86
+ color = vec4(color.rgb * mix(1.0, shade, layer.opacity), color.a);
87
+ } else {
88
+ // deck's framebuffer is PREMULTIPLIED (the 0.9.1 lesson), so the colour is
89
+ // scaled by its own alpha on the way out.
90
+ color = vec4(vec3(shade) * layer.opacity, layer.opacity);
91
+ }
92
+ `
93
+ ), E = {
94
+ name: "hillshade",
95
+ fs: g,
96
+ inject: {
97
+ "fs:#decl": z,
98
+ "fs:DECKGL_FILTER_COLOR": v
99
+ },
100
+ uniformTypes: {
101
+ azimuths: "vec4<f32>",
102
+ weights: "vec4<f32>",
103
+ interiorOffset: "vec2<f32>",
104
+ interiorScale: "vec2<f32>",
105
+ texel: "vec2<f32>",
106
+ metresPerTexel: "vec2<f32>",
107
+ latBounds: "vec2<f32>",
108
+ latMode: "f32",
109
+ sunElevation: "f32",
110
+ zFactor: "f32",
111
+ composite: "f32"
112
+ },
113
+ // The sampler rides alongside the uniform block, exactly as CompositeBands
114
+ // binds band0-band3: a texture is a BINDING, never a member of a UBO.
115
+ getUniforms: (e) => e
116
+ };
117
+ function c(e, a) {
118
+ return [e[0] ?? a, e[1] ?? a, e[2] ?? a, e[3] ?? a];
119
+ }
120
+ function x(e) {
121
+ return Math.log(Math.tan(Math.PI / 4 + Math.max(-85.0511, Math.min(85.0511, e)) * o / 2));
122
+ }
123
+ function y(e, a, s) {
124
+ const h = d / 2 ** e;
125
+ return { metresPerTexel: [h / a, h / s], latMode: "mercator" };
126
+ }
127
+ function T(e) {
128
+ const { unitsPerPixelX: a, unitsPerPixelY: s, crsUnits: h } = e;
129
+ if (h === "degree")
130
+ return {
131
+ metresPerTexel: [a * m, s * u],
132
+ latMode: "geographic"
133
+ };
134
+ const t = h === "foot" ? 0.3048 : 1;
135
+ return { metresPerTexel: [a * t, s * t], latMode: "none" };
136
+ }
137
+ function w(e) {
138
+ const a = e.width + 2, s = e.height + 2, h = (t) => e.latMode === "mercator" ? x(t) : t * o;
139
+ return {
140
+ azimuths: c(
141
+ e.azimuths.map((t) => (t + (e.azimuthOffset ?? 0)) * o),
142
+ 0
143
+ ),
144
+ // A light that does not exist contributes nothing: the unused slots carry
145
+ // weight 0, which is why the shader can unroll to four unconditional
146
+ // multiply-adds and never branch on a light count.
147
+ weights: c(e.weights, 0),
148
+ interiorOffset: [1 / a, 1 / s],
149
+ interiorScale: [e.width / a, e.height / s],
150
+ texel: [1 / a, 1 / s],
151
+ metresPerTexel: e.metresPerTexel,
152
+ latBounds: [h(e.north), h(e.south)],
153
+ latMode: f[e.latMode],
154
+ sunElevation: e.sunElevation * o,
155
+ zFactor: e.zFactor,
156
+ composite: e.composite === "framebuffer" ? 2 : e.composite ? 1 : 0
157
+ };
158
+ }
159
+ export {
160
+ E as a,
161
+ w as h,
162
+ y as m,
163
+ p,
164
+ T as r
165
+ };
@@ -0,0 +1,168 @@
1
+ /**
2
+ * The hillshade GPU module and its arithmetic — shared by BOTH entry points.
3
+ *
4
+ * `HillshadeLayer` (tiled DEM, Web Mercator) and `shading="hillshade"` on a
5
+ * raster source (the author's own DEM, in its own CRS) run THIS module, with
6
+ * the same uniforms. They do not produce identical pixels over the same
7
+ * ground and should not be asked to: the tile path is integer-encoded height
8
+ * in Web Mercator at a tile zoom, the raster path is float bands in the
9
+ * source CRS at the source resolution, so pixel ground size, reprojection and
10
+ * nodata all differ before the shader runs. What is shared is the ARITHMETIC,
11
+ * which is the part that could silently drift.
12
+ *
13
+ * WHY THIS IS NOT IN `raster-pipeline.ts`. That pipeline's modules inject at
14
+ * `DECKGL_FILTER_COLOR`, which is POINTWISE — a module there is handed
15
+ * `color`, not the means to sample its neighbours. Hillshade is the first
16
+ * neighbourhood operation anyone has wanted, and a neighbourhood operation
17
+ * needs its own sampler and texel size. Declaring the sampler here (via
18
+ * `fs:#decl`, exactly as upstream's `CompositeBands` declares `band0`–
19
+ * `band3`) also frees the module from any host layer's declaration order —
20
+ * which is not a nicety but the only thing that compiles: a module's
21
+ * `DECKGL_FILTER_COLOR` injection becomes a function emitted ABOVE the host
22
+ * layer's own source, so reaching for BitmapLayer's `bitmapTexture` there
23
+ * gives "undeclared identifier" on every tap.
24
+ */
25
+ /** Equatorial circumference (m) — the Web Mercator scale numerator. */
26
+ export declare const EARTH_CIRCUMFERENCE = 40075016.686;
27
+ /** Metres per degree of latitude (mean). Latitude degrees barely vary; longitude degrees do, which is the whole point of `latMode`. */
28
+ export declare const METRES_PER_DEGREE_LAT = 110574;
29
+ /** Metres per degree of longitude AT THE EQUATOR — scaled by cos(latitude) per fragment. */
30
+ export declare const METRES_PER_DEGREE_LNG = 111320;
31
+ export declare const DEG: number;
32
+ /**
33
+ * How ground scale varies with latitude across one tile.
34
+ *
35
+ * This is the one place the two entry points genuinely differ, and getting it
36
+ * wrong does not look like a bug — it looks like SHEARED terrain, with every
37
+ * shadow falling at a consistently wrong angle.
38
+ *
39
+ * - `none` — a projected CRS whose units are already linear ground distance
40
+ * (UTM metres, state-plane feet). The scale is constant across the tile.
41
+ * - `mercator` — Web Mercator. Conformal, so ONE scale serves both axes, and
42
+ * the falloff is exact via cos φ = 1 / cosh(y) with y the Mercator
43
+ * ordinate. No inverse projection in the shader.
44
+ * - `geographic` — a lng/lat CRS (EPSG:4326). ANISOTROPIC: a degree of
45
+ * latitude is ~constant while a degree of longitude shrinks with cos φ, so
46
+ * only the X axis scales. At 36°N that is a 1.23x difference between the
47
+ * axes — ignore it and east-west slopes come out ~23% too gentle.
48
+ */
49
+ export type LatitudeMode = "none" | "mercator" | "geographic";
50
+ /**
51
+ * Parses `sun-azimuth` / `sun-weight`: one to four numbers, space- or
52
+ * comma-separated.
53
+ *
54
+ * `multi-directional` is deliberately NOT a boolean anywhere in this feature.
55
+ * A preset must be expressible in the tier below it (the rule `presets.ts`
56
+ * states for `<om-effect>`), and a boolean that blended azimuths the author
57
+ * could not otherwise name would be capability reachable only from the
58
+ * shorthand. Swiss-style relief wants the azimuths CHOSEN for the terrain,
59
+ * which is a tuning job, not a toggle.
60
+ */
61
+ export declare function parseLights(azimuth: string | number | null | undefined, weight: string | number | null | undefined, label?: string): {
62
+ azimuths: number[];
63
+ weights: number[];
64
+ };
65
+ /** The luma shader module. Identical object for both entry points — only the uniforms differ. */
66
+ export declare const hillshadeModule: {
67
+ name: string;
68
+ fs: string;
69
+ inject: {
70
+ "fs:#decl": string;
71
+ "fs:DECKGL_FILTER_COLOR": string;
72
+ };
73
+ uniformTypes: {
74
+ azimuths: string;
75
+ weights: string;
76
+ interiorOffset: string;
77
+ interiorScale: string;
78
+ texel: string;
79
+ metresPerTexel: string;
80
+ latBounds: string;
81
+ latMode: string;
82
+ sunElevation: string;
83
+ zFactor: string;
84
+ composite: string;
85
+ };
86
+ getUniforms: (props: Record<string, unknown>) => Record<string, unknown>;
87
+ };
88
+ export interface HillshadeUniformValues {
89
+ azimuths: [number, number, number, number];
90
+ weights: [number, number, number, number];
91
+ interiorOffset: [number, number];
92
+ interiorScale: [number, number];
93
+ texel: [number, number];
94
+ metresPerTexel: [number, number];
95
+ latBounds: [number, number];
96
+ latMode: number;
97
+ sunElevation: number;
98
+ zFactor: number;
99
+ composite: number;
100
+ }
101
+ /** Mercator ordinate (radians) of a latitude, clamped to the projection's own limit. */
102
+ export declare function mercatorY(lat: number): number;
103
+ /**
104
+ * Ground scale for one Web Mercator tile, stated AT THE EQUATOR — the shader
105
+ * applies the cos φ falloff per fragment, which is why this number is
106
+ * deliberately latitude-free.
107
+ */
108
+ export declare function mercatorTileScale(zoom: number, width: number, height: number): {
109
+ metresPerTexel: [number, number];
110
+ latMode: LatitudeMode;
111
+ };
112
+ /**
113
+ * Ground scale for one raster tile from a source with a known pixel size.
114
+ *
115
+ * `unitsPerPixel` is in the CRS's own units — degrees for a geographic CRS,
116
+ * metres or feet for a projected one. A geographic source keeps its X scale
117
+ * stated at the equator (the shader scales it by cos φ); everything else is
118
+ * already linear and converts once, here.
119
+ */
120
+ export declare function rasterTileScale(opts: {
121
+ unitsPerPixelX: number;
122
+ unitsPerPixelY: number;
123
+ /** Pixels of the SOURCE covered by this tile, per axis. */
124
+ tileWidth: number;
125
+ tileHeight: number;
126
+ crsUnits: "degree" | "metre" | "foot";
127
+ }): {
128
+ metresPerTexel: [number, number];
129
+ latMode: LatitudeMode;
130
+ };
131
+ /**
132
+ * Every uniform for one tile. Pure, so the arithmetic that decides what the
133
+ * relief MEANS is unit-testable without a GPU.
134
+ *
135
+ * `north`/`south` are the tile's latitude bounds in degrees, and are read
136
+ * only when `latMode` needs them — a projected source may pass anything.
137
+ */
138
+ export declare function hillshadeUniformsForTile(opts: {
139
+ /** INTERIOR size of the padded heightfield; the apron is one pixel outside it. */
140
+ width: number;
141
+ height: number;
142
+ metresPerTexel: [number, number];
143
+ latMode: LatitudeMode;
144
+ north: number;
145
+ south: number;
146
+ azimuths: number[];
147
+ weights: number[];
148
+ sunElevation: number;
149
+ zFactor: number;
150
+ /**
151
+ * What the shade does with the colour already in the chain. `false`/`0`
152
+ * replaces it. `"colour"` multiplies into the layer's own sampled picture —
153
+ * the raster path's colormap. `"framebuffer"` emits the shade alone for a
154
+ * multiply BLEND to apply, which is the only correct choice when the layer's
155
+ * texture is the heightfield rather than a picture.
156
+ */
157
+ composite: boolean | "colour" | "framebuffer";
158
+ /**
159
+ * Degrees added to every azimuth before it reaches the shader — the grid
160
+ * convergence, on a projected sheet whose sun means SHEET north (§4a).
161
+ *
162
+ * It is applied HERE rather than in GLSL because shading runs in the source
163
+ * tile's own grid, where up is geographic north: the rotation is a property
164
+ * of where the tile sits on the sheet, which is a per-tile constant, not a
165
+ * per-fragment one. Zero on a Mercator map, where the two norths coincide.
166
+ */
167
+ azimuthOffset?: number;
168
+ }): HillshadeUniformValues;
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Hillshade / shaded relief — the lazy chunk (docs/design/hillshade.md).
3
+ *
4
+ * WHAT THIS IS, AND IS NOT. Cartographic shaded relief is RENDERED TEXTURE:
5
+ * pixels, never numbers. Nothing here is queryable, classified or reported,
6
+ * which is the line issue #13 drew when it put "raster analysis
7
+ * (hillshade/slope)" out of scope — the boundary there is QUERYABILITY, not
8
+ * the arithmetic. This ships no analytic product.
9
+ *
10
+ * It is a LAYER, not a mode of `terrain=`. `terrain=` means a 3D surface: it
11
+ * replaces the basemap, changes what the camera means, and is meaningless at
12
+ * pitch 0. Relief on a print sheet has to compose underneath the data layers
13
+ * like any other layer — and, decisively, a layer draws inside deck's own
14
+ * framebuffer, so it lands in `snapshot()` and UNDER `<om-effect>`. Relief a
15
+ * print finish could not reach would be worth very little.
16
+ *
17
+ * THE SEAM IS THE WHOLE DESIGN PROBLEM. A hillshade is a derivative, so every
18
+ * fragment needs its neighbours — and at a tile's edge the neighbours live in
19
+ * a different tile. Sampling with clamp-to-edge instead makes the derivative
20
+ * collapse to zero along every border, drawing a pale grid over the world:
21
+ * the single most recognisable way a hand-rolled hillshade looks broken.
22
+ * Rather than bind nine textures per draw, each tile is decoded on the CPU
23
+ * (`dem-decode.ts`, which exists because these bytes are heights and must not
24
+ * be colour-managed) into a heightfield with a ONE-PIXEL APRON copied from
25
+ * its eight neighbours. The shader then samples one texture with no edge
26
+ * cases at all, and the neighbour fetches are nearly free because a
27
+ * neighbour is almost always a tile the map is drawing anyway — see
28
+ * `tileCache`.
29
+ */
30
+ import { CompositeLayer, type Layer } from "@deck.gl/core";
31
+ import { type ElevationDecoder } from "./terrain";
32
+ import { type PaddedHeights } from "./hillshade-apron";
33
+ import type { PlaneFrame } from "./projection";
34
+ /** Drops every cached decode — exported for tests and for a page tearing a map down. */
35
+ export declare function clearHillshadeTileCache(): void;
36
+ /**
37
+ * Builds one tile's padded heightfield, fetching the eight neighbours for the
38
+ * apron. x wraps around the antimeridian; y does not, because the poles are
39
+ * not a seam. The composition itself — including what happens when a
40
+ * neighbour genuinely does not exist — lives in `hillshade-apron.ts`, shared
41
+ * with the raster entry point.
42
+ */
43
+ export declare function buildPaddedHeights(template: string, decoder: ElevationDecoder, index: {
44
+ x: number;
45
+ y: number;
46
+ z: number;
47
+ }): Promise<PaddedHeights | null>;
48
+ export interface OmHillshadeLayerProps {
49
+ /** A `registerTerrain` preset name, or a raw `{z}/{x}/{y}` DEM URL template. */
50
+ src: string;
51
+ /** Decoder name or explicit scalers — required alongside a RAW url, implied by a preset. */
52
+ decoder?: string | ElevationDecoder | null;
53
+ sunAzimuth?: string | number | null;
54
+ sunWeight?: string | number | null;
55
+ sunElevation?: number | null;
56
+ zFactor?: number | null;
57
+ blend?: string | null;
58
+ maxZoom?: number | null;
59
+ zoomOffset?: number | null;
60
+ opacity?: number;
61
+ /**
62
+ * The map's projection plane, set by the runtime when `<om-map crs>` is
63
+ * projected (§9, Phase 6). Present: tiles are selected through a plane-aware
64
+ * `Tileset2D` and drawn as subdivided warped meshes. Absent: the Mercator
65
+ * path, byte for byte as before — a projected map is the exception, and the
66
+ * common case must not pay for it.
67
+ */
68
+ _planeFrame?: PlaneFrame | null;
69
+ /**
70
+ * Which north `sun-azimuth` means on a PROJECTED sheet (§4a, §12.4). Inert
71
+ * on a Mercator map, where the two are the same thing.
72
+ *
73
+ * `"sheet"` (the default) keeps the apparent light constant across the plate,
74
+ * which is what relief atlases do — on a CONUS sheet geographic north swings
75
+ * 34 degrees from one edge to the other, and light that rotates across a
76
+ * plate reads as a mistake rather than as physics. `"geographic"` is
77
+ * physically true: that slope really is lit from the north-west.
78
+ */
79
+ sunDatum?: string | null;
80
+ }
81
+ /**
82
+ * `src` resolution mirrors `parseTerrainAttrs` exactly: a registered preset
83
+ * name, or a raw `{z}/{x}/{y}` template plus a `decoder`. `src` is REQUIRED
84
+ * even for the keyless global default, which is a deliberate departure from
85
+ * "the bare element just works": every other keyless default in this library
86
+ * is still NAMED by the author (`basemap="positron"`, `terrain="terrarium"`).
87
+ * Keyless-first means no key and no account, not no attribute — and an
88
+ * element that reaches a public tile host with nothing written on it is a
89
+ * network call the markup does not show.
90
+ */
91
+ export declare function resolveHillshadeSource(props: OmHillshadeLayerProps): {
92
+ template: string;
93
+ decoder: ElevationDecoder;
94
+ maxZoom: number;
95
+ } | null;
96
+ /**
97
+ * How much sharper the DEM should be than the screen asks for.
98
+ *
99
+ * A 300 dpi plate rendered from screen-resolution relief is mush, and this is
100
+ * the same class of bug the millimetre knobs solved for `<om-effect>`: a
101
+ * capture changes the pixel budget, so anything keyed to pixels has to be
102
+ * re-pointed. `useDevicePixels` is what `withCapturePixelRatio` moves, so the
103
+ * ratio of the canvas's device ratio to the DISPLAY's is exactly the capture
104
+ * boost — 1 while nobody is exporting, whatever the display's own density.
105
+ */
106
+ export declare function captureZoomOffset(deviceRatio: number, displayRatio: number): number;
107
+ export declare class OmHillshadeLayer extends CompositeLayer<OmHillshadeLayerProps> {
108
+ static layerName: string;
109
+ static defaultProps: {
110
+ src: {
111
+ type: string;
112
+ value: string;
113
+ };
114
+ decoder: {
115
+ type: string;
116
+ value: null;
117
+ optional: boolean;
118
+ };
119
+ sunAzimuth: {
120
+ type: string;
121
+ value: string;
122
+ };
123
+ sunWeight: {
124
+ type: string;
125
+ value: null;
126
+ optional: boolean;
127
+ };
128
+ sunElevation: {
129
+ type: string;
130
+ value: number;
131
+ };
132
+ zFactor: {
133
+ type: string;
134
+ value: number;
135
+ };
136
+ blend: {
137
+ type: string;
138
+ value: string;
139
+ };
140
+ maxZoom: {
141
+ type: string;
142
+ value: null;
143
+ optional: boolean;
144
+ };
145
+ zoomOffset: {
146
+ type: string;
147
+ value: number;
148
+ };
149
+ _planeFrame: {
150
+ type: string;
151
+ value: null;
152
+ optional: boolean;
153
+ compare: boolean;
154
+ };
155
+ sunDatum: {
156
+ type: string;
157
+ value: string;
158
+ };
159
+ };
160
+ renderLayers(): Layer | null;
161
+ initializeState(): void;
162
+ finalizeState(): void;
163
+ }
@@ -17,7 +17,7 @@ interface TagData {
17
17
  /** Hand-authored action list — validated against hasAction() in html-data.test.ts. */
18
18
  export declare const BUILTIN_ACTIONS: readonly ["toggle-layer", "set-pickable", "zoom-in", "zoom-out", "filter-layer", "highlight-feature", "fade", "pulse", "populate", "trace", "story-play", "story-pause", "story-seek", "fly-to", "zoom-to-feature", "show-overlay", "hide-overlay", "show-tooltip", "hide-tooltip", "draw-mode", "draw-commit", "draw-cancel", "draw-delete", "draw-clear", "draw-config", "draw-save", "export-region-3d", "measure-mode", "measure-clear", "measure-units", "set-basemap", "set-effect", "set-lighting", "set-terrain", "set-clip-box", "clip-box-edit", "set-widgets-visible", "undo", "redo", "warm-tiles"];
19
19
  /** Hand-authored widget types — validated against the widget registry in html-data.test.ts. */
20
- export declare const BUILTIN_WIDGETS: readonly ["legend", "layer-switcher", "zoom-controls", "scale-bar", "attribution", "filter", "vega-lite", "dynamic-chart", "player", "draw", "measure", "basemap-switcher", "lighting", "clip-box", "undo-redo", "widgets-toggle", "time-slider", "ifc-browser", "ifc-legend", "feature-inspector", "ifc-inspector", "ifc-loader", "ifc-clash"];
20
+ export declare const BUILTIN_WIDGETS: readonly ["legend", "layer-switcher", "zoom-controls", "scale-bar", "attribution", "filter", "vega-lite", "dynamic-chart", "player", "draw", "measure", "basemap-switcher", "lighting", "effects", "clip-box", "undo-redo", "widgets-toggle", "time-slider", "ifc-browser", "ifc-legend", "feature-inspector", "ifc-inspector", "ifc-loader", "ifc-clash"];
21
21
  export declare function buildHtmlCustomData(): {
22
22
  version: number;
23
23
  tags: TagData[];