@nika-js/onlymap 0.9.1 → 0.10.1

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 (79) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +27 -3
  3. package/dist/{basemap-DL0mk9Bf.js → basemap-DzQBuqBn.js} +3882 -3980
  4. package/dist/cartograph/elements/om-frame.d.ts +67 -1
  5. package/dist/cartograph/georef.d.ts +18 -4
  6. package/dist/cartograph/schema.d.ts +11 -0
  7. package/dist/cartograph.js +1480 -1311
  8. package/dist/cartograph.standalone.js +1808 -1615
  9. package/dist/{cityjson-D_V5GY8b.js → cityjson-k-z1r6c0.js} +1 -1
  10. package/dist/{crs-DsDQ4Q4i.js → crs-BzE_KP4M.js} +25 -2
  11. package/dist/{crs-Ciu7Xs7a.js → crs-ChglCB3O.js} +39 -16
  12. package/dist/elements/om-map.d.ts +10 -0
  13. package/dist/{geoparquet-DJxZA0if.js → geoparquet-BlFSeNwf.js} +10 -10
  14. package/dist/globe-view-qTt7YaiC.js +104 -0
  15. package/dist/hillshade-Ds0pONmA.js +298 -0
  16. package/dist/{hillshade-shader-n_zManfZ.js → hillshade-shader-DI2uLSNU.js} +15 -10
  17. package/dist/hillshade-shader.d.ts +18 -2
  18. package/dist/hillshade.d.ts +30 -0
  19. package/dist/{ifc-Dc-TdSJr.js → ifc-DXwePQRv.js} +131 -131
  20. package/dist/{index-vLXZuog4.js → index-B9kwlhFA.js} +1 -1
  21. package/dist/index-BCTAq6uy.js +65 -0
  22. package/dist/{index-DdTZSuAb.js → index-BK99wPf_.js} +106 -106
  23. package/dist/index-BSwEOxkR.js +322 -0
  24. package/dist/{index-BjcPjICh.js → index-Bpk1EipB.js} +59 -59
  25. package/dist/index-C2VK-Is6.js +641 -0
  26. package/dist/index-C4oddUIX.js +459 -0
  27. package/dist/{index-oY3XHIux.js → index-CBYDP-_0.js} +18178 -16943
  28. package/dist/{index-CvuDsvnk.js → index-oL_18WvP.js} +47 -47
  29. package/dist/index.d.ts +4 -0
  30. package/dist/layer-registry.d.ts +27 -0
  31. package/dist/{lerc-Bph62dCb.js → lerc-xM89n_hR.js} +1 -1
  32. package/dist/onlymap.standalone.js +48211 -45574
  33. package/dist/onlymapjs.js +77 -74
  34. package/dist/parse-manifest.d.ts +6 -0
  35. package/dist/plane-camera.d.ts +59 -0
  36. package/dist/plane-layers.d.ts +56 -0
  37. package/dist/plane-tiles.d.ts +99 -0
  38. package/dist/plane-tileset.d.ts +31 -0
  39. package/dist/plane-warp.d.ts +91 -0
  40. package/dist/post-process-effect-CNMzoP-h.js +197 -0
  41. package/dist/programmatic.d.ts +16 -1
  42. package/dist/projection.d.ts +118 -0
  43. package/dist/{raster-pipeline-BlOnMPJe.js → raster-pipeline-B_gY9-5f.js} +4 -3
  44. package/dist/{raster-D-eTzCE3.js → raster-yVRqHYLH.js} +4 -4
  45. package/dist/runtime-core.d.ts +140 -1
  46. package/dist/serialize/clip.d.ts +50 -0
  47. package/dist/serialize/declutter.d.ts +44 -0
  48. package/dist/serialize/emit.d.ts +60 -0
  49. package/dist/serialize/index.d.ts +64 -0
  50. package/dist/serialize/strategy.d.ts +30 -0
  51. package/dist/serialize/style.d.ts +77 -0
  52. package/dist/snapshot.d.ts +46 -0
  53. package/dist/surface-anchor.d.ts +6 -0
  54. package/dist/text-on-path-D-fhYDqa.js +146 -0
  55. package/dist/text-on-path.d.ts +157 -0
  56. package/dist/transform/buffer.d.ts +63 -0
  57. package/dist/transform/contour.d.ts +37 -0
  58. package/dist/transform/dot-density.d.ts +19 -0
  59. package/dist/transform/field.d.ts +80 -0
  60. package/dist/transform/geometry.d.ts +20 -0
  61. package/dist/transform/index.d.ts +29 -0
  62. package/dist/transform/simplify.d.ts +10 -0
  63. package/dist/transform/smooth.d.ts +12 -0
  64. package/dist/transform-stage.d.ts +92 -0
  65. package/dist/version.d.ts +1 -1
  66. package/dist/{zarr-BGDoEtFb.js → zarr-BPeWy3ro.js} +2 -2
  67. package/docs/cartograph.md +12 -4
  68. package/docs/cartography.md +328 -0
  69. package/docs/design/arrows.md +182 -0
  70. package/docs/design/carto-substrate.md +1055 -0
  71. package/docs/design/extensions.md +250 -0
  72. package/llms.txt +3 -2
  73. package/onlymapjs.attributes.json +18 -0
  74. package/onlymapjs.html-data.json +169 -19
  75. package/package.json +1 -1
  76. package/skills/onlymapjs/SKILL.md +6 -2
  77. package/skills/onlymapjs/references/syntax.md +22 -2
  78. package/dist/hillshade-DR3TxO1a.js +0 -186
  79. package/dist/index-DO_w0tqR.js +0 -514
