@nika-js/onlymap 0.9.0 → 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 +20 -0
- package/README.md +25 -2
- package/dist/{LercDecode.es-BMcxSLhD.js → LercDecode.es-IEPCRZOv.js} +1 -1
- package/dist/{basemap-m98j2wxG.js → basemap-DL0mk9Bf.js} +1 -1
- package/dist/dem-decode.d.ts +58 -0
- package/dist/elements/om-map.d.ts +2 -0
- package/dist/{geoparquet-XOwOmChh.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 +1 -1
- package/dist/{index-HZWdgtm4.js → index-BjcPjICh.js} +59 -59
- package/dist/{index-DzOvV-O7.js → index-CvuDsvnk.js} +22 -22
- package/dist/{index-CfPbQUqO.js → index-DO_w0tqR.js} +86 -83
- package/dist/{index-DDNElBTs.js → index-DdTZSuAb.js} +106 -106
- package/dist/{index-BSAY6CWm.js → index-oY3XHIux.js} +9843 -9623
- package/dist/{index-BMbpftvm.js → index-vLXZuog4.js} +1 -1
- package/dist/lerc-Bph62dCb.js +22 -0
- package/dist/onlymap.standalone.js +21279 -20558
- package/dist/onlymapjs.js +37 -37
- package/dist/{raster-Dg5p_99H.js → raster-D-eTzCE3.js} +609 -499
- package/dist/raster-hillshade.d.ts +119 -0
- package/dist/{raster-pipeline-DhjkqDYd.js → raster-pipeline-BlOnMPJe.js} +510 -484
- package/dist/raster-pipeline.d.ts +10 -0
- package/dist/raster.d.ts +5 -0
- 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-D3CzK1Zm.js → zarr-BGDoEtFb.js} +2 -2
- package/docs/cartograph.md +2 -2
- package/docs/design/hillshade.md +290 -0
- package/docs/effects.md +11 -0
- package/docs/hillshade.md +203 -0
- package/llms.txt +2 -1
- package/onlymapjs.attributes.json +27 -2
- package/onlymapjs.html-data.json +44 -6
- package/package.json +13 -9
- package/skills/onlymapjs/SKILL.md +3 -2
- package/skills/onlymapjs/references/syntax.md +11 -3
- package/dist/lerc-qK-nhCaB.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
|
/**
|
|
@@ -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.9.
|
|
26
|
-
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.9.
|
|
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.
|
package/docs/effects.md
CHANGED
|
@@ -158,6 +158,17 @@ mutation, so **undo/redo** see it like any other edit. Knob overrides ride as
|
|
|
158
158
|
`<op>-<param>` keys: `{ preset: "vintage", "grain-amount": 0.02 }`.
|
|
159
159
|
`{ preset: "none" }` removes it. A hand-composed op chain is left alone.
|
|
160
160
|
|
|
161
|
+
For a switcher your users can see, `<om-widget type="effects">` renders one radio
|
|
162
|
+
per preset plus **Off**, and emits exactly that action:
|
|
163
|
+
|
|
164
|
+
```html
|
|
165
|
+
<om-widget type="effects" position="top-right" title="Finish"></om-widget>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The widget holds no state. It writes the document and reads it back, so a hand
|
|
169
|
+
edit, an undo, or an agent changing the preset moves the radio too — the same
|
|
170
|
+
contract `<om-widget type="lighting">` follows.
|
|
171
|
+
|
|
161
172
|
> **Not story-rewindable yet.** A story step can apply a finish, but seeking back
|
|
162
173
|
> will not remove it: story rewind restores `<om-map>` attributes, and this action
|
|
163
174
|
> adds a child element. Element-level capture is a follow-up.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Shaded relief — `HillshadeLayer`
|
|
2
|
+
|
|
3
|
+
> **Available in 0.9.1.** `<om-layer type="HillshadeLayer">` shades a DEM on
|
|
4
|
+
> the GPU. It is a layer, so it obeys document order, lands in `snapshot()`,
|
|
5
|
+
> and sits under `<om-effect>`.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<om-map center="[7.65, 45.98]" zoom="9" basemap="none">
|
|
9
|
+
<om-layer id="relief" type="HillshadeLayer" src="terrarium"
|
|
10
|
+
sun-azimuth="315" sun-elevation="45"></om-layer>
|
|
11
|
+
</om-map>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
That is the whole minimum: keyless global tiles, no data of your own, and it
|
|
15
|
+
works at pitch 0 on a flat sheet.
|
|
16
|
+
|
|
17
|
+
Runnable: [`dev/examples/features/styling/shade-the-terrain.html`](../dev/examples/features/styling/shade-the-terrain.html).
|
|
18
|
+
|
|
19
|
+
## Why this is a layer and not `terrain=`
|
|
20
|
+
|
|
21
|
+
`terrain="terrarium"` means a **3D surface**. It replaces the active basemap,
|
|
22
|
+
changes what the camera means, and is meaningless at pitch 0.
|
|
23
|
+
|
|
24
|
+
Shaded relief is the other thing: a **flat raster** that composes underneath
|
|
25
|
+
your data like any other layer. Same DEM decoders, different rendering
|
|
26
|
+
contract. Folding them together would make both harder to explain.
|
|
27
|
+
|
|
28
|
+
Being a layer also buys the property that matters most for print. A layer
|
|
29
|
+
draws inside deck's own framebuffer, so relief is captured by `snapshot()` and
|
|
30
|
+
**treated by `<om-effect>`**. A MapLibre basemap composites *beneath* deck and
|
|
31
|
+
stays untouched by a print finish — relief that behaved that way would be
|
|
32
|
+
worth very little on a sheet you intend to print.
|
|
33
|
+
|
|
34
|
+
## Sources
|
|
35
|
+
|
|
36
|
+
`src` takes a registered terrain preset or a raw tile template.
|
|
37
|
+
|
|
38
|
+
| `src` | |
|
|
39
|
+
|---|---|
|
|
40
|
+
| `terrarium` | AWS Open Data, keyless, global |
|
|
41
|
+
| `mapterhorn` | keyless, global |
|
|
42
|
+
| `https://…/{z}/{x}/{y}.png` | your own tiles — needs `decoder` |
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<om-layer id="relief" type="HillshadeLayer"
|
|
46
|
+
src="https://example.com/dem/{z}/{x}/{y}.png"
|
|
47
|
+
decoder="mapbox-rgb"></om-layer>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`decoder` is `terrarium`, `mapbox-rgb`, or `{rScaler, gScaler, bScaler, offset}`
|
|
51
|
+
JSON — the same vocabulary `terrain-decoder` uses. A raw template with no
|
|
52
|
+
decoder is a validation warning rather than a guess, because reading
|
|
53
|
+
Mapbox-encoded heights as terrarium produces smooth, plausible relief that is
|
|
54
|
+
wrong by a factor of about 25.
|
|
55
|
+
|
|
56
|
+
**`src` is required**, even though the default source needs no key. Every
|
|
57
|
+
keyless default in this library is still named by the author —
|
|
58
|
+
`basemap="positron"`, `terrain="terrarium"` — because keyless means *no key and
|
|
59
|
+
no account*, not *no attribute*. An element that reaches a public tile host
|
|
60
|
+
with nothing written on it is a network call the markup does not show.
|
|
61
|
+
|
|
62
|
+
> DEM tiles must be PNG or lossless WebP. Heights live in the RGB bytes, so a
|
|
63
|
+
> lossy codec invents terrain; a lossy source logs one warning per host.
|
|
64
|
+
|
|
65
|
+
## The sun is a list
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<om-layer id="relief" type="HillshadeLayer" src="terrarium"
|
|
69
|
+
sun-azimuth="315 45 135" sun-weight="3 1 1"></om-layer>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`sun-azimuth` takes **one to four** azimuths, ° clockwise from north. One is
|
|
73
|
+
the single light every slippy map already ships. Two to four blended is
|
|
74
|
+
Swiss-style relief, which fills the dead black a single light leaves on
|
|
75
|
+
away-facing slopes. `sun-weight` gives one weight per azimuth (equal if
|
|
76
|
+
omitted); the weights are normalized for you.
|
|
77
|
+
|
|
78
|
+
There is deliberately **no `multi-directional` boolean**. A shorthand must
|
|
79
|
+
never reach capability the tier below it cannot express — the same rule that
|
|
80
|
+
makes an `<om-effect>` preset nothing but a saved op list. Multi-directional
|
|
81
|
+
relief also wants its azimuths *chosen for the terrain*, which is a tuning
|
|
82
|
+
job rather than a toggle.
|
|
83
|
+
|
|
84
|
+
Azimuth and elevation use `scene-lighting`'s convention exactly, so
|
|
85
|
+
`sun-azimuth` here and `lighting-sun-azimuth` on the map mean the same number.
|
|
86
|
+
They are **not** coupled: a 3D scene light silently driving a 2D raster is the
|
|
87
|
+
kind of thing that is impossible to debug from markup.
|
|
88
|
+
|
|
89
|
+
## Knobs
|
|
90
|
+
|
|
91
|
+
| Attribute | Default | |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `src` | *(required)* | preset name or `{z}/{x}/{y}` template |
|
|
94
|
+
| `decoder` | `terrarium` | required with a raw template |
|
|
95
|
+
| `sun-azimuth` | `315` | 1–4 azimuths, ° clockwise from north |
|
|
96
|
+
| `sun-weight` | equal | one weight per azimuth |
|
|
97
|
+
| `sun-elevation` | `45` | ° above the horizon, exclusive of 0 and 90 |
|
|
98
|
+
| `z-factor` | `1` | vertical exaggeration |
|
|
99
|
+
| `blend` | `normal` | or `multiply` |
|
|
100
|
+
| `opacity` | `1` | |
|
|
101
|
+
| `max-zoom` | the preset's | the provider's real tileset cap |
|
|
102
|
+
| `zoom-offset` | `0` | sharper relief than the view asks for |
|
|
103
|
+
|
|
104
|
+
Every illumination knob is a **uniform**. Moving the sun, deepening the relief
|
|
105
|
+
or changing the blend rebuilds no tile and fetches nothing.
|
|
106
|
+
|
|
107
|
+
## Composing with your data
|
|
108
|
+
|
|
109
|
+
By default relief draws as its own greyscale image, so it works as the base of
|
|
110
|
+
a sheet. Put it first and it sits under everything:
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<om-layer id="relief" type="HillshadeLayer" src="terrarium"></om-layer>
|
|
114
|
+
<om-layer id="parks" type="GeoJsonLayer" data="./parks.geojson" color="#93c47d"></om-layer>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
With fills above it, `blend="multiply"` makes relief read **through** them
|
|
118
|
+
rather than greying them out — the terrain shows in the parks' own green
|
|
119
|
+
instead of flattening it:
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<om-layer id="parks" type="GeoJsonLayer" data="./parks.geojson" color="#93c47d"></om-layer>
|
|
123
|
+
<om-layer id="relief" type="HillshadeLayer" src="terrarium" blend="multiply" opacity="0.6"></om-layer>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`multiply` needs something beneath it: multiplying against an empty sheet
|
|
127
|
+
draws nothing, which is why `normal` is the default.
|
|
128
|
+
|
|
129
|
+
## What it gets right
|
|
130
|
+
|
|
131
|
+
**No tile seams.** A hillshade is a derivative, so a fragment at a tile edge
|
|
132
|
+
needs a neighbour that lives in a different tile. Clamping there instead
|
|
133
|
+
collapses the gradient and draws a pale grid over the whole world — the most
|
|
134
|
+
recognisable way a hand-rolled hillshade looks broken. Each tile is decoded
|
|
135
|
+
with a one-pixel apron taken from its eight neighbours, so there is no edge
|
|
136
|
+
case in the shader at all. The neighbours are nearly free, because a
|
|
137
|
+
neighbour is almost always a tile the map is drawing anyway.
|
|
138
|
+
|
|
139
|
+
**Latitude.** Web Mercator's ground metres per pixel fall off with cos φ, so a
|
|
140
|
+
fixed step flattens relief toward the equator and exaggerates it toward the
|
|
141
|
+
poles. The correction is applied per fragment, not per tile.
|
|
142
|
+
|
|
143
|
+
**Print resolution.** The DEM tile zoom follows the capture pixel ratio, so a
|
|
144
|
+
300 dpi plate renders relief at plate resolution instead of upscaling the
|
|
145
|
+
screen image. This is the same class of problem the millimetre knobs solve for
|
|
146
|
+
`<om-effect>`.
|
|
147
|
+
|
|
148
|
+
**Exaggeration is display-only.** `terrain-exaggeration` scales the *rendered*
|
|
149
|
+
3D surface; this layer never reads through it, so relief and a measured
|
|
150
|
+
elevation always agree about the ground.
|
|
151
|
+
|
|
152
|
+
## Relief from your own DEM
|
|
153
|
+
|
|
154
|
+
`shading="hillshade"` on a `COGLayer` or `ZarrLayer` shades the raster you
|
|
155
|
+
already have, using the same illumination attributes:
|
|
156
|
+
|
|
157
|
+
```html
|
|
158
|
+
<om-layer id="dem" type="COGLayer" src="./dem.tif"
|
|
159
|
+
shading="hillshade" sun-azimuth="315 45 135" z-factor="1.4"></om-layer>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Runnable: [`dev/examples/features/rasters/shade-your-own-dem.html`](../dev/examples/features/rasters/shade-your-own-dem.html).
|
|
163
|
+
|
|
164
|
+
Pair it with a colormap and you get the thing this entry point exists for — a
|
|
165
|
+
**hypsometric tint with relief through it, as one layer rather than two**:
|
|
166
|
+
|
|
167
|
+
```html
|
|
168
|
+
<om-layer id="dem" type="COGLayer" src="./dem.tif"
|
|
169
|
+
colormap="terrain" shading="hillshade"></om-layer>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Relief runs last in the styling chain, after the colormap, so it *multiplies*
|
|
173
|
+
onto the tint rather than replacing it. Without a colormap there is nothing to
|
|
174
|
+
tint, so relief is drawn on its own.
|
|
175
|
+
|
|
176
|
+
It reads **one band as elevation** — the first selected band. A `bands` triple
|
|
177
|
+
is a false-colour composite, where "the elevation band" is not a question with
|
|
178
|
+
an answer, and the validator says so.
|
|
179
|
+
|
|
180
|
+
Ground scale comes from the file's own geotransform and CRS, so it is right
|
|
181
|
+
whether your DEM is in UTM metres, state-plane feet or degrees. A geographic
|
|
182
|
+
(lng/lat) source is the interesting case: its pixel is **not square on the
|
|
183
|
+
ground**, because a degree of longitude shrinks with latitude while a degree of
|
|
184
|
+
latitude does not. That correction is applied for you.
|
|
185
|
+
|
|
186
|
+
> **`identify="off"` does not save memory here.** Relief reads neighbouring
|
|
187
|
+
> pixels on the CPU to keep tile edges seamless, so the decode is retained even
|
|
188
|
+
> with that flag set. The validator points it out rather than letting the flag
|
|
189
|
+
> look like it worked. Drop `shading` if you need the memory back.
|
|
190
|
+
|
|
191
|
+
## Bundle cost
|
|
192
|
+
|
|
193
|
+
None, unless you use it. The schema (for validation and IntelliSense) is in
|
|
194
|
+
the core bundle; the layer, the tile loader and the GLSL are a separate chunk
|
|
195
|
+
fetched only when a map actually has relief — pinned by a browser test.
|
|
196
|
+
|
|
197
|
+
## Not implemented yet
|
|
198
|
+
|
|
199
|
+
- **Slope and aspect as queryable values.** Deliberately out of scope: this
|
|
200
|
+
feature ships rendered texture, never an analytic product. The boundary is
|
|
201
|
+
queryability, not the arithmetic.
|
|
202
|
+
- **Sky-view factor / ambient occlusion relief**, a heavier multi-sample
|
|
203
|
+
technique worth revisiting only if blended azimuths prove insufficient.
|