@nika-js/onlymap 0.10.10 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +14 -2
  3. package/dist/{basemap-BH76eQA0.js → basemap-Bg73oXUb.js} +2 -2
  4. package/dist/cluster-index.d.ts +77 -0
  5. package/dist/cluster-options.d.ts +92 -0
  6. package/dist/ctx.d.ts +2 -0
  7. package/dist/elements/om-map.d.ts +6 -0
  8. package/dist/{geoparquet-DzKLe-0r.js → geoparquet-BASBa9tf.js} +1 -1
  9. package/dist/{globe-view-B-prUQFh.js → globe-view-CTkofOiM.js} +1 -1
  10. package/dist/{hillshade-CDng2Jsi.js → hillshade-DdVEO8lc.js} +1 -1
  11. package/dist/html-data.d.ts +1 -1
  12. package/dist/{index-laD2SEAB.js → index-BCDmJfeb.js} +3 -3
  13. package/dist/{index-DOfIeNux.js → index-BLfj5bIo.js} +1 -1
  14. package/dist/{index-D86S8KJ1.js → index-BOjo5N6i.js} +1 -1
  15. package/dist/{index-DvEcTZ4i.js → index-C-YAnesV.js} +17527 -16473
  16. package/dist/{index-CpLydTmE.js → index-C7CNrOGW.js} +1 -1
  17. package/dist/{index-Rvd-zFrS.js → index-CVAyXg52.js} +1 -1
  18. package/dist/{index-cwieLGSg.js → index-DbfTOgYl.js} +1 -1
  19. package/dist/{index-8Fj-yh7f.js → index-DsLNa_IB.js} +2 -2
  20. package/dist/{index-CIo8LgRZ.js → index-FtNZZGWv.js} +3 -3
  21. package/dist/ir-snapshot.d.ts +10 -0
  22. package/dist/ir.d.ts +9 -0
  23. package/dist/layer-registry.d.ts +8 -0
  24. package/dist/layers/cluster-layer.d.ts +111 -0
  25. package/dist/{lerc-BJB4-X6n.js → lerc-CoNq0xxX.js} +1 -1
  26. package/dist/onlymap.standalone.js +35944 -34890
  27. package/dist/onlymapjs.js +1 -1
  28. package/dist/{post-process-effect-Bd5plkno.js → post-process-effect-CrZoIEYa.js} +1 -1
  29. package/dist/programmatic.d.ts +6 -0
  30. package/dist/{raster-DJ6vvro6.js → raster-CZMdghdy.js} +3 -3
  31. package/dist/{raster-pipeline-BQhNhrPq.js → raster-pipeline-n2wrLc9r.js} +1 -1
  32. package/dist/runtime-core.d.ts +24 -0
  33. package/dist/{text-on-path-CrqchF3O.js → text-on-path-CHkHjky-.js} +1 -1
  34. package/dist/version.d.ts +1 -1
  35. package/dist/{zarr-oAkG7ZLM.js → zarr-DRBhsEZZ.js} +2 -2
  36. package/docs/cartograph.md +2 -2
  37. package/llms.txt +2 -1
  38. package/onlymapjs.attributes.json +33 -0
  39. package/onlymapjs.html-data.json +68 -0
  40. package/package.json +7 -3
  41. package/skills/onlymapjs/SKILL.md +3 -2
  42. package/skills/onlymapjs/references/react.md +1 -0
  43. package/skills/onlymapjs/references/syntax.md +47 -2
  44. package/docs/design/arrows.md +0 -182
  45. package/docs/design/carto-substrate.md +0 -1067
  46. package/docs/design/cog-v2.md +0 -223
  47. package/docs/design/extensions.md +0 -250
  48. package/docs/design/frame-sources.md +0 -229
  49. package/docs/design/hillshade.md +0 -290
  50. package/docs/design/paced-flyby.md +0 -42
  51. package/docs/design/trace-link-failure.md +0 -20