@@ -1,4 +1,4 @@
1
- import { C as F, a as q } from "./crs-Ciu7Xs7a.js";
1
+ import { CRS_DEFS as F, COMPOUND_TO_HORIZONTAL as q } from "./crs-ChglCB3O.js";
2
2
  const j = 0.5;
3
3
  function G(e, t) {
4
4
  if (!Array.isArray(e)) return [];
@@ -53,6 +53,29 @@ const s = [
53
53
  // own extent and confirming it lands in Singapore (103.68-103.99°E,
54
54
  // 1.27-1.46°N — matches).
55
55
  3414: { def: "+proj=tmerc +lat_0=1.36666666666667 +lon_0=103.833333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" },
56
+ // Great Britain — OSGB36 / British National Grid. Bundled because a projected
57
+ // cartographic sheet in BNG is one of the two worked examples the plane-view
58
+ // design names (docs/design/carto-substrate.md), and a national grid nobody
59
+ // can author is a grid nobody uses. The 7-parameter Helmert below is the
60
+ // standard OSGB36 shift and is good to a few metres; the definitive transform
61
+ // is the OSTN15 correction GRID, which this library does not ship — survey
62
+ // work needs that, cartography does not.
63
+ 27700: {
64
+ def: "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs"
65
+ },
66
+ // United States — NAD83 / Conus Albers, the equal-area sheet projection for
67
+ // the lower 48 and the design's other worked example. No `+towgs84`: NAD83
68
+ // and WGS84 differ by 1-2 m, which is below anything a sheet resolves, and a
69
+ // fabricated shift would be worse than none.
70
+ 5070: { def: "+proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs" },
71
+ // France — RGF93 / Lambert-93, the fourth national grid the plane-view design
72
+ // measures its warp against and the only one of them that was missing here.
73
+ // Conformal, so its scale is isotropic and its subdivision error behaves like
74
+ // the Swiss and British cases rather than like equal-area Albers. RGF93 is
75
+ // WGS84 for cartographic purposes, so no `+towgs84`.
76
+ 2154: {
77
+ def: "+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +units=m +no_defs"
78
+ },
56
79
  // Japan — JGD2011 geographic 2D. EPSG axis order is (lat, lon).
57
80
  6668: { def: "+proj=longlat +ellps=GRS80 +no_defs", geographic: !0, swapXY: !0 },
58
81
  // WGS 84. Files in the wild store lon/lat despite EPSG's formal (lat, lon).
@@ -60,9 +83,9 @@ const s = [
60
83
  3857: { def: "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +no_defs" }
61
84
  };
62
85
  for (let e = 0; e < s.length; e++) {
63
- const [o, t] = s[e];
86
+ const [_, o] = s[e];
64
87
  l[6669 + e] = {
65
- def: `+proj=tmerc +lat_0=${o} +lon_0=${t} +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs`,
88
+ def: `+proj=tmerc +lat_0=${_} +lon_0=${o} +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs`,
66
89
  swapXY: !0
67
90
  };
68
91
  }
@@ -1,4 +1,4 @@
1
- const c = {
1
+ const m = {
2
2
  7415: 28992,
3
3
  // Amersfoort / RD New + NAP height — the 3DBAG default
4
4
  6697: 6668,
@@ -62,6 +62,29 @@ const c = {
62
62
  // own extent and confirming it lands in Singapore (103.68-103.99°E,
63
63
  // 1.27-1.46°N — matches).
64
64
  3414: { def: "+proj=tmerc +lat_0=1.36666666666667 +lon_0=103.833333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" },
65
+ // Great Britain — OSGB36 / British National Grid. Bundled because a projected
66
+ // cartographic sheet in BNG is one of the two worked examples the plane-view
67
+ // design names (docs/design/carto-substrate.md), and a national grid nobody
68
+ // can author is a grid nobody uses. The 7-parameter Helmert below is the
69
+ // standard OSGB36 shift and is good to a few metres; the definitive transform
70
+ // is the OSTN15 correction GRID, which this library does not ship — survey
71
+ // work needs that, cartography does not.
72
+ 27700: {
73
+ def: "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs"
74
+ },
75
+ // United States — NAD83 / Conus Albers, the equal-area sheet projection for
76
+ // the lower 48 and the design's other worked example. No `+towgs84`: NAD83
77
+ // and WGS84 differ by 1-2 m, which is below anything a sheet resolves, and a
78
+ // fabricated shift would be worse than none.
79
+ 5070: { def: "+proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs" },
80
+ // France — RGF93 / Lambert-93, the fourth national grid the plane-view design
81
+ // measures its warp against and the only one of them that was missing here.
82
+ // Conformal, so its scale is isotropic and its subdivision error behaves like
83
+ // the Swiss and British cases rather than like equal-area Albers. RGF93 is
84
+ // WGS84 for cartographic purposes, so no `+towgs84`.
85
+ 2154: {
86
+ def: "+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +units=m +no_defs"
87
+ },
65
88
  // Japan — JGD2011 geographic 2D. EPSG axis order is (lat, lon).
66
89
  6668: { def: "+proj=longlat +ellps=GRS80 +no_defs", geographic: !0, swapXY: !0 },
67
90
  // WGS 84. Files in the wild store lon/lat despite EPSG's formal (lat, lon).
@@ -76,33 +99,33 @@ for (let t = 0; t < f.length; t++) {
76
99
  };
77
100
  }
78
101
  let p = null;
79
- async function m() {
102
+ async function c() {
80
103
  return (await import("./index-CW1n5LdO.js")).default;
81
104
  }
82
- function g() {
83
- return p ??= m(), p;
84
- }
85
105
  function j() {
106
+ return p ??= c(), p;
107
+ }
108
+ function g() {
86
109
  return Object.keys(u).map(Number).sort((t, e) => t - e);
87
110
  }
88
111
  async function i(t, e, o) {
89
- const a = c[t] ?? t, n = u[a];
112
+ const _ = m[t] ?? t, n = u[_];
90
113
  if (!n) return null;
91
114
  const [s, l] = n.swapXY ? [o, e] : [e, o];
92
115
  if (n.geographic) return [s, l];
93
- const _ = await g(), [r, d] = _(n.def, "+proj=longlat +datum=WGS84 +no_defs").forward([s, l]);
116
+ const a = await j(), [r, d] = a(n.def, "+proj=longlat +datum=WGS84 +no_defs").forward([s, l]);
94
117
  return Number.isFinite(r) && Number.isFinite(d) ? [r, d] : null;
95
118
  }
96
- async function w(t, e, o, a = 100) {
97
- const n = await i(t, e, o), s = await i(t, e, o + a);
119
+ async function y(t, e, o, _ = 100) {
120
+ const n = await i(t, e, o), s = await i(t, e, o + _);
98
121
  if (!n || !s) return null;
99
- const l = (n[1] + s[1]) / 2 * Math.PI / 180, _ = (s[0] - n[0]) * Math.cos(l), r = s[1] - n[1];
100
- return Math.atan2(_, r) * 180 / Math.PI;
122
+ const l = (n[1] + s[1]) / 2 * Math.PI / 180, a = (s[0] - n[0]) * Math.cos(l), r = s[1] - n[1];
123
+ return Math.atan2(a, r) * 180 / Math.PI;
101
124
  }
102
125
  export {
103
- u as C,
104
- c as a,
105
- j as b,
106
- w as g,
107
- i as p
126
+ m as COMPOUND_TO_HORIZONTAL,
127
+ u as CRS_DEFS,
128
+ g as bundledCrsCodes,
129
+ y as gridConvergence,
130
+ i as projectedToLonLat
108
131
  };
@@ -330,6 +330,16 @@ export declare class OmMapElement extends HTMLElementBase {
330
330
  pitch: number;
331
331
  bearing: number;
332
332
  } | undefined;
333
+ /**
334
+ * The ground corners of a `widthPx × heightPx` render of this map, or null
335
+ * when it is an ordinary Web Mercator map and the caller's own
336
+ * reconstruction is correct. A cartograph frame asks this so a PROJECTED map
337
+ * is georeferenced through its own projection rather than through a Mercator
338
+ * viewport rebuilt from its (geographic) camera.
339
+ */
340
+ groundCorners(widthPx: number, heightPx: number): [number, number][] | null;
341
+ /** The CRS this map is projected into, or null for Web Mercator. */
342
+ projectedCrs(): string | null;
333
343
  /** Live Tileset3D per currently-present 3D-tiles layer — the paced-flyby driver's isLoaded() gate (same surface the warm-tiles action reads). */
334
344
  getLiveTilesetsInternal(): Map<string, unknown>;
335
345
  /** The basemap's event-latched settle state — the paced driver's per-frame gate consults it beside the tileset loop (remotion §5: MapLibre throttles symbol placement while the camera moves, so a gate that only watches 3D tilesets records moving takes with no labels). True when standalone/headless. */
@@ -1,4 +1,4 @@
1
- import { r as p, n as d } from "./index-oY3XHIux.js";
1
+ import { a4 as p, a5 as d } from "./index-CBYDP-_0.js";
2
2
  function g(t) {
3
3
  if (t == null) return !0;
4
4
  const e = t, n = e.id?.code;
@@ -9,24 +9,24 @@ function y(t) {
9
9
  return typeof e?.name == "string" && e.name ? `"${e.name}"` : e?.id?.code != null ? `${e.id.authority ?? "?"}:${e.id.code}` : "a non-CRS84 CRS";
10
10
  }
11
11
  function h(t, e, n) {
12
- const o = e.primary_column;
13
- if (!o)
12
+ const r = e.primary_column;
13
+ if (!r)
14
14
  throw new Error(`data="${n}": GeoParquet "geo" metadata names no primary_column — can't tell which column is geometry.`);
15
- const c = e.columns?.[o]?.crs;
15
+ const c = e.columns?.[r]?.crs;
16
16
  if (!g(c))
17
17
  throw new Error(
18
18
  `data="${n}": GeoParquet CRS ${y(c)} isn't CRS84/EPSG:4326 — reprojection isn't supported yet (deck.gl renders lng/lat). Reproject first, e.g. ogr2ogr -t_srs EPSG:4326 out.parquet in.parquet.`
19
19
  );
20
20
  if (t.length === 0)
21
21
  return console.warn(`[onlymapjs] data="${n}": GeoParquet has no rows — empty layer.`), [];
22
- const u = t.map((r) => r[o]);
23
- if (u.every((r) => r != null && r.type === "Point")) {
24
- const r = t.map(({ [o]: i, ...m }) => m), a = p(r), s = u.map((i) => i.coordinates ?? void 0);
25
- return { length: t.length, columns: { ...a?.columns ?? {}, [o]: s } };
22
+ const u = t.map((o) => o[r]);
23
+ if (u.every((o) => o != null && o.type === "Point")) {
24
+ const o = t.map(({ [r]: i, ...m }) => m), a = p(o), s = u.map((i) => i.coordinates ?? void 0);
25
+ return { length: t.length, columns: { ...a?.columns ?? {}, [r]: s } };
26
26
  }
27
- const l = t.map(({ [o]: r, ...a }) => {
27
+ const l = t.map(({ [r]: o, ...a }) => {
28
28
  const s = a.id;
29
- return { type: "Feature", ...s != null ? { id: s } : {}, geometry: r ?? null, properties: a };
29
+ return { type: "Feature", ...s != null ? { id: s } : {}, geometry: o ?? null, properties: a };
30
30
  });
31
31
  return d({ type: "FeatureCollection", features: l });
32
32
  }
@@ -0,0 +1,104 @@
1
+ import { d as L, j as x, a6 as A, a7 as E, a8 as d, a9 as h, aa as u, ab as z, p as V, W as Z, G as D } from "./index-CBYDP-_0.js";
2
+ const c = Math.PI / 180, G = 180 / Math.PI;
3
+ function w(l, t = 0) {
4
+ const a = Math.min(180, l) * c;
5
+ return z * 2 * Math.sin(a / 2) * Math.pow(2, t);
6
+ }
7
+ function S(l, t = 0) {
8
+ const a = l / Math.pow(2, t);
9
+ return Math.asin(Math.min(1, a / z / 2)) * 2 * G;
10
+ }
11
+ class b extends A {
12
+ constructor(t) {
13
+ const { startPanPos: a, ...o } = t;
14
+ o.normalize = !1, super(o), a !== void 0 && (this._state.startPanPos = a);
15
+ }
16
+ panStart({ pos: t }) {
17
+ const { latitude: a, longitude: o, zoom: e } = this.getViewportProps();
18
+ return this._getUpdatedState({
19
+ startPanLngLat: [o, a],
20
+ startPanPos: t,
21
+ startZoom: e
22
+ });
23
+ }
24
+ pan({ pos: t, startPos: a }) {
25
+ const o = this.getState(), e = o.startPanLngLat || this._unproject(a);
26
+ if (!e)
27
+ return this;
28
+ const s = o.startZoom ?? this.getViewportProps().zoom, n = o.startPanPos || a, i = [e[0], e[1], s], m = this.makeViewport(this.getViewportProps()).panByPosition(i, t, n);
29
+ return this._getUpdatedState(m);
30
+ }
31
+ panEnd() {
32
+ return this._getUpdatedState({
33
+ startPanLngLat: null,
34
+ startPanPos: null,
35
+ startZoom: null
36
+ });
37
+ }
38
+ zoom({ scale: t }) {
39
+ const o = (this.getState().startZoom || this.getViewportProps().zoom) + Math.log2(t);
40
+ return this._getUpdatedState({ zoom: o });
41
+ }
42
+ applyConstraints(t) {
43
+ const { longitude: a, latitude: o, maxBounds: e } = t;
44
+ if (t.zoom = this._constrainZoom(t.zoom, t), (a < -180 || a > 180) && (t.longitude = E(a + 180, 360) - 180), t.latitude = d(o, -h, h), e && (t.longitude = d(t.longitude, e[0][0], e[1][0]), t.latitude = d(t.latitude, e[0][1], e[1][1])), e) {
45
+ const s = t.zoom - u(o), n = e[1][0] - e[0][0], i = e[1][1] - e[0][1];
46
+ if (i > 0 && i < h * 2) {
47
+ const r = Math.min(S(t.height, s), i) / 2;
48
+ t.latitude = d(t.latitude, e[0][1] + r, e[1][1] - r);
49
+ }
50
+ if (n > 0 && n < 360) {
51
+ const r = Math.min(S(t.width / Math.cos(t.latitude * c), s), n) / 2;
52
+ t.longitude = d(t.longitude, e[0][0] + r, e[1][0] - r);
53
+ }
54
+ }
55
+ return t.latitude !== o && (t.zoom += u(t.latitude) - u(o)), t;
56
+ }
57
+ _constrainZoom(t, a) {
58
+ a || (a = this.getViewportProps());
59
+ const { latitude: o, maxZoom: e, maxBounds: s } = a;
60
+ let { minZoom: n } = a;
61
+ const i = u(0), r = u(o) - i;
62
+ if (s !== null && a.width > 0 && a.height > 0) {
63
+ const g = s[0][1], M = s[1][1], _ = Math.sign(g) === Math.sign(M) ? Math.min(Math.abs(g), Math.abs(M)) : 0, P = w(s[1][0] - s[0][0]) * Math.cos(_ * c), f = w(s[1][1] - s[0][1]);
64
+ P > 0 && (n = Math.max(n, Math.log2(a.width / P) + i)), f > 0 && (n = Math.max(n, Math.log2(a.height / f) + i)), n > e && (n = e);
65
+ }
66
+ return d(t, n + r, e + r);
67
+ }
68
+ }
69
+ class T extends L {
70
+ constructor() {
71
+ super(...arguments), this.ControllerState = b, this.transition = {
72
+ transitionDuration: 300,
73
+ transitionInterpolator: new x(["longitude", "latitude", "zoom"])
74
+ }, this.dragMode = "pan";
75
+ }
76
+ setProps(t) {
77
+ super.setProps(t), this.dragRotate = !1, this.touchRotate = !1;
78
+ }
79
+ }
80
+ const I = {
81
+ cullMode: "back"
82
+ };
83
+ class R extends V {
84
+ constructor(t = {}) {
85
+ super({
86
+ ...t,
87
+ parameters: {
88
+ ...I,
89
+ ...t.parameters
90
+ }
91
+ });
92
+ }
93
+ getViewportType(t) {
94
+ return t.zoom > 12 ? Z : D;
95
+ }
96
+ get ControllerType() {
97
+ return T;
98
+ }
99
+ }
100
+ R.displayName = "GlobeView";
101
+ export {
102
+ T as G,
103
+ R as a
104
+ };
@@ -0,0 +1,298 @@
1
+ import { al as P, am as T, an as N, ao as Z, c as B, ap as E, aq as C, ar as b, as as D, at as I, au as O } from "./index-CBYDP-_0.js";
2
+ import { N as _, c as H } from "./hillshade-apron-Bem3DWyJ.js";
3
+ import { p as $, h as j, m as A, a as U } from "./hillshade-shader-DI2uLSNU.js";
4
+ function R(t, e, o) {
5
+ return [t.west + (t.east - t.west) * e, t.north + (t.south - t.north) * o];
6
+ }
7
+ function W(t, e, o) {
8
+ const n = Math.max(1, Math.round(o)), a = n + 1, s = a * a, m = new Float64Array(s * 3), i = new Float32Array(s * 2), u = new Uint32Array(n * n * 6);
9
+ for (let h = 0; h < a; h++) {
10
+ const f = h / n;
11
+ for (let d = 0; d < a; d++) {
12
+ const l = d / n, c = h * a + d, [p, g] = e.toPlane(R(t, l, f));
13
+ m[c * 3] = p, m[c * 3 + 1] = g, m[c * 3 + 2] = 0, i[c * 2] = l, i[c * 2 + 1] = f;
14
+ }
15
+ }
16
+ let r = 0;
17
+ for (let h = 0; h < n; h++)
18
+ for (let f = 0; f < n; f++) {
19
+ const d = h * a + f, l = d + 1, c = d + a, p = c + 1;
20
+ u[r++] = d, u[r++] = c, u[r++] = l, u[r++] = l, u[r++] = c, u[r++] = p;
21
+ }
22
+ return { positions: m, texCoords: i, indices: u, vertexCount: u.length };
23
+ }
24
+ function k(t, e = 1) {
25
+ const o = Number.isFinite(t) ? t : 0, n = o <= 3 ? 8 : o <= 5 ? 4 : o <= 8 ? 2 : 1, a = Number.isFinite(e) && e > 1 ? Math.sqrt(e) : 1;
26
+ return Math.min(16, Math.max(1, Math.round(n * a)));
27
+ }
28
+ function q(t, e, o = 1e3) {
29
+ const [n, a] = t.toPlane(e), s = o / (t.projection.metresPerUnit || 1), m = t.fromPlane([n, a]), i = t.fromPlane([n, a + s]);
30
+ if (!Number.isFinite(i[0]) || !Number.isFinite(i[1])) return 0;
31
+ const u = (m[1] + i[1]) / 2 * Math.PI / 180, r = (i[0] - m[0]) * Math.cos(u), h = i[1] - m[1], f = Math.atan2(r, h) * 180 / Math.PI;
32
+ return Number.isFinite(f) ? f : 0;
33
+ }
34
+ const w = 512;
35
+ function J(t, e, o, n = w) {
36
+ return Z(t.zoom, o, e.projection.metresPerUnit) + Math.log2(w / (n || w));
37
+ }
38
+ const M = /* @__PURE__ */ new WeakMap();
39
+ function K(t) {
40
+ const e = M.get(t);
41
+ if (e) return e;
42
+ class o extends P {
43
+ getTileIndices(a) {
44
+ const s = a.viewport, m = this, i = s.unproject([s.width / 2, s.height / 2]), [, u] = t.fromPlane([i[0], i[1]]), r = a.zoomOffset ?? m.opts.zoomOffset ?? 0;
45
+ let h = Math.round(J(s, t, u, m.opts.tileSize) + r);
46
+ const f = a.maxZoom ?? m.opts.maxZoom, d = a.minZoom ?? m.opts.minZoom;
47
+ if (typeof f == "number" && (h = Math.min(h, f)), typeof d == "number" && (h = Math.max(h, d)), !Number.isFinite(h)) return [];
48
+ const l = s.unproject([0, 0]), c = s.unproject([s.width, s.height]), p = {
49
+ left: Math.min(l[0], c[0]),
50
+ right: Math.max(l[0], c[0]),
51
+ bottom: Math.min(l[1], c[1]),
52
+ top: Math.max(l[1], c[1])
53
+ };
54
+ return T(t, p, Math.max(0, h));
55
+ }
56
+ /**
57
+ * Two extents, because a warped tile genuinely has two.
58
+ *
59
+ * `bbox` is what deck CULLS against, and it compares against
60
+ * `viewport.unproject()` of the screen rectangle — plane metres here. A
61
+ * geographic bbox put in this slot compares degrees against metres, never
62
+ * overlaps, and every tile is silently invisible: tiles fetch, nothing
63
+ * draws, and no error is raised anywhere. It is the `left/top/right/bottom`
64
+ * form, which is the one deck reads for a non-geospatial viewport.
65
+ *
66
+ * `lngLatBbox` is the tile's own geographic extent, which is what the warp
67
+ * mesh projects. The plane envelope is taken by sampling the tile's EDGES,
68
+ * not its corners — a conic bows them, so a corner-only envelope clips the
69
+ * tile away at exactly the zoom where the bowing matters.
70
+ */
71
+ getTileMetadata(a) {
72
+ const s = N(a.x, a.y, a.z);
73
+ let m = 1 / 0, i = -1 / 0, u = 1 / 0, r = -1 / 0;
74
+ const h = 5;
75
+ for (let f = 0; f <= h; f++) {
76
+ const d = f / h, l = s.west + (s.east - s.west) * d, c = s.south + (s.north - s.south) * d;
77
+ for (const p of [
78
+ t.toPlane([l, s.north]),
79
+ t.toPlane([l, s.south]),
80
+ t.toPlane([s.west, c]),
81
+ t.toPlane([s.east, c])
82
+ ])
83
+ !Number.isFinite(p[0]) || !Number.isFinite(p[1]) || (p[0] < m && (m = p[0]), p[0] > i && (i = p[0]), p[1] < u && (u = p[1]), p[1] > r && (r = p[1]));
84
+ }
85
+ return {
86
+ bbox: { left: m, top: r, right: i, bottom: u },
87
+ lngLatBbox: { west: s.west, south: s.south, east: s.east, north: s.north }
88
+ };
89
+ }
90
+ }
91
+ return M.set(t, o), o;
92
+ }
93
+ const G = 64, y = /* @__PURE__ */ new Map();
94
+ function z(t) {
95
+ const e = y.get(t);
96
+ if (e) return e;
97
+ const o = I(t);
98
+ if (y.set(t, o), y.size > G) {
99
+ const n = y.keys().next().value;
100
+ n !== void 0 && y.delete(n);
101
+ }
102
+ return o;
103
+ }
104
+ function F(t, e, o, n) {
105
+ return t.replace("{z}", String(n)).replace("{x}", String(e)).replace("{y}", String(o));
106
+ }
107
+ async function V(t, e, o) {
108
+ const n = await z(F(t, o.x, o.y, o.z));
109
+ if (!n) return null;
110
+ const a = (i) => ({
111
+ width: i.width,
112
+ height: i.height,
113
+ at: (u, r) => {
114
+ const h = (r * i.width + u) * 4;
115
+ return O(e, i.data[h], i.data[h + 1], i.data[h + 2]);
116
+ }
117
+ }), s = 2 ** o.z, m = /* @__PURE__ */ new Map();
118
+ return await Promise.all(
119
+ _.map(async ({ dx: i, dy: u }) => {
120
+ const r = o.y + u;
121
+ if (r < 0 || r >= s) return;
122
+ const h = ((o.x + i) % s + s) % s;
123
+ m.set(`${i},${u}`, await z(F(t, h, r, o.z)));
124
+ })
125
+ ), H(a(n), (i, u) => {
126
+ const r = m.get(`${i},${u}`);
127
+ return r ? a(r) : null;
128
+ });
129
+ }
130
+ const Y = {
131
+ blendColorSrcFactor: "dst",
132
+ blendColorDstFactor: "zero",
133
+ blendAlphaSrcFactor: "zero",
134
+ blendAlphaDstFactor: "one"
135
+ };
136
+ class S extends D {
137
+ static layerName = "HillshadeBitmapLayer";
138
+ getShaders() {
139
+ const e = super.getShaders();
140
+ return { ...e, modules: [...e.modules, U] };
141
+ }
142
+ draw(e) {
143
+ const o = this.props, n = { ...o.hillshadeUniforms, hillshadeHeights: o.image };
144
+ for (const a of this.getModels()) a.shaderInputs.setProps({ hillshade: n });
145
+ super.draw(e);
146
+ }
147
+ }
148
+ class Q extends S {
149
+ static layerName = "WarpedHillshadeBitmapLayer";
150
+ _createMesh() {
151
+ const e = this.props, o = e._planeFrame, n = e._planeBounds;
152
+ return !o || !n ? super._createMesh() : W(n, o, e._subdivision ?? 1);
153
+ }
154
+ }
155
+ function X(t, e) {
156
+ if (!t) return e;
157
+ if (typeof t != "string") return t;
158
+ if (t in b) return b[t];
159
+ try {
160
+ const o = JSON.parse(t);
161
+ if ([o?.rScaler, o?.gScaler, o?.bScaler, o?.offset].every((n) => typeof n == "number" && Number.isFinite(n))) return o;
162
+ } catch {
163
+ }
164
+ return console.warn(`[onlymapjs] HillshadeLayer: decoder="${t}" is not "terrarium", "mapbox-rgb" or {rScaler,gScaler,bScaler,offset} JSON — using terrarium.`), e;
165
+ }
166
+ function tt(t) {
167
+ const e = C(t.src);
168
+ return e ? e.requiresKey ? (console.warn(`[onlymapjs] HillshadeLayer: src="${t.src}" needs a ${e.requiresKey} key, which this layer does not plumb — use a keyless source such as "terrarium".`), null) : {
169
+ template: e.elevationData,
170
+ decoder: typeof e.decoder == "string" ? b[e.decoder] : e.decoder,
171
+ maxZoom: t.maxZoom ?? e.maxZoom
172
+ } : !t.src || !t.src.includes("{z}") ? (console.warn(`[onlymapjs] HillshadeLayer: src="${t.src}" is neither a registered terrain preset nor a {z}/{x}/{y} DEM URL template.`), null) : { template: t.src, decoder: X(t.decoder, b.terrarium), maxZoom: t.maxZoom ?? 14 };
173
+ }
174
+ function et(t, e) {
175
+ return !Number.isFinite(t) || !Number.isFinite(e) || e <= 0 ? 0 : Math.max(0, Math.round(Math.log2(Math.max(1, t / e))));
176
+ }
177
+ class rt extends B {
178
+ static layerName = "OmHillshadeLayer";
179
+ static defaultProps = {
180
+ src: { type: "string", value: "terrarium" },
181
+ decoder: { type: "string", value: null, optional: !0 },
182
+ sunAzimuth: { type: "string", value: "315" },
183
+ sunWeight: { type: "string", value: null, optional: !0 },
184
+ sunElevation: { type: "number", value: 45 },
185
+ zFactor: { type: "number", value: 1 },
186
+ blend: { type: "string", value: "normal" },
187
+ maxZoom: { type: "number", value: null, optional: !0 },
188
+ zoomOffset: { type: "number", value: 0 },
189
+ _planeFrame: { type: "object", value: null, optional: !0, compare: !1 },
190
+ sunDatum: { type: "string", value: "sheet" }
191
+ };
192
+ renderLayers() {
193
+ const e = tt(this.props);
194
+ if (!e) return null;
195
+ const { azimuths: o, weights: n } = $(this.props.sunAzimuth, this.props.sunWeight), a = this.props.blend === "multiply", s = this.context.device, m = s?.canvasContext?.cssToDeviceRatio?.() ?? 1, i = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, u = this.state.textures, r = this.props._planeFrame ?? null, h = Math.max(1, m / i), f = this.props.sunDatum === "geographic";
196
+ return new E(
197
+ this.getSubLayerProps({ id: "tiles" }),
198
+ {
199
+ data: e.template,
200
+ tileSize: 256,
201
+ maxZoom: e.maxZoom,
202
+ // A plane view's viewport zoom is in PLANE units — about -12 for a
203
+ // continental Albers sheet, because a plane unit is a metre and a
204
+ // Mercator world unit at that latitude is sixty kilometres. TileLayer's
205
+ // `minZoom` gate compares the VIEWPORT's zoom against it, so deck's
206
+ // default of 0 hid every tile: they fetched, they were selected, and
207
+ // `renderSubLayers` was never called — no error anywhere. The tile
208
+ // PYRAMID's zoom range is a different number entirely, and the plane
209
+ // tileset applies it to the geographic zoom it derives.
210
+ ...r ? { TilesetClass: K(r), minZoom: -1 / 0 } : {},
211
+ zoomOffset: (this.props.zoomOffset ?? 0) + et(m, i),
212
+ // deck compares FUNCTION props by their update triggers, never by
213
+ // identity — inline closures would otherwise invalidate everything on
214
+ // every render. So anything a closure captures is invisible to deck
215
+ // unless it is declared here, which is why moving the sun with no
216
+ // trigger produced a byte-identical frame.
217
+ //
218
+ // The split is exactly the one we want. `getTileData` names only what
219
+ // changes the HEIGHTS, so a new decoder or source refetches; the
220
+ // illumination names `renderSubLayers`, which regenerates the draw
221
+ // calls and refetches nothing — moving the sun costs no network at
222
+ // all, because every knob below is a uniform.
223
+ updateTriggers: {
224
+ getTileData: [e.template, JSON.stringify(e.decoder)],
225
+ renderSubLayers: [o.join(","), n.join(","), this.props.sunElevation, this.props.zFactor, a, f, r?.projection.code ?? ""]
226
+ },
227
+ getTileData: async (d) => {
228
+ const l = await V(e.template, e.decoder, d.index);
229
+ if (!l || !s) return null;
230
+ const c = `${d.index.z}/${d.index.x}/${d.index.y}`;
231
+ u.get(c)?.destroy();
232
+ const p = s.createTexture({
233
+ data: l.data,
234
+ format: "r32float",
235
+ width: l.width + 2,
236
+ height: l.height + 2,
237
+ // NEAREST, because linear filtering of a float texture needs
238
+ // OES_texture_float_linear, which is not universal (the same
239
+ // constraint raster-pipeline.ts documents).
240
+ sampler: { minFilter: "nearest", magFilter: "nearest", addressModeU: "clamp-to-edge", addressModeV: "clamp-to-edge" }
241
+ });
242
+ return u.set(c, p), { texture: p, width: l.width, height: l.height, key: c };
243
+ },
244
+ onTileUnload: (d) => {
245
+ const l = `${d.index.z}/${d.index.x}/${d.index.y}`;
246
+ u.get(l)?.destroy(), u.delete(l);
247
+ },
248
+ renderSubLayers: (d) => {
249
+ const l = d.data;
250
+ if (!l) return null;
251
+ const c = d.tile, [[p, g], [v, x]] = r && c.lngLatBbox ? [[c.lngLatBbox.west, c.lngLatBbox.south], [c.lngLatBbox.east, c.lngLatBbox.north]] : c.boundingBox, L = r ? Q : S;
252
+ return new L(d, {
253
+ id: `${d.id}-bitmap`,
254
+ data: void 0,
255
+ image: l.texture,
256
+ bounds: [p, g, v, x],
257
+ _planeFrame: r,
258
+ _planeBounds: r ? { west: p, south: g, east: v, north: x } : void 0,
259
+ _subdivision: r ? k(c.index.z, h) : 1,
260
+ multiply: a,
261
+ parameters: a ? Y : {},
262
+ hillshadeUniforms: j({
263
+ width: l.width,
264
+ height: l.height,
265
+ azimuthOffset: r && !f ? q(r, [(p + v) / 2, (x + g) / 2]) : 0,
266
+ // Web Mercator: one scale for both axes, stated at the equator
267
+ // and given its cos-phi falloff per fragment by the shader.
268
+ ...A(c.index.z, l.width, l.height),
269
+ north: x,
270
+ south: g,
271
+ azimuths: o,
272
+ weights: n,
273
+ sunElevation: this.props.sunElevation ?? 45,
274
+ zFactor: this.props.zFactor ?? 1,
275
+ // This layer's texture IS the heightfield, so there is no
276
+ // sampled colour to multiply into — a multiply-blended tile emits
277
+ // the shade and lets the GL blend put it in the framebuffer.
278
+ composite: a ? "framebuffer" : !1
279
+ })
280
+ });
281
+ }
282
+ }
283
+ );
284
+ }
285
+ initializeState() {
286
+ this.setState({ textures: /* @__PURE__ */ new Map() });
287
+ }
288
+ finalizeState() {
289
+ for (const e of this.state.textures.values()) e.destroy();
290
+ this.state.textures.clear();
291
+ }
292
+ }
293
+ export {
294
+ rt as OmHillshadeLayer,
295
+ V as buildPaddedHeights,
296
+ et as captureZoomOffset,
297
+ tt as resolveHillshadeSource
298
+ };
@@ -1,5 +1,5 @@
1
1
  const d = 40075016686e-3, u = 110574, m = 111320, o = Math.PI / 180, f = { none: 0, mercator: 1, geographic: 2 };
2
- function E(e, a, s = "HillshadeLayer") {
2
+ function p(e, a, s = "HillshadeLayer") {
3
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
4
  let t = h(e);
5
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));
@@ -74,10 +74,15 @@ float hillshade_light(vec3 normal, float azimuth, float elevation) {
74
74
  + hillshade.weights.w * hillshade_light(normal, hillshade.azimuths.w, hillshade.sunElevation);
75
75
  shade = clamp(shade, 0.0, 1.0);
76
76
 
77
- if (hillshade.composite > 0.5) {
78
- // Multiply into whatever the chain produced — a hypsometric colormap, or
79
- // (with the layer's multiply blend parameters) the framebuffer itself,
80
- // where white is the identity and opacity fades toward it.
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.
81
86
  color = vec4(color.rgb * mix(1.0, shade, layer.opacity), color.a);
82
87
  } else {
83
88
  // deck's framebuffer is PREMULTIPLIED (the 0.9.1 lesson), so the colour is
@@ -85,7 +90,7 @@ float hillshade_light(vec3 normal, float azimuth, float elevation) {
85
90
  color = vec4(vec3(shade) * layer.opacity, layer.opacity);
86
91
  }
87
92
  `
88
- ), p = {
93
+ ), E = {
89
94
  name: "hillshade",
90
95
  fs: g,
91
96
  inject: {
@@ -133,7 +138,7 @@ function w(e) {
133
138
  const a = e.width + 2, s = e.height + 2, h = (t) => e.latMode === "mercator" ? x(t) : t * o;
134
139
  return {
135
140
  azimuths: c(
136
- e.azimuths.map((t) => t * o),
141
+ e.azimuths.map((t) => (t + (e.azimuthOffset ?? 0)) * o),
137
142
  0
138
143
  ),
139
144
  // A light that does not exist contributes nothing: the unused slots carry
@@ -148,13 +153,13 @@ function w(e) {
148
153
  latMode: f[e.latMode],
149
154
  sunElevation: e.sunElevation * o,
150
155
  zFactor: e.zFactor,
151
- composite: e.composite ? 1 : 0
156
+ composite: e.composite === "framebuffer" ? 2 : e.composite ? 1 : 0
152
157
  };
153
158
  }
154
159
  export {
155
- p as a,
160
+ E as a,
156
161
  w as h,
157
162
  y as m,
158
- E as p,
163
+ p,
159
164
  T as r
160
165
  };