@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
@@ -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
  };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * DEM tile decode — the ONE place an RGB-encoded elevation tile becomes
3
+ * numbers.
4
+ *
5
+ * WHY THIS EXISTS. A DEM tile is not a picture. Its bytes are a big-endian
6
+ * integer split across the R, G and B channels, so every step of the normal
7
+ * image path that is *allowed* to adjust a colour is, here, allowed to adjust
8
+ * a height. Two of them do, and both are off by default:
9
+ *
10
+ * - `colorSpaceConversion` — a PNG carrying an `sRGB`, `gAMA` or `iCCP` chunk
11
+ * gets converted toward the display's colour space on decode. That is
12
+ * correct for a photograph and catastrophic for a height: the channel
13
+ * values move.
14
+ * - `premultiplyAlpha` — premultiplying and then un-premultiplying a tile
15
+ * that has any alpha below 255 is a lossy round trip through integers.
16
+ *
17
+ * Both sites that read DEM pixels used to call bare
18
+ * `createImageBitmap(blob)`, which leaves these at "default" — i.e. the
19
+ * browser's choice. For a single point query the resulting ±1 LSB is
20
+ * sub-metre noise nobody sees. But a derivative (hillshade, slope, any
21
+ * neighbour difference) amplifies exactly that error, and a ±1 LSB wobble
22
+ * across a smooth slope becomes visible banding. Fixing it once, here, is
23
+ * also what makes a GPU hillshade and a CPU line-of-sight agree about the
24
+ * same ground.
25
+ *
26
+ * The canvas is the second half of the same problem: an `alpha: true` 2D
27
+ * canvas stores premultiplied and un-premultiplies on `getImageData`, so the
28
+ * context is pinned to `alpha: false` and `colorSpace: "srgb"` — an opaque
29
+ * surface in a fixed space performs no conversion on the way in or out.
30
+ */
31
+ /** Reset for tests — the lossy notice is once-per-host for the session. */
32
+ export declare function resetDemDecodeWarningsForTests(): void;
33
+ /**
34
+ * Decoded DEM tile pixels: RGBA bytes, row-major, `width * height * 4` long.
35
+ * Deliberately the raw `Uint8ClampedArray` rather than an `ImageData` —
36
+ * volumetrics' worker postMessages these, and the decoder that turns the
37
+ * bytes into metres lives with the caller.
38
+ */
39
+ export interface DemPixels {
40
+ width: number;
41
+ height: number;
42
+ data: Uint8ClampedArray;
43
+ }
44
+ /**
45
+ * Fetch and decode one DEM tile. `null` on any failure — the caller's
46
+ * contract everywhere is "treat as no terrain", never a thrown error.
47
+ *
48
+ * `init` carries the abort signal for callers that bound tile latency.
49
+ */
50
+ export declare function fetchDemTile(url: string, init?: RequestInit): Promise<DemPixels | null>;
51
+ /**
52
+ * Decode an already-fetched DEM image to exact RGBA bytes.
53
+ *
54
+ * Split out from `fetchDemTile` so the decode path is testable without a
55
+ * network, and so a caller holding a blob from somewhere else cannot
56
+ * accidentally reintroduce the bare `createImageBitmap` call.
57
+ */
58
+ export declare function decodeDemBlob(blob: Blob): Promise<DemPixels | null>;
@@ -32,6 +32,8 @@ export declare class OmMapElement extends HTMLElementBase {
32
32
  private contextmenuHandler?;
33
33
  private mount;
34
34
  private reconcilePending;
35
+ /** Last seen `<om-effect>` markup, so the `effects` watch token fires on real changes only. */
36
+ private effectSignature;
35
37
  private readonly dataOwner;
36
38
  private dataReleasePending;
37
39
  /** Decoded property tables per pick-features layer — see RuntimeCoreCallbacks.onFeatureTable. */
@@ -328,6 +330,16 @@ export declare class OmMapElement extends HTMLElementBase {
328
330
  pitch: number;
329
331
  bearing: number;
330
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;
331
343
  /** Live Tileset3D per currently-present 3D-tiles layer — the paced-flyby driver's isLoaded() gate (same surface the warm-tiles action reads). */
332
344
  getLiveTilesetsInternal(): Map<string, unknown>;
333
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-BSAY6CWm.js";
1
+ import { a4 as p, a5 as d } from "./index-JjyDEqAS.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-JjyDEqAS.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-JjyDEqAS.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
+ };