@@ -1,1067 +0,0 @@
1
- # Cartographic substrate — plane view, geometry transforms, vector export
2
-
3
- Design for the layer beneath the cartograph overhaul: **real projections**,
4
- **geometry the data doesn't contain**, and **vector output**.
5
-
6
- **Versions are assigned at release, not here.** The phases in §9 are independently
7
- shippable and deliberately not mapped onto a fixed set of version numbers: there are
8
- several of them, the warp is plausibly a release on its own, and an earlier draft of this
9
- line had already gone stale before anything was built. Each phase lands as a minor
10
- while pre-1.0, which is also the only boundary at which the bundled deck.gl pin may
11
- move — nothing here requires it to.
12
-
13
- The goal is flexibility of the cartograph use case — a sheet that can be in Albers or
14
- British National Grid, whose coastlines are smoothed and whose land carries a coastal
15
- vignette, and whose frozen frame is editable vector rather than a bitmap — **without a
16
- second renderer**. Everything here is a lazy chunk in core that the cartograph calls
17
- through the seam it already has.
18
-
19
- Every file, line and mechanism below was read in this codebase or in the pinned deck
20
- (9.3.5). Where a claim rests on a prior decision, the decision is cited. Where a
21
- number appears — buffer accuracy in §5, warp subdivision and projection scale factors
22
- in §9 — it was **measured**, not estimated, against analytically exact references; the
23
- harnesses are small and standalone, and the phase gates re-run them.
24
-
25
- ---
26
-
27
- ## 1. Why not a second renderer (the decision this document rests on)
28
-
29
- The two capabilities a second renderer would buy are non-Mercator projections and
30
- vector output. Neither needs one:
31
-
32
- - deck's maintainers' own path for a non-Mercator map is *pre-project the data and
33
- render in `OrthographicView`* (tracked in #2, re-sequenced 2026-09-03). For static
34
- data that is pixel-identical to a GPU projection — the shader version only matters
35
- for switching projection live.
36
- - Vector output is a **serializer** over the IR, not a renderer: it needs no picking,
37
- no tiles, no interaction, no 3D.
38
-
39
- A second interactive renderer would duplicate the attribute surface, legend
40
- derivation, widgets, picking, stories/`seek()`, validation, IntelliSense and the
41
- skill/`llms.txt` surfaces, and would *lose* effects, hillshade, terrain, Tile3D/BIM and
42
- the COG/Zarr stack — a fork with a different feature set, plus a permanent double tax
43
- on `onlymap-native` and `onlymap-remotion`, which pin this package exactly. Not taken.
44
-
45
- ## 2. Where it lives, and why the cartograph can't own it
46
-
47
- `src/cartograph/core-loader.ts` states **the lazy-core rule**: `src/cartograph/` never
48
- imports the core entry at module scope, so a static-only sheet loads no deck.gl and no
49
- MapLibre. `dev/assert-bundle-cdn-safe.mjs` (check 5) fails the build if that regresses.
50
- The cartograph's only route to the runtime is typed `typeof import("../index")` — the
51
- core's **public** entry.
52
-
53
- The serializer needs the IR (`LayerIR.props` holds compiled deck accessors,
54
- `src/ir.ts:99`) and the projection step needs the data pipeline
55
- (`src/parse-manifest.ts`). Housing them in the cartograph would mean widening the
56
- public API just to reach internals. So:
57
-
58
- | Piece | Home | Loaded when |
59
- |---|---|---|
60
- | Projection core (`src/projection.ts`) | core | `<om-map crs>` or a projected transform/export asks; proj4 stays lazy as it is in `src/crs.ts` today |
61
- | Plane view | core (`runtime-core.ts`) | `<om-map crs>` |
62
- | Geometry transforms (`src/transforms/`) | core, lazy chunk | first `<om-transform>` |
63
- | Vector serializer (`src/vector-export/`) | core, lazy chunk | first `snapshot({ format: "svg" })` |
64
- | Raster warp (`src/warp/`) | core, lazy chunk | a projected map that carries a raster, relief or contours (Phase 6) |
65
- | Freeze-to-vector, print plumbing | cartograph | live frame freeze |
66
-
67
- The pattern is `src/post-process/`: metadata in core, the heavy part in a chunk
68
- fetched only when a document uses it, pinned by a "never downloads it" browser test.
69
-
70
- A vector static frame keeps the static-only promise **better** than today's PNG: the
71
- serialization happens at freeze time while the live core is mounted, and what lands in
72
- the file is inert markup that the static build renders with no runtime at all.
73
-
74
- ## 3. The shared piece: one projection function outside the GPU
75
-
76
- Both the plane view (at ingest) and the serializer (at export) need *"lng/lat → plane
77
- x/y, and back"* without the GPU. Today that exists twice, half each:
78
-
79
- - `src/cartograph/georef.ts` — `CrsForward` interface, closed-form Mercator (clamped
80
- and `MERCATOR_CONTINUOUS`), `resolveCrsForward()` reaching proj4 lazily, homography
81
- and `FrameGeoref { crs, corners }`.
82
- - `src/crs.ts` — `CRS_DEFS` for a handful of codes, `projectedToLonLat()` (inverse
83
- only, built for IFC placement), `gridConvergence()`.
84
-
85
- `src/projection.ts` unifies them: `registerCrs(code, def)`, `resolveProjection(crs)`
86
- returning `{ forward, inverse, code, units }`, a batch `forwardCoords(Float64Array)`
87
- for whole layers, and a **local origin**. The cartograph's georef keeps its interface
88
- and becomes a consumer.
89
-
90
- **Justifications.**
91
- - *Local origin is not optional.* Measured, fp32 resolves no better than **0.48 m** at
92
- a 500 km easting and **5.7 m** at a 6 000 km northing, against **1.9 mm** two
93
- kilometres from an origin — and fp32 is what reaches the screen, whatever the CPU
94
- computed. #2 §0 called this jitter and predicted "whoever builds it will hit this in
95
- the first hour"; the numbers are worse than the word, since metres of error is
96
- geometry in the wrong place rather than shimmer. The plane holds `(x − x₀, y − y₀)`; the origin is the map's initial centre,
97
- fixed for the map's life, and is written into the frame georef so nothing downstream
98
- has to know.
99
- - *The interface is the contract, not the library.* proj4 covers the conic,
100
- cylindrical and azimuthal families most sheets need (Albers, LCC, UTM, BNG, State
101
- Plane) and several world projections. Anything missing — an interrupted or artistic
102
- projection — registers as a `CrsForward` from another library without changing a
103
- caller. The cartograph's graticule already works this way.
104
- - *Web Mercator is just another code.* `EPSG:3857` resolves to the closed form, so a
105
- map with no `crs` pays nothing and changes nothing.
106
-
107
- ## 4. Part A — the plane view: `<om-map crs="EPSG:5070">`
108
-
109
- ### What changes
110
-
111
- Data is projected **once, at ingest**, in `parse-manifest`'s data stage — after
112
- `normalizeData` and before accessor resolution and `applySurfaceAnchor`
113
- (`src/parse-manifest.ts:38`, `:129`) — and the renderer swaps `MapView` for
114
- `OrthographicView`. Every layer, accessor, classification, effect and the legend are
115
- untouched: none of them ever asked what the coordinates meant.
116
-
117
- **Corrected while building: positional ACCESSORS did ask.** The sentence above is
118
- true of colours, sizes and classification and false of positions.
119
- `get-position="[$lon, $lat]"` compiles to a function deck evaluates per row at draw
120
- time, reading fields off the row, so projecting the data never reaches it — the layer
121
- keeps emitting lng/lat into a metre plane and renders nothing, silently. Five accessors
122
- across every registered schema return coordinates (`getPosition`, `getPath`,
123
- `getPolygon`, `getSourcePosition`, `getTargetPosition`) and are wrapped alongside the
124
- ingest projection, at the single point where a deck layer is constructed —
125
- deliberately NOT in `parse-manifest` or `attribute-resolution`, which are the hottest
126
- shared paths in the library and must stay byte-identical for a Mercator map.
127
-
128
- Two things make that safe rather than merely working. The wrappers are memoised per
129
- `(accessor, plane)`, because an accessor's cache key IS its deck `updateTrigger`: a
130
- wrapper minted per rebuild would leave the trigger unchanged while the reference
131
- churned, and deck would recompute every attribute of every layer on every frame. And
132
- the list is guarded by a test that enumerates every registered schema and fails when an
133
- unclassified spatial accessor appears — a hand-maintained list would otherwise rot the
134
- first time a layer type was added, and the symptom would be geometry in the wrong place
135
- rather than an error.
136
-
137
- **Six accessors cannot be fixed this way and are a limit instead.** `getHexagon`,
138
- `getHexagons`, `getGeohash`, `getPentagon`, `getQuadkey` and `getS2Token` hand deck a
139
- spatial-index TOKEN, and deck builds the geometry inside the layer using its own
140
- geographic maths. There is no coordinate to intercept, so H3, S2, geohash and quadkey
141
- layers cannot draw in a plane view at all; that is a validation error naming the
142
- conversion to polygons, not a layer that quietly vanishes.
143
-
144
- ### What deliberately does not change: the authored camera
145
-
146
- `center="[lng, lat]"` and `zoom` stay geographic. The plane view translates:
147
- `target = forward(center) − origin`, and orthographic zoom is chosen so that
148
- **metres per CSS pixel at the centre equal Web Mercator's at that latitude** —
149
- `zoom="9"` means the same visual scale it always meant. `getCamera()`,
150
- `om-view-changed`, `setCamera` and `flyTo` speak lng/lat/zoom by unprojecting.
151
-
152
- *Justification:* stories, `seek()`, `paced-flyby`, `onlymap-remotion`'s frame driver and
153
- every existing document express cameras geographically. A projected map that required
154
- a projected camera would fork the story format. Translation at the boundary keeps one
155
- camera model.
156
-
157
- ### The limits, each a validation error with a fix
158
-
159
- From #2 step 2, plus what this codebase adds:
160
-
161
- | Limit | Why | Fix string points to |
162
- |---|---|---|
163
- | No MapLibre basemap | separate Mercator renderer | `basemap="none"` — already required for effects and relief |
164
- | No `terrain` | `TerrainLayer` is Mercator | drop `terrain`, or use Mercator |
165
- | No `pitch`, no `bearing` | `OrthographicView` is planimetric; rotation via a model matrix is a follow-up | a print sheet is planimetric; rotate the frame in the layout |
166
- | ~~`HillshadeLayer` is Mercator-only~~ — **LIFTED by Phase 6.** `contour` off the same tiles still is | the warp re-indexes Mercator tiles from the plane's own geography and draws them as subdivided meshes; `contour` needs marching squares in the source grid and the polylines projected, which is Phase 5 | nothing — global relief works on a projected sheet. Freezing relief from a Mercator frame is still affine and sound only over small extents (C3b) |
167
- | CRS fixed for the map's life | re-ingest on switch is a remount | author two maps |
168
- | `flyTo` arcs are linear | `FlyToInterpolator` is Web Mercator only; the `LinearInterpolator` branch at `runtime-core.ts:2235` is the plane path | none needed |
169
-
170
- ### Relief on a projected sheet — available from Phase 1
171
-
172
- **Both routes now work.** A DEM of the author's own worked from Phase 1, by the route a
173
- cartographer would take anyway; the keyless global source works from Phase 6. The
174
- original framing — that the limits table's Mercator-only row read as though a projected
175
- sheet could not carry relief at all — is kept below because the reasoning is what made
176
- the second route cheap.
177
-
178
- `shading="hillshade"` on a raster source takes the file's geotransform, the file's CRS
179
- units, and the tile's own pixels — **no viewport, no map projection, no zoom**. The
180
- shade at a ground point is therefore the same whatever projection the sheet is drawn
181
- in, and the feature is projection-independent by construction rather than by effort.
182
- So an author with a DEM — in the sheet's CRS, in UTM, in anything — gets correct relief
183
- as soon as the plane view exists. What Phase 1 owes it is placement: the raster tileset
184
- projects to Web Mercator today and must target the plane instead, which is close to
185
- identity when the DEM is already in the sheet's CRS.
186
-
187
- What Phase 6 buys is narrower than "relief on a projected sheet": it is **global relief
188
- with no data of your own**, the keyless convenience. Worth having, not load-bearing.
189
-
190
- #### Shade first, warp second
191
-
192
- Which also settles the warp's internal order. Shading in the **source** grid and warping
193
- the result is simpler than warping heights into a plane-space heightfield and shading
194
- there — no offscreen float target, and the gradient is never taken over resampled data,
195
- which is where a derivative finds the resampler. `contour` gains more: march squares in
196
- the source grid and project the resulting **polylines**, which is exact, instead of
197
- contouring a warped raster.
198
-
199
- #### Which north does the sun mean?
200
-
201
- Shading in the source grid makes the *apparent* light direction vary across a projected
202
- sheet, because geographic north is not sheet-up. Measured, at latitude 40:
203
-
204
- | Albers CONUS, longitude | north tilts from sheet-up |
205
- |---|---|
206
- | −124 (west coast) | +16.9° |
207
- | −96 (central meridian) | 0° |
208
- | −70 (east coast) | −15.7° |
209
-
210
- A 34° swing across the plate. On British National Grid the same figure is ±4° and
211
- nobody would notice; on a continental sheet it is unmissable.
212
-
213
- Both readings are defensible. **Geographic north** is physically true — that slope
214
- really is lit from the north-west. **Sheet north** is what relief atlases do, because
215
- constant apparent illumination looks right and lighting that rotates across a plate
216
- reads as a mistake. Proposed: **sheet north by default, geographic as an opt-in**,
217
- applied per tile through `crs.ts`'s existing `gridConvergence()`. Open question §12.4 —
218
- a cartographic judgement, not a technical one, and visible only on the sheets this
219
- document exists to serve.
220
-
221
- ### Everything else the view touches
222
-
223
- - **Picking, hover, draw, snapping** — screen-space, but NOT unchanged, which an
224
- earlier draft assumed on #2's word. Two seams carry coordinates out of the renderer
225
- and both spoke lng/lat only because every viewport used to. `getViewport()` is the
226
- shared one — overlays anchor through it, widgets read `getBounds()` for filtering and
227
- stats, `ctx` hands it to accessors — so a plane view returns an adapter that converts
228
- at the seam rather than teaching each consumer about the plane (its `getBounds`
229
- samples along the EDGES, since a conic's extreme latitude sits mid-edge, not at a
230
- corner). And deck reports `info.coordinate` in the viewport's own world space, which
231
- is metres here: draw, measure, `om-map-point` and every behaviour would have received
232
- plane coordinates. The resolution runs in the plane, where geometry and viewport
233
- agree, and converts once on the way out. **Measuring is why this matters rather than
234
- being tidy** — the measure tool feeds those points to `geodesy.ts`, and a projected
235
- metre in a geodesic formula returns a confident, wrong distance. One snap branch
236
- (BIMLayer's edge overlay, which builds its candidates in lng/lat from the model's own
237
- georeference) is skipped on a projected map, because mixing those with plane
238
- candidates would snap to a point hundreds of kilometres away rather than fail.
239
- - **Measure** — unproject to lng/lat, then the existing `geodesy.ts`. Never measure
240
- in projected metres: scale factor varies across a conic sheet.
241
- - **Scale bar** — computed at the frame centre, the cartographic convention; the
242
- cartograph scale bar already resolves proj4 lazily for projected grids.
243
- - **Graticule** — already reprojects and densifies (`docs/cartograph.md`); in a conic
244
- view it curves correctly with no new work. This is the first visible payoff.
245
- - **Frame georef** — an orthographic frame's corners are an **affine** map of the
246
- plane, so `FrameGeoref { crs: "EPSG:5070", corners }` is exact and world-file-able:
247
- no pitch cap, no wrap, and the projective fit carries no residue (interior points
248
- land where the plane's own linear mapping says, to 1e-5 mm). The continuous-Mercator
249
- georef work stays for Mercator frames. **Measured cost of getting it wrong:** fitting
250
- a projected frame's corners in Mercator's plane instead puts the SHEET CENTRE 7.12 mm
251
- out on a 180×120 mm sheet — a homography through four corners is least constrained
252
- exactly in the middle, which is where a reader looks. Only the map can tell a frame
253
- which case it is in, so it answers rather than being asked to guess.
254
- - **World copies** — a projected plane does not wrap. The antimeridian seam and
255
- `repeat: true` are Mercator-only concerns.
256
- - **Camera limits** — the Mercator zoom floor/pitch logic is bypassed; the plane needs
257
- only a zoom range.
258
- - **`snapshot({scale})`** — the composite draws `deck.getCanvas()`
259
- (`runtime-core.ts:1444`), view-agnostic.
260
-
261
- ## 5. Part B — geometry transforms: `<om-transform>`
262
-
263
- ```html
264
- <om-layer id="coast" type="GeoJsonLayer" data="./coast.geojson">
265
- <om-transform type="simplify" tolerance="0.15mm"></om-transform>
266
- <om-transform type="smooth" iterations="3"></om-transform>
267
- <om-transform type="buffer" distance="1.2mm" repeat="5" fade></om-transform>
268
- </om-layer>
269
- ```
270
-
271
- ### Placement in the pipeline, and why it is the whole design
272
-
273
- Transforms run in the **data stage**, after normalisation and before accessor
274
- resolution — the same seam as the plane view's projection, immediately after it. That
275
- placement is what makes the rest of this document coherent:
276
-
277
- - the GPU and the serializer receive **the same geometry**, so a smoothed coastline is
278
- smoothed in the interactive frame and in the frozen vector;
279
- - `anchor="surface"` (`src/surface-anchor.ts`) and the legend see the transformed
280
- shape;
281
- - transforms are pure functions of `(geometry, params, metresPerMm)` — worker-able,
282
- cacheable by data identity + params, and unit-testable headless.
283
-
284
- **Correction, from building it: transforms run on lng/lat, not on the plane.** §5's
285
- first draft placed them "immediately after" the plane view's projection. In the code
286
- those are not the same seam at all — ingest lands in `parse-manifest.ts`, while the
287
- plane projection happens at layer-construction time in `runtime-core.ts`, because it
288
- also has to reach positional accessors (C18). Putting geometry transforms after it
289
- would have meant either moving the projection earlier — which C18 says cannot be done
290
- — or running transforms twice.
291
-
292
- They run on lng/lat instead, in a per-feature **equirectangular metric frame** about
293
- the feature's own centre latitude: metres in, metres out, degrees only at the boundary.
294
- That is what makes a tolerance mean the same thing everywhere; simplifying raw degrees
295
- thins a Norwegian coastline five times harder than an Ecuadorian one from the same
296
- authored number, and there is a test that measures exactly this with the naive version
297
- as its negative control. The frame is exact north-south and off by the cosine
298
- difference across the feature's own latitude span east-west: 0.02% across a 1°-tall
299
- feature at 45°, 0.3% across 10°. A tolerance is a threshold, not a measurement, so that
300
- is well inside the point of the number.
301
-
302
- **Columnar layers are out of scope, and say so.** Every primitive here operates on line
303
- or polygon geometry, while a columnar layer is precisely the case that has none: large
304
- point datasets stay in columns for speed, and GeoArrow lines and polygons are already
305
- converted to features on the way in. So `<om-transform>` on a columnar layer is a
306
- validation error naming the layer, not a silent no-op — the same treatment, for the
307
- same reason, that the full-JS accessor opt-in already gets on Arrow sources.
308
-
309
- ### Units
310
-
311
- Spatial knobs are **millimetres on paper**, resolved against metres-per-mm at a
312
- reference scale — in a plane view directly, in Mercator at the centre latitude. Same
313
- contract as `<om-effect>`, same reason: a tolerance in metres silently changes the
314
- look between a screen and a 300 dpi plate.
315
-
316
- **"At what scale" is an open question, not a detail** (§12.3). Unlike an effect's
317
- millimetre knobs, which are uniforms re-pointed per frame for nothing, geometry cannot
318
- be re-resolved for free: transforms run once at ingest and are cached by data identity
319
- plus params, while an interactive map's scale changes on every zoom. A sheet has a
320
- scale and the question is moot; a live map does not. This decides the caching key, so
321
- it is settled before Phase 2 rather than during it.
322
-
323
- ### Determinism
324
-
325
- Dot density takes a `seed` (default fixed). `onlymap-remotion` drives stories
326
- frame-by-frame and cross-checks against `onlymapjs record`; a random scatter that
327
- differs per frame would fail its battery. Seeded, it is a pure function.
328
-
329
- ### Primitives, ranked by payoff over cost
330
-
331
- 1. **`simplify`** (Douglas–Peucker, mm tolerance) — small, self-contained.
332
- 2. **`smooth`** (Chaikin, iterations) — small; with 1, the loudest "web map" tell gone.
333
- 3. **`dot-density`** (points per value inside a polygon, seeded) — small; unreachable today.
334
- 4. **`contour`** from a DEM — marching squares over the tiles the hillshade already
335
- fetches and decodes (`src/hillshade.ts`, `dem-decode.ts`). Not deck's
336
- `ContourLayer`, which contours *point density*, not a raster. Off the tiled DEM it
337
- inherits that path's Mercator tie until the warp (Phase 6); off a raster of the
338
- author's own it is projection-independent for the same reason relief is (§4a).
339
- 5. **`buffer`** (with `repeat` + `fade` for the coastal vignette) — see below. No
340
- longer the primitive that decides the project's shape, and still not on the
341
- critical path for 1–4.
342
-
343
- ### `buffer` is a cartographic ornament, not an analytic product
344
-
345
- The earlier draft deferred this behind a spike — vendor a proven clipper, or write
346
- the narrow subset — on the grounds that robust polygon offsetting is where geometry
347
- libraries die (self-intersections, slivers, collapse). That framing asked the wrong
348
- question. The right one is *which feature is this*, and the answer follows a line this
349
- library has already drawn once.
350
-
351
- Shaded relief shipped after a closed decision that said "raster analysis — app
352
- territory", because the boundary turned out to be **queryability, not the arithmetic**:
353
- cartographic relief is rendered texture, slope-in-degrees is an analytic product. The
354
- same split applies here. A coastal vignette is an ornament measured by eye; a 500 m
355
- setback is a number somebody will act on. **The first is in scope; the second is not,
356
- and is a non-goal (§11).**
357
-
358
- That decides the method, because an ornament does not need exact offsetting:
359
-
360
- 1. rasterize the polygon (the scanline fill the volumetrics grid already uses);
361
- 2. run an exact Euclidean distance transform (Felzenszwalb & Huttenlocher — separable,
362
- O(n), ~40 lines, no dependency);
363
- 3. sign it by transforming from both sides;
364
- 4. iso-contour at *d* with the marching squares `contour` needs anyway.
365
-
366
- A buffer of *d* is "the set of points at distance *d*", so once a distance field
367
- exists a buffer is a **threshold** — and `repeat` + `fade` is three thresholds of one
368
- field rather than three offset operations.
369
-
370
- **Measured error.** Against analytically exact signed distance, every output vertex
371
- compared to its true distance, across three grid resolutions (errors in cell widths
372
- `h`, and stable across resolutions — so absolute error falls linearly with cell size):
373
-
374
- | Shape | full pipeline mean / max | reconstruction only mean / max |
375
- |---|---|---|
376
- | circle | 0.22 / 0.54 | 0.0003 / 0.0011 |
377
- | coastline | 0.18 / 0.70 | 0.0003 / 0.045 |
378
- | square | 0.64 / 1.42 | 0.003 / 0.007 |
379
- | L-shape | 0.77 / 1.42 | 0.003 / 0.007 |
380
-
381
- Two results matter. **Virtually all the error is the rasterization step** — the
382
- transform is exact and marching squares on a distance field contributes about a
383
- thousandth of a cell, because such a field is locally linear and that is what linear
384
- interpolation reconstructs well. And the 1.42 worst case is √2, the cell diagonal,
385
- reached only at sharp convex corners; coastlines do not have those.
386
-
387
- **Re-measured on the shipped implementation, which is better than the spike** — and
388
- better for a reason worth recording, because the spike's numbers were used to argue the
389
- whole method:
390
-
391
- | Shape | mean | max |
392
- |---|---|---|
393
- | circle | 0.27 | 0.50 |
394
- | coastline | 0.26 | 0.50 |
395
- | square | 0.48 | 0.50 |
396
-
397
- The √2 corner penalty is gone and the bound is **half a cell everywhere, corners
398
- included**. The spike signed its field from one side; the shipped one transforms from
399
- both and subtracts, then shrinks the magnitude by half a cell — because a cell centre
400
- *t* outside the boundary has its nearest inside centre at about *t* + ½, so the raw
401
- difference is biased outward by exactly that. Uncorrected, the zero crossing still lands
402
- correctly (the biases cancel across the boundary) but every level ABOVE zero — which is
403
- every buffer anyone asks for — sits half a cell too far out. It presented as a maximum
404
- vertex error of exactly 1.000 cell widths, and *exactly* is the tell: noise is never
405
- round. The residual is now the rasterisation's own quantisation and nothing else, which
406
- is what the spike predicted and could not reach.
407
-
408
- On paper, at 300 dpi on a 200 mm frame: 0.085 mm cell, so **0.022 mm mean and 0.042 mm
409
- max** — against a 0.088 mm hairline and a ~0.1 mm visual threshold. Comfortably under
410
- half a hairline at the worst point of the worst shape.
411
-
412
- On a 200×150 mm frame that is:
413
-
414
- | | cell | coastline mean | coastline max | sharp corner |
415
- |---|---|---|---|---|
416
- | 300 dpi | 0.085 mm | 0.017 mm | 0.059 mm | 0.12 mm |
417
- | 600 dpi | 0.042 mm | 0.008 mm | 0.030 mm | 0.06 mm |
418
-
419
- A 0.25 pt hairline is 0.088 mm and the eye resolves about 0.1 mm at reading distance,
420
- so at 300 dpi the coastline error is roughly a fifth of visual threshold. Cost,
421
- measured single-threaded: 4.2 M cells and ~100 ms at 300 dpi, 16.7 M cells and ~390 ms
422
- at 600 dpi, one Float32 field being 17 MB and 67 MB respectively. Acceptable for a
423
- freeze, which happens once; an interactive vignette wants a worker.
424
-
425
- **The trade, stated plainly.** An exact clipper has zero error and unbounded failure
426
- modes on exactly the input this feature targets. A distance field has bounded,
427
- measurable, sub-visual error and **cannot** self-intersect, because it never performs
428
- polygon arithmetic. It also adds no dependency and needs no licence review.
429
-
430
- **If the error ever matters**, do not refine the grid — 4× the memory buys 2× the
431
- accuracy. The measurement says the rasterizer is the whole error, so seed the field
432
- with exact point-to-edge distances in a narrow band around the boundary and let the
433
- transform propagate outward: that lands in the right-hand column above, at the same
434
- resolution, for about thirty extra lines.
435
-
436
- **Consequences to plan for.** Features below a cell vanish at rasterization (0.085 mm
437
- on paper at 300 dpi — below a printable line, but a silent change to the data);
438
- areas are only grid-accurate; ring nesting is re-derived from the contour rather than
439
- carried through; and the output carries roughly one vertex per crossed cell edge —
440
- about 2 400 per band across a 200 mm frame — so a faded five-band vignette is ~12 000
441
- vertices of ornament. That last one is why `simplify` and `buffer` belong in the same
442
- phase: the buffer's output is the simplifier's input.
443
-
444
- The four open draw-editing tickets (#43 snapping, #44 angle-constrained, #45 split,
445
- #46 cut with an area-conserving polygonizer) need the same primitives; this seam is
446
- where they should land rather than each bringing its own.
447
-
448
- ## 6. Part C — the vector serializer: `snapshot({ format: "svg" })`
449
-
450
- ### Contract
451
-
452
- Walk the IR in document order; for each layer choose a strategy:
453
-
454
- | Layer kind | Strategy |
455
- |---|---|
456
- | Polygon / path / point / text (`GeoJsonLayer`, `PolygonLayer`, `PathLayer`, `ScatterplotLayer`, `TextLayer`, `IconLayer`, …) | `<path d>` / `<circle>` / `<text>` with the style the accessors resolve |
457
- | Raster (`COGLayer`, `ZarrLayer`, `BitmapLayer`, `TileLayer`, `HillshadeLayer`) | rendered by the GPU into a **raster band**, embedded as `<image>` at the correct stacking position |
458
- | 3D (`Tile3DLayer`, `BIMLayer`, `ScenegraphLayer`, terrain) | raster band |
459
- | a **post-process pass** is present | **the whole map frame** becomes one raster band at `effect-dpi` — such a pass treats the finished frame, and there is no vector equivalent (see below) |
460
-
461
- Consecutive raster layers merge into one band. The "hybrid" is not a fallback: vector
462
- linework over placed relief is how cartographic production has always worked.
463
-
464
- ### Effects: the whole frame rasterises, at a resolution you choose
465
-
466
- A post-process pass treats the **finished frame**, so there is no "some layers". Every
467
- layer is beneath every such pass, and a sheet carrying a finish exports its map frame
468
- as a single raster band.
469
-
470
- **The test is `instanceof PostProcessEffect`**, applied to the resolved effect chain —
471
- not "is there an `<om-effect>` element", and not "does deck have any effects". Both of
472
- those are wrong, in opposite directions, and §13.1 has the reasoning: deck's effect
473
- array also carries effects it installs itself, while the authored element is not the
474
- only way an author supplies a real pass. Legend, crop marks, graticule labels and the rest of the sheet furniture
475
- stay vector, because they are not inside the frame.
476
-
477
- What that actually costs is narrower than it sounds. Almost everything on a map
478
- survives print rasterization; **type does not**, and linework only just — a 0.1 mm
479
- hairline at 300 dpi is one pixel, and a 6 pt label is about 25 pixels tall. So the band
480
- carries its own resolution, `effect-dpi`, independent of the sheet's: raise it to 600
481
- and fine type is genuinely good, at the cost of embedded bytes. This is a knob, not a
482
- wall, and it is the whole mitigation.
483
-
484
- The serializer emits a **dev notice** whenever it rasterises for this reason — naming
485
- the effect, the resolution used, and that removing the effect yields fully editable
486
- linework. An author who wanted vector type and did not realise a finish forecloses it
487
- should be told, not left to discover it in a print shop.
488
-
489
- **Why not the alternatives.** Three were considered and are recorded here so they are
490
- not re-proposed as though new:
491
-
492
- - *SVG filter primitives* (`feColorMatrix`, `feTurbulence`, `feGaussianBlur`, …) would
493
- keep linework vector and carry a finish, and most of the op catalogue maps onto them
494
- at least approximately. **Ruled out, and specifically because this is a print
495
- product:** SVG filters are the format's least reliable corner in print workflows —
496
- editors rasterise them on import and RIP support varies — so the file would look
497
- vector and be flattened downstream at a resolution nobody chose. Rasterising
498
- deliberately, at a stated dpi, is strictly better than that. (`halftone` has no
499
- equivalent regardless, and filter output would not match the GLSL, loosening the SSIM
500
- gate.)
501
- - *Decomposing the effect* — baking pointwise colour maths into the vector fills,
502
- emitting position-dependent texture as one overlay, rasterising only for
503
- neighbourhood ops — is exact for flat fills and would keep type vector. It reaches
504
- only `muted` and `night`; the other five shipped presets contain `edges`, `blur` or
505
- `halftone`, because that pressed-ink line is the look. Shelved, not rejected: if
506
- type-crispness under a finish proves to matter, it lands precisely on `muted`, which
507
- is documented as the type-safe preset. It would be an internal optimisation for
508
- pointwise-only chains, never an authored mode.
509
- - *Per-layer effect scoping* — letting an author place layers above the effect — is
510
- cartographically correct (treating the base and laying clean type over it is how
511
- sheets have always been made) and is the right long-term answer. But it does not
512
- exist in the live renderer, and inventing it for export alone would make one document
513
- mean two things: grained labels on screen, clean labels in the file, contradicting
514
- this document's own parity criterion. If it is wanted it belongs in the renderer, as
515
- layer grouping with its own pass — at which point the serializer needs no effect
516
- policy at all, and this section shrinks to a sentence.
517
-
518
- ### Style mapping, and the gate that keeps it honest
519
-
520
- deck's blending, antialiasing and dash rendering will not match SVG's exactly. The
521
- mapping is explicit (fill/stroke/opacity, `dash` → `stroke-dasharray` in line-width
522
- units, `line-width-units` pixels vs metres, `visibleZoomRange`, `opacity`) and a
523
- **visual-diff gate** compares the SVG rasterised by the browser against the GPU
524
- capture of the same fixture within an SSIM threshold. Where they must diverge, the
525
- divergence is documented, not discovered.
526
-
527
- ### Text — parity by construction
528
-
529
- `src/cartograph/textlayout.ts` already states the rule: compute line boxes once and
530
- have every renderer draw *those*, because two measurers disagree at the margins. The
531
- serializer follows it. Labels are emitted as real `<text>` with the same measured
532
- positions; the font family is carried, and when a font URL is known it is embedded via
533
- `@font-face` so the sheet renders identically off-machine. Outline-to-path (glyphs as
534
- `<path>`) is a later option for print shops that reject embedded fonts.
535
-
536
- **Decluttering caveat, and why it is a feature.** `CollisionFilterExtension` decides
537
- survivors on the GPU at a resolution that scales with capture ratio (its framebuffer
538
- is canvas pixels ÷ 2), so the serializer *cannot* ask deck which labels it hid. The
539
- serializer runs its own **CPU greedy pass by priority over measured boxes** —
540
- deterministic, resolution-independent, and the natural home for the gallery-grade
541
- placement work (candidate positions, leader lines, text on a path) that the GPU path
542
- has no room for. Deck-side collision remains the interactive preview; the CPU pass is
543
- the print truth.
544
-
545
- ### Feature-count guard
546
-
547
- A print sheet is thousands of features; an SVG with half a million paths is unusable.
548
- Geometry is clipped to the frame bounds before emission (also removes the giant-path
549
- problem), and above a configurable count the serializer emits a dev notice and offers
550
- `simplify`. Below the count, it just works.
551
-
552
- ### Bundle
553
-
554
- The serializer chunk pins a "never downloads it" browser test, like
555
- `e2e/effects.spec.ts` does for `/post-process/ops`. `dev/assert-bundle-cdn-safe.mjs`
556
- gains the assertion that no serializer symbol appears in the core chunk.
557
-
558
- ## 7. Part D — the cartograph: freeze to vector
559
-
560
- Today freezing a live frame calls `snapshot({scale})` and stores a PNG data URL
561
- (`src/cartograph/elements/om-frame.ts:556`); a static frame is a georeferenced `<img>`
562
- placed by `crs` + `corners` (`docs/cartograph.md`, "`<om-frame>` mode=static").
563
-
564
- A vector static frame is an inline `<svg>` child placed by the **same** `crs` +
565
- `corners`, with the raster bands embedded inside it. The georef model does not change;
566
- the plane view makes it exact (§4). Print CSS, bleed, crop marks and the atlas treat it
567
- as they treat the `<img>`. The producer-written legend rows for static frames carry
568
- over unchanged.
569
-
570
- Downstream: `nika-agent`'s cartograph export path embeds frame rasters into the
571
- standalone document; it needs a branch for an inline `<svg>` with embedded `<image>`
572
- data URIs. That is its ticket, filed when Phase 4 lands.
573
-
574
- `docs/cartograph.md`'s non-goals line — *"SVG export; … projections other than Web
575
- Mercator on live frames; automatic label placement"* — was right for a raster-sheet
576
- product. Phases 1, 3 and 4 retire the first two deliberately; the third is narrowed to
577
- "on the GPU path" once the CPU pass exists. The line is rewritten in Phase 7, not
578
- silently contradicted.
579
-
580
- ## 8. Caveat register
581
-
582
- Everything learned on the way here that a builder would otherwise rediscover.
583
-
584
- | # | Caveat | Decision |
585
- |---|---|---|
586
- | C1 | fp32 cannot resolve METRES at projected magnitudes — measured 0.48 m at a 500 km easting and **5.7 m** at a 6 000 km northing, against 1.9 mm at 2 km from an origin | local origin, fixed per map, written into georef. "Jitter" understated it: at a real northing this is geometry in the wrong place, not shimmer |
587
- | C2 | `FlyToInterpolator` is Mercator-only | plane view uses the existing `LinearInterpolator` branch |
588
- | C3 | `HillshadeLayer` samples Mercator `{z}/{x}/{y}` tiles, so **that layer** is Mercator-only | A limit on the keyless-global-tiles convenience, NOT on relief. `shading="hillshade"` on a raster is projection-independent already (§4a), so a projected sheet can carry relief from Phase 1. The warp (Phase 6) restores the keyless path; validation error with the fix meanwhile |
589
- | C3b | Relief frozen from a Mercator frame into a projected sheet is an **affine approximation** | Sound over a city, wrong over a continent — the Mercator↔target difference is not affine. Bound the interim workaround by extent, or use a DEM in the sheet's own CRS (§4a) |
590
- | C4 | A post-process pass cannot be vectorised, and treats the whole frame, so there is no partial answer | the map frame becomes one raster band at its own `effect-dpi` (600 keeps fine type good), with a dev notice naming the trade. Triggered by `instanceof PostProcessEffect` over the resolved chain — not by the authored element, not by deck having effects (§13.1). SVG filters ruled out on print reliability; decomposition shelved; per-layer scoping is a renderer feature, not an export policy (§6) |
591
- | C5 | GPU collision is resolution-dependent and unqueryable | serializer runs its own CPU pass; deck collision stays preview-only — which means the two legitimately keep different label sets, so §10 excepts labels from the parity bar and §13.2 records the choice |
592
- | C6 | Two text measurers disagree | one measured layout (`textlayout.ts` rule); fonts embedded when known |
593
- | C7 | deck vs SVG rendering differences | explicit mapping + SSIM gate |
594
- | C8 | Random scatter breaks remotion determinism | seeded `dot-density`, default seed |
595
- | C9 | Robust polygon offsetting is where geometry libraries die | sidestepped, not solved: `buffer` is scoped as a cartographic ornament and built on a distance field, which cannot self-intersect because it never does polygon arithmetic (§5). Exact offsetting is a non-goal |
596
- | C10 | Measuring in projected metres is wrong on a conic | unproject then geodesic |
597
- | C11 | Camera model fork | authored camera stays geographic; translation at the boundary |
598
- | C12 | Lazy-core rule | nothing runtime-dependent lives in `src/cartograph/`; each new chunk gets a "never downloads it" test and a bundle assertion |
599
- | C13 | `docs/` ships to the public mirror | this document is public; no internal detail, no cross-repo hyperlinks |
600
- | C14 | Downstream pins are exact | native parity and the remotion battery run against each release; plane-view stories go into remotion's fixtures |
601
- | C15 | Reports of "still broken" may be a stale dep cache | every phase's gate runs in a real browser with a negative control (the spec against the previous version) |
602
- | C16 | Millimetre geometry cannot be re-resolved per frame the way a millimetre uniform can | transforms resolve against a reference scale, fixed for the map's life; open question §12.3 |
603
- | C17 | Geographic north is not sheet-up on a projection — ±17° across an Albers CONUS sheet | `sun-azimuth` needs a stated datum. Default **sheet north** (constant apparent lighting, the relief-atlas convention), geographic as an opt-in, corrected per tile through `gridConvergence()` (§4a) |
604
- | C18 | Positional ACCESSORS are not reached by ingest projection | five of them, wrapped at the layer-construction site and memoised per `(accessor, plane)` — an accessor's cache key is its deck `updateTrigger`, so a wrapper minted per rebuild would silently recompute every attribute every frame. A schema-enumerating test stops the list rotting (§4) |
605
- | C19 | Spatial-index layers (H3, S2, geohash, quadkey) build geometry inside deck from a token | no coordinate to intercept, so a limit rather than a fix: validation error naming the conversion to polygons (§4) |
606
- | C20 | `MapController` asserts on a viewState with no longitude/latitude | a plane view takes `OrthographicController`, with only the overrides that mean anything without a third dimension. An `OrthographicController` also normalises its initial viewState DURING `new Deck()`, so the controlled-viewState echo fires once before the assignment lands |
607
- | C21 | A projected map cannot build its renderer synchronously | proj4 is lazy and the view type depends on its answer, so Deck creation defers exactly as the basemap adapter already defers on its chunk — `isReady()` stays false and `om-map-ready` waits, which is what "the renderer finished async init" already meant. Layers reconciled before the projection lands are REBUILT, never replayed: they were prepared for a Mercator world |
608
- | C22 | A transformed layer has nothing honest to show on its first pass | the primitives are a lazy chunk and ingest is synchronous, so the first parse resolves to the EMPTY placeholder — the same Q6 state a URL-backed layer sits in before its fetch lands — and the chunk's completion triggers the reparse. Emitting the untransformed coastline and smoothing it a frame later is a flash of the wrong map, not progressive loading (§5) |
609
- | C23 | `dot-density` replaces the row set rather than rewriting geometry | it is the one primitive whose output is a different number of features, so every accessor the author already wrote has to keep working — each dot carries its source row's own `properties`. Dots are distributed across a MultiPolygon BY AREA, or a state's mainland and its offshore island get the same count; rejection sampling is budgeted, because an unbounded loop on a panhandle is a hung tab |
610
- | C24 | A plane view's VIEWPORT zoom is about -12, and deck's TileLayer gates on it | `minZoom: 0` is deck's default and it compares the viewport's own zoom, which is in plane units — a metre against a sixty-kilometre Mercator world unit. Every tile was selected, fetched and decoded, and `renderSubLayers` was never called: a blank sheet, no error, no warning. The plane path passes `minZoom: -Infinity` and applies the PYRAMID's zoom range inside the tileset, where it means something |
611
- | C25 | A tile's cull box and its geographic extent are different facts | deck culls `tile.bbox` against `viewport.unproject()` of the screen rect — plane metres here — so a geographic bbox in that slot compares degrees against metres, never overlaps, and every tile is invisible with nothing logged. The plane tileset returns BOTH: `bbox` as a plane-metre envelope (sampled along the tile's edges, since a conic bows them) and `lngLatBbox` for the warp to project |
612
- | C26 | Deck's `log2(512 / tileSize)` term is not optional | leaving it out of the plane's zoom derivation chose a pyramid level one coarser than the identical Mercator map — half the relief resolution, rendering perfectly, looking only slightly soft. Found by comparing against a Mercator control, which is now a test: a projected sheet must request the same DEM zooms as the same document without `crs` |
613
- | C27 | deck has no single accessor vocabulary, and the wrong guess renders plausibly | `PathLayer` and `LineLayer` declare `getColor`/`getWidth`; `GeoJsonLayer`, `PolygonLayer` and `ScatterplotLayer` declare `getLineColor`/`getLineWidth`; `ArcLayer` declares `getSourceColor`. Reading only the GeoJSON names exported every path layer as a black hairline — deck's own defaults, faithfully applied, and nothing like the authored sheet. The serializer tries each family's names in order, enumerated from the registry rather than remembered, and a test pins each one |
614
- | C28 | A serializer that throws loses the sheet, not the row | an authored expression that fails on one feature must cost that feature, exactly as it does in the renderer, which catches accessor errors itself. Otherwise a document that draws on screen refuses to export, and the author has no way to see which row did it. The vector path had this tolerance from the start and the text path did not; the asymmetry surfaced the first time a fixture had a wrong expression |
615
- | C29 | Most of this library's maps have no GeoJSON geometry at all | `<om-layer type="ScatterplotLayer" get-position="[$lng,$lat]">` over flat rows is the house style, and those coordinates exist ONLY as a compiled accessor's return value. A serializer reading `row.geometry` emitted a correctly-formed, entirely blank sheet for every one of them, with no error anywhere — found by the first fixture whose only layer was authored that way. Geometry now falls back to the positional accessors (`getPolygon`, then `getPath`, then a source/target pair, then `getPosition`), richest first |
616
- | C30 | Freezing a frame whose projection has not resolved must REFUSE | a projected live frame has no corners until proj4 lands, and they are not merely unknown — they are about to change. Freezing there would place the sheet by corners that were wrong, and a sheet placed wrong looks exactly like a sheet placed right, which is the failure this document exists to avoid. `freeze()` returns false and writes nothing; the caller waits for `ready` |
617
- | C31 | A signed distance field needs a half-cell correction, or every buffer is too wide | transforming from one side only, or from both without the correction, biases every non-zero level outward by half a cell. The zero crossing stays right, so a *validity* check passes and only the thing anyone actually draws is wrong. Diagnosed from a maximum vertex error of exactly 1.000 cell widths — noise is never round (§5) |
618
- | C32 | Marching-squares segments cannot be chained by direction | the sixteen cases only agree on orientation if every one of them was written to, including the two saddles where "agree" is itself ambiguous. A start→end chainer broke each contour into a dozen fragments — a dashed vignette, which reads as a broken field rather than broken bookkeeping. Matching at EITHER endpoint removes the class |
619
- | C33 | `contour` sources geometry, so two of the stage's own rules invert | its layer legitimately has ZERO rows (the transform fills them, as `dot-density` replaces them), and zero rows otherwise means "not fetched yet"; and it is the one step that FETCHES, which made the whole chain async. Both are stated at the seam rather than special-cased downstream |
620
- | C34 | A probe viewport must copy the LIVE view's `flipY` | deck's `OrthographicViewport` defaults to `flipY: true`; the plane view renders `flipY: false`. A probe built without it returned the frame's corners vertically MIRRORED — graticule labelled 50° at the bottom, north arrow pointing south, a frozen sheet placed inverted — while the map on screen stayed perfectly correct. It survived an entire phase of tests because those compared corners to themselves, where a flip cancels. It took composing a real plate to see |
621
- | C35 | `blend="multiply"` multiplied the shade into the HEIGHTFIELD | the composite branch was written for the raster path, where the layer's texture is a colormap. On the tiled layer that texture is the r32float heightfield — height in red, nothing in green or blue — so a multiply-blended relief painted whole sheets RED. `composite` now has three modes, because the two entry points genuinely do not sample the same thing, and the third emits the shade alone for the GL blend to apply |
622
- | C36 | A sourcing chain's cache has nothing stable to key on | the transform cache is a WeakMap keyed by the source data, which is right for a layer that has some. `contour` has none — its rows are the empty placeholder, and `[]` is a fresh array every parse — so every reconcile missed and re-ran, re-fetching every DEM tile. 112 requests where the cover is 16. It anchors on the layer's own identity instead |
623
- | C37 | A warped tile cover is one tile short at the corners | a tile's extent is a lng/lat rectangle whose image in the plane is a CURVED quadrilateral, so the tiles covering a plane rect's lng/lat box do not quite tile the rect — and the shortfall is where curvature is greatest, at the corners. It presented as an unshaded wedge with every selected tile loaded: a cover honestly computed and geometrically short. One tile of margin, and a test that samples the whole boundary rather than the four corners |
624
- | C38 | Every failure path here was only ever exercised with inputs that succeed | review found nine defects and the pattern behind them is one sentence: the phases tested the happy path of each seam and the unhappy path of none. An unresolvable `crs` left the map HANGING (deck is never built, so `isReady()` stays false, `om-map-ready` never fires and the page's own `await` never returns); `this.deck!` dereferenced an undefined deck for the whole proj4 window; a frame's `pendingLiveCrs` cleared only on success, so one unresolvable CRS wedged it permanently. None of these needed a new mechanism to find — only a fixture that fails |
625
- | C39 | A failed projection must NOT fall back to Web Mercator | tempting, because the page stays alive. Rejected: a sheet drawn in the wrong projection looks exactly like a sheet drawn in the right one, which is the failure class this entire document exists to avoid. Readiness settles so nothing hangs, the error is reported, and nothing is drawn |
626
- | C40 | A serializer must carry deck's ACCESSOR defaults, because the registry does not | the registry materialises scalar defaults (`sizeScale: 1`) but never an accessor's (`getSize: 32`), so reading `sizeScale` as the size's fallback exported every unstyled label at `font-size="1"` — invisible in the file, correct on screen, and the declutter pass measured the same wrong number so nothing was suppressed either. `getPixelOffset` was dropped entirely, collapsing every offset label onto the symbol it labels. Both are the export disagreeing with the screen, which is the one property the serializer exists to hold |
627
- | C41 | A LineString's coordinates are STRUCTURALLY a polygon ring | nothing in the coordinate tree can tell them apart, so `buffer` scanline-filled an open line as though its ends joined and seeded the field from a polygon present nowhere in the data. Measured on three sides of a square: 5 476 of 10 404 cells filled, and the square's own centre reported as 10 950 m INSIDE the phantom. Refused by geometry TYPE, which is the only thing that can distinguish them; unclosed polygon rings are CLOSED rather than rejected, because producers in the wild emit them and every other layer draws them |
628
- | C42 | The controller is set in FIVE places, and four of them did not know about the plane | Deck creation plus `setDrawCapture`, `setDragPan`, `setMaxPitch` and `setMinZoom`, each building a `MapController` unconditionally — so the first draw-tool activation on a projected map swapped a Mercator controller onto an orthographic viewState, and `MapState`'s constructor asserts on one with no longitude. C20 recorded exactly this failure for Deck creation; it came back through the setters. One `currentController()` now serves all five, and `minZoom` gets the geographic→plane conversion `maxZoom` already had |
629
- | C43 | A plane rect's extremes are not always on its boundary | edge-only sampling assumed a conic's extreme latitude sits mid-edge — true away from the apex, false for a sheet CONTAINING a pole (the pole is interior, and a 6 000 km polar plate's bounds bottomed out at −62.9° against a true −90°) and false across the ANTIMERIDIAN (longitudes wrap, min/max collapses to the whole world, the cover blows its budget and falls back three pyramid levels). Interior sampling plus longitude unwrapping fixes both. What it CANNOT fix: Web Mercator stops at ±85.05°, so a polar cap has no tiles at any zoom — a limit of the source, now stated |
630
- | C44 | The vector serializer requires `basemap="none"`, like its neighbours | `captureBand` goes through `snapshot()`, which composites a MapLibre basemap into EVERY band — so a map ordered relief → roads → imagery exported the roads and then covered them with the second band's opaque basemap. Refused rather than repaired, because `<om-effect>` and `crs` already carry the same requirement and a third behaviour would be one more rule to remember. Imagery that bands correctly is an ordinary deck layer |
631
- | C45 | A ceiling has to be sized against what is actually allocated | `signedDistanceField` holds 26 bytes per cell across five simultaneous arrays, so the 40 M-cell buffer ceiling was 1.04 GB — the tab-wedging it exists to prevent rather than a guard against it. 4 M cells is ~104 MB. The same arithmetic is worth doing wherever a guard is stated in units that are not bytes |
632
-
633
- ## 9. Phases
634
-
635
- Each independently shippable, each with its own doc-sync per the repo checklist.
636
-
637
- **Order is a recommendation, and one ordering decision is already made.** The warp
638
- (Phase 6) carries the capability a cartographic sheet most wants — relief and contours
639
- on a projected map — and it was originally last, behind the transforms and the
640
- serializer, on the assumption that client-side reprojection was the riskiest thing
641
- here. The measurement in Phase 6 says otherwise: sub-pixel at 8×8 subdivision, ~64
642
- quads per tile. So **spike the warp immediately after Phase 1**, whose plane view is
643
- its only prerequisite — the expensive question is already answered, and what remains is
644
- a day of plumbing against a real projection. If the spike holds, running the warp ahead
645
- of Phase 3 is reasonable: a projected sheet with relief is a more compelling first
646
- release than a projected sheet without it, and the serializer does not care which order
647
- it arrives in.
648
-
649
- **Phase 0 — projection core — IMPLEMENTED 2026-09-23** (`src/projection.ts`). Unify `georef.ts`'s `CrsForward`
650
- and `crs.ts`; forward/inverse/batch; local origin; `registerCrs`. Gate: fixtures for
651
- BNG, UTM 32N, Albers 5070 and Swiss LV95 agree with proj reference values to 1e-6
652
- relative, headless.
653
-
654
- **Phase 1 — plane view — IMPLEMENTED 2026-09-23**, affine frame georef included. `<om-map crs>`; ingest projection; view swap; camera
655
- translation; events; measure/scale bar/graticule checks; the limits table as
656
- validator rules; affine frame georef. Gate (real GPU): an Albers US sheet with
657
- `basemap="none"` — a known lng/lat lands within 1 px of the CPU prediction,
658
- parallels visibly curve, `getCamera()` round-trips, no jitter at zoom 14 near
659
- (500 000, 6 000 000), `snapshot({scale: 3.125})` renders at scale, and the manifest
660
- validates with exactly the listed limits and no others.
661
-
662
- **Phase 2 — transforms v1 — IMPLEMENTED 2026-09-23.** The `<om-transform>` seam, mm units, `simplify`,
663
- `smooth`, `dot-density`. Gate: seed determinism at 1× and 4×; a transformed layer's
664
- legend and `anchor="surface"` follow the new shape; and **the renderer and the
665
- serializer receive identical transformed geometry**, asserted by hashing the coordinate
666
- arrays rather than the IR — `LayerIR.props` holds compiled accessor *functions*, which
667
- are not comparable, so "byte-identical IR" (as an earlier draft put it) is not a
668
- property anything can test. Hash both paths: the shared in-process result, and a
669
- re-parse of the same document, since the second is what proves a transform is the pure
670
- function §5 claims and not quietly dependent on call order or state.
671
-
672
- **Phase 3 — vector serializer v1 — IMPLEMENTED 2026-09-23.** Vector strategies, raster bands, effect policy,
673
- style mapping, SSIM gate, text parity, CPU declutter, feature guard, bundle assertion.
674
- Gate: the print-finish example and an Albers sheet round-trip within threshold; a map
675
- that never asks for SVG never fetches the chunk; and the effect path is exercised both
676
- ways — a sheet with a finish emits one raster band plus vector furniture and raises the
677
- notice, the same sheet without the finish emits no band at all, and `effect-dpi`
678
- demonstrably changes the band's pixel dimensions rather than only its scaling. The
679
- trigger is pinned from both sides (§13.1): a map with a decluttering layer and no
680
- finish must emit **vector**, and a map whose only finish arrived through
681
- `setEffects()` must emit a **raster band**.
682
-
683
- **All of it landed** (`e2e/serialize.spec.ts`, `src/serialize/`). SSIM between the GPU
684
- capture and the browser-rasterised SVG measured **0.97** on a Mercator sheet and again
685
- on the same document with `crs="EPSG:5070"`, against a threshold of 0.9 — with an empty
686
- SVG as the negative control, which scores below it, so the gate is known to be able to
687
- fail. `effect-dpi` 96 → 288 widens the embedded band by more than 2.5×, so it changes
688
- pixels rather than scaling. The bundle assertion is stronger than "absent from the core
689
- chunk": the serializer's symbols must appear in **exactly one** chunk, which also
690
- catches the case where a future static import quietly duplicates it into two.
691
-
692
- **Phase 4 — freeze to vector — IMPLEMENTED 2026-09-23.** `<om-frame>` stores an inline `<svg>`; print CSS,
693
- bleed, crop marks, atlas; validator; downstream ticket for `nika-agent`'s exporter.
694
- Gate: a frozen vector sheet opens with no runtime, prints at 300 dpi with crisp
695
- linework, and its georef matches the live frame's to 1e-6.
696
-
697
- **Landed as `frame.freeze({format})`** (`e2e/freeze-vector.spec.ts`). The no-runtime
698
- claim is checked against the SAVED MARKUP on a page that imports nothing and defines no
699
- custom elements: the picture is still there, the corners are still on the attribute, and
700
- the stylesheet alone lays it out at the authored size. Corners round-trip to 1e-6
701
- degrees and the frame's INTERIOR lands **3.0e-6 mm** from where the live frame put it —
702
- the floor being the corners written with eight decimal places, about 1.1 mm of ground,
703
- which is 0.02 mm of paper at 1:50 000.
704
-
705
- Print needs no swap at all, and that is the point: `enterPrintMode` exists because a
706
- WebGL canvas prints blank, and inline vector has no such problem. The CANVAS exporter
707
- still needs pixels — `drawImage` cannot take an `<svg>` element — so a frozen vector
708
- frame rasterises itself from its own markup at the export's resolution, which is a
709
- different thing from being stored as a bitmap.
710
-
711
- **Phase 5 — the raster-derived transforms — IMPLEMENTED 2026-09-23.** `contour` from DEM (Mercator), then
712
- `buffer` with `repeat` + `fade` on the shared distance field (§5). The two are one
713
- piece of machinery — rasterize, transform, iso-contour — so `contour` lands first and
714
- `buffer` is a second threshold over it. Gate: the coastal vignette example; buffered
715
- output within the measured error of analytic truth on a circle and a square fixture;
716
- no self-intersection artefacts on a coastline fixture (which the method makes
717
- structurally impossible, so the test is a guard against regressing to another one);
718
- and a faded five-band vignette simplifies to a sane vertex count.
719
-
720
- **And a real coastline at print resolution.** The error figures in §5 were measured
721
- against synthetic shapes — a circle, a square, an L, and a pseudo-coastline built from
722
- summed harmonics. The error model should carry over, since it is grid-proportional and
723
- shape-independent except at sharp convex corners, but two things are only knowable
724
- against real data: whether a genuine coastline's small islands and inlets survive
725
- rasterization at the chosen cell size in numbers the author would accept, and what the
726
- vertex count actually comes to once a fjorded shoreline is contoured rather than a
727
- smooth analytic curve. Both decide whether the default grid resolution is right. So the
728
- gate takes a real shoreline extract at 300 dpi and reports island survival, vertex
729
- count before and after `simplify`, and the band's deviation from a reference offset —
730
- with the numbers recorded in this document, replacing the synthetic ones as the
731
- published figures.
732
-
733
- **Phase 6 — raster in the plane: the warp — IMPLEMENTED 2026-09-23** (hillshade; `contour` waits for Phase 5). Lifts C3, and is the phase that decides
734
- whether a projected sheet can carry relief at all.
735
-
736
- The Mercator tiles covering the frame (`loadHeightfieldForBounds` already fetches and
737
- decodes them seam-correctly) are drawn as **subdivided meshes** whose vertices are
738
- projected on the CPU through `projection.ts`; the GPU interpolates the texture across
739
- each warped quad. No projection math in GLSL — the same technique deck's `_GlobeView`
740
- and MapLibre's globe use for raster tiles. The same warp pass is what a COG in another
741
- CRS or a raster basemap needs in a plane view, so it is built once.
742
-
743
- **Shade first, warp second** (§4a). The existing hillshade shader runs in the tile's own
744
- grid, exactly as it does today, and the warp moves the *shaded* result. An earlier draft
745
- had it the other way — warp heights into an offscreen plane-space heightfield, then
746
- shade there — which needs a float render target, requires the plane's anisotropic scale
747
- factors, and takes a gradient over resampled data, which is where a derivative finds the
748
- resampler. Shading first needs none of that and changes no shader. `contour` gains more
749
- still: march squares in the source grid and **project the resulting polylines**, which
750
- is exact, rather than contouring a warped raster.
751
-
752
- ### How much subdivision, measured
753
-
754
- The obvious fear about client-side reprojection is that a piecewise-bilinear warp is
755
- too coarse. Measured — max deviation between the interpolated and the true projected
756
- position, in output pixels, for an N×N subdivided Mercator tile:
757
-
758
- | Projection | z=3, N=8 | z=5, N=4 | z=8, N=2 |
759
- |---|---|---|---|
760
- | Albers CONUS (5070) | 0.40 | 0.26 | 0.11 |
761
- | British National Grid (27700) | 0.45 | 0.31 | 0.15 |
762
- | Swiss LV95 (2056) | 0.34 | 0.28 | 0.14 |
763
- | Lambert 93 (2154) | 0.34 | 0.28 | 0.14 |
764
-
765
- Re-measured by the shipped harness (`src/plane-warp.test.ts`, headless, no GPU), which
766
- samples strictly INSIDE each cell — the corners are exact by construction, so a sampler
767
- that hit them would report zero and prove nothing. The same test asserts the 1/N² fall
768
- and keeps an un-subdivided quad as its negative control: at z=3 that is 2.6 px, plainly
769
- wrong, which is what makes 0.40 px mean something. Lambert 93 had to be added to the
770
- bundled CRS table to measure it at all, so it is now authorable like the other three.
771
-
772
- Error falls as 1/N², so it is **sub-pixel at 8×8 even at continental zoom** — 64 quads
773
- and ~81 projection calls per tile, worst case, against a viewport of a few dozen tiles.
774
- The geometric risk is not the risk.
775
-
776
- **The subdivision criterion is projection curvature, not capture ratio.** An earlier
777
- draft had the warp grid follow the capture ratio; that is a sampling concern, while
778
- what actually drives subdivision is how much the projection bends across a tile, which
779
- is a function of **zoom**. Capture ratio enters only through what "half a pixel" means,
780
- and only as `N ∝ √ratio`. The rule is: subdivide until the deviation is under half an
781
- output pixel, with the table above as the starting values.
782
-
783
- ### Two things that do not follow, corrected
784
-
785
- *The per-tile apron stays, and is what makes the warp seamless.* An earlier draft had
786
- it becoming unnecessary — one continuous texture, no tile boundaries. It does not
787
- follow: while warping, pixels near a source tile's edge sample that tile near its edge,
788
- and with clamp-to-edge they interpolate against nothing. Both sides of every source
789
- boundary acquire a half-texel resampling kink, and a hillshade is a derivative, so it
790
- finds exactly that. Sampling the apron-padded texture removes it. `composeApron` is
791
- therefore reused on this path, not retired.
792
-
793
- *Plane ground scale is not uniform, which is one more reason to shade before warping.*
794
- An earlier draft treated it as uniform, dropping the cos φ correction. That holds for a
795
- conformal projection and fails for an equal-area one — measured local scale factors for
796
- Albers CONUS:
797
-
798
- | latitude | k east | k north | anisotropy |
799
- |---|---|---|---|
800
- | 25°N (south edge) | 1.0128 | 0.9831 | 3.0% |
801
- | 37°N | 0.9916 | 1.0066 | 1.5% |
802
- | 49°N (north edge) | 1.0144 | 0.9867 | 2.8% |
803
-
804
- Shading in the source grid sidesteps this entirely: the tile's own scale is already
805
- known and already correct. The figures stand as the reason **not** to shade in plane
806
- space — and if that order is ever revisited, the shipped shader takes `metresPerTexel`
807
- as a **vec2** (added for the geographic-raster case), so the anisotropy is expressible
808
- without a shader change.
809
-
810
- ### What is actually hard here
811
-
812
- Not the geometry. Two structural things:
813
-
814
- - **A third height-source path**, alongside tiled-Mercator and raster-in-its-own-CRS.
815
- The shader and the apron are shared, which is what keeps this honest — "one shader,
816
- one apron, every entry point" is the discipline that made relief coherent in the
817
- first place, and the warp must join it rather than fork it.
818
- - **Per-tile source zoom.** A sheet spanning Alaska to Florida needs different Mercator
819
- source zooms at different latitudes to hold constant plane resolution, so the choice
820
- is per tile, not per frame.
821
-
822
- Resampling twice also adds slight smoothing; the warp target's resolution follows the
823
- capture ratio for the same reason the grain and the collision pass do.
824
-
825
- Gate: an Albers US sheet with hillshade and contours matches a QGIS render of the same
826
- DEM within threshold; no seam at any source-tile boundary; relief detail scales with
827
- `snapshot({scale})`; the subdivision rule is asserted directly — deviation stays under
828
- half an output pixel at z=3, 5 and 8, a headless test needing no GPU; and the azimuth
829
- datum (§4a, §12.4) is visible in the output, with sheet-north illumination constant from
830
- one edge of a CONUS sheet to the other and geographic-north demonstrably not.
831
-
832
- **What the gate actually holds, and one item it does not.** Landed as
833
- `e2e/plane-relief.spec.ts` against the shared synthetic DEM: the sheet inks and carries
834
- relief; it is a DIFFERENT picture from the same document without `crs` (15.9 luminance
835
- levels of 255); no source-tile boundary spikes out of the crowd; the document validates
836
- clean; the azimuth datum changes the projected picture and changes the Mercator one by
837
- EXACTLY zero, against a run-to-run noise floor of exactly zero. Plus the headless
838
- subdivision assertions above.
839
-
840
- Two substitutions, stated rather than quietly made. **A QGIS reference render** is not
841
- in the harness; the Mercator control plays that role — same DEM, same camera, same sun,
842
- one attribute apart — which catches a wrong projection but not a wrong projection
843
- *library*, a risk `projection.ts`'s own definitional-anchor fixtures carry instead.
844
- **"Relief detail scales with `snapshot({scale})`" is not asserted at the pixel level**:
845
- the Mercator control fails it identically, because a scaled capture returns before the
846
- deeper tiles it just requested arrive, so measuring it would report on the fixture's
847
- settling rather than on the warp. That claim is held by `captureZoomOffset`'s unit test,
848
- `subdivisionFor`'s √ratio term, and the tile-zoom parity test — which is the part the
849
- warp can actually get wrong, and did (C26).
850
-
851
- **Phase 6b — native-CRS pyramids (deferred until asked for).** `TileMatrixSet` from
852
- the registry: where a provider serves tiles already in the target grid (OS Terrain in
853
- BNG, swisstopo in LV95) they would be consumed directly, with no warp and no second
854
- resample. This was Phase 6's "Tier 1" and is now separated and deprioritised, because
855
- the measurement above changed its value: it is a whole alternative tiling scheme whose
856
- only advantage over the warp is avoiding one resample, for the handful of national
857
- grids where such a pyramid exists — and the warp is general, covers every projection,
858
- and is cheap. Worth building when a user asks for a specific grid by name; not worth
859
- building on speculation. (It remains the route to #2 step 2's "tiles within 1 px of
860
- QGIS" acceptance, if that is ever wanted literally.)
861
-
862
- **Phase 7 — surfaces and release.** Examples, `docs/`, README, skill + `llms.txt`,
863
- `html-data.ts`, `dev/build-public.ts` + `npm run test:public`, architecture
864
- traceability, CHANGELOG, the rewritten non-goals line, downstream pins with the
865
- remotion battery dispatched **before** the pin moves.
866
-
867
- ## 10. Acceptance (the document-level bar)
868
-
869
- - [ ] A sheet in Albers or BNG with curved graticule, smoothed coastline, dot-density
870
- thematic layer and a coastal vignette, frozen to an editable vector frame, opens
871
- with no runtime and prints crisp at 300 dpi.
872
- - [ ] The same document renders identically in the interactive frame and in the
873
- vector frame within the SSIM threshold, raster bands included — **labels
874
- excepted**, and deliberately: the serializer declutters on the CPU while the
875
- preview declutters on the GPU, so the two legitimately keep different label sets
876
- (C5, §13.2). The comparison masks label glyphs; that exception is the one place
877
- this bar is not "identical", and it is a decision rather than a tolerance.
878
- - [ ] Every limit is a validator error with a fix; nothing is silently inert.
879
- - [ ] No new eager weight: three lazy chunks — transforms, serializer, warp — each
880
- pinned by a "never downloads it" browser test and a bundle assertion.
881
- - [ ] Stories and `seek()` on a projected map need no document changes.
882
- - [ ] `onlymap-remotion`'s battery passes on a projected, transformed story.
883
-
884
- ## 11. Non-goals
885
-
886
- - A second interactive renderer (§1).
887
- - GPU shader projection — #2 step 4, still gated on live CRS switching.
888
- - Globe — #2 step 3, unchanged.
889
- - SVG picking or interaction; the vector frame is output, not a UI.
890
- - Hyphenation, bidi, or paragraph typography in labels.
891
- - **Exact polygon offsetting** — a measured setback, a catchment, any buffer whose
892
- *area* is the answer. `buffer` here is an ornament (§5); the boundary is
893
- queryability, not the arithmetic, and it is the same boundary shaded relief was
894
- admitted under.
895
- - Sheet annotations (callouts, leaders, connectors) — a separate design (`<om-arrow>`),
896
- cartograph-only and independent of this plan.
897
-
898
- ## 12. Open questions (maintainer input)
899
-
900
- 1. **Font policy for vector frames:** embed via `@font-face` when a URL is known and
901
- otherwise carry the family name, or convert every glyph to a path? Proposed: embed
902
- when known, family otherwise, outline-to-path as an explicit option.
903
- 2. *(Resolved — see §6.)* **Effects on a vector sheet.** The map frame rasterises as
904
- one band at its own `effect-dpi`; the sheet's furniture stays vector; a dev notice
905
- names the trade. SVG filters were ruled out on print reliability, effect
906
- decomposition shelved as a possible later optimisation for pointwise-only chains,
907
- and per-layer scoping identified as a live-renderer feature rather than an export
908
- policy. The one thing left to pick is the **default** for `effect-dpi`: 300 matches
909
- the sheet and keeps files small; 600 keeps fine type good and roughly quadruples the
910
- embedded bytes. Proposed: **600**, on the grounds that anyone exporting vector is
911
- exporting for print quality, and a surprising file size is easier to discover and
912
- fix than surprising soft type.
913
- 3. *(Resolved — taken as proposed, and open to being overturned.)* **What scale do
914
- millimetre transforms resolve against?** (§5 Units, C16.) The third candidate
915
- shipped: a **declared reference scale**. A frame supplies its own from the georef; a
916
- live map declares `reference-scale="1:50000"` (or `"50m"`, the ground metres one
917
- millimetre stands for); a map with neither gets a validation error the moment a
918
- transform asks for millimetres, naming the fix. The two rejected options both fail
919
- quietly — freezing at the initial scale reveals over-simplified geometry on zoom-in,
920
- and per-zoom-bucket re-running puts geometry work on the pan path and destroys the
921
- cache key. **Ground units are the escape hatch that keeps this from being a wall:**
922
- `tolerance="50m"` needs no scale and says exactly what it means, which is what makes
923
- the millimetre error an error rather than an obstacle. This decision was taken
924
- without maintainer input so the phase could proceed; it is cheap to reverse, because
925
- the scale enters at exactly one place (`groundMetres`) and the cache key already
926
- carries it.
927
- 4. *(Resolved — taken as proposed, and open to being overturned.)* **Which north does
928
- `sun-azimuth` mean on a projected sheet?** (§4a, C17.) **Sheet north by default,
929
- `sun-datum="geographic"` as the opt-in.** Shading runs in the source tile's own grid,
930
- where up IS geographic north, so sheet north is a per-tile rotation of the authored
931
- azimuths by the grid convergence — applied where the uniforms are built, not in GLSL,
932
- because it is a property of where the tile sits on the sheet rather than of a
933
- fragment. Measured against the plane rather than by EPSG code
934
- (`planeGridConvergence`), so a CRS registered as a bare pair of functions answers it
935
- too. The swing is ±17° across Albers CONUS, ±4° on British National Grid, and exactly
936
- zero in Mercator — where the attribute is therefore inert, and the validator says so.
937
- Like §12.3 this was taken without maintainer input so the phase could finish; it is a
938
- default flip to reverse.
939
-
940
- *Resolved since the first draft:* the buffer-library question (vendor a clipper vs
941
- write the narrow subset) is answered by scoping `buffer` as an ornament and building it
942
- on a distance field — no library, no licence review, no self-intersection class at all
943
- (§5).
944
-
945
- ## 13. Adjacent designs, deconflicted
946
-
947
- Two other designs are in flight against this codebase — **layer extensions**
948
- (decluttering, masking, pattern fills, offset lines) and **sheet annotation arrows**.
949
- They were written independently and they touch this one in six places. Recording the
950
- interactions here so none of them is discovered by a failing gate.
951
-
952
- ### 13.0 Frame sources — `frame-sources.md`
953
-
954
- Written later, and it touches §7 in one place. `freeze()` converts a live frame to a
955
- static one and stamps `corners` + `crs`; that georef contract is reused there for a
956
- RASTER SOURCE on a frame that is still live, rather than a second contract being
957
- invented. Freeze remains the only way a frame stops being live.
958
-
959
- The motivating failure is worth recording here because it is invisible from this
960
- document: a sheet's live `src` resolves outside the host app and the map it names then
961
- draws nothing, because its layers are on a host-local protocol. The failure is silent,
962
- so anything hung off an error path never fires.
963
-
964
- ### 13.1 The rasterise trigger is a post-process pass, by type
965
-
966
- The sharpest one, and it has a wrong answer on each side.
967
-
968
- `CollisionFilterExtension` installs a map-level effect *by itself* — its
969
- `initializeState` calls deck's `_addDefaultEffect`, and deck resolves
970
- `userEffects.concat(defaultEffects)`. So the moment decluttering ships, **a map with no
971
- finish at all still has an effect in deck's resolved array.** Rasterise on "deck has
972
- effects" and every map with decluttered labels silently exports as a bitmap — the
973
- vector feature disabled by an unrelated one, with no error and no notice.
974
-
975
- The obvious correction — "rasterise only when the document contains an `<om-effect>`
976
- element" — is wrong the other way. `MapController.setEffects()` takes deck `Effect`
977
- instances directly and outranks the document's chain while set, so a programmatic
978
- author supplying a genuine post-process pass would get vector output with the finish
979
- silently missing. Same class of failure, opposite direction.
980
-
981
- **The test is the effect's type, not its provenance.** Verified against the pin:
982
- `PostProcessEffect` is the only class that runs a shader pass over the finished frame,
983
- and `CollisionFilterEffect`, `MaskEffect` and `LightingEffect` are each standalone
984
- classes, none of them subclasses of it. So `instanceof PostProcessEffect` over the
985
- resolved chain admits exactly the cases that have no vector equivalent — the
986
- `<om-effect>` chain and a programmatic `setEffects` — and excludes exactly the ones that
987
- do: collision (the CPU declutter pass, §13.2), masks (`<clipPath>`, §13.4), and
988
- lighting, which shades layers rather than treating the frame.
989
-
990
- Pin it both ways: a map with decluttering and no finish must emit vector; a map whose
991
- only finish arrived through `setEffects` must emit a raster band.
992
-
993
- *Known edge, stated rather than engineered around:* a bespoke `Effect` passed to
994
- `setEffects` that post-renders without extending `PostProcessEffect` is not detected.
995
- Nothing the library produces does that, and the dev notice names what was emitted, so
996
- the failure is visible rather than silent.
997
-
998
- The same fact qualifies a sentence already shipped in the effects guide —
999
- `setEffects([])` no longer means "no effects run" once a decluttering layer is present.
1000
-
1001
- ### 13.2 Decluttering: two algorithms, and which one is authoritative
1002
-
1003
- §6 has the serializer run its own CPU greedy pass, because deck's collision map is
1004
- resolution-dependent and its survivors are not queryable (C5). The extensions design
1005
- reaches the same fact from the other side and treats a preview/plate divergence as a
1006
- *contract problem* rather than an accepted cost.
1007
-
1008
- Both cannot be right, and the honest reading is that **this document was internally
1009
- inconsistent**: it claimed the interactive and vector frames render identically while
1010
- specifying two different decluttering algorithms. Acceptance (§10) now states the
1011
- exception explicitly and masks labels from the comparison.
1012
-
1013
- That leaves a real choice, and it belongs to whichever design lands second:
1014
-
1015
- - *Accept the divergence* — GPU collision is the preview, the CPU pass is print truth,
1016
- and the two may keep different labels. Cheapest, and defensible because the print
1017
- pass is the better algorithm.
1018
- - *Make the CPU pass authoritative for both* — the preview asks the same code the
1019
- serializer does. Exact parity, at the cost of doing placement on the CPU every frame.
1020
-
1021
- Proposed: **accept the divergence, and say so in both places**, revisiting only if the
1022
- measurement the extensions design plans for its own phase 0 shows the label sets
1023
- differing by more than a couple of items on a real sheet.
1024
-
1025
- ### 13.3 Millimetres-on-paper is one question asked three times
1026
-
1027
- `<om-effect>` answered it for uniforms, where re-resolving per frame is free. This
1028
- document asks it again for geometry (§5 Units, §12.3), and the extensions design asks
1029
- it a third time for fill patterns, which deck anchors in **world** space — a pattern
1030
- authored in metres silently changes size between screen and sheet.
1031
-
1032
- One answer serves all three, and §12.3's proposal is it: a **declared reference scale**,
1033
- supplied by a frame, declared on a live map, and a validation error where neither
1034
- exists. Patterns are the easy case — the scale is a prop, re-derived per frame like a
1035
- uniform — and geometry is the hard one, because a transform runs once at ingest. Both
1036
- should read the same declared value rather than each inventing a rule.
1037
-
1038
- ### 13.4 Mask layers need a serializer strategy
1039
-
1040
- The extensions design ships masking, where a layer carries `operation: "mask"`, draws
1041
- nothing, and clips others. §6's strategy table has no row for that, and the layer is
1042
- not `visible: false`, so a naive walk would emit its geometry as artwork.
1043
-
1044
- SVG maps it exactly: a mask layer becomes a **`<clipPath>`**, referenced by the layers
1045
- it masks. Better than the raster fallback, and worth stating before the table is
1046
- implemented. Deck caps masks at four; SVG does not, so the cap is inherited from the
1047
- live renderer rather than imposed by the serializer.
1048
-
1049
- ### 13.5 Arrows compose, and the plane view improves them
1050
-
1051
- Sheet annotation arrows are furniture: they live outside the map frame, so they stay
1052
- vector even when §6 rasterises the frame, and the freeze-to-vector work (§7) does not
1053
- disturb them. Their geographic anchors resolve through the frame's `FrameGeoref`, which
1054
- is exactly what §7 keeps unchanged.
1055
-
1056
- The plane view makes them **better**, which nobody should have to rediscover: an
1057
- orthographic frame's corners are an affine map of the plane (§4), so a geographic
1058
- anchor on a projected sheet is exact rather than homography-approximated. Arrows
1059
- anchored to features are one of the clearer beneficiaries of Part A.
1060
-
1061
- ### 13.6 The shared follow-up has one owner
1062
-
1063
- Label candidate positions, leader lines and text on a path appear in both designs — as
1064
- explicit non-goals of the extensions work ("placement logic, not extension work") and
1065
- as the natural home of this document's CPU declutter pass (§6). They are the same
1066
- follow-up, and it belongs to the **placement pass**, not to extensions. Recorded so it
1067
- is not scheduled twice or dropped by both.