@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.
Files changed (93) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +50 -3
  3. package/dist/{LercDecode.es-BMcxSLhD.js → LercDecode.es-IEPCRZOv.js} +1 -1
  4. package/dist/{basemap-m98j2wxG.js → basemap-9lXclX9H.js} +3882 -3980
  5. package/dist/cartograph/elements/om-frame.d.ts +67 -1
  6. package/dist/cartograph/georef.d.ts +18 -4
  7. package/dist/cartograph/schema.d.ts +11 -0
  8. package/dist/cartograph.js +1480 -1311
  9. package/dist/cartograph.standalone.js +1808 -1615
  10. package/dist/{cityjson-D_V5GY8b.js → cityjson-k-z1r6c0.js} +1 -1
  11. package/dist/{crs-DsDQ4Q4i.js → crs-BzE_KP4M.js} +25 -2
  12. package/dist/{crs-Ciu7Xs7a.js → crs-ChglCB3O.js} +39 -16
  13. package/dist/dem-decode.d.ts +58 -0
  14. package/dist/elements/om-map.d.ts +12 -0
  15. package/dist/{geoparquet-XOwOmChh.js → geoparquet-DFDZDBun.js} +10 -10
  16. package/dist/globe-view-D9wjfL0T.js +104 -0
  17. package/dist/hillshade-C2BQr6pd.js +298 -0
  18. package/dist/hillshade-apron-Bem3DWyJ.js +40 -0
  19. package/dist/hillshade-apron.d.ts +54 -0
  20. package/dist/hillshade-shader-DI2uLSNU.js +165 -0
  21. package/dist/hillshade-shader.d.ts +168 -0
  22. package/dist/hillshade.d.ts +163 -0
  23. package/dist/html-data.d.ts +1 -1
  24. package/dist/{ifc-Dc-TdSJr.js → ifc-DXwePQRv.js} +131 -131
  25. package/dist/{index-DzOvV-O7.js → index-4Tvlt0iO.js} +57 -57
  26. package/dist/{index-HZWdgtm4.js → index-Bn66l3KG.js} +1 -1
  27. package/dist/index-BuXrMq5D.js +322 -0
  28. package/dist/index-CNRbZHkK.js +459 -0
  29. package/dist/{index-DDNElBTs.js → index-CkovmN47.js} +1 -1
  30. package/dist/index-CmuOizAF.js +641 -0
  31. package/dist/index-CvT5QHBS.js +65 -0
  32. package/dist/{index-BMbpftvm.js → index-DnVHKI61.js} +1 -1
  33. package/dist/{index-BSAY6CWm.js → index-JjyDEqAS.js} +18911 -17456
  34. package/dist/index.d.ts +4 -0
  35. package/dist/layer-registry.d.ts +27 -0
  36. package/dist/lerc-C1mQ_Kqq.js +22 -0
  37. package/dist/onlymap.standalone.js +49075 -45717
  38. package/dist/onlymapjs.js +73 -70
  39. package/dist/parse-manifest.d.ts +6 -0
  40. package/dist/plane-camera.d.ts +59 -0
  41. package/dist/plane-layers.d.ts +56 -0
  42. package/dist/plane-tiles.d.ts +99 -0
  43. package/dist/plane-tileset.d.ts +31 -0
  44. package/dist/plane-warp.d.ts +91 -0
  45. package/dist/post-process-effect-DfslKPM6.js +197 -0
  46. package/dist/programmatic.d.ts +16 -1
  47. package/dist/projection.d.ts +118 -0
  48. package/dist/{raster-Dg5p_99H.js → raster-D2NzdjZE.js} +609 -499
  49. package/dist/raster-hillshade.d.ts +119 -0
  50. package/dist/{raster-pipeline-DhjkqDYd.js → raster-pipeline-qnD1icOv.js} +511 -484
  51. package/dist/raster-pipeline.d.ts +10 -0
  52. package/dist/raster.d.ts +5 -0
  53. package/dist/runtime-core.d.ts +140 -1
  54. package/dist/serialize/clip.d.ts +50 -0
  55. package/dist/serialize/declutter.d.ts +44 -0
  56. package/dist/serialize/emit.d.ts +60 -0
  57. package/dist/serialize/index.d.ts +64 -0
  58. package/dist/serialize/strategy.d.ts +30 -0
  59. package/dist/serialize/style.d.ts +77 -0
  60. package/dist/snapshot.d.ts +46 -0
  61. package/dist/surface-anchor.d.ts +6 -0
  62. package/dist/terrain-heightfield.d.ts +0 -16
  63. package/dist/terrain-sample.d.ts +0 -13
  64. package/dist/text-on-path-Dm7vtNqt.js +146 -0
  65. package/dist/text-on-path.d.ts +157 -0
  66. package/dist/transform/buffer.d.ts +63 -0
  67. package/dist/transform/contour.d.ts +37 -0
  68. package/dist/transform/dot-density.d.ts +19 -0
  69. package/dist/transform/field.d.ts +80 -0
  70. package/dist/transform/geometry.d.ts +20 -0
  71. package/dist/transform/index.d.ts +29 -0
  72. package/dist/transform/simplify.d.ts +10 -0
  73. package/dist/transform/smooth.d.ts +12 -0
  74. package/dist/transform-stage.d.ts +92 -0
  75. package/dist/version.d.ts +1 -1
  76. package/dist/volumetrics.d.ts +7 -0
  77. package/dist/{zarr-D3CzK1Zm.js → zarr-D5e5agMG.js} +2 -2
  78. package/docs/cartograph.md +12 -4
  79. package/docs/cartography.md +328 -0
  80. package/docs/design/arrows.md +182 -0
  81. package/docs/design/carto-substrate.md +1055 -0
  82. package/docs/design/extensions.md +250 -0
  83. package/docs/design/hillshade.md +290 -0
  84. package/docs/effects.md +11 -0
  85. package/docs/hillshade.md +203 -0
  86. package/llms.txt +4 -2
  87. package/onlymapjs.attributes.json +45 -2
  88. package/onlymapjs.html-data.json +213 -25
  89. package/package.json +13 -9
  90. package/skills/onlymapjs/SKILL.md +7 -2
  91. package/skills/onlymapjs/references/syntax.md +31 -3
  92. package/dist/index-CfPbQUqO.js +0 -511
  93. package/dist/lerc-qK-nhCaB.js +0 -30
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The eager half of `<om-transform>` (spec: cartographic substrate, Part B).
3
+ *
4
+ * Geometry transforms run in the DATA stage — after normalisation, before
5
+ * accessor resolution — so the GPU, `anchor="surface"`, the legend and the
6
+ * vector serializer all see the SAME geometry. But the primitives themselves
7
+ * (Douglas-Peucker, Chaikin, seeded dot density) live in a lazy chunk, because
8
+ * almost every map has no transforms and should not download them. This module
9
+ * is what stays eager: the presence check, the unit grammar, and the cache that
10
+ * lets a synchronous parse pass return an already-transformed array.
11
+ *
12
+ * The first pass over a transformed layer therefore resolves to the EMPTY
13
+ * placeholder rather than to untransformed geometry — the same Q6 state a
14
+ * URL-backed layer sits in before its fetch lands, and for the same reason:
15
+ * showing a coastline unsmoothed and then smoothing it a frame later is a
16
+ * flash of the wrong map, not progressive loading.
17
+ */
18
+ import type { LayerData } from "./ir";
19
+ import type { Shape } from "./expr";
20
+ export declare const TRANSFORM_TAG = "om-transform";
21
+ /**
22
+ * The transform types, named here in the EAGER module rather than in the
23
+ * chunk: the validator has to know what a valid `type=` is in order to reject
24
+ * a typo, and making it import the chunk to find out would pull every
25
+ * primitive into the eager graph of every map that validates.
26
+ */
27
+ export declare const TRANSFORM_TYPES: readonly ["simplify", "smooth", "dot-density", "buffer", "contour"];
28
+ /** One authored `<om-transform>`, as a plain record — the lazy chunk validates and interprets it. */
29
+ export interface TransformSpec {
30
+ type: string;
31
+ params: Record<string, string>;
32
+ }
33
+ /**
34
+ * A length authored on a transform: millimetres ON PAPER, or a ground length.
35
+ *
36
+ * Millimetres are the contract `<om-effect>` set and §5 keeps: a tolerance in
37
+ * metres silently changes the look between a screen and a 300 dpi plate. They
38
+ * resolve against a declared reference scale (see `parseReferenceScale`) and
39
+ * are a validation error where none exists — geometry runs once at ingest and
40
+ * cannot be re-resolved per frame the way an effect's uniforms can, so the
41
+ * scale has to be something the author states rather than something the
42
+ * current zoom happens to be.
43
+ *
44
+ * Ground units are the escape hatch that keeps "no reference scale" from being
45
+ * a wall: `tolerance="50m"` means fifty metres at any zoom, and says so.
46
+ */
47
+ export interface AuthoredLength {
48
+ value: number;
49
+ unit: "mm" | "m";
50
+ }
51
+ export declare function parseLength(raw: string | null | undefined): AuthoredLength | null;
52
+ /**
53
+ * `reference-scale` on `<om-map>` — the metres of ground one millimetre of
54
+ * paper stands for. Two spellings, because cartographers write one and
55
+ * engineers reach for the other:
56
+ *
57
+ * - `1:50000` — a representative fraction. One mm of paper is 50,000 mm of
58
+ * ground, so 50 m/mm.
59
+ * - `50m` — the same thing said directly.
60
+ *
61
+ * A cartograph frame does not need either: its georef already knows
62
+ * (`groundMetersPerMm()`), and the frame supplies it. This attribute is for a
63
+ * live `<om-map>`, which has no sheet to ask.
64
+ */
65
+ export declare function parseReferenceScale(raw: string | null | undefined): number | null;
66
+ /** Resolve an authored length to ground metres, or null when it needs a reference scale there is none of. */
67
+ export declare function groundMetres(length: AuthoredLength, metresPerMm: number | null): number | null;
68
+ /** The authored chain, read straight off the DOM. Eager: it is three DOM calls and no geometry. */
69
+ export declare function readTransformEls(layerEl: Element): TransformSpec[];
70
+ /** Stable identity for a chain plus the scale it resolves against — the cache key, and the reparse trigger. */
71
+ export declare function transformKey(specs: readonly TransformSpec[], metresPerMm: number | null): string;
72
+ export declare function cachedTransform(data: LayerData, key: string): LayerData | undefined;
73
+ export declare function cacheTransform(data: LayerData, key: string, out: LayerData): void;
74
+ /** Transform types that PRODUCE geometry rather than rewriting the layer's own. */
75
+ export declare const SOURCING_TYPES: readonly ["contour"];
76
+ /** Whether a chain sources its own geometry — one predicate, so adding a second sourcing type is one edit. */
77
+ export declare function sourcesGeometry(specs: readonly TransformSpec[]): boolean;
78
+ /** Test seams for the anchor map's identity and its bound — both are invisible from outside otherwise. */
79
+ export declare function cacheAnchorForTest(data: LayerData, specs: readonly TransformSpec[], warnLabel: string): object;
80
+ export declare function sourceAnchorCountForTest(): number;
81
+ /**
82
+ * Resolves once every chain currently running has finished. Tests await this
83
+ * instead of guessing a timeout, which is the difference between a suite that
84
+ * proves the seam and one that proves the machine was fast enough.
85
+ */
86
+ export declare function whenTransformsSettled(): Promise<void>;
87
+ /**
88
+ * The seam parse-manifest calls. Returns transformed data when the chunk has
89
+ * run this chain before, and otherwise kicks off the load and returns the
90
+ * empty placeholder — the caller reparses when `onReady` fires.
91
+ */
92
+ export declare function applyTransformStage(data: LayerData, shape: Shape, specs: readonly TransformSpec[], metresPerMm: number | null, warnLabel: string, onReady: () => void): LayerData;
package/dist/version.d.ts CHANGED
@@ -5,4 +5,4 @@
5
5
  * the build rootDir, and a `define` would need repeating across vite/vitest/
