@nika-js/onlymap 0.8.4 → 0.9.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 (53) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +56 -3
  3. package/dist/{LercDecode.es-BKustV-1.js → LercDecode.es-IEPCRZOv.js} +1 -1
  4. package/dist/{basemap-B0SwrOqQ.js → basemap-DL0mk9Bf.js} +780 -780
  5. package/dist/dem-decode.d.ts +58 -0
  6. package/dist/elements/om-map.d.ts +12 -0
  7. package/dist/{geoparquet-C5E6N6G0.js → geoparquet-DJxZA0if.js} +1 -1
  8. package/dist/hillshade-DR3TxO1a.js +186 -0
  9. package/dist/hillshade-apron-Bem3DWyJ.js +40 -0
  10. package/dist/hillshade-apron.d.ts +54 -0
  11. package/dist/hillshade-shader-n_zManfZ.js +160 -0
  12. package/dist/hillshade-shader.d.ts +152 -0
  13. package/dist/hillshade.d.ts +133 -0
  14. package/dist/html-data.d.ts +2 -2
  15. package/dist/{index-BLIjrGOE.js → index-BjcPjICh.js} +28 -28
  16. package/dist/{index-xUVMTGZG.js → index-CvuDsvnk.js} +23 -23
  17. package/dist/index-DO_w0tqR.js +514 -0
  18. package/dist/{index-BnQDfKfE.js → index-DdTZSuAb.js} +1 -1
  19. package/dist/{index-D5Fqn_eZ.js → index-oY3XHIux.js} +13145 -12484
  20. package/dist/{index-CaM1C93G.js → index-vLXZuog4.js} +1 -1
  21. package/dist/index.d.ts +3 -0
  22. package/dist/lerc-Bph62dCb.js +22 -0
  23. package/dist/onlymap.standalone.js +28919 -27259
  24. package/dist/onlymapjs.js +95 -92
  25. package/dist/post-process/catalogue.d.ts +61 -0
  26. package/dist/post-process/compile.d.ts +37 -0
  27. package/dist/post-process/index.d.ts +71 -0
  28. package/dist/post-process/ops.d.ts +22 -0
  29. package/dist/post-process/presets.d.ts +33 -0
  30. package/dist/post-process/validate.d.ts +8 -0
  31. package/dist/programmatic.d.ts +11 -0
  32. package/dist/{raster-B_wekCHv.js → raster-D-eTzCE3.js} +609 -499
  33. package/dist/raster-hillshade.d.ts +119 -0
  34. package/dist/{raster-pipeline-Dn2fkLYx.js → raster-pipeline-BlOnMPJe.js} +510 -484
  35. package/dist/raster-pipeline.d.ts +10 -0
  36. package/dist/raster.d.ts +5 -0
  37. package/dist/runtime-core.d.ts +39 -1
  38. package/dist/terrain-heightfield.d.ts +0 -16
  39. package/dist/terrain-sample.d.ts +0 -13
  40. package/dist/version.d.ts +1 -1
  41. package/dist/volumetrics.d.ts +7 -0
  42. package/dist/{zarr-Dan2ab-l.js → zarr-BGDoEtFb.js} +2 -2
  43. package/docs/cartograph.md +2 -2
  44. package/docs/design/hillshade.md +290 -0
  45. package/docs/effects.md +208 -0
  46. package/docs/hillshade.md +203 -0
  47. package/llms.txt +3 -1
  48. package/onlymapjs.attributes.json +27 -2
  49. package/onlymapjs.html-data.json +207 -6
  50. package/package.json +13 -9
  51. package/skills/onlymapjs/SKILL.md +4 -2
  52. package/skills/onlymapjs/references/syntax.md +17 -2
  53. package/dist/lerc-TxsFLMlC.js +0 -30
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Shaded relief from the AUTHOR'S OWN raster — `shading="hillshade"` on a
3
+ * COGLayer or ZarrLayer.
4
+ *
5
+ * The second of hillshade's two entry points. It runs the same GPU module as
6
+ * `HillshadeLayer` (`hillshade-shader.ts`) and builds the same one-pixel
7
+ * apron (`hillshade-apron.ts`); what differs is everything below the
8
+ * arithmetic, and the differences are the reason this file exists.
9
+ *
10
+ * GROUND SCALE. The tiled path gets its scale free from Web Mercator, which
11
+ * is conformal — one number serves both axes, with an exact cos φ falloff. A
12
+ * COG has no such luck: its tiles are its OWN internal tiles in its OWN CRS
13
+ * (deck.gl-geotiff builds an `AffineTilesetLevel` per overview from the
14
+ * image's geotransform — it does not reproject into a Mercator tile grid).
15
+ * So the scale comes from the affine, and whether it varies across the tile
16
+ * depends on the CRS's units. A geographic source is ANISOTROPIC: a degree of
17
+ * latitude is ~constant while a degree of longitude shrinks with cos φ. At
18
+ * the latitude of the repo's own Grand Canyon fixture that is a factor of
19
+ * 1.23 between the axes, and ignoring it does not look like a bug — the
20
+ * relief renders, still looks like terrain, and is simply sheared, with every
21
+ * shadow falling at a consistently wrong angle.
22
+ *
23
+ * NEIGHBOURS. The tiled path fetches its own neighbours. Here the tiles are
24
+ * fetched by the COG reader, so a neighbour is usually ALREADY decoded and in
25
+ * memory — `raster.ts` retains every tile's decode for pixel-identify. This
26
+ * module reads those first and fetches only the genuine gaps, which is the
27
+ * same algorithm the tiled path runs against its own cache. It is eager on
28
+ * purpose: relief correct only at the centre of the view would bake a
29
+ * hairline into a print plate at exactly the edge nobody can crop.
30
+ */
31
+ import type { Device, Texture } from "@luma.gl/core";
32
+ import { type HeightSource, type PaddedHeights } from "./hillshade-apron";
33
+ import { type LatitudeMode } from "./hillshade-shader";
34
+ import { type OmTileData, type RasterArrayLike } from "./raster-pipeline";
35
+ /** `[a, b, c, d, e, f]`: `(x, y) → (a·x + b·y + c, d·x + e·y + f)` — pixel grid to CRS. */
36
+ export type Affine = readonly [number, number, number, number, number, number];
37
+ /** A source CRS's linear unit, as proj4 reports it. */
38
+ export type CrsUnits = "degree" | "metre" | "foot";
39
+ /**
40
+ * proj4's `units` string → the three cases ground scale actually cares about.
41
+ * Anything unrecognised is treated as metres, which is what every projected
42
+ * CRS in practice uses and the only assumption that fails quietly rather than
43
+ * catastrophically.
44
+ */
45
+ export declare function normalizeCrsUnits(units: string | null | undefined): CrsUnits;
46
+ /** Units per pixel along each axis, robust to a rotated or skewed geotransform. */
47
+ export declare function affinePixelSize(affine: Affine): {
48
+ x: number;
49
+ y: number;
50
+ };
51
+ /**
52
+ * The CRS-Y bounds of one tile's rows, which for a geographic source are its
53
+ * north and south latitudes — what the shader needs to apply cos φ per
54
+ * fragment. Read from the affine rather than from the tile's lng/lat
55
+ * bounding box because the tile's PIXEL ROWS are what the texture is indexed
56
+ * by, and only the affine describes those.
57
+ */
58
+ export declare function tileLatitudeBounds(affine: Affine, firstRow: number, rowCount: number): {
59
+ north: number;
60
+ south: number;
61
+ };
62
+ /** Ground scale + latitude mode for one raster tile. */
63
+ export declare function rasterGroundScale(affine: Affine, units: CrsUnits): {
64
+ metresPerTexel: [number, number];
65
+ latMode: LatitudeMode;
66
+ };
67
+ /**
68
+ * One band of a decoded tile as a `HeightSource`.
69
+ *
70
+ * Deliberately reads the retained array rather than the GPU texture: the
71
+ * apron needs a NEIGHBOUR's pixels, and a neighbour's texture is bound to a
72
+ * different draw call. The decode is already in memory for pixel-identify,
73
+ * so this is a read, not a cost — which is also why `shading` has to keep
74
+ * that decode alive even when `identify="off"` would otherwise drop it.
75
+ */
76
+ export declare function bandHeights(array: RasterArrayLike, band: number): HeightSource;
77
+ /** A tile the reader has already decoded, or one this module fetched to fill an apron gap. */
78
+ export interface NeighbourLookup {
79
+ /** Already-decoded tiles, keyed `"x,y"` — `raster.ts`'s identify table. */
80
+ loaded(x: number, y: number): RasterArrayLike | null;
81
+ /** Fetch + decode a tile the reader has not asked for. Resolves null off the source's extent. */
82
+ fetch(x: number, y: number): Promise<RasterArrayLike | null>;
83
+ /** The level's tile-grid size, so an off-extent neighbour is never requested. */
84
+ matrixWidth: number;
85
+ matrixHeight: number;
86
+ }
87
+ /**
88
+ * Builds one raster tile's padded heightfield.
89
+ *
90
+ * Reads already-decoded neighbours first and fetches only the gaps. Unlike
91
+ * the tiled DEM path there is no wrap: a COG's grid ends where its data ends,
92
+ * so an out-of-range neighbour is genuinely absent and clamps.
93
+ */
94
+ export declare function buildRasterApron(opts: {
95
+ own: RasterArrayLike;
96
+ band: number;
97
+ x: number;
98
+ y: number;
99
+ neighbours: NeighbourLookup;
100
+ }): Promise<PaddedHeights>;
101
+ export declare function cacheApronDecode(image: object, x: number, y: number, load: () => Promise<RasterArrayLike | null>): Promise<RasterArrayLike | null>;
102
+ /** Drops every cached apron decode for an image — exported for tests. */
103
+ export declare function clearApronDecodes(image: object): void;
104
+ /** Uploads a padded heightfield as the `r32float` texture the shader samples. */
105
+ export declare function createHeightTexture(device: Device, padded: PaddedHeights): Texture;
106
+ /** A tile's hillshade attachment, hung off the OmTileData the reader already owns. */
107
+ export interface TileShading {
108
+ texture: Texture;
109
+ width: number;
110
+ height: number;
111
+ north: number;
112
+ south: number;
113
+ metresPerTexel: [number, number];
114
+ latMode: LatitudeMode;
115
+ }
116
+ /** Frees a tile's height texture — called from the same unload hook that frees its band textures. */
117
+ export declare function destroyTileShading(tile: OmTileData & {
118
+ shading?: TileShading | null;
119
+ }): void;