@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.
- package/CHANGELOG.md +32 -0
- package/README.md +56 -3
- package/dist/{LercDecode.es-BKustV-1.js → LercDecode.es-IEPCRZOv.js} +1 -1
- package/dist/{basemap-B0SwrOqQ.js → basemap-DL0mk9Bf.js} +780 -780
- package/dist/dem-decode.d.ts +58 -0
- package/dist/elements/om-map.d.ts +12 -0
- package/dist/{geoparquet-C5E6N6G0.js → geoparquet-DJxZA0if.js} +1 -1
- package/dist/hillshade-DR3TxO1a.js +186 -0
- package/dist/hillshade-apron-Bem3DWyJ.js +40 -0
- package/dist/hillshade-apron.d.ts +54 -0
- package/dist/hillshade-shader-n_zManfZ.js +160 -0
- package/dist/hillshade-shader.d.ts +152 -0
- package/dist/hillshade.d.ts +133 -0
- package/dist/html-data.d.ts +2 -2
- package/dist/{index-BLIjrGOE.js → index-BjcPjICh.js} +28 -28
- package/dist/{index-xUVMTGZG.js → index-CvuDsvnk.js} +23 -23
- package/dist/index-DO_w0tqR.js +514 -0
- package/dist/{index-BnQDfKfE.js → index-DdTZSuAb.js} +1 -1
- package/dist/{index-D5Fqn_eZ.js → index-oY3XHIux.js} +13145 -12484
- package/dist/{index-CaM1C93G.js → index-vLXZuog4.js} +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/lerc-Bph62dCb.js +22 -0
- package/dist/onlymap.standalone.js +28919 -27259
- package/dist/onlymapjs.js +95 -92
- package/dist/post-process/catalogue.d.ts +61 -0
- package/dist/post-process/compile.d.ts +37 -0
- package/dist/post-process/index.d.ts +71 -0
- package/dist/post-process/ops.d.ts +22 -0
- package/dist/post-process/presets.d.ts +33 -0
- package/dist/post-process/validate.d.ts +8 -0
- package/dist/programmatic.d.ts +11 -0
- package/dist/{raster-B_wekCHv.js → raster-D-eTzCE3.js} +609 -499
- package/dist/raster-hillshade.d.ts +119 -0
- package/dist/{raster-pipeline-Dn2fkLYx.js → raster-pipeline-BlOnMPJe.js} +510 -484
- package/dist/raster-pipeline.d.ts +10 -0
- package/dist/raster.d.ts +5 -0
- package/dist/runtime-core.d.ts +39 -1
- package/dist/terrain-heightfield.d.ts +0 -16
- package/dist/terrain-sample.d.ts +0 -13
- package/dist/version.d.ts +1 -1
- package/dist/volumetrics.d.ts +7 -0
- package/dist/{zarr-Dan2ab-l.js → zarr-BGDoEtFb.js} +2 -2
- package/docs/cartograph.md +2 -2
- package/docs/design/hillshade.md +290 -0
- package/docs/effects.md +208 -0
- package/docs/hillshade.md +203 -0
- package/llms.txt +3 -1
- package/onlymapjs.attributes.json +27 -2
- package/onlymapjs.html-data.json +207 -6
- package/package.json +13 -9
- package/skills/onlymapjs/SKILL.md +4 -2
- package/skills/onlymapjs/references/syntax.md +17 -2
- package/dist/lerc-TxsFLMlC.js +0 -30
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import type { Device, Texture } from "@luma.gl/core";
|
|
23
23
|
import { type RasterModule } from "@developmentseed/deck.gl-raster/gpu-modules";
|
|
24
|
+
import type { TileShading } from "./raster-hillshade";
|
|
24
25
|
/**
|
|
25
26
|
* The decoded source a tile retains — structural subset of
|
|
26
27
|
* `@developmentseed/geotiff`'s RasterArray (band-separate carries `bands`,
|
|
@@ -49,6 +50,8 @@ export interface OmTileData {
|
|
|
49
50
|
colormapTexture: Texture;
|
|
50
51
|
bandCount: number;
|
|
51
52
|
nodata: number | null;
|
|
53
|
+
/** shading="hillshade": the padded heightfield + its ground scale. Built in raster.ts's getTileData, freed with the band textures. */
|
|
54
|
+
shading?: TileShading | null;
|
|
52
55
|
}
|
|
53
56
|
/** The styling scalars every raster source (COG, Zarr) exposes. */
|
|
54
57
|
export interface RasterStyle {
|
|
@@ -67,6 +70,13 @@ export interface RasterStyle {
|
|
|
67
70
|
stretch?: string | null;
|
|
68
71
|
/** Power-law exponent > 0 (display gamma); 1 = identity. */
|
|
69
72
|
gamma?: number | null;
|
|
73
|
+
/** "hillshade" shades the source as relief. Single-band only — it reads ONE band as height. */
|
|
74
|
+
shading?: string | null;
|
|
75
|
+
/** One to four azimuths, ° clockwise from north. A list, never a boolean (see hillshade-shader.ts). */
|
|
76
|
+
sunAzimuth?: string | number | null;
|
|
77
|
+
sunWeight?: string | number | null;
|
|
78
|
+
sunElevation?: number | null;
|
|
79
|
+
zFactor?: number | null;
|
|
70
80
|
}
|
|
71
81
|
export declare function getColormapTexture(device: Device): Promise<Texture>;
|
|
72
82
|
export declare function resolveColormapIndex(name: string): number;
|
package/dist/raster.d.ts
CHANGED
|
@@ -92,6 +92,11 @@ export declare class OmCOGLayer extends OmCOGLayer_base {
|
|
|
92
92
|
stretch: null;
|
|
93
93
|
gamma: null;
|
|
94
94
|
reverse: null;
|
|
95
|
+
shading: null;
|
|
96
|
+
sunAzimuth: null;
|
|
97
|
+
sunWeight: null;
|
|
98
|
+
sunElevation: null;
|
|
99
|
+
zFactor: null;
|
|
95
100
|
};
|
|
96
101
|
constructor(props: AnyProps);
|
|
97
102
|
/**
|
package/dist/runtime-core.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type HoverPickMode } from "./hover-pick";
|
|
2
|
-
import type { PickingInfo } from "@deck.gl/core";
|
|
2
|
+
import type { Effect, PickingInfo } from "@deck.gl/core";
|
|
3
3
|
import { type LightingIR } from "./scene-lighting";
|
|
4
|
+
import type { EffectsIR } from "./post-process";
|
|
4
5
|
import { type TerrainIR } from "./terrain";
|
|
5
6
|
import { type ClipBoxIR } from "./clip-box";
|
|
6
7
|
import { type SnapAgent, type SnapConfig } from "./snapping";
|
|
@@ -286,6 +287,13 @@ export declare class RuntimeCore {
|
|
|
286
287
|
/** setMaxPitch's last value — the controller's tilt ceiling, or null for the default. */
|
|
287
288
|
private maxPitch;
|
|
288
289
|
private minZoom;
|
|
290
|
+
/** The authored `<om-effect>` chain, and the deck effects compiled from it. */
|
|
291
|
+
private effectsIR;
|
|
292
|
+
private postProcess;
|
|
293
|
+
/** Set by the programmatic lane; outranks the document's own chain. */
|
|
294
|
+
private rawEffects;
|
|
295
|
+
/** The capture override in force, or null at display resolution. */
|
|
296
|
+
private capturePixelRatio;
|
|
289
297
|
/** Retained descriptors — what the per-frame channel re-applies against. */
|
|
290
298
|
private lastIRs;
|
|
291
299
|
/** layerId → effect-driven plain-prop patches (the per-frame channel). */
|
|
@@ -471,6 +479,36 @@ export declare class RuntimeCore {
|
|
|
471
479
|
private pickCallbacks;
|
|
472
480
|
/** The current lighting as a deck `effects` array — [] restores deck's default lights. */
|
|
473
481
|
private buildEffects;
|
|
482
|
+
/** Push the current effect list at whichever renderer is live. */
|
|
483
|
+
private applyEffects;
|
|
484
|
+
/**
|
|
485
|
+
* Device pixels per millimetre right now — CSS's 96 dpi, times whatever
|
|
486
|
+
* rasterisation scale is in force. A capture at 300 dpi makes this ~3x the
|
|
487
|
+
* display value, which is exactly how a millimetre-valued knob keeps its
|
|
488
|
+
* physical size in print.
|
|
489
|
+
*/
|
|
490
|
+
private pixelsPerMm;
|
|
491
|
+
/**
|
|
492
|
+
* Replace the post-process chain.
|
|
493
|
+
*
|
|
494
|
+
* The op catalogue and its GLSL are a LAZY chunk — a map with no
|
|
495
|
+
* `<om-effect>` never loads a line of it, which is the same bundle
|
|
496
|
+
* discipline the basemap adapter and the cartograph entry follow. The
|
|
497
|
+
* identity guard on `this.effectsIR` is what keeps a late-arriving chunk
|
|
498
|
+
* from applying a chain the document has already moved past.
|
|
499
|
+
*/
|
|
500
|
+
setEffects(ir: EffectsIR): void;
|
|
501
|
+
/** The authored chain, for tests and the headless lane. */
|
|
502
|
+
getEffectsInternal(): EffectsIR;
|
|
503
|
+
/**
|
|
504
|
+
* Deck effects supplied directly — the programmatic lane's 1:1 surface.
|
|
505
|
+
*
|
|
506
|
+
* Takes precedence over the authored `<om-effect>` chain while set, because
|
|
507
|
+
* an app that reaches for this is driving the renderer itself. `null` hands
|
|
508
|
+
* the document its chain back; `[]` is the different request "render no
|
|
509
|
+
* effects at all", and keeps the document's chain suppressed.
|
|
510
|
+
*/
|
|
511
|
+
setRawEffects(effects: Effect[] | null): void;
|
|
474
512
|
/**
|
|
475
513
|
* Scene lighting (spec: "Scene Lighting") — swap the LightingEffect on
|
|
476
514
|
* the live renderer. null restores deck's default lights. Headless stores
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bulk terrain heightfield (spec item C2 / "Elevation profile" — the shared
|
|
3
|
-
* infrastructure both reference, "sampling shares C2's bulk heightfield, not
|
|
4
|
-
* per-point elevationAt()"). `terrain-sample.ts`'s `sampleTerrainElevation`
|
|
5
|
-
* is one fetch per point — fine for volume mode's handful of footprint
|
|
6
|
-
* vertices, but the wrong shape for a profile's tens-to-hundreds of samples
|
|
7
|
-
* along a line or the volumetrics grid's 10⁵–10⁶ cells: nearby points share
|
|
8
|
-
* DEM tiles, so fetching (and decoding) each tile once and reading every
|
|
9
|
-
* point out of it in memory is both fewer round-trips and what the per-cell
|
|
10
|
-
* volume integrator (volumetrics.ts) builds on.
|
|
11
|
-
*
|
|
12
|
-
* This module is the DOM-TOUCHING half (fetch + canvas decode); the pixel
|
|
13
|
-
* math — bilinear sampling with tile-seam handling — lives in
|
|
14
|
-
* volumetrics.ts's `sampleBilinear`, which is pure and shared with the
|
|
15
|
-
* volumetrics worker (decoded tiles postMessage across; canvases don't).
|
|
16
|
-
*/
|
|
17
1
|
import type { LngLat } from "./geodesy";
|
|
18
2
|
import type { TerrainIR } from "./terrain";
|
|
19
3
|
import { type HeightfieldTiles } from "./volumetrics";
|
package/dist/terrain-sample.d.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One-shot terrain elevation sampling (spec: "Cut/fill volume measurement").
|
|
3
|
-
* Kept separate from terrain.ts, whose header documents it as PURE and
|
|
4
|
-
* unit-testable without a GPU — this module is deliberately the DOM-touching
|
|
5
|
-
* half (fetch + canvas), for the one thing nothing else in this codebase
|
|
6
|
-
* needed before: "what is the real ground height at this lng/lat".
|
|
7
|
-
*
|
|
8
|
-
* Fetches the DEM tile as a blob (never an `<img src>`) so the canvas read
|
|
9
|
-
* below is never tainted regardless of the provider's CORS posture — and
|
|
10
|
-
* since deck.gl's own TerrainLayer already fetches this exact URL template
|
|
11
|
-
* cross-origin to RENDER the surface, a caller only ever reaches this with a
|
|
12
|
-
* URL that's already proven fetchable.
|
|
13
|
-
*/
|
|
14
1
|
import type { LngLat } from "./geodesy";
|
|
15
2
|
import type { TerrainIR } from "./terrain";
|
|
16
3
|
/** Slippy-map tile + fractional pixel covering `lngLat` at `zoom` (256px tiles). Exported for `terrain-heightfield.ts`'s bulk loader — same tile math, no reason to duplicate it. */
|
package/dist/version.d.ts
CHANGED
package/dist/volumetrics.d.ts
CHANGED
|
@@ -52,6 +52,13 @@ export interface HeightfieldTiles {
|
|
|
52
52
|
tiles: HeightfieldTile[];
|
|
53
53
|
decoder: ElevationDecoderSpec;
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Height in metres from one RGB triple. The whole of "what a DEM tile means"
|
|
57
|
+
* — kept in one exported function so the bulk path here, the one-shot query
|
|
58
|
+
* in terrain-sample.ts, and any future GPU port all agree on the arithmetic
|
|
59
|
+
* rather than each writing it out.
|
|
60
|
+
*/
|
|
61
|
+
export declare function decodeElevationRgb(d: ElevationDecoderSpec, r: number, g: number, b: number): number;
|
|
55
62
|
/**
|
|
56
63
|
* Bilinear heightfield sample at `lngLat`, correct across TILE SEAMS.
|
|
57
64
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ur, d as lr, R as zt, e as fr, m as dr, p as St, f as hr,
|
|
2
|
-
import {
|
|
1
|
+
import { A as ur, d as lr, R as zt, e as fr, m as dr, p as St, f as hr, k as pr, l as mr } from "./raster-pipeline-BlOnMPJe.js";
|
|
2
|
+
import { C as gr } from "./index-oY3XHIux.js";
|
|
3
3
|
import $t from "./index-CW1n5LdO.js";
|
|
4
4
|
var Et;
|
|
5
5
|
function h(e, t, n) {
|
package/docs/cartograph.md
CHANGED
|
@@ -22,8 +22,8 @@ to PDF at true page size via CSS `@page` and exports PNG/JPEG at print DPI throu
|
|
|
22
22
|
<html>
|
|
23
23
|
<head>
|
|
24
24
|
<meta charset="utf-8">
|
|
25
|
-
<script type="module" src="https://unpkg.com/@nika-js/onlymap@0.
|
|
26
|
-
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.
|
|
25
|
+
<script type="module" src="https://unpkg.com/@nika-js/onlymap@0.9.1/dist/cartograph.standalone.js"></script>
|
|
26
|
+
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.9.1/dist/cartograph.css">
|
|
27
27
|
</head>
|
|
28
28
|
<body>
|
|
29
29
|
<om-cartograph cartograph-id="cg-lot-12" format="cartograph/2" size="A4" theme="minimal"
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# Hillshade / shaded relief — design (shipped in 0.9.1)
|
|
2
|
+
|
|
3
|
+
## The tracker situation
|
|
4
|
+
|
|
5
|
+
There is **no open hillshade issue**. All 45 issues on the public mirror were read
|
|
6
|
+
(title, body and comments); the only place hillshade appears anywhere in the tracker
|
|
7
|
+
is issue **#13 — COGLayer v2**, which is `CLOSED / COMPLETED`, and which names it in
|
|
8
|
+
the *Non-goals* line:
|
|
9
|
+
|
|
10
|
+
> Raster analysis (hillshade/slope — app territory).
|
|
11
|
+
|
|
12
|
+
The nearest **open** issue is **#23 — Terrain GPU viewshed + point-to-point
|
|
13
|
+
line-of-sight**, which shares this feature's DEM machinery without sharing its
|
|
14
|
+
purpose. So the reconciliation below is against those two: a closed decision that
|
|
15
|
+
currently says *no*, and an open ticket that owns the same substrate.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Reconciling #13's "no" with the cartographic "yes"
|
|
20
|
+
|
|
21
|
+
#13 was written from a **raster-analysis** framing: a user brings a DEM COG, and the
|
|
22
|
+
library derives a queryable product from it — slope in degrees, aspect classes,
|
|
23
|
+
numbers you identify and legend. That is app territory, and it still is.
|
|
24
|
+
|
|
25
|
+
Cartography wants a different thing that happens to use the same arithmetic:
|
|
26
|
+
**shaded relief as rendered texture**. Nothing is queried, nothing is classified,
|
|
27
|
+
nothing is reported. It is styling output, in exactly the sense that `classify` and
|
|
28
|
+
the raster colormap are styling output while statistics are not. The library already
|
|
29
|
+
draws its line there.
|
|
30
|
+
|
|
31
|
+
| | #13's hillshade (out) | Cartographic hillshade (in) |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| Output | numbers per cell (slope°, aspect) | pixels |
|
|
34
|
+
| Queried by `identify` | yes | no |
|
|
35
|
+
| Needs the user's own DEM | yes | no — a named keyless global source |
|
|
36
|
+
| Lives in | an analysis toolbox | the render pipeline |
|
|
37
|
+
|
|
38
|
+
**Resolution:** the non-goal in #13 stands as written. This feature does not
|
|
39
|
+
contradict it, because it ships no analytic product. If slope/aspect *values* are
|
|
40
|
+
ever wanted, that is still a separate ticket and still probably app territory.
|
|
41
|
+
|
|
42
|
+
The one line worth adding to #13's record, if it is ever reopened: the boundary is
|
|
43
|
+
**queryability**, not the arithmetic.
|
|
44
|
+
|
|
45
|
+
## Reconciling with #23 (viewshed / LOS)
|
|
46
|
+
|
|
47
|
+
#23's implementation plan item 2 is "DEM read-back". That work is **already done** —
|
|
48
|
+
it landed for cut/fill volumetrics:
|
|
49
|
+
|
|
50
|
+
- `src/terrain-sample.ts` — `tilePixel()` slippy-tile math, one-shot elevation query.
|
|
51
|
+
- `src/terrain-heightfield.ts` — bulk tile loader with a per-tile timeout, `elevationAt()`.
|
|
52
|
+
- `src/volumetrics.ts` — `sampleBilinear()`, seam-correct, pure, worker-shareable.
|
|
53
|
+
- `src/terrain.ts` — `DECODERS` (`terrarium`, `mapbox-rgb`), `registerTerrain`, three presets
|
|
54
|
+
including the keyless AWS terrarium default.
|
|
55
|
+
|
|
56
|
+
Hillshade and #23 therefore **share a substrate and diverge above it**:
|
|
57
|
+
|
|
58
|
+
| | Hillshade | #23 viewshed |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| Sampling | GPU, in the fragment shader, per tile texture | CPU (`terrain-heightfield`) for LOS; depth pass for viewshed |
|
|
61
|
+
| Needs `terrain=` active | **no** — works at pitch 0 on a flat sheet | yes, hard requirement |
|
|
62
|
+
| deck seam | a layer + a raster module | a `LayersPass` fork in `buildEffects()` |
|
|
63
|
+
| Coverage honesty | tile pyramid, same as any raster | must clamp to loaded-tile coverage |
|
|
64
|
+
|
|
65
|
+
Shared, and worth doing once: **decode correctness** (below), the unexaggerated-height
|
|
66
|
+
rule (`terrain-exaggeration` is a display transform; neither feature may read through
|
|
67
|
+
it), and the lazy-chunk discipline.
|
|
68
|
+
|
|
69
|
+
**Nothing here blocks or is blocked by #23.** The only thing hillshade takes off
|
|
70
|
+
#23's plate is half of its item 2, and it hardens it.
|
|
71
|
+
|
|
72
|
+
## Not a mode of `terrain=`
|
|
73
|
+
|
|
74
|
+
`terrain="…"` means a 3D surface: it replaces the active basemap, changes what the
|
|
75
|
+
camera means, and is meaningless at pitch 0. A print sheet wants a flat shaded raster
|
|
76
|
+
that composes *underneath the data layers like any other layer*. Same decoders,
|
|
77
|
+
different rendering contract — folding them together would make both harder to
|
|
78
|
+
explain. Hillshade is a **layer**.
|
|
79
|
+
|
|
80
|
+
That also buys the cartographic property that matters most: a layer draws inside
|
|
81
|
+
deck's own framebuffer, so it lands in `snapshot()` and **under `<om-effect>`** — where
|
|
82
|
+
a MapLibre basemap composites beneath the effect pass and stays untreated (the exact
|
|
83
|
+
case `validateEffectEl` already warns about). Shaded relief that the print finish
|
|
84
|
+
cannot reach would be worth very little.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Two entry points, one shader
|
|
89
|
+
|
|
90
|
+
1. **`<om-layer type="HillshadeLayer">`** over `{z}/{x}/{y}` RGB-encoded DEM tiles —
|
|
91
|
+
the cartographic path. Keyless and global — no key, no account, no data of the
|
|
92
|
+
author's own — reusing `DECODERS` and the `registerTerrain` presets as sources,
|
|
93
|
+
named through `src` (open question 2).
|
|
94
|
+
2. **`shading="hillshade"` on `COGLayer` / `ZarrLayer`** — the author's own DEM, in
|
|
95
|
+
float, composing with the existing `stretch` / `gamma` / `colormap` chain so a
|
|
96
|
+
hypsometric tint under relief is one layer, not two.
|
|
97
|
+
|
|
98
|
+
> **Corrected after phase 2.** This section originally said both entry points would
|
|
99
|
+
> compile to one module inside `src/raster-pipeline.ts`. They do not, and the reason
|
|
100
|
+
> is worth recording. That pipeline's modules inject at `DECKGL_FILTER_COLOR`, which
|
|
101
|
+
> is **pointwise** — a module there receives `color`, not the means to sample its
|
|
102
|
+
> neighbours. Hillshade is the first *neighbourhood* module anyone has wanted in it,
|
|
103
|
+
> and a neighbourhood module must own a sampler and a texel size. So the shipped
|
|
104
|
+
> module lives in `src/hillshade.ts`, declares its own sampler through `fs:#decl` and
|
|
105
|
+
> binds it through `getUniforms` — exactly how upstream's own `CompositeBands` binds
|
|
106
|
+
> `band0`–`band3`, and what frees it from any host layer's declaration order.
|
|
107
|
+
>
|
|
108
|
+
> The GLSL is therefore already host-agnostic, which is what phase 4 needs: the COG
|
|
109
|
+
> path supplies a different texture and a different texel-to-metres factor, not
|
|
110
|
+
> different arithmetic. What phase 4 still has to solve is **ground scale**, which
|
|
111
|
+
> the tile path gets free from Web Mercator and a COG does not.
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<!-- cartographic: keyless relief under everything else -->
|
|
115
|
+
<om-map center="[7.65, 45.98]" zoom="9" basemap="none" validate>
|
|
116
|
+
<om-layer type="HillshadeLayer" src="terrarium"
|
|
117
|
+
sun-azimuth="315 45 135" sun-elevation="45" z-factor="1.4"
|
|
118
|
+
opacity="0.55"></om-layer>
|
|
119
|
+
<om-layer id="trails" type="GeoJsonLayer" data="./trails.geojson"></om-layer>
|
|
120
|
+
<om-effect preset="vintage"></om-effect>
|
|
121
|
+
</om-map>
|
|
122
|
+
|
|
123
|
+
<!-- the author's own DEM, relief over a hypsometric tint, one layer -->
|
|
124
|
+
<om-layer type="COGLayer" src="./dem.tif" colormap="terrain" shading="hillshade"></om-layer>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Illumination reuses `scene-lighting.ts`'s convention exactly — **azimuth ° clockwise
|
|
128
|
+
from north, elevation ° above the horizon** — so `sun-azimuth` on a hillshade and
|
|
129
|
+
`lighting-sun-azimuth` on the map mean the same number. It does **not** auto-inherit
|
|
130
|
+
the map's lighting (silent coupling between a 3D scene light and a 2D raster is the
|
|
131
|
+
kind of thing that is impossible to debug from markup); see open question 1.
|
|
132
|
+
|
|
133
|
+
## Multi-directional is a list, not a boolean
|
|
134
|
+
|
|
135
|
+
`sun-azimuth` takes **one to four azimuths**, and `sun-weight` optionally takes the
|
|
136
|
+
matching blend weights (defaulting to equal). One value is a single light; three is
|
|
137
|
+
Swiss-style relief. There is no `multi-directional` boolean, and this is a tiering
|
|
138
|
+
rule rather than a style preference:
|
|
139
|
+
|
|
140
|
+
> a preset must be expressible in the tier below it … If a preset ever needed
|
|
141
|
+
> something the op tier could not express, the op tier would be the thing to fix.
|
|
142
|
+
> — `src/post-process/presets.ts`
|
|
143
|
+
|
|
144
|
+
A boolean that blends azimuths the author cannot otherwise name would be exactly
|
|
145
|
+
the violation that comment exists to prevent: capability reachable only from the
|
|
146
|
+
shorthand. The list is the Tier 1 surface; `multi-directional` may return later as
|
|
147
|
+
a *named seeding* of it — `sun-azimuth="315 15 75 135"` under a word — the way
|
|
148
|
+
`lighting="daylight"` only seeds `lighting-ambient` / `lighting-sun`, and
|
|
149
|
+
`preset="vintage"` only seeds an op list that `expandPreset` will hand back. If it
|
|
150
|
+
does, it ejects the same way.
|
|
151
|
+
|
|
152
|
+
For cartography this is also the better surface on its own terms: the whole point
|
|
153
|
+
of multi-directional relief is that the azimuths are *chosen* for the terrain —
|
|
154
|
+
which is a tuning job, not a toggle.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## The five things that will actually bite
|
|
159
|
+
|
|
160
|
+
1. **Decode precision.** Neither `terrain-sample.ts:45` nor `terrain-heightfield.ts:62`
|
|
161
|
+
passes `{ premultiplyAlpha: "none", colorSpaceConversion: "none" }` to
|
|
162
|
+
`createImageBitmap`, and both then read through a canvas 2D context. For a point
|
|
163
|
+
elevation query a ±1 LSB error is sub-metre noise nobody sees. Hillshade
|
|
164
|
+
**differentiates neighbouring samples**, so the same error becomes visible banding
|
|
165
|
+
across a whole slope. Fix at every site; #23's LOS half inherits the fix. Lossy-
|
|
166
|
+
recompressed DEM tiles are unusable for the same reason and warrant a dev notice.
|
|
167
|
+
2. **Tile-edge seams.** A derivative needs a one-pixel halo from the neighbouring
|
|
168
|
+
tile. Without it, every tile boundary draws a dark grid line — the single most
|
|
169
|
+
recognisable way a hand-rolled hillshade looks broken. Either sample a 1px overlap
|
|
170
|
+
or bind neighbour textures; decide in phase 2, test for it explicitly.
|
|
171
|
+
3. **Resolution.** The DEM tile zoom must follow the **capture** pixel ratio, or a
|
|
172
|
+
300 dpi plate renders mushy relief at screen resolution. This is the same class of
|
|
173
|
+
bug as the pixel-keyed grain that `<om-effect>` solved with millimetres; bind to
|
|
174
|
+
the existing `withCapturePixelRatio` seam in `runtime-core.ts`.
|
|
175
|
+
4. **Latitude.** Web Mercator ground metres per pixel scale with cos(latitude). A
|
|
176
|
+
fixed z-factor makes relief flatten toward the equator and exaggerate toward the
|
|
177
|
+
poles. Scale the horizontal step per tile by cos φ.
|
|
178
|
+
5. **One light looks like a web map.** Swiss-style relief blends two to four azimuths.
|
|
179
|
+
Single-light shading is what every slippy map already ships and is precisely the
|
|
180
|
+
look we are trying to get away from. Blended azimuths are a quality feature, not a
|
|
181
|
+
nicety — which is why they are an authorable list and not a boolean (above).
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Phases
|
|
186
|
+
|
|
187
|
+
Each phase is independently green and independently shippable, with its own doc-sync
|
|
188
|
+
per the repo checklist.
|
|
189
|
+
|
|
190
|
+
**Phase 1 — decode correctness (shared with #23). — IMPLEMENTED 2026-09-21.**
|
|
191
|
+
`src/dem-decode.ts` is now the single decode path: exact-byte `createImageBitmap`
|
|
192
|
+
options into an opaque, fixed-colour-space canvas, with `fetchDemTile` used by both
|
|
193
|
+
`terrain-sample.ts` and `terrain-heightfield.ts`, and the RGB→metres arithmetic
|
|
194
|
+
shared as `volumetrics.ts`'s `decodeElevationRgb`. A lossy DEM source warns once per
|
|
195
|
+
host. Pinned by `src/dem-decode.test.ts`, which asserts the decode OPTIONS rather
|
|
196
|
+
than a picture — a unit test cannot prove a browser skipped colour management, only
|
|
197
|
+
that every site asked it to.
|
|
198
|
+
|
|
199
|
+
**Phase 2 — the module and the layer. — IMPLEMENTED 2026-09-21.** The hillshade GPU module in
|
|
200
|
+
`raster-pipeline.ts`; `HillshadeLayer` over `{z}/{x}/{y}` RGB DEM tiles resolving
|
|
201
|
+
`src` through `getTerrain()` presets (`src="terrarium"`) or a raw URL + `decoder`,
|
|
202
|
+
exactly as `parseTerrainAttrs` already does. `src` is **required** — see open
|
|
203
|
+
question 2. Single light, greyscale. Registered through `layer-registry`'s `loadClass` seam so the shader chunk is lazy and
|
|
204
|
+
core pages are unaffected (CI size check). e2e: renders non-blank, differs from a flat
|
|
205
|
+
raster, **no tile-boundary seam**, and a map without a hillshade never fetches the chunk.
|
|
206
|
+
|
|
207
|
+
**Phase 3 — cartographic quality. — IMPLEMENTED 2026-09-21.** Multi-azimuth `sun-azimuth` / `sun-weight` (2–4
|
|
208
|
+
lights blended), `z-factor`, the cos φ correction, and capture-ratio-aware tile zoom.
|
|
209
|
+
Verify at capture scale against a 300 dpi plate, and under each `<om-effect>` preset.
|
|
210
|
+
|
|
211
|
+
**Phase 3b — composition. — IMPLEMENTED 2026-09-21 as `blend="normal|multiply"`.** Multiply alone FAILED acceptance criterion 1 (a multiply layer over an empty sheet multiplies against nothing and draws nothing), so it is a two-valued attribute local to this layer rather than a baked constant. No general `blend=` surface was opened.
|
|
212
|
+
|
|
213
|
+
**Original note.** Opacity alone greys the fills
|
|
214
|
+
above the relief; the cartographic answer is a multiply blend. But **there is no
|
|
215
|
+
blend-mode surface in this library today** — nothing in `attribute-resolution.ts` or
|
|
216
|
+
`layer-registry.ts` exposes deck's layer `parameters`, so this is not a knob on a new
|
|
217
|
+
layer, it is a new authoring concept with no precedent to follow. Two honest options:
|
|
218
|
+
bake the multiply into the hillshade module itself (narrow, ships with phase 3, no
|
|
219
|
+
general surface promised), or open a real `blend=` attribute for layers in general
|
|
220
|
+
(wider, and a design of its own). **Proposed: bake it**, and let a general `blend=`
|
|
221
|
+
arrive when a second layer type asks for it. Do not let a general blend surface ride
|
|
222
|
+
in on this feature unannounced.
|
|
223
|
+
|
|
224
|
+
**Phase 4 — the author's own DEM. — IMPLEMENTED 2026-09-22.** `shading="hillshade"` on `COGLayer`/`ZarrLayer`, sharing the GPU module and the apron with the tiled path. Ground scale comes from the geotransform + CRS units and is ANISOTROPIC for a geographic source. Relief runs LAST (after the colormap, not before it: earlier would hand the ramp a shade value and paint the hillshade in viridis). `identify="off"` is overridden while shading is on, and the validator says so.
|
|
225
|
+
|
|
226
|
+
**Original note.** `shading="hillshade"` on `COGLayer` / `ZarrLayer`,
|
|
227
|
+
running the same module on the float band path, ordered after nodata filtering and
|
|
228
|
+
before the colormap so hypsometric tint and relief compose. Validation messages for
|
|
229
|
+
"shading on a multi-band source" and "shading without a single band selected".
|
|
230
|
+
|
|
231
|
+
**Phase 5 — surfaces and release. — IMPLEMENTED 2026-09-21** (example page, `docs/hillshade.md`, README section, skill + `llms.txt`, `html-data.ts` regeneration, `dev/build-public.ts` allowlist, architecture entry 148). Remaining: CHANGELOG at the version bump, and the downstream pins. Example page under
|
|
232
|
+
`dev/examples/features/styling/`, `docs/hillshade.md`, README feature row, skill +
|
|
233
|
+
`llms.txt`, `html-data.ts` regeneration, `dev/build-public.ts` allowlist +
|
|
234
|
+
`npm run test:public`, architecture traceability + dated entry, CHANGELOG, then the
|
|
235
|
+
downstream pins.
|
|
236
|
+
|
|
237
|
+
## Acceptance criteria
|
|
238
|
+
|
|
239
|
+
- [ ] Relief renders from `src="terrarium"` with **zero author-supplied DEM data** and
|
|
240
|
+
no API key, at pitch 0, on a `basemap="none"` sheet.
|
|
241
|
+
- [ ] No tile-boundary seam at any zoom, pinned by a browser test that samples across
|
|
242
|
+
a known boundary.
|
|
243
|
+
- [ ] A 300 dpi `snapshot({scale})` shows relief detail proportional to the scale, not
|
|
244
|
+
an upscaled screen-resolution image.
|
|
245
|
+
- [ ] Shading is visibly affected by `<om-effect>` passes — it is inside deck's frame,
|
|
246
|
+
not beneath it.
|
|
247
|
+
- [ ] Three-azimuth shading is distinguishable from single-light in a pixel test, and
|
|
248
|
+
reordering the azimuth list changes the result.
|
|
249
|
+
- [ ] **One shader, not one image.** Both entry points run the same GPU module with the
|
|
250
|
+
same uniforms — pinned by a unit test on the module, not a pixel diff between the
|
|
251
|
+
two paths. They will *not* match pixel-for-pixel on the same area and should not
|
|
252
|
+
be asked to: the tile path is integer-encoded height in Web Mercator at a tile
|
|
253
|
+
zoom, the COG path is float bands in the source CRS at the source resolution, so
|
|
254
|
+
pixel ground size, reprojection and nodata all differ before the shader runs.
|
|
255
|
+
- [ ] Hillshade chunk is lazy; core/2D pages unaffected (CI size check).
|
|
256
|
+
- [ ] No analytic product is exposed — no slope/aspect values, no identify integration.
|
|
257
|
+
|
|
258
|
+
## Non-goals
|
|
259
|
+
|
|
260
|
+
- **Slope / aspect as queryable values** — #13's non-goal, unchanged.
|
|
261
|
+
- **Viewshed / line-of-sight** — #23, which this neither implements nor blocks.
|
|
262
|
+
- **Replacing `terrain=`** — the 3D surface is a different contract and stays as is.
|
|
263
|
+
- **Sky-view factor / ambient occlusion relief** — a heavier multi-sample technique;
|
|
264
|
+
revisit only if multi-azimuth shading proves insufficient.
|
|
265
|
+
- **A general `blend=` attribute for layers** — phase 3b bakes multiply into this one
|
|
266
|
+
module rather than opening a blend surface the whole layer registry would then owe.
|
|
267
|
+
- **Server-side relief tiles** — client-side is the differentiator, as with COG.
|
|
268
|
+
|
|
269
|
+
## Status
|
|
270
|
+
|
|
271
|
+
**All six phases implemented; staged for 0.9.1.** What remains is publishing
|
|
272
|
+
and the downstream pins (`onlymap-native`, `onlymap-remotion`), which per the
|
|
273
|
+
repo checklist must be proved against the candidate before their pins move.
|
|
274
|
+
|
|
275
|
+
## Open questions (maintainer input)
|
|
276
|
+
|
|
277
|
+
1. **Does hillshade inherit the map's sun?** Proposed: no. Same vocabulary and
|
|
278
|
+
convention as `lighting-sun-*`, but an independent value, with an explicit opt-in
|
|
279
|
+
(`sun="lighting"`) deferred until someone asks.
|
|
280
|
+
2. **Is the keyless terrarium source the default for a bare `<om-layer type="HillshadeLayer">`?**
|
|
281
|
+
Proposed: **no — require `src`**, with `src="terrarium"` as the keyless one-word
|
|
282
|
+
answer. The precedent cuts this way: every keyless default in this library is still
|
|
283
|
+
*named* by the author (`basemap="positron"`, `terrain="terrarium"`). Keyless-first
|
|
284
|
+
means "no key and no account", not "no attribute" — and an element that reaches AWS
|
|
285
|
+
with nothing written on it is a network call the markup does not show. The cost of
|
|
286
|
+
the rule is one word; the benefit is that `src` always says where the heights came
|
|
287
|
+
from, which is also what the legend needs to credit.
|
|
288
|
+
3. **Stacking.** Auto-place relief beneath all data layers, or strictly honour
|
|
289
|
+
document order as every other layer does? Proposed: document order — the rule is
|
|
290
|
+
already universal here, and an exception costs more than it saves.
|