@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.
- package/CHANGELOG.md +38 -0
- package/README.md +50 -3
- package/dist/{LercDecode.es-BMcxSLhD.js → LercDecode.es-IEPCRZOv.js} +1 -1
- package/dist/{basemap-m98j2wxG.js → basemap-9lXclX9H.js} +3882 -3980
- package/dist/cartograph/elements/om-frame.d.ts +67 -1
- package/dist/cartograph/georef.d.ts +18 -4
- package/dist/cartograph/schema.d.ts +11 -0
- package/dist/cartograph.js +1480 -1311
- package/dist/cartograph.standalone.js +1808 -1615
- package/dist/{cityjson-D_V5GY8b.js → cityjson-k-z1r6c0.js} +1 -1
- package/dist/{crs-DsDQ4Q4i.js → crs-BzE_KP4M.js} +25 -2
- package/dist/{crs-Ciu7Xs7a.js → crs-ChglCB3O.js} +39 -16
- package/dist/dem-decode.d.ts +58 -0
- package/dist/elements/om-map.d.ts +12 -0
- package/dist/{geoparquet-XOwOmChh.js → geoparquet-DFDZDBun.js} +10 -10
- package/dist/globe-view-D9wjfL0T.js +104 -0
- package/dist/hillshade-C2BQr6pd.js +298 -0
- package/dist/hillshade-apron-Bem3DWyJ.js +40 -0
- package/dist/hillshade-apron.d.ts +54 -0
- package/dist/hillshade-shader-DI2uLSNU.js +165 -0
- package/dist/hillshade-shader.d.ts +168 -0
- package/dist/hillshade.d.ts +163 -0
- package/dist/html-data.d.ts +1 -1
- package/dist/{ifc-Dc-TdSJr.js → ifc-DXwePQRv.js} +131 -131
- package/dist/{index-DzOvV-O7.js → index-4Tvlt0iO.js} +57 -57
- package/dist/{index-HZWdgtm4.js → index-Bn66l3KG.js} +1 -1
- package/dist/index-BuXrMq5D.js +322 -0
- package/dist/index-CNRbZHkK.js +459 -0
- package/dist/{index-DDNElBTs.js → index-CkovmN47.js} +1 -1
- package/dist/index-CmuOizAF.js +641 -0
- package/dist/index-CvT5QHBS.js +65 -0
- package/dist/{index-BMbpftvm.js → index-DnVHKI61.js} +1 -1
- package/dist/{index-BSAY6CWm.js → index-JjyDEqAS.js} +18911 -17456
- package/dist/index.d.ts +4 -0
- package/dist/layer-registry.d.ts +27 -0
- package/dist/lerc-C1mQ_Kqq.js +22 -0
- package/dist/onlymap.standalone.js +49075 -45717
- package/dist/onlymapjs.js +73 -70
- package/dist/parse-manifest.d.ts +6 -0
- package/dist/plane-camera.d.ts +59 -0
- package/dist/plane-layers.d.ts +56 -0
- package/dist/plane-tiles.d.ts +99 -0
- package/dist/plane-tileset.d.ts +31 -0
- package/dist/plane-warp.d.ts +91 -0
- package/dist/post-process-effect-DfslKPM6.js +197 -0
- package/dist/programmatic.d.ts +16 -1
- package/dist/projection.d.ts +118 -0
- package/dist/{raster-Dg5p_99H.js → raster-D2NzdjZE.js} +609 -499
- package/dist/raster-hillshade.d.ts +119 -0
- package/dist/{raster-pipeline-DhjkqDYd.js → raster-pipeline-qnD1icOv.js} +511 -484
- package/dist/raster-pipeline.d.ts +10 -0
- package/dist/raster.d.ts +5 -0
- package/dist/runtime-core.d.ts +140 -1
- package/dist/serialize/clip.d.ts +50 -0
- package/dist/serialize/declutter.d.ts +44 -0
- package/dist/serialize/emit.d.ts +60 -0
- package/dist/serialize/index.d.ts +64 -0
- package/dist/serialize/strategy.d.ts +30 -0
- package/dist/serialize/style.d.ts +77 -0
- package/dist/snapshot.d.ts +46 -0
- package/dist/surface-anchor.d.ts +6 -0
- package/dist/terrain-heightfield.d.ts +0 -16
- package/dist/terrain-sample.d.ts +0 -13
- package/dist/text-on-path-Dm7vtNqt.js +146 -0
- package/dist/text-on-path.d.ts +157 -0
- package/dist/transform/buffer.d.ts +63 -0
- package/dist/transform/contour.d.ts +37 -0
- package/dist/transform/dot-density.d.ts +19 -0
- package/dist/transform/field.d.ts +80 -0
- package/dist/transform/geometry.d.ts +20 -0
- package/dist/transform/index.d.ts +29 -0
- package/dist/transform/simplify.d.ts +10 -0
- package/dist/transform/smooth.d.ts +12 -0
- package/dist/transform-stage.d.ts +92 -0
- package/dist/version.d.ts +1 -1
- package/dist/volumetrics.d.ts +7 -0
- package/dist/{zarr-D3CzK1Zm.js → zarr-D5e5agMG.js} +2 -2
- package/docs/cartograph.md +12 -4
- package/docs/cartography.md +328 -0
- package/docs/design/arrows.md +182 -0
- package/docs/design/carto-substrate.md +1055 -0
- package/docs/design/extensions.md +250 -0
- package/docs/design/hillshade.md +290 -0
- package/docs/effects.md +11 -0
- package/docs/hillshade.md +203 -0
- package/llms.txt +4 -2
- package/onlymapjs.attributes.json +45 -2
- package/onlymapjs.html-data.json +213 -25
- package/package.json +13 -9
- package/skills/onlymapjs/SKILL.md +7 -2
- package/skills/onlymapjs/references/syntax.md +31 -3
- package/dist/index-CfPbQUqO.js +0 -511
- package/dist/lerc-qK-nhCaB.js +0 -30
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Layer extensions — design
|
|
2
|
+
|
|
3
|
+
Mounting deck's unused extensions behind curated attributes: **label decluttering**,
|
|
4
|
+
**pattern fills**, **geofence masking**, **parallel offset lines**.
|
|
5
|
+
|
|
6
|
+
**Versions are assigned at release, not here.** An earlier draft of this line pinned
|
|
7
|
+
0.11.0 and went stale before anything was built; the phases below are independently
|
|
8
|
+
shippable and each lands as a minor while pre-1.0.
|
|
9
|
+
|
|
10
|
+
**Deconflicted with the cartographic substrate** (`carto-substrate.md` §13), which
|
|
11
|
+
touches this design in four places: the rasterise trigger is decided by effect *type*
|
|
12
|
+
rather than by who installed the effect, so `CollisionFilterExtension`'s self-installed
|
|
13
|
+
effect must not force a map frame to rasterise on export (§13.1); the CPU declutter
|
|
14
|
+
pass in the vector serializer and this design's GPU decluttering are two algorithms for
|
|
15
|
+
one job, and the GPU one is authoritative wherever it runs (§13.2); S3's pattern-scale
|
|
16
|
+
question is the same millimetres-on-paper question the substrate asks of geometry, and
|
|
17
|
+
both read one declared reference scale (§13.3); and a mask layer serializes to a
|
|
18
|
+
`<clipPath>`, not to artwork (§13.4). Label candidate positions and leader lines are a
|
|
19
|
+
non-goal here and belong to the placement pass, which owns them for both designs
|
|
20
|
+
(§13.6).
|
|
21
|
+
|
|
22
|
+
Everything below was verified against the pinned deck (**9.3.5**) in `node_modules`,
|
|
23
|
+
not from memory. Sources are cited so the next reader can re-check rather than
|
|
24
|
+
re-litigate.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Verified: what already works in our favour
|
|
29
|
+
|
|
30
|
+
1. **Every extension carries a static `defaultProps`** in exactly the shape
|
|
31
|
+
`deriveSchemaFromDeckClass` (`src/layer-registry.ts`) already walks —
|
|
32
|
+
`CollisionFilterExtension` declares `getCollisionPriority, collisionEnabled,
|
|
33
|
+
collisionGroup, collisionTestProps`; `FillStyleExtension` seven; `MaskExtension`
|
|
34
|
+
three. Attribute derivation, validation and IntelliSense come along for free.
|
|
35
|
+
2. **Extension props reach sublayers automatically.** `LayerExtension.getSubLayerProps`
|
|
36
|
+
(deck `lib/layer-extension.js`) forwards every key in the extension's `defaultProps`
|
|
37
|
+
to sublayers, wrapping `type: 'accessor'` props in `getSubLayerAccessor` and
|
|
38
|
+
carrying their update triggers. `getCollisionPriority` therefore reaches
|
|
39
|
+
`TextLayer`'s character sublayers with no plumbing from us.
|
|
40
|
+
3. **Composite layers propagate `extensions`** (deck `lib/composite-layer.js:126`), and
|
|
41
|
+
`FillStyleExtension.isEnabled` excludes path-tesselator layers — so a
|
|
42
|
+
`GeoJsonLayer`'s polygon sublayer patterns while its line sublayers correctly skip it.
|
|
43
|
+
4. **Fresh instances every reconcile are free.** `diffExtensions` (deck
|
|
44
|
+
`lifecycle/props.js:201`) compares with `.equals()` — constructor identity plus a
|
|
45
|
+
shallow `opts` compare — so no shader churn. This is already the pattern at
|
|
46
|
+
`src/attribute-resolution.ts:278`, which pushes `new PathStyleExtension({dash:true})`.
|
|
47
|
+
5. **The aliasing trap is already guarded.** `cloneDefault` exists precisely because
|
|
48
|
+
deck's `extensions: []` default was being shared by reference across every layer of
|
|
49
|
+
a type (see its comment in `src/attribute-resolution.ts`).
|
|
50
|
+
6. **`operation` is already authorable.** It sits on `Layer.defaultProps` as `'draw'`,
|
|
51
|
+
so the derive walk exposes it — `MaskExtension`'s prerequisite needs no new surface.
|
|
52
|
+
|
|
53
|
+
## Verified: the surprises
|
|
54
|
+
|
|
55
|
+
These are the reasons this document exists. Each changes the design or the plan.
|
|
56
|
+
|
|
57
|
+
### S1 — collision installs a map-level Effect by itself
|
|
58
|
+
|
|
59
|
+
`CollisionFilterExtension.initializeState` calls
|
|
60
|
+
`this.context.deck?._addDefaultEffect(new CollisionFilterEffect())`. Deck keeps
|
|
61
|
+
`_defaultEffects` **separate** from `props.effects` and resolves
|
|
62
|
+
`userEffects.concat(defaultEffects)` (`lib/effect-manager.js`), deduping by
|
|
63
|
+
`effect.id` (`'collision-filter-effect'`).
|
|
64
|
+
|
|
65
|
+
Consequences:
|
|
66
|
+
- **No conflict** with `buildEffects()` / `setEffects()` — our array is untouched, and
|
|
67
|
+
repeated layer initialisation cannot accumulate duplicates.
|
|
68
|
+
- **But `setEffects([])` no longer means "no effects".** `docs/effects.md` currently
|
|
69
|
+
says `[]` "renders no effects at all"; with a decluttering layer present a
|
|
70
|
+
collision effect still runs. The sentence needs qualifying, and a test should pin it.
|
|
71
|
+
- The collision effect declares `useInPicking: true`, and the extension's
|
|
72
|
+
`getNeedsPickingBuffer()` returns true whenever collision is on — so label layers
|
|
73
|
+
allocate picking buffers whether or not they are `pickable`.
|
|
74
|
+
|
|
75
|
+
### S2 — decluttering is resolution-dependent, and capture changes the resolution
|
|
76
|
+
|
|
77
|
+
`collision-filter-effect.js` sizes its framebuffer from
|
|
78
|
+
`device.canvasContext.getPixelSize()` divided by a hardcoded `DOWNSCALE = 2`. Our
|
|
79
|
+
capture path sets `useDevicePixels: ratio` (`src/runtime-core.ts:1394`), which is
|
|
80
|
+
exactly what `getPixelSize()` reports.
|
|
81
|
+
|
|
82
|
+
So a label of *w* CSS pixels occupies `w·r/2` collision-map pixels: **half a pixel per
|
|
83
|
+
CSS pixel at r=1, two at r=4**. The rasterised footprints that decide overlap are
|
|
84
|
+
four times finer on a 300 dpi plate than on screen, so **the print can keep labels the
|
|
85
|
+
preview dropped**. Same family as the pixel-keyed grain bug `<om-effect>` fixed with
|
|
86
|
+
millimetres, and it must be measured before the API is designed around it — see
|
|
87
|
+
Phase 0. `DOWNSCALE` is not configurable from outside deck.
|
|
88
|
+
|
|
89
|
+
### S3 — fill patterns are glued to the ground, not to the paper
|
|
90
|
+
|
|
91
|
+
The pattern shader sets `fill_uv = geometry.position.xy` in **common space**, and
|
|
92
|
+
deck documents `getFillPatternScale`: *"If the pattern is 24 x 24 pixels, scale 1
|
|
93
|
+
roughly yields 24 **meters**."* Patterns are anchored in world coordinates and grow
|
|
94
|
+
on the screen as you zoom in.
|
|
95
|
+
|
|
96
|
+
That is the opposite of the contract `<om-effect>` established, where every spatial
|
|
97
|
+
knob is millimetres on paper and survives a change of resolution. A paper-constant
|
|
98
|
+
hachure therefore needs `getFillPatternScale` **derived from the current zoom and the
|
|
99
|
+
sheet scale**, not authored as a constant. This is a design decision, not a defect —
|
|
100
|
+
but authoring raw metres would produce a pattern that silently changes size between
|
|
101
|
+
the screen and the sheet.
|
|
102
|
+
|
|
103
|
+
### S4 — only one of the three takes constructor options
|
|
104
|
+
|
|
105
|
+
`new FillStyleExtension({pattern: true})` — and `pattern` defaults to **false**, so an
|
|
106
|
+
extension mounted without opts silently does nothing. `CollisionFilterExtension` and
|
|
107
|
+
`MaskExtension` take no options at all (verified: constructor arity 0, `opts`
|
|
108
|
+
undefined).
|
|
109
|
+
|
|
110
|
+
Constructor options are **not** in `defaultProps`, so they are invisible to the derive
|
|
111
|
+
walk. This is the concrete gap that a generic `<om-extension>` passthrough would have
|
|
112
|
+
to solve, and the reason the curated route goes first.
|
|
113
|
+
|
|
114
|
+
### S5 — two object-typed props derive as strings
|
|
115
|
+
|
|
116
|
+
The derive walk maps a spec with no `type` key, or `type: 'object'`, to
|
|
117
|
+
`coerceType = "string"`. That mis-types exactly two props we need:
|
|
118
|
+
`collisionTestProps` (`{}`, no `type`) and `fillPatternMapping` (`{type: 'object'}`).
|
|
119
|
+
|
|
120
|
+
Fix with **curated overrides**, not by widening the walk: making plain-object defaults
|
|
121
|
+
derive as `json` would silently reclassify props across every bundled layer type.
|
|
122
|
+
|
|
123
|
+
### S6 — a mask layer is invisible but not `visible: false`
|
|
124
|
+
|
|
125
|
+
Masks cap at four (`mask-effect.js`: *"Too many mask layers. The max supported is 4"*).
|
|
126
|
+
More importantly, a mask layer carries `operation: "mask"` and draws nothing, yet its
|
|
127
|
+
`visible` stays `true` — and `src/cartograph/legend.ts:106` skips entries only on
|
|
128
|
+
`visible === false`. **A mask would appear in the printed legend and in the layers
|
|
129
|
+
widget as a togglable entry.** Both need an `operation` check.
|
|
130
|
+
|
|
131
|
+
### S7 — collision and mask are coupled inside deck
|
|
132
|
+
|
|
133
|
+
`collision-filter-effect.js` reads `preRenderStats['mask-effect']?.didRender` to decide
|
|
134
|
+
whether to re-run, beside deck's own comment: *"TODO: better dependency system for
|
|
135
|
+
Effects"*. Shipping both lands on that seam, so they should not ship in the same phase.
|
|
136
|
+
|
|
137
|
+
### S8 — the pattern atlas is an async fetch
|
|
138
|
+
|
|
139
|
+
`fillPatternAtlas` is an async image prop and `fillPatternMapping` an async object.
|
|
140
|
+
A standalone cartograph is one file that opens by double-click with no server, so a
|
|
141
|
+
shipped atlas must inline as a `data:` URI or patterns vanish offline.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Decisions these facts settle
|
|
146
|
+
|
|
147
|
+
- **Curated attributes, not a generic passthrough** — unchanged, and S4 is the
|
|
148
|
+
concrete reason. Implement each by merging the extension's *derived* schema rather
|
|
149
|
+
than hand-listing props (fact 1), so the machinery a future `<om-extension>` needs
|
|
150
|
+
gets built as a side effect and the passthrough stays a separate, later decision.
|
|
151
|
+
- **Collision and mask ship in different phases** (S7).
|
|
152
|
+
- **Patterns are authored in millimetres on paper**, with the world-space scale derived
|
|
153
|
+
(S3) — consistent with `<om-effect>`.
|
|
154
|
+
- **Phase 0 exists** because S2 could change the API: if decluttering diverges between
|
|
155
|
+
preview and plate, that is a contract problem, not a polish item.
|
|
156
|
+
|
|
157
|
+
## Phases
|
|
158
|
+
|
|
159
|
+
### Phase 0 — measure, before any API (half a day)
|
|
160
|
+
|
|
161
|
+
Answer three questions with a real GPU, not reasoning:
|
|
162
|
+
|
|
163
|
+
1. **Capture divergence (S2).** Render a dense label set, count survivors at
|
|
164
|
+
`useDevicePixels` 1, 2 and 4. If the set differs, decide the mitigation *now*:
|
|
165
|
+
document it, or render the preview at the capture ratio, or expose the ratio a
|
|
166
|
+
sheet was designed at.
|
|
167
|
+
2. **World copies.** The effect tests `viewports[0]` only; check labels in repeated
|
|
168
|
+
world copies (`repeat: true`) near the antimeridian — the seam that bit us before.
|
|
169
|
+
3. **Cost.** Picking-buffer allocation (S1) on a large label layer, measured.
|
|
170
|
+
|
|
171
|
+
Deliverable: numbers in this document, and a go/no-go on the collision API shape.
|
|
172
|
+
|
|
173
|
+
### Phase 1 — the extension seam + decluttering
|
|
174
|
+
|
|
175
|
+
The seam: declare an extension on a layer, merge its derived schema into that layer's
|
|
176
|
+
prop surface, mount the instance through the `cloneDefault`-guarded `extensions` array.
|
|
177
|
+
Curated overrides for `collisionTestProps` (S5).
|
|
178
|
+
|
|
179
|
+
Authoring: a `declutter` attribute plus `get-label-priority`. `collisionTestProps`
|
|
180
|
+
should default to the documented sizing bump rather than being left to the author —
|
|
181
|
+
the prop exists so a label reserves more room than it draws, and getting it wrong
|
|
182
|
+
looks like "decluttering doesn't work" rather than an error.
|
|
183
|
+
|
|
184
|
+
Validation: `get-label-priority` without `declutter` is silently inert — an error with
|
|
185
|
+
a fix string, in the `<om-effect>` validator's idiom.
|
|
186
|
+
|
|
187
|
+
Docs: qualify the `setEffects([])` sentence in `docs/effects.md` (S1).
|
|
188
|
+
|
|
189
|
+
### Phase 2 — masking
|
|
190
|
+
|
|
191
|
+
`mask="<layer-id>"` plus `mask-inverted`. Requires the `operation` fix in
|
|
192
|
+
`src/cartograph/legend.ts` and the layers widget (S6), and a structured error when
|
|
193
|
+
`maskId` names a layer that is missing or not `operation="mask"` — deck silently
|
|
194
|
+
disables masking in both cases. Validate the four-mask cap with a real message.
|
|
195
|
+
|
|
196
|
+
Visual targets: relief clipped to land at the coastline; a study area at full
|
|
197
|
+
saturation with everything outside knocked back.
|
|
198
|
+
|
|
199
|
+
### Phase 3 — pattern fills
|
|
200
|
+
|
|
201
|
+
`new FillStyleExtension({pattern: true})` (S4), a shipped monochrome atlas —
|
|
202
|
+
hachures, dot screens, cross-hatch, stipple — inlined as a `data:` URI (S8), with
|
|
203
|
+
`fillPatternMask` left at its default so each feature's own fill colour tints the
|
|
204
|
+
texture. `fill-pattern="hachure-45"` names an entry; `fill-pattern-size="1.5mm"`
|
|
205
|
+
resolves to `getFillPatternScale` against the current zoom (S3).
|
|
206
|
+
|
|
207
|
+
This phase has a design cost the others don't: someone has to draw the atlas, and it
|
|
208
|
+
is the thing that most changes how a sheet looks.
|
|
209
|
+
|
|
210
|
+
Pairs with the cartograph's colour-vision lint, which can currently only report that
|
|
211
|
+
two categories are indistinguishable — patterns are the fix it has no way to suggest.
|
|
212
|
+
|
|
213
|
+
### Phase 4 — offset lines
|
|
214
|
+
|
|
215
|
+
`get-offset` on the already-mounted `PathStyleExtension` (only `dash` and
|
|
216
|
+
`dash-justified` are exposed today, `src/attribute-resolution.ts:117`). Road casings,
|
|
217
|
+
divided carriageways, boundaries drawn inside the line. Cheapest phase by a wide margin.
|
|
218
|
+
|
|
219
|
+
### Phase 5 — surfaces and release
|
|
220
|
+
|
|
221
|
+
Example pages, `docs/`, README, skill + `llms.txt`, `html-data.ts` regeneration,
|
|
222
|
+
`dev/build-public.ts` + `npm run test:public`, architecture traceability, CHANGELOG,
|
|
223
|
+
downstream pins.
|
|
224
|
+
|
|
225
|
+
## Acceptance criteria
|
|
226
|
+
|
|
227
|
+
- [ ] Dense labels declutter by authored priority, and the survivor set at capture
|
|
228
|
+
resolution is either identical to the preview or the difference is documented
|
|
229
|
+
with a stated mitigation (Phase 0).
|
|
230
|
+
- [ ] A layer masked to another's geometry clips at the boundary; the mask layer
|
|
231
|
+
appears in neither the derived legend nor the layers widget.
|
|
232
|
+
- [ ] A pattern fill holds the same **paper** size across a zoom change and a
|
|
233
|
+
300 dpi capture.
|
|
234
|
+
- [ ] Patterns survive in a standalone cartograph opened offline.
|
|
235
|
+
- [ ] Extension props are authored through derived schemas, not hand-listed — adding a
|
|
236
|
+
future extension is a registration, not a port.
|
|
237
|
+
- [ ] Every silently-inert combination reports a validator error with a fix.
|
|
238
|
+
- [ ] Bundle: eager growth measured and stated (`@deck.gl/extensions` is already in the
|
|
239
|
+
eager graph via `attribute-resolution.ts`, so this is tree-shake delta, not a new
|
|
240
|
+
dependency).
|
|
241
|
+
|
|
242
|
+
## Non-goals
|
|
243
|
+
|
|
244
|
+
- **A generic `<om-extension>` passthrough** — a separate decision, deliberately left
|
|
245
|
+
open; S4 is the work it would have to do first.
|
|
246
|
+
- **Label candidate positions and leader lines** — real cartographic wins, but placement
|
|
247
|
+
logic, not extension work. Follow-up.
|
|
248
|
+
- **Text on a curve** — a composite layer placing per-glyph `TextLayer` entries along a
|
|
249
|
+
path. Feasible in deck; unrelated to this ticket.
|
|
250
|
+
- **`BrushingExtension`** — an interaction effect with no print equivalent.
|
|
@@ -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.
|