6
6
  * vite-node configs.
7
7
  */
8
- export declare const LIBRARY_VERSION = "0.9.0";
8
+ export declare const LIBRARY_VERSION = "0.10.0";
@@ -52,6 +52,13 @@ export interface HeightfieldTiles {
52
52
  tiles: HeightfieldTile[];
53
53
  decoder: ElevationDecoderSpec;
54
54
  }
55
+ /**
56
+ * Height in metres from one RGB triple. The whole of "what a DEM tile means"
57
+ * — kept in one exported function so the bulk path here, the one-shot query
58
+ * in terrain-sample.ts, and any future GPU port all agree on the arithmetic
59
+ * rather than each writing it out.
60
+ */
61
+ export declare function decodeElevationRgb(d: ElevationDecoderSpec, r: number, g: number, b: number): number;
55
62
  /**
56
63
  * Bilinear heightfield sample at `lngLat`, correct across TILE SEAMS.
57
64
  *
@@ -1,5 +1,5 @@
1
- import { A as ur, d as lr, R as zt, e as fr, m as dr, p as St, f as hr, j as pr, k as mr } from "./raster-pipeline-DhjkqDYd.js";
2
- import { aD as gr } from "./index-BSAY6CWm.js";
1
+ import { A as ur, d as lr, R as zt, e as fr, m as dr, p as St, f as hr, k as pr, l as mr } from "./raster-pipeline-qnD1icOv.js";
2
+ import { c as gr } from "./index-JjyDEqAS.js";
3
3
  import $t from "./index-CW1n5LdO.js";
4
4
  var Et;
5
5
  function h(e, t, n) {
@@ -22,8 +22,8 @@ to PDF at true page size via CSS `@page` and exports PNG/JPEG at print DPI throu
22
22
  <html>
23
23
  <head>
24
24
  <meta charset="utf-8">
25
- <script type="module" src="https://unpkg.com/@nika-js/onlymap@0.9.0/dist/cartograph.standalone.js"></script>
26
- <link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.9.0/dist/cartograph.css">
25
+ <script type="module" src="https://unpkg.com/@nika-js/onlymap@0.10.0/dist/cartograph.standalone.js"></script>
26
+ <link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.10.0/dist/cartograph.css">
27
27
  </head>
28
28
  <body>
29
29
  <om-cartograph cartograph-id="cg-lot-12" format="cartograph/2" size="A4" theme="minimal"
@@ -400,5 +400,13 @@ and send nothing.
400
400
 
401
401
  ## Non-goals
402
402
 
403
- SVG export; multi-page non-atlas documents (`om-page` is reserved-inert); projections other
404
- than Web Mercator on **live** frames; automatic label placement.
403
+ Multi-page non-atlas documents (`om-page` is reserved-inert); automatic label placement
404
+ **on the GPU path** — the vector exporter runs its own deterministic CPU pass, and that
405
+ is where candidate positions and leader lines will land.
406
+
407
+ Two entries left this list in 0.10.0. **SVG export** shipped as
408
+ `snapshot({ format: "svg" })`, and a frame freezes to inline vector with
409
+ `freeze({ format: "svg" })`. **Projections other than Web Mercator on live frames**
410
+ shipped as `crs` on the frame's own `<om-map>` — the frame takes its projection from the
411
+ map it mounts, and its georeference is then an exact affine fit rather than a homography.
412
+ See [cartography.md](cartography.md).
@@ -0,0 +1,328 @@
1
+ # Cartography — projections, geometry transforms, vector export
2
+
3
+ > **Available in 0.10.0.** Four capabilities that only make sense together: a
4
+ > map drawn in a **real projection**, **geometry the data doesn't contain**,
5
+ > **vector output**, and a frozen sheet that stays editable. Everything here is
6
+ > a lazy chunk — a map that uses none of it downloads none of it.
7
+
8
+ ```html
9
+ <om-map crs="EPSG:5070" reference-scale="1:6500000" basemap="none"
10
+ center="[-96.8, 38.6]" zoom="3.8">
11
+ <om-layer id="land" type="GeoJsonLayer" data="./countries.geojson">
12
+ <om-transform type="simplify" tolerance="0.18mm"></om-transform>
13
+ <om-transform type="smooth" iterations="2"></om-transform>
14
+ </om-layer>
15
+ <om-layer id="relief" type="HillshadeLayer" src="terrarium"
16
+ sun-datum="sheet"></om-layer>
17
+ </om-map>
18
+ ```
19
+
20
+ Runnable: [`dev/examples/features/cartography/compose-an-atlas-plate.html`](../dev/examples/features/cartography/compose-an-atlas-plate.html).
21
+
22
+ ---
23
+
24
+ ## The plane view — `crs=`
25
+
26
+ `crs` puts the whole renderer in a projection's plane. Parallels curve, an
27
+ equal-area projection is genuinely equal-area, and a state-plane sheet is drawn
28
+ in state plane rather than stretched from Web Mercator.
29
+
30
+ ```html
31
+ <om-map crs="EPSG:5070" basemap="none" center="[-98, 39]" zoom="4">
32
+ ```
33
+
34
+ Bundled: Web Mercator and plate carrée need nothing. British National Grid,
35
+ Swiss LV95, Albers CONUS, Lambert 93, RD New, the UTM zones and a dozen others
36
+ resolve through proj4, which loads only when a map asks for one. Anything else
37
+ takes `crs-def="+proj=…"`, or registers as a pair of functions:
38
+
39
+ ```js
40
+ OmMap.registerCrs("EPSG:2154", "+proj=lcc +lat_0=46.5 …");
41
+ OmMap.registerCrs("MY:PROJECTION", { forward, inverse, units: "linear", metresPerUnit: 1 });
42
+ ```
43
+
44
+ **The authored camera stays geographic.** `center` is lng/lat and `zoom` means
45
+ what it always meant, on a projected map as much as a Mercator one — so stories,
46
+ `seek()`, `getCamera()` and every state bridge keep working unchanged. Clicks
47
+ report lng/lat too, not plane metres, which matters because the measure tool
48
+ feeds those points to geodesic formulas and a projected metre in a geodesic
49
+ formula returns a confident wrong answer.
50
+
51
+ ### What a projected map cannot do
52
+
53
+ Each is a validation error with a fix, never a silent no-op:
54
+
55
+ | Limit | Why | What to do instead |
56
+ |---|---|---|
57
+ | No MapLibre basemap | it is a second renderer with its own camera | `basemap="none"` — already required for print finishes and relief |
58
+ | No `terrain` | the 3D surface and its tiles are Mercator throughout | drop it, or use Mercator |
59
+ | No `pitch` / `bearing` | the projected view is planimetric | a print sheet is planimetric; rotate the frame in the layout |
60
+ | No H3 / S2 / geohash / quadkey layers | deck builds their geometry from a token, inside the layer | convert the cells to polygons and use a `GeoJsonLayer` |
61
+ | CRS fixed for the map's life | re-ingesting on a switch is a remount | author two maps |
62
+
63
+ **Relief works.** Both routes: `shading="hillshade"` on a DEM of your own has no
64
+ projection tie at all, and the global keyless `HillshadeLayer` re-indexes its
65
+ Mercator tiles from the plane's own geography and draws them as subdivided
66
+ warped meshes. Sub-pixel at practical subdivisions — measured at 0.40 output
67
+ pixels for Albers at z=3, falling as 1/N².
68
+
69
+ ### Which north does the sun mean?
70
+
71
+ On a projected sheet, geographic north is not sheet-up. Across an Albers CONUS
72
+ plate the difference swings **34°** from one edge to the other.
73
+
74
+ - `sun-datum="sheet"` (the default) keeps the apparent light constant across the
75
+ plate. This is what relief atlases do: light that rotates across a sheet reads
76
+ as a mistake.
77
+ - `sun-datum="geographic"` is physically true — that slope really is lit from
78
+ the north-west.
79
+
80
+ Inert on a Web Mercator map, where the two are the same direction, and the
81
+ validator says so rather than letting you wonder.
82
+
83
+ ---
84
+
85
+ ## Geometry transforms — `<om-transform>`
86
+
87
+ Children of an `<om-layer>`, applied in document order, in the **data stage** —
88
+ so deck, `anchor="surface"`, the legend and the vector exporter all see the same
89
+ geometry rather than each deriving its own.
90
+
91
+ ```html
92
+ <om-layer id="coast" type="GeoJsonLayer" data="./coast.geojson">
93
+ <om-transform type="simplify" tolerance="0.15mm"></om-transform>
94
+ <om-transform type="smooth" iterations="2"></om-transform>
95
+ </om-layer>
96
+ ```
97
+
98
+ | `type` | What it does |
99
+ |---|---|
100
+ | `simplify` | Douglas–Peucker at a `tolerance`. No vertex moves further than that. |
101
+ | `smooth` | Chaikin corner-cutting, `iterations="1"`–`6`. One pass removes the straight-segment look — the loudest "web map" tell there is. |
102
+ | `dot-density` | Scatters points inside polygons: `field="population" per="1000"`. Seeded, so a recorded story and a live map place the same dots. |
103
+ | `buffer` | Bands around a shape: `distance="0.9mm" repeat="5" fade`. The engraved shoreline of an old chart. |
104
+ | `contour` | Isolines marched off a DEM: `src="terrarium" bounds="[w,s,e,n]" interval="100m"`. |
105
+
106
+ ### Millimetres on paper, and the scale they resolve against
107
+
108
+ Spatial knobs are **millimetres on the page**, for the same reason `<om-effect>`'s
109
+ are: a tolerance in metres silently changes the look between a screen and a
110
+ 300 dpi plate.
111
+
112
+ Unlike an effect's knobs — uniforms, re-pointed per frame for nothing — geometry
113
+ runs **once at ingest**, so it cannot be re-resolved as the camera moves. A
114
+ millimetre therefore needs a scale you *declare*:
115
+
116
+ ```html
117
+ <om-map reference-scale="1:50000"> <!-- or reference-scale="50m" -->
118
+ ```
119
+
120
+ A cartograph frame supplies its own from its georeference. A map with neither is
121
+ a validation error naming the fix — never a tolerance that quietly means whatever
122
+ the current zoom happened to be. **Ground units need no scale**: `tolerance="50m"`
123
+ means fifty metres at every zoom and says so.
124
+
125
+ Tolerances are measured on the ground, not in degrees. A degree of longitude is
126
+ 111 km at the equator and 56 km at 60°N, so simplifying raw degrees would thin a
127
+ Norwegian coastline twice as hard as an Ecuadorian one from the same number.
128
+
129
+ ### `buffer` is an ornament, not a measurement
130
+
131
+ A coastal vignette is judged by eye; a 500 m setback is a number somebody acts
132
+ on. **The first is in scope and the second is not** — the same line shaded relief
133
+ drew between rendered texture and analytic product.
134
+
135
+ That decides the method. The shape is rasterised, an exact Euclidean distance
136
+ transform runs over it, and each band is a **threshold** of that one field — so
137
+ `repeat="5"` costs what one band costs, and the output cannot self-intersect,
138
+ because no polygon arithmetic ever happens.
139
+
140
+ The error is bounded and measured: **half a grid cell**, everywhere, corners
141
+ included. At 300 dpi on a 200 mm frame that is 0.042 mm against a 0.088 mm
142
+ hairline. Features thinner than a cell vanish at rasterisation, areas are
143
+ grid-accurate, and ring nesting is re-derived from the contour.
144
+
145
+ Asking for it as a setback is an error that names the alternative — compute it in
146
+ PostGIS or turf and load the result as data.
147
+
148
+ ```html
149
+ <om-transform type="buffer" distance="0.9mm" repeat="5" fade></om-transform>
150
+ ```
151
+
152
+ `fade` gives each band a `_bandOpacity` property, outermost faintest, which an
153
+ accessor can read: `get-fill-color="[125,155,173, $_bandOpacity * 165]"`. Bands
154
+ come out **outermost first**, so they stack correctly under a fill.
155
+
156
+ ### `contour` declares its extent
157
+
158
+ `contour` is the one transform that *sources* geometry rather than rewriting the
159
+ layer's own — its layer legitimately has no data. It is also the one that
160
+ fetches, so its extent is declared rather than taken from the camera:
161
+
162
+ ```html
163
+ <om-layer id="contours" type="GeoJsonLayer"
164
+ get-line-width="$index ? 1.6 : 0.8" line-width-units="pixels">
165
+ <om-transform type="contour" src="terrarium" zoom="10"
166
+ bounds="[-105.95,39.42,-105.38,39.82]" interval="100m"></om-transform>
167
+ </om-layer>
168
+ ```
169
+
170
+ Each line carries `elevation`, and `index` is true on every fifth contour — the
171
+ cartographer's heavier line. The interval is a ground height, never paper
172
+ millimetres, and writing `interval="2mm"` is an error saying so.
173
+
174
+ Not deck's `ContourLayer`, which contours point *density*.
175
+
176
+ **Columnar layers are out of scope** and say so: a columnar source is precisely
177
+ the case with no line or polygon geometry, so a transform on one is an error
178
+ naming the layer rather than a silent no-op.
179
+
180
+ ---
181
+
182
+ ## Labels that follow their line — `TextOnPathLayer`
183
+
184
+ A river's name runs along the river; a range's along the range. It is the oldest
185
+ label convention there is, and deck has no layer for it.
186
+
187
+ ```html
188
+ <om-layer id="rivers" type="TextOnPathLayer"
189
+ get-path="$path" get-text="$name" get-size="10"
190
+ get-color="[52,84,112]" font-family="Georgia, serif"
191
+ letter-spacing="1.4" offset="5" placement="middle">
192
+ <script type="application/json">[
193
+ {"name":"Rio Grande","path":[[-106.6,35.1],[-104.7,29.4],[-97.4,25.9]]}
194
+ ]</script>
195
+ </om-layer>
196
+ ```
197
+
198
+ | Attribute | |
199
+ |---|---|
200
+ | `get-path`, `get-text` | the line and the words. Either without the other is a validation error — each is silently inert alone |
201
+ | `get-size`, `get-color`, `font-family`, `font-weight` | as any text |
202
+ | `letter-spacing` | extra tracking in pixels. Letter-spaced names are a convention, not a flourish: an ocean or a range is conventionally tracked across its own extent |
203
+ | `offset` | perpendicular pixels; positive sits to the **left** of the line's direction |
204
+ | `placement` | `start`, `middle` (default) or `end` along the line |
205
+ | `max-labels` | ceiling on emitted glyphs |
206
+
207
+ **It reads left to right whichever way the line was drawn.** A path's direction
208
+ is an accident of how the data was digitised, and a label following a
209
+ right-to-left line comes out upside down and mirrored — so the layer flips the
210
+ path when it needs to. `start` and `end` flip with it, because they mean a place
211
+ on the line rather than a direction.
212
+
213
+ **A name that does not fit is dropped**, not compressed and not run off the end.
214
+ That is what a cartographer would do, and it is the only option that never
215
+ leaves a label pointing at nothing.
216
+
217
+ **Placement happens in screen pixels**, so it is recomputed as the camera moves
218
+ — a glyph advance is a length in pixels while a path is a length in the world,
219
+ and only the current scale relates them. On a print sheet, where the camera is
220
+ fixed, it resolves once and stays put.
221
+
222
+ **The SVG export beats the screen here.** On the GPU this is one text instance
223
+ per glyph, because that is what a text layer can do. SVG has the real primitive,
224
+ so `snapshot({format: "svg"})` emits a single `<textPath>` — one editable word
225
+ still attached to the river's own path, rather than nine rotated characters.
226
+
227
+ ---
228
+
229
+ ## Vector export — `snapshot({ format: "svg" })`
230
+
231
+ ```js
232
+ const svg = await map.snapshot({ format: "svg", onNotice: (n) => console.log(n.message) });
233
+ ```
234
+
235
+ Returns the SVG as **text** (`as: "blob"` for a file). The walk is per layer:
236
+
237
+ | Layer | Emitted as |
238
+ |---|---|
239
+ | Polygon / path / point layers | `<path>` / `<circle>` with the style the accessors resolve |
240
+ | `TextLayer` | real `<text>`, after a CPU decluttering pass |
241
+ | Rasters, tiles, 3D, aggregations | a **raster band** as `<image>`, at the right stacking position |
242
+
243
+ The result is a hybrid — vector linework over placed relief — which is not a
244
+ fallback but how cartographic production has always worked.
245
+
246
+ **It needs `basemap="none"`**, the same requirement `<om-effect>` and `crs`
247
+ already carry. A MapLibre basemap is a second renderer whose output is raster
248
+ tiles; compositing it into every band would paint it over the vector linework
249
+ above it. Imagery that exports correctly is an ordinary deck layer — a
250
+ `TileLayer` of raster tiles bands in the right stacking position.
251
+
252
+ **Consecutive raster layers merge into one band**; a vector layer between two of
253
+ them keeps them apart, because stacking order is the one thing an exporter must
254
+ not quietly rearrange.
255
+
256
+ ### A print finish rasterises the frame
257
+
258
+ A post-process pass treats the *finished frame*, so there is no "some layers":
259
+ a sheet carrying a finish exports its map as one raster band, and the exporter
260
+ says so through `onNotice` rather than letting you discover it at a print shop.
261
+
262
+ `effectDpi` (default **600**) is the band's own resolution, independent of the
263
+ sheet's — it changes the band's pixel dimensions, not its scaling. Almost
264
+ everything survives print rasterisation; type does not, and linework only just,
265
+ so this is the knob that decides whether a 6 pt label is good.
266
+
267
+ A decluttering layer does **not** trigger this. The test is whether a real
268
+ post-process pass is running, not whether deck has any effects — a label layer
269
+ installs one of its own.
270
+
271
+ ### Decluttering, and why the exporter runs its own
272
+
273
+ `CollisionFilterExtension` decides survivors on the GPU, in a framebuffer sized
274
+ from the canvas — so which labels it kept depends on the capture ratio, and the
275
+ exporter cannot ask. It runs a deterministic CPU pass by priority instead. Deck's
276
+ collision stays the interactive preview; the CPU pass is the print truth.
277
+
278
+ ### Guards
279
+
280
+ Geometry is clipped to the frame before emission, which also removes the
281
+ giant-path problem. Past a feature budget the result carries a notice offering
282
+ `simplify`.
283
+
284
+ ---
285
+
286
+ ## Freeze a frame to vector
287
+
288
+ ```js
289
+ await document.getElementById("main").freeze({ format: "svg" });
290
+ ```
291
+
292
+ The frame becomes `mode="static"`, placed by the same `crs` + `corners` it
293
+ already reported, with an inline `<svg>` where the `<img>` used to be. The
294
+ georeference model does not change: a frozen frame is a picture plus four
295
+ corners, and that was true before vector and stays true after.
296
+
297
+ A frozen sheet is a **document, not an application** — it opens with no runtime,
298
+ no network and nothing defining its custom elements, and the stylesheet alone
299
+ lays it out at the authored size. Print needs no swap either: a browser prints
300
+ inline vector natively at whatever resolution the printer has.
301
+
302
+ `freeze({ format: "raster" })` stores the PNG it always did.
303
+
304
+ It returns `false` and writes nothing when the frame has no georeference to
305
+ freeze at — a projected frame still resolving its CRS has corners that are about
306
+ to change, and a sheet placed by those would look exactly like one placed right.
307
+
308
+ ---
309
+
310
+ ## Bundle cost
311
+
312
+ Nothing here is in the eager graph. The projection core loads with the first
313
+ `crs`; proj4 only for a CRS with no closed form; the transform primitives with
314
+ the first `<om-transform>`; the serializer with the first
315
+ `snapshot({format: "svg"})`. A bundle assertion pins the last one: its symbols
316
+ must appear in exactly one chunk.
317
+
318
+ ## Not implemented yet
319
+
320
+ - **Masking relief to land.** Clipping one layer to another's geometry is
321
+ layer-extension work; until then a global DEM shades the sea too.
322
+ - **Native-CRS tile pyramids.** Where a provider serves tiles already in the
323
+ target grid, they would be consumed directly with no warp. Deferred until
324
+ asked for.
325
+ - **`contour` in a plane view** inherits the DEM's Mercator grid for its
326
+ marching pass. The polylines project exactly, so the lines are right; what is
327
+ Mercator is the sampling.
328
+ - **An analytic `buffer`.** A deliberate non-goal — see above.
@@ -0,0 +1,182 @@
1
+ # `<om-arrow>` — routed indicator arrows for cartographs
2
+
3
+ Callouts, leaders and connectors in the draw.io sense: an arrow that **attaches** to
4
+ things (a page point, another element, a geographic position inside a frame) and
5
+ **routes** between them in a chosen style — straight, cardinal-only orthogonal, curved,
6
+ or the technical-illustration "diagonal then horizontal" leader.
7
+
8
+ Cartograph-only. Pure DOM/SVG furniture with a canvas painter, no map runtime, so it
9
+ lives in `src/cartograph/` in full compliance with the lazy-core rule. Targeting one
10
+ release; independent of the substrate plan (`carto-substrate.md`), and deconflicted
11
+ with it in that document's §13.5: arrows are furniture, so they stay vector even where
12
+ the substrate rasterises a map frame on export, and the freeze-to-vector work leaves
13
+ their geographic anchors alone. The plane view makes those anchors *exact* — an
14
+ orthographic frame's corners are an affine map of the projection plane, so a geographic
15
+ anchor on a projected sheet no longer carries the homography's interior residue
16
+ (measured at 7.12mm at the centre of a 180x120mm sheet when fitted in the wrong plane).
17
+ Label placement and leader lines are shared follow-up work owned by the placement pass
18
+ (§13.6), not by this element.
19
+
20
+ ---
21
+
22
+ ## What exists, and why it is not enough
23
+
24
+ `<om-shape kind="arrow">` draws a straight arrow from its box's top-left to its
25
+ bottom-right (`elements/om-shape.ts:91`). It has no anchors, no routing, one head
26
+ style, and its geometry is the box — so pointing at a feature means computing a box by
27
+ hand and re-computing it when anything moves. It stays as the simple case; `<om-arrow>`
28
+ supersedes it for anything anchored or routed, and the validator says so.
29
+
30
+ ## Model — the parts that decide everything else
31
+
32
+ ### 1. An arrow has no authored box
33
+
34
+ Every other placed element is `x y w h` in mm (`schema.ts:43`, `paint.ts:boxMm`). An
35
+ arrow's box is **derived** from its routed path plus head size, because its identity is
36
+ its two ends, not a rectangle. `z`, `locked`, `hidden` apply; `x y w h rotation` are
37
+ validation errors on `<om-arrow>` (fix: move the ends).
38
+
39
+ This is not a restriction on *where* an arrow can go. A **floating arrow** is simply two
40
+ page points — `from="120,40" to="150,60"` — attached to nothing; the box attributes are
41
+ rejected only because the ends already carry the position, and two sources of truth
42
+ for one placement is how furniture drifts. The element still writes the
43
+ derived box through `applyPlacement()` so stacking and hit-testing behave like any
44
+ other furniture.
45
+
46
+ *Consequence for consumers:* `nika-agent`'s selection overlay finds placed elements by
47
+ `hasAttribute("x")` (`CartographSelectionOverlay.tsx:234`) and drags them by writing
48
+ `x y`. Arrows need an **endpoint-handle** mode that writes `from`/`to`. That is a
49
+ consumer ticket, filed with Phase 2.
50
+
51
+ ### 2. Three anchor forms, one grammar, both ends
52
+
53
+ | Form | Example | Resolves to |
54
+ |---|---|---|
55
+ | Page point | `from="120,40"` | that mm point |
56
+ | Element | `from="#callout"` | a point on that element's box edge — side auto-chosen from relative position, or forced with `from-side="left|right|top|bottom|center"` and `from-offset="0…1"` along the side |
57
+ | Geographic | `to="#main@-122.42,37.78"` | `frame.georef.project(lngLat)` → frame-relative mm, plus the frame's box → page mm |
58
+
59
+ The geographic form is the reason to build this at all: a callout that stays on the
60
+ feature. It works identically on live and static frames because both expose the same
61
+ `FrameGeoref` (`docs/cartograph.md`, "Georeferencing"), and it is exactly the mapping
62
+ `overview-of` already performs for a frame footprint (`om-frame.ts:452`).
63
+
64
+ Element anchors attach to the **rotated** box when the target has `rotation`.
65
+ A `gap="1mm"` standoff keeps the tip off the target's edge (draw.io's perimeter spacing).
66
+
67
+ ### 3. Compute the path once; both renderers draw it
68
+
69
+ `textlayout.ts` states the rule: two measurers disagree at the margins, so the DOM and
70
+ the canvas exporter draw *the same computed boxes*. Arrows follow it. A pure
71
+ `src/cartograph/route.ts` turns `(fromMm, toMm, sides, style, knobs)` into a list of
72
+ path commands and head polygons in page mm; `om-arrow.ts` writes them as an SVG `d`
73
+ and `paintCartograph()` replays them on the 2D context. One geometry, two outputs, no
74
+ drift — and a headless unit test per routing style against golden paths.
75
+
76
+ ### 4. Refresh follows the things it depends on
77
+
78
+ Furniture re-renders on `om-frame-view` (`om-cartograph.ts:81`), which covers geographic
79
+ anchors on a live frame and every atlas page refit. Element anchors additionally observe
80
+ the target's placement attributes (`x y w h rotation`) with the `scheduleRender()`
81
+ coalescing that `element-base.ts` already provides, so a consumer dragging a text box
82
+ drags its arrow.
83
+
84
+ ## Attributes
85
+
86
+ ```html
87
+ <om-arrow from="#callout-1" from-side="right"
88
+ to="#main@-122.4194,37.7749"
89
+ route="elbow" angle="45deg"
90
+ end="arrow" head-size="2.5mm" gap="1mm"
91
+ stroke="#1a1612" stroke-width="0.35mm"></om-arrow>
92
+ ```
93
+
94
+ | Attribute | Values / units | Default |
95
+ |---|---|---|
96
+ | `from`, `to` | anchor grammar above | required |
97
+ | `from-side`, `to-side` | `left right top bottom center auto` | `auto` |
98
+ | `from-offset`, `to-offset` | `0…1` along the side | `0.5` |
99
+ | `route` | `straight orthogonal curved elbow` | `straight` |
100
+ | `via` | `[[x,y],…]` page mm waypoints | none |
101
+ | `angle` | `elbow` only — the diagonal's angle | `45deg` |
102
+ | `elbow-axis` | `elbow` only — the final run: `horizontal vertical` | `horizontal` |
103
+ | `elbow-length` | `elbow` only — pin the diagonal instead of deriving it | derived |
104
+ | `curvature` | `curved` only, `0…1` | `0.5` |
105
+ | `corner-radius` | `orthogonal` only, mm | `0` |
106
+ | `start`, `end` | `none arrow open dot bar diamond` | `none`, `arrow` |
107
+ | `head-size` | mm | `2.5mm` |
108
+ | `gap` | mm standoff from an element anchor | `0` |
109
+ | `stroke`, `stroke-width`, `dash`, `opacity` | as `<om-shape>`; `dash` in mm | theme `--om-carto-arrow-stroke`, falling back to the shape stroke |
110
+ | `label` | short text at the path midpoint | none |
111
+ | `label-at`, `label-side` | `0…1`; `above below on` | `0.5`, `above` |
112
+
113
+ Lengths are millimetres, as everywhere on the sheet.
114
+
115
+ ## Routing styles
116
+
117
+ **`straight`.** One segment; with `via`, a polyline.
118
+
119
+ **`orthogonal`** — the cardinal-only case. Segments are horizontal or vertical, never
120
+ diagonal. The exit direction is the attached side (or the dominant axis for a bare
121
+ point); the router chooses the fewest bends that work — 0, an L (one bend), or a Z
122
+ (two bends, with the middle segment placed at the midpoint). `corner-radius` rounds the
123
+ bends. With `via`, every consecutive pair must share an x or a y — the validator
124
+ rejects a diagonal waypoint with the fix "add an intermediate point".
125
+
126
+ **`curved`.** A cubic Bézier whose tangents leave perpendicular to the attached sides
127
+ (or along the chord for bare points); `curvature` scales the control-arm length from
128
+ 0 (a straight line) to 1 (a full S). With `via`, a Catmull-Rom spline through the
129
+ points, converted to cubics.
130
+
131
+ **`elbow`** — the "diagonal then horizontal" leader of technical drawing. A segment
132
+ at `angle` from `from`, then an axis-aligned run to `to`. The diagonal's length is
133
+ *derived*: where the ray from `from` meets the axis line through `to`; `elbow-length`
134
+ pins it instead, and the run then meets `to` with a second bend. `elbow-axis="vertical"`
135
+ flips the final run.
136
+
137
+ No obstacle avoidance: `via` is the manual escape hatch, which is also what draw.io
138
+ users reach for when its auto-router does the wrong thing.
139
+
140
+ ## Validation
141
+
142
+ Every entry an error with a fix, in the `<om-effect>` validator's idiom:
143
+
144
+ - dangling `#id` (either form) — error, and the **visible unlinked placeholder** from
145
+ `refs.ts`, never nothing: an arrow that silently vanishes is indistinguishable on
146
+ paper from one the author removed;
147
+ - geographic anchor on a frame with a degenerate georef — error;
148
+ - geographic anchor that projects **outside** its frame's box — warning (may be
149
+ intentional for an inset; say so);
150
+ - `x y w h rotation` on `<om-arrow>` — error, fix: move the ends;
151
+ - non-axis-aligned `via` under `orthogonal` — error, fix as above;
152
+ - `from` and `to` resolve to the same point — warning;
153
+ - unknown `route`, `start`, `end`, side — error listing the values;
154
+ - `<om-shape kind="arrow">` with a `for=` or anything anchor-like — hint to `<om-arrow>`.
155
+
156
+ ## Surfaces
157
+
158
+ `schema.ts` entry (`PLACED_ATTR_NAMES` minus the box attrs, plus the table above);
159
+ `cartograph/html-data.ts` with `values(...)` for every enum; `validate.ts` in the
160
+ `FURNITURE_TAGS` set; `docs/cartograph.md` element table; an example sheet with all four
161
+ routes pointing at one earthquake; skill + `llms.txt`; architecture traceability;
162
+ CHANGELOG.
163
+
164
+ ## Phases
165
+
166
+ **Phase 1 — `route.ts`.** Pure routing for all four styles, `via`, heads, `gap`, side
167
+ auto-selection. Gate: golden-path unit tests per style; orthogonal output contains no
168
+ diagonal segment for any of a fuzzed set of endpoint pairs.
169
+
170
+ **Phase 2 — the element.** Anchors, derived box, refresh wiring, DOM + canvas painters,
171
+ validation, IntelliSense. Gate: DOM-rendered and canvas-painted arrows match pixel-wise
172
+ at 96 and 300 dpi; a geographic anchor follows a live frame's camera and an atlas
173
+ refit; the consumer ticket for endpoint handles is filed.
174
+
175
+ **Phase 3 — finish.** `label`, `corner-radius`, the example sheet, doc-sync.
176
+
177
+ ## Non-goals
178
+
179
+ - Obstacle avoidance and line jumps over crossings (`via` covers the need).
180
+ - Anchoring to a *feature* by id inside a frame (would need the runtime; a
181
+ geographic point is the static equivalent and works on frozen sheets).
182
+ - Multi-segment labels or text along the path.