@nika-js/onlymap 0.9.1 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +27 -3
- package/dist/{basemap-DL0mk9Bf.js → basemap-DzQBuqBn.js} +3882 -3980
- package/dist/cartograph/elements/om-frame.d.ts +67 -1
- package/dist/cartograph/georef.d.ts +18 -4
- package/dist/cartograph/schema.d.ts +11 -0
- package/dist/cartograph.js +1480 -1311
- package/dist/cartograph.standalone.js +1808 -1615
- package/dist/{cityjson-D_V5GY8b.js → cityjson-k-z1r6c0.js} +1 -1
- package/dist/{crs-DsDQ4Q4i.js → crs-BzE_KP4M.js} +25 -2
- package/dist/{crs-Ciu7Xs7a.js → crs-ChglCB3O.js} +39 -16
- package/dist/elements/om-map.d.ts +10 -0
- package/dist/{geoparquet-DJxZA0if.js → geoparquet-BlFSeNwf.js} +10 -10
- package/dist/globe-view-qTt7YaiC.js +104 -0
- package/dist/hillshade-Ds0pONmA.js +298 -0
- package/dist/{hillshade-shader-n_zManfZ.js → hillshade-shader-DI2uLSNU.js} +15 -10
- package/dist/hillshade-shader.d.ts +18 -2
- package/dist/hillshade.d.ts +30 -0
- package/dist/{ifc-Dc-TdSJr.js → ifc-DXwePQRv.js} +131 -131
- package/dist/{index-vLXZuog4.js → index-B9kwlhFA.js} +1 -1
- package/dist/index-BCTAq6uy.js +65 -0
- package/dist/{index-DdTZSuAb.js → index-BK99wPf_.js} +106 -106
- package/dist/index-BSwEOxkR.js +322 -0
- package/dist/{index-BjcPjICh.js → index-Bpk1EipB.js} +59 -59
- package/dist/index-C2VK-Is6.js +641 -0
- package/dist/index-C4oddUIX.js +459 -0
- package/dist/{index-oY3XHIux.js → index-CBYDP-_0.js} +18178 -16943
- package/dist/{index-CvuDsvnk.js → index-oL_18WvP.js} +47 -47
- package/dist/index.d.ts +4 -0
- package/dist/layer-registry.d.ts +27 -0
- package/dist/{lerc-Bph62dCb.js → lerc-xM89n_hR.js} +1 -1
- package/dist/onlymap.standalone.js +48211 -45574
- package/dist/onlymapjs.js +77 -74
- package/dist/parse-manifest.d.ts +6 -0
- package/dist/plane-camera.d.ts +59 -0
- package/dist/plane-layers.d.ts +56 -0
- package/dist/plane-tiles.d.ts +99 -0
- package/dist/plane-tileset.d.ts +31 -0
- package/dist/plane-warp.d.ts +91 -0
- package/dist/post-process-effect-CNMzoP-h.js +197 -0
- package/dist/programmatic.d.ts +16 -1
- package/dist/projection.d.ts +118 -0
- package/dist/{raster-pipeline-BlOnMPJe.js → raster-pipeline-B_gY9-5f.js} +4 -3
- package/dist/{raster-D-eTzCE3.js → raster-yVRqHYLH.js} +4 -4
- package/dist/runtime-core.d.ts +140 -1
- package/dist/serialize/clip.d.ts +50 -0
- package/dist/serialize/declutter.d.ts +44 -0
- package/dist/serialize/emit.d.ts +60 -0
- package/dist/serialize/index.d.ts +64 -0
- package/dist/serialize/strategy.d.ts +30 -0
- package/dist/serialize/style.d.ts +77 -0
- package/dist/snapshot.d.ts +46 -0
- package/dist/surface-anchor.d.ts +6 -0
- package/dist/text-on-path-D-fhYDqa.js +146 -0
- package/dist/text-on-path.d.ts +157 -0
- package/dist/transform/buffer.d.ts +63 -0
- package/dist/transform/contour.d.ts +37 -0
- package/dist/transform/dot-density.d.ts +19 -0
- package/dist/transform/field.d.ts +80 -0
- package/dist/transform/geometry.d.ts +20 -0
- package/dist/transform/index.d.ts +29 -0
- package/dist/transform/simplify.d.ts +10 -0
- package/dist/transform/smooth.d.ts +12 -0
- package/dist/transform-stage.d.ts +92 -0
- package/dist/version.d.ts +1 -1
- package/dist/{zarr-BGDoEtFb.js → zarr-BPeWy3ro.js} +2 -2
- package/docs/cartograph.md +12 -4
- package/docs/cartography.md +328 -0
- package/docs/design/arrows.md +182 -0
- package/docs/design/carto-substrate.md +1055 -0
- package/docs/design/extensions.md +250 -0
- package/llms.txt +3 -2
- package/onlymapjs.attributes.json +18 -0
- package/onlymapjs.html-data.json +169 -19
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +6 -2
- package/skills/onlymapjs/references/syntax.md +22 -2
- package/dist/hillshade-DR3TxO1a.js +0 -186
- package/dist/index-DO_w0tqR.js +0 -514
|
@@ -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.
|