@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
@@ -21,6 +21,7 @@
21
21
  */
22
22
  import type { Device, Texture } from "@luma.gl/core";
23
23
  import { type RasterModule } from "@developmentseed/deck.gl-raster/gpu-modules";
24
+ import type { TileShading } from "./raster-hillshade";
24
25
  /**
25
26
  * The decoded source a tile retains — structural subset of
26
27
  * `@developmentseed/geotiff`'s RasterArray (band-separate carries `bands`,
@@ -49,6 +50,8 @@ export interface OmTileData {
49
50
  colormapTexture: Texture;
50
51
  bandCount: number;
51
52
  nodata: number | null;
53
+ /** shading="hillshade": the padded heightfield + its ground scale. Built in raster.ts's getTileData, freed with the band textures. */
54
+ shading?: TileShading | null;
52
55
  }
53
56
  /** The styling scalars every raster source (COG, Zarr) exposes. */
54
57
  export interface RasterStyle {
@@ -67,6 +70,13 @@ export interface RasterStyle {
67
70
  stretch?: string | null;
68
71
  /** Power-law exponent > 0 (display gamma); 1 = identity. */
69
72
  gamma?: number | null;
73
+ /** "hillshade" shades the source as relief. Single-band only — it reads ONE band as height. */
74
+ shading?: string | null;
75
+ /** One to four azimuths, ° clockwise from north. A list, never a boolean (see hillshade-shader.ts). */
76
+ sunAzimuth?: string | number | null;
77
+ sunWeight?: string | number | null;
78
+ sunElevation?: number | null;
79
+ zFactor?: number | null;
70
80
  }
71
81
  export declare function getColormapTexture(device: Device): Promise<Texture>;
72
82
  export declare function resolveColormapIndex(name: string): number;
package/dist/raster.d.ts CHANGED
@@ -92,6 +92,11 @@ export declare class OmCOGLayer extends OmCOGLayer_base {
92
92
  stretch: null;
93
93
  gamma: null;
94
94
  reverse: null;
95
+ shading: null;
96
+ sunAzimuth: null;
97
+ sunWeight: null;
98
+ sunElevation: null;
99
+ zFactor: null;
95
100
  };
96
101
  constructor(props: AnyProps);
97
102
  /**
@@ -268,6 +268,7 @@ export interface BasemapRuntimeOptions {
268
268
  attribution?: boolean;
269
269
  }
270
270
  export declare class RuntimeCore {
271
+ /** MapView on a Mercator map, OrthographicView over a projected plane — see createStandaloneDeck. */
271
272
  private deck?;
272
273
  private basemap?;
273
274
  /**
@@ -318,6 +319,19 @@ export declare class RuntimeCore {
318
319
  private firstSettleDrawDone;
319
320
  private destroyed;
320
321
  private viewState;
322
+ /** `<om-map crs>` — set only for a projected map; fixed for the map's life. */
323
+ private crs?;
324
+ private crsDef?;
325
+ /**
326
+ * The projected plane, once its projection has resolved. Null on a Mercator
327
+ * map, and null on a projected one until proj4 lands — which is why the Deck
328
+ * waits for it.
329
+ */
330
+ private plane;
331
+ /** A `crs` that could not be resolved. Readiness settles so the page's own await returns; nothing is drawn. */
332
+ private projectionFailed;
333
+ /** While set, only these layer ids draw — the serializer's band isolation. */
334
+ private bandIsolation;
321
335
  private callbacks;
322
336
  private parent;
323
337
  /** The live `basemap` attribute value — re-read by the lazy adapter chunk so a switch during its load lands the LATEST style. */
@@ -432,7 +446,10 @@ export declare class RuntimeCore {
432
446
  private quotaNotice?;
433
447
  private unsubscribeLicense?;
434
448
  private readonly chromeHosts;
435
- constructor(parent: HTMLElement, initialView: InitialView, callbacks?: RuntimeCoreCallbacks, basemapAttr?: string, headless?: HeadlessOptions, basemapOptions?: BasemapRuntimeOptions, chromeHosts?: MandatedChromeHosts);
449
+ constructor(parent: HTMLElement, initialView: InitialView, callbacks?: RuntimeCoreCallbacks, basemapAttr?: string, headless?: HeadlessOptions, basemapOptions?: BasemapRuntimeOptions, chromeHosts?: MandatedChromeHosts, projected?: {
450
+ crs?: string | null;
451
+ crsDef?: string | null;
452
+ });
436
453
  /** Zoom ±1 about the cursor (shift inverts), animated, tagged "user" — a real gesture, so one burst latch before the transition's programmatic frames. */
437
454
  private readonly standaloneDblclick;
438
455
  /** `basemap` attribute → concrete style, logging resolution problems (unknown preset / missing key) — the demo-style fallback still renders. */
@@ -443,6 +460,54 @@ export declare class RuntimeCore {
443
460
  * (none ↔ maplibre). Reads/seeds the camera from `this.viewState`.
444
461
  */
445
462
  private initRenderer;
463
+ /**
464
+ * `this.viewState` is ALWAYS geographic, on a projected map as much as a
465
+ * Mercator one — stories, seek(), the scale bar, the Remotion frame driver
466
+ * and every camera API read it, and a second camera model would fork all of
467
+ * them. These two functions are the only places the plane exists, and they
468
+ * are deliberately the only places.
469
+ */
470
+ /**
471
+ * The standalone overrides that still mean something without a third
472
+ * dimension. `dragRotate`/pitch caps are dropped rather than passed through,
473
+ * because an orthographic controller would either ignore them or assert.
474
+ */
475
+ /**
476
+ * `STANDALONE_MAX_ZOOM` in PLANE zoom, which is a different scale entirely.
477
+ *
478
+ * Plane zoom and geographic zoom differ by roughly sixteen levels (a plane
479
+ * unit is a metre; a Mercator world unit at mid-latitude is tens of
480
+ * kilometres), so handing the geographic constant straight to an
481
+ * `OrthographicController` set a cap so far out of range that it never
482
+ * engaged — a gesture could zoom well past where `zoomBy()` and `setView()`
483
+ * clamp, and the two disagreed about the same map's limits.
484
+ *
485
+ * Converted at the plane's ORIGIN latitude, which is fixed for the map's
486
+ * life for the same reason the origin itself is.
487
+ */
488
+ private planeMaxZoom;
489
+ private planeControllerOverrides;
490
+ /**
491
+ * The controller this map should be running, whichever mode it is in.
492
+ *
493
+ * ONE definition, because there are five places that set it: Deck creation
494
+ * and four later `setProps` calls (draw capture, drag-pan suspend, the tilt
495
+ * ceiling, the zoom floor). Those four each built a `MapController`
496
+ * unconditionally, so on a PROJECTED map the first draw-tool activation
497
+ * swapped a Mercator controller onto an orthographic viewState — and
498
+ * `MapState`'s constructor asserts on a viewState with no longitude or
499
+ * latitude, which is exactly what a plane view has. C20 recorded that
500
+ * failure for Deck creation; it came back through the four setters.
501
+ */
502
+ private currentController;
503
+ private toDeckViewState;
504
+ private fromDeckViewState;
505
+ /**
506
+ * The standalone Deck — Mercator by default, orthographic over a projected
507
+ * plane when `this.plane` is set. Split out of `initRenderer` because a
508
+ * projected map has to await its projection first.
509
+ */
510
+ private createStandaloneDeck;
446
511
  /**
447
512
  * The five pick/drag deck callbacks, shared verbatim by the lazy MapLibre
448
513
  * adapter's deckProps and the standalone `new Deck` — one place to edit the
@@ -579,7 +644,19 @@ export declare class RuntimeCore {
579
644
  * mode only, terrain's own required mode) rather than a general-purpose
580
645
  * picking API this codebase otherwise avoids.
581
646
  */
647
+ /**
648
+ * deck reports `info.coordinate` in the viewport's own world space, which on
649
+ * a plane view is METRES, not lng/lat. Everything downstream — draw, measure,
650
+ * `om-map-point`, behaviors, coordinate-anchored overlays — expects lng/lat,
651
+ * so the whole resolution runs in the plane (where the layer geometry and
652
+ * the viewport already agree) and converts once, here, on the way out.
653
+ *
654
+ * Measuring is the reason this matters rather than merely being tidy: the
655
+ * measure tool feeds these points to `geodesy.ts`, and a projected metre fed
656
+ * to a geodesic formula returns a confident, wrong distance.
657
+ */
582
658
  private resolveMapPoint;
659
+ private resolveMapPointInViewSpace;
583
660
  /**
584
661
  * See `resolveMapPoint`'s own doc comment for why this re-picks rather than
585
662
  * reusing deck's own top-level `info`. `radius` mirrors the configured
@@ -663,6 +740,30 @@ export declare class RuntimeCore {
663
740
  withCapturePixelRatio<T>(scale: number, body: () => Promise<T>, opts?: {
664
741
  timeout?: number;
665
742
  }): Promise<T>;
743
+ /**
744
+ * Capture a raster band containing only `layerIds` (or every layer when
745
+ * null), as a PNG data URI at `dpi` — the one thing the vector serializer
746
+ * needs a renderer for (§6).
747
+ *
748
+ * Isolation is a COMPOSED gate, not an edit: the IRs are the document, and
749
+ * a capture must not change it. The restore runs in a `finally` because a
750
+ * failed export that left half the sheet hidden would be a far worse bug
751
+ * than the export failing.
752
+ */
753
+ captureBand(layerIds: readonly string[] | null, dpi: number): Promise<string>;
754
+ /**
755
+ * Whether the RESOLVED effect chain carries a real post-process pass.
756
+ *
757
+ * `instanceof PostProcessEffect` against what deck is actually running —
758
+ * not "is there an `<om-effect>` element", which misses `setEffects()`, and
759
+ * not "does deck have any effects", which catches the collision effect a
760
+ * decluttering layer installs by itself (§13.1). Both are wrong, in opposite
761
+ * directions, and each would make one document export two different ways.
762
+ */
763
+ resolvedPostProcessPass(): Promise<{
764
+ present: boolean;
765
+ label?: string;
766
+ }>;
666
767
  snapshot(): Promise<HTMLCanvasElement>;
667
768
  /**
668
769
  * Live basemap change (spec: "Basemap presets & switching"), both paths:
@@ -721,7 +822,45 @@ export declare class RuntimeCore {
721
822
  * resolves) and the first frame. With a basemap: the MapLibre-backed
722
823
  * adapter, once the basemap's style has loaded.
723
824
  */
825
+ /**
826
+ * The four ground corners a `widthPx × heightPx` box of THIS map would see,
827
+ * in tl, tr, br, bl order — or null when the map is not projected, which
828
+ * leaves the caller's own Web Mercator reconstruction untouched.
829
+ *
830
+ * Only the map can answer this for a projected view: the camera is
831
+ * geographic, so a caller reconstructing a `WebMercatorViewport` from it
832
+ * gets a plausible box for a map that is not drawn that way. A cartograph
833
+ * frame renders at its own print-resolution pixel size rather than the
834
+ * map's CSS size, so the viewport is rebuilt here at the size asked for.
835
+ *
836
+ * The payoff downstream is exactness: an orthographic frame's corners are an
837
+ * AFFINE map of the plane, so the georeference fitted from them has no
838
+ * projective residue at all — no pitch cap, no wrap, world-file-able.
839
+ */
840
+ groundCorners(widthPx: number, heightPx: number): [number, number][] | null;
841
+ /** The CRS this map is projected into, or null for a Web Mercator map. */
842
+ projectedCrs(): string | null;
724
843
  getViewport(): MapViewport | undefined;
844
+ /**
845
+ * The vector serializer's whole runtime dependency, in one method
846
+ * (§6, Part C).
847
+ *
848
+ * Everything the serializer needs that only a live map knows: the IRs in
849
+ * document order, how to project lng/lat to frame pixels, the ground scale
850
+ * for metre-valued widths, whether a real post-process pass is running, and
851
+ * a way to capture a band. The serializer itself is pure and headless.
852
+ */
853
+ serializeSvg(opts?: {
854
+ effectDpi?: number;
855
+ featureBudget?: number;
856
+ }): Promise<{
857
+ svg: string;
858
+ notices: {
859
+ code: string;
860
+ message: string;
861
+ fix: string;
862
+ }[];
863
+ }>;
725
864
  /** Renderer init state — feeds the `om-map-ready` signal. Headless has nothing async to wait for. */
726
865
  isReady(): boolean;
727
866
  /**
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Clipping geometry to the frame, in screen pixels
3
+ * (docs/design/carto-substrate.md §6, "Feature-count guard").
4
+ *
5
+ * Two jobs in one pass. A print sheet is thousands of features and an SVG with
6
+ * half a million paths is unusable, so anything outside the frame is dropped
7
+ * before it is ever written. And a feature that merely CROSSES the frame is
8
+ * trimmed rather than emitted whole — otherwise a coastline spanning a
9
+ * continent arrives as a single path with a hundred thousand vertices, 99% of
10
+ * them off the page, which is the "giant path" that makes editors crawl.
11
+ *
12
+ * Clipping happens in SCREEN space, after projection, on purpose: the frame is
13
+ * a rectangle there and an arbitrary quadrilateral in any projected plane, and
14
+ * a rectangle is the only shape Sutherland-Hodgman is simple against.
15
+ */
16
+ export type Point = [number, number];
17
+ export interface Rect {
18
+ left: number;
19
+ top: number;
20
+ right: number;
21
+ bottom: number;
22
+ }
23
+ export declare function containsPoint(rect: Rect, p: Point): boolean;
24
+ /** Whether a polyline's or ring's bounding box misses the rect entirely — the cheap reject. */
25
+ export declare function boundsMiss(points: readonly Point[], rect: Rect): boolean;
26
+ /**
27
+ * Clip one segment to the rect. Returns null when it misses entirely.
28
+ *
29
+ * Liang-Barsky rather than Cohen-Sutherland: it computes the surviving
30
+ * parameter interval directly instead of iterating, which matters when the
31
+ * input is a densely-digitized coastline and most segments are decided by
32
+ * arithmetic alone.
33
+ */
34
+ export declare function clipSegment(a: Point, b: Point, rect: Rect): [Point, Point] | null;
35
+ /**
36
+ * Clip a polyline, returning the surviving RUNS. A line that leaves the frame
37
+ * and comes back is two runs, not one — joining them would draw a chord
38
+ * straight across the page.
39
+ */
40
+ export declare function clipPolyline(points: readonly Point[], rect: Rect): Point[][];
41
+ /**
42
+ * Clip a polygon RING to the rect. Returns an empty array when nothing
43
+ * survives.
44
+ *
45
+ * Sutherland-Hodgman produces degenerate zero-width connections when a concave
46
+ * ring leaves and re-enters — a known artefact, and harmless here: they are
47
+ * invisible under a fill and this output is artwork, not an analytic product.
48
+ * The same line §5 draws around `buffer`.
49
+ */
50
+ export declare function clipRing(ring: readonly Point[], rect: Rect): Point[];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The CPU label pass (docs/design/carto-substrate.md §6, "Text").
3
+ *
4
+ * `CollisionFilterExtension` decides survivors on the GPU, in a framebuffer
5
+ * sized from the canvas and halved — so the set of labels it kept depends on
6
+ * the capture ratio, and the serializer cannot ask deck which ones they were.
7
+ * It runs its own pass instead: greedy by priority over measured boxes,
8
+ * deterministic and resolution-independent.
9
+ *
10
+ * That is a feature rather than a workaround. Deck-side collision stays the
11
+ * interactive preview; this is the print truth, and it is the natural home for
12
+ * the placement work the GPU path has no room for — candidate positions,
13
+ * leader lines, text on a path — when that lands.
14
+ */
15
+ export interface LabelBox {
16
+ id: string;
17
+ /** Higher wins. Ties break by index, so the pass is a pure function of its input order. */
18
+ priority: number;
19
+ left: number;
20
+ top: number;
21
+ right: number;
22
+ bottom: number;
23
+ }
24
+ /**
25
+ * Greedy by priority. Returns the indices that survive, in the INPUT's order —
26
+ * so the caller emits labels in document order rather than priority order, and
27
+ * two runs over the same input produce the same file byte for byte.
28
+ *
29
+ * `padding` is the breathing room between boxes, in the same pixels the boxes
30
+ * are measured in. It exists because two labels that merely touch read as one
31
+ * word, and because deck's own `collisionTestProps` convention is to reserve
32
+ * more room than the glyphs occupy.
33
+ */
34
+ export declare function declutter(boxes: readonly LabelBox[], padding?: number): number[];
35
+ /**
36
+ * Measure a label's box from its text, size and anchor, without a DOM.
37
+ *
38
+ * A real measurement needs the font; this is the fallback the serializer uses
39
+ * when no measurer is supplied, and it is DELIBERATELY generous: 0.6em per
40
+ * character is wider than most proportional faces, so the pass drops a label
41
+ * that would have fitted rather than keeping one that would have collided.
42
+ * Erring toward a sparser sheet is the right direction for print.
43
+ */
44
+ export declare function estimateLabelBox(text: string, x: number, y: number, sizePx: number, anchor?: "start" | "middle" | "end", baseline?: "top" | "center" | "bottom"): Omit<LabelBox, "id" | "priority">;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * IR + viewport → SVG elements (docs/design/carto-substrate.md §6).
3
+ *
4
+ * Pure: no DOM, no deck, no map state. Everything it needs arrives as an
5
+ * argument, which is what lets the whole strategy table be unit-tested against
6
+ * hand-written IR instead of a GPU.
7
+ */
8
+ import type { LayerIR } from "../ir";
9
+ import { type Point, type Rect } from "./clip";
10
+ /** Projects lng/lat to screen pixels — `viewport.project`, narrowed to what this needs. */
11
+ export type Project = (lngLat: [number, number]) => Point;
12
+ export interface EmitContext {
13
+ project: Project;
14
+ frame: Rect;
15
+ /** Ground metres per screen pixel at the frame centre — for metre-valued widths and radii. */
16
+ metresPerPixel: number;
17
+ /** Above this many emitted elements the caller is told to simplify. */
18
+ featureBudget: number;
19
+ }
20
+ export interface EmitResult {
21
+ markup: string;
22
+ elementCount: number;
23
+ }
24
+ /**
25
+ * A layer's features as `<path>` / `<circle>`.
26
+ *
27
+ * Holes are emitted as extra subpaths of ONE `<path>` with the default
28
+ * `fill-rule: nonzero`... which is wrong for a ring wound the same way as its
29
+ * outer. GeoJSON does not guarantee winding, so `fill-rule="evenodd"` is used
30
+ * instead: it needs no winding convention and gives the right answer for every
31
+ * ring order, at no cost the renderer can see.
32
+ */
33
+ export declare function emitVectorLayer(ir: LayerIR, ctx: EmitContext): EmitResult;
34
+ /** Text measurement, when the caller has a real one (a canvas 2D context). */
35
+ export type MeasureText = (text: string, sizePx: number, family: string) => number;
36
+ /**
37
+ * A TextLayer as real `<text>`, after the CPU declutter pass.
38
+ *
39
+ * Positions are the MEASURED ones, not re-derived here — `textlayout.ts`
40
+ * already states the rule that two measurers disagree at the margins, so every
41
+ * renderer draws the same computed boxes. The serializer follows it: when a
42
+ * measurer is supplied it is the SAME one the frame was laid out with.
43
+ */
44
+ export declare function emitTextLayer(ir: LayerIR, ctx: EmitContext, measure?: MeasureText): EmitResult;
45
+ /**
46
+ * A `TextOnPathLayer` as SVG `<textPath>` — one editable string per label,
47
+ * still following its own line.
48
+ *
49
+ * This is the one place the exporter produces BETTER output than the renderer
50
+ * rather than merely equivalent output. The layer draws N independently
51
+ * rotated glyphs because that is what a GPU text layer can do; SVG has the
52
+ * real primitive, so the file carries the word "Rio Grande" attached to the
53
+ * river's own path. An editor lets you retype it; the glyphs would not.
54
+ *
55
+ * The path goes in a `<defs>` and is referenced, because a `<textPath>` needs a
56
+ * path it can name and the line itself is usually drawn by a different layer.
57
+ */
58
+ export declare function emitTextOnPathLayer(ir: LayerIR, ctx: EmitContext): EmitResult;
59
+ /** A raster band as `<image>`, at the frame's own size. */
60
+ export declare function emitRasterBand(href: string, frame: Rect, ids: readonly string[]): string;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * `snapshot({ format: "svg" })` — the vector serializer
3
+ * (docs/design/carto-substrate.md §6, Part C).
4
+ *
5
+ * A lazy chunk. A map that never asks for SVG must never download it, which is
6
+ * asserted from both ends: an e2e that watches the network, and a bundle
7
+ * assertion that no serializer symbol appears in the core chunk.
8
+ *
9
+ * The output is a HYBRID by design — vector linework over placed raster bands.
10
+ * That is not a fallback: it is how cartographic production has always worked,
11
+ * and it lets the serializer be honest about what it cannot vectorise rather
12
+ * than refusing or faking it.
13
+ */
14
+ import type { LayerIR } from "../ir";
15
+ import { type MeasureText } from "./emit";
16
+ export { groupIntoRuns, strategyFor, isKnownType } from "./strategy";
17
+ export { declutter, estimateLabelBox } from "./declutter";
18
+ export { emitVectorLayer, emitTextLayer, emitTextOnPathLayer, emitRasterBand } from "./emit";
19
+ export { clipRing, clipPolyline, clipSegment } from "./clip";
20
+ export { resolveFeatureStyle, resolveLineWidth, resolveRadius, resolveDashArray, deckColorToSvg } from "./style";
21
+ /** A dev notice — something the author should be told, not left to find in a print shop. */
22
+ export interface SerializerNotice {
23
+ code: "rasterised-by-effect" | "unknown-layer-type" | "feature-budget";
24
+ message: string;
25
+ fix: string;
26
+ }
27
+ export interface SerializeOptions {
28
+ width: number;
29
+ height: number;
30
+ project: (lngLat: [number, number]) => [number, number];
31
+ metresPerPixel: number;
32
+ /**
33
+ * Captures a band for the named layers and returns a data URI. The caller
34
+ * owns this because it is the one thing here that needs the renderer.
35
+ */
36
+ captureBand: (layerIds: string[] | null, dpi: number) => Promise<string>;
37
+ /**
38
+ * True when the RESOLVED effect chain contains a real post-process pass.
39
+ *
40
+ * The caller tests `instanceof PostProcessEffect` against the chain deck is
41
+ * actually running — not "is there an `<om-effect>` element" and not "does
42
+ * deck have any effects". Both of those are wrong, in opposite directions:
43
+ * deck's array also carries effects it installs itself (a decluttering layer
44
+ * adds one), while an authored element is not the only way a real pass
45
+ * arrives (`setEffects()` is the other). §13.1 has the reasoning.
46
+ */
47
+ hasPostProcessPass: boolean;
48
+ /** The pass's name, for the notice. */
49
+ postProcessLabel?: string;
50
+ /** Raster band resolution, independent of the sheet's. Default 600 (§12.2). */
51
+ effectDpi?: number;
52
+ featureBudget?: number;
53
+ measureText?: MeasureText;
54
+ }
55
+ export interface SerializeResult {
56
+ svg: string;
57
+ notices: SerializerNotice[];
58
+ elementCount: number;
59
+ }
60
+ export declare const DEFAULT_EFFECT_DPI = 600;
61
+ export declare const DEFAULT_FEATURE_BUDGET = 50000;
62
+ /** CSS pixels are 96 dpi by definition; a band at `dpi` is that much denser. */
63
+ export declare function bandScaleFor(dpi: number): number;
64
+ export declare function serializeToSvg(irs: readonly LayerIR[], opts: SerializeOptions): Promise<SerializeResult>;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Which route each layer takes out of the renderer
3
+ * (docs/design/carto-substrate.md §6, "Contract").
4
+ *
5
+ * The "hybrid" output — vector linework over placed relief — is not a
6
+ * fallback. It is how cartographic production has always worked, and it is the
7
+ * reason this serializer can be honest about the layers it cannot vectorise
8
+ * instead of refusing or faking them.
9
+ */
10
+ export type Strategy = "vector" | "raster" | "text" | "path-text";
11
+ export declare function strategyFor(type: string): Strategy;
12
+ /** For diagnostics — whether the type was RECOGNISED, as opposed to defaulted into a band. */
13
+ export declare function isKnownType(type: string): boolean;
14
+ export interface LayerRun {
15
+ strategy: Strategy;
16
+ /** Layer ids, in document order. */
17
+ ids: string[];
18
+ }
19
+ /**
20
+ * Group layers into runs, merging CONSECUTIVE raster layers into one band.
21
+ *
22
+ * Consecutive is load-bearing: two raster layers with a vector layer between
23
+ * them are three bands, not two, because merging them would move the vector
24
+ * layer's linework underneath relief it was authored above. Stacking order is
25
+ * the one thing a serializer must not quietly rearrange.
26
+ */
27
+ export declare function groupIntoRuns(layers: readonly {
28
+ id: string;
29
+ type: string;
30
+ }[]): LayerRun[];
@@ -0,0 +1,77 @@
1
+ /**
2
+ * deck props → SVG presentation attributes
3
+ * (docs/design/carto-substrate.md §6, "Style mapping").
4
+ *
5
+ * The mapping is EXPLICIT and its divergences are documented rather than
6
+ * discovered. deck's blending, antialiasing and dash rendering do not match
7
+ * SVG's exactly; what matters is that every difference here is a decision
8
+ * somebody made, and that the visual-diff gate measures the total.
9
+ */
10
+ import type { LayerIR } from "../ir";
11
+ export interface ResolvedStyle {
12
+ fill: string;
13
+ fillOpacity: number;
14
+ stroke: string;
15
+ strokeOpacity: number;
16
+ strokeWidth: number;
17
+ dashArray?: string;
18
+ /** Point radius in px — Scatterplot and friends. */
19
+ radius?: number;
20
+ }
21
+ /** deck colours are `[r, g, b]` or `[r, g, b, a]` with a in 0-255; SVG wants a hex triple plus a 0-1 opacity. */
22
+ export declare function deckColorToSvg(value: unknown): {
23
+ color: string;
24
+ opacity: number;
25
+ };
26
+ /**
27
+ * The accessor names, per family, in the order they should be tried.
28
+ *
29
+ * deck does NOT use one vocabulary. `PathLayer` and `LineLayer` say
30
+ * `getColor`/`getWidth`; `GeoJsonLayer`, `PolygonLayer` and `ScatterplotLayer`
31
+ * say `getLineColor`/`getLineWidth`; `ArcLayer` says `getSourceColor`. Reading
32
+ * only the GeoJSON names made every PathLayer export as a black hairline —
33
+ * deck's defaults, faithfully rendered, and nothing like the authored map.
34
+ * Enumerated from the registry rather than remembered, and pinned by a test.
35
+ */
36
+ export declare const STROKE_COLOR_PROPS: readonly ["getLineColor", "getColor", "getSourceColor"];
37
+ export declare const STROKE_WIDTH_PROPS: readonly ["getLineWidth", "getWidth"];
38
+ export declare const WIDTH_SCALE_PROPS: readonly ["lineWidthScale", "widthScale"];
39
+ export declare const WIDTH_UNITS_PROPS: readonly ["lineWidthUnits", "widthUnits"];
40
+ export declare const WIDTH_MIN_PROPS: readonly ["lineWidthMinPixels", "widthMinPixels"];
41
+ export declare const WIDTH_MAX_PROPS: readonly ["lineWidthMaxPixels", "widthMaxPixels"];
42
+ export declare const RADIUS_PROPS: readonly ["getRadius", "getPointRadius"];
43
+ export declare const RADIUS_SCALE_PROPS: readonly ["radiusScale", "pointRadiusScale"];
44
+ export declare const RADIUS_UNITS_PROPS: readonly ["radiusUnits", "pointRadiusUnits"];
45
+ export declare const RADIUS_MIN_PROPS: readonly ["radiusMinPixels", "pointRadiusMinPixels"];
46
+ export declare const RADIUS_MAX_PROPS: readonly ["radiusMaxPixels", "pointRadiusMaxPixels"];
47
+ /**
48
+ * Line width in SCREEN PIXELS, which is what SVG needs.
49
+ *
50
+ * `lineWidthUnits: "meters"` is deck's other mode, and it is the one that
51
+ * cannot be resolved per feature without the viewport's scale — so the caller
52
+ * passes `metresPerPixel` and this converts. Getting that wrong is not subtle:
53
+ * a 20-metre road casing emitted as 20 px is a black sheet.
54
+ */
55
+ export declare function resolveLineWidth(ir: LayerIR, row: unknown, index: number, metresPerPixel: number): number;
56
+ /** Point radius in screen pixels, by the same rules deck applies to `getRadius`. */
57
+ export declare function resolveRadius(ir: LayerIR, row: unknown, index: number, metresPerPixel: number): number;
58
+ /**
59
+ * `dash` → `stroke-dasharray`.
60
+ *
61
+ * deck's `PathStyleExtension` states the dash in LINE-WIDTH UNITS, and SVG's
62
+ * dasharray is in user units — pixels here. So the pattern scales with the
63
+ * resolved stroke width, which is also what makes a dashed border look the
64
+ * same after a zoom change.
65
+ */
66
+ export declare function resolveDashArray(ir: LayerIR, strokeWidthPx: number): string | undefined;
67
+ /**
68
+ * Everything a single feature needs to be drawn, resolved once.
69
+ *
70
+ * `filled` and `stroked` are honoured as deck honours them — a `filled: false`
71
+ * polygon layer emits `fill="none"` rather than a transparent fill, because a
72
+ * transparent fill still costs the renderer a shape and still shows in an
73
+ * editor's object list.
74
+ */
75
+ export declare function resolveFeatureStyle(ir: LayerIR, row: unknown, index: number, metresPerPixel: number): ResolvedStyle;
76
+ /** The presentation attributes for a filled+stroked shape, as an attribute string. */
77
+ export declare function styleAttributes(style: ResolvedStyle, kind: "area" | "line"): string;
@@ -4,6 +4,30 @@
4
4
  * serialized to the consumer's preferred shape.
5
5
  */
6
6
  export interface SnapshotOptions {
7
+ /**
8
+ * `"raster"` (the default) is the canvas capture every existing caller gets.
9
+ * `"svg"` runs the vector serializer instead (docs/design/carto-substrate.md
10
+ * §6): vector linework for the layers whose geometry IS the data, raster
11
+ * bands for the ones whose appearance is pixels, real `<text>` for labels.
12
+ *
13
+ * The serializer is a LAZY chunk — asking for raster never downloads it.
14
+ */
15
+ format?: "raster" | "svg";
16
+ /**
17
+ * SVG only: the raster bands' own resolution, independent of the sheet's.
18
+ * Default 600 — anyone exporting vector is exporting for print quality, and
19
+ * a surprising file size is easier to discover and fix than surprising soft
20
+ * type.
21
+ */
22
+ effectDpi?: number;
23
+ /** SVG only: above this many emitted elements the result carries a notice offering `simplify`. */
24
+ featureBudget?: number;
25
+ /** SVG only: receives the serializer's dev notices. Without it they go to the console. */
26
+ onNotice?: (notice: {
27
+ code: string;
28
+ message: string;
29
+ fix: string;
30
+ }) => void;
7
31
  /** Image MIME type — default "image/png". */
8
32
  type?: "image/png" | "image/jpeg" | "image/webp";
9
33
  /** Lossy-format quality 0–1 (jpeg/webp). */
@@ -44,3 +68,25 @@ export declare function captureStable(core: {
44
68
  maxRounds?: number;
45
69
  requiredStableRuns?: number;
46
70
  }): Promise<string | Blob>;
71
+ /**
72
+ * `snapshot({ format: "svg" })` — shared by both front-ends, one definition,
73
+ * for the same reason `captureStable` is.
74
+ *
75
+ * Notices reach the caller through `onNotice` when it supplies one, and the
76
+ * console otherwise. They are never silent: an author who wanted editable type
77
+ * and did not realise a finish forecloses it should be told here, not in a
78
+ * print shop.
79
+ */
80
+ export declare function snapshotSvg(core: {
81
+ serializeSvg(opts: {
82
+ effectDpi?: number;
83
+ featureBudget?: number;
84
+ }): Promise<{
85
+ svg: string;
86
+ notices: {
87
+ code: string;
88
+ message: string;
89
+ fix: string;
90
+ }[];
91
+ }>;
92
+ }, opts: SnapshotOptions): Promise<string | Blob>;
@@ -11,6 +11,12 @@
11
11
  */
12
12
  import type { LayerData } from "./ir";
13
13
  import type { Shape } from "./expr";
14
+ /**
15
+ * Even-odd crossing test. Exported because `transform/dot-density.ts` needs
16
+ * exactly this and had a byte-identical private copy — so a fix to the
17
+ * degenerate horizontal-edge case would have landed in one of them.
18
+ */
19
+ export declare function pointInRing(ring: readonly (readonly number[])[], x: number, y: number): boolean;
14
20
  /** A point guaranteed inside the largest ring of the geometry (see module doc). */
15
21
  export declare function pointOnSurface(coords: unknown): [number, number] | null;
16
22
  /** Installs the surface-anchored getPosition (no-ops: no anchor, authored position, no rows yet). */
@@ -1,19 +1,3 @@
1
- /**
2
- * Bulk terrain heightfield (spec item C2 / "Elevation profile" — the shared
3
- * infrastructure both reference, "sampling shares C2's bulk heightfield, not
4
- * per-point elevationAt()"). `terrain-sample.ts`'s `sampleTerrainElevation`
5
- * is one fetch per point — fine for volume mode's handful of footprint
6
- * vertices, but the wrong shape for a profile's tens-to-hundreds of samples
7
- * along a line or the volumetrics grid's 10⁵–10⁶ cells: nearby points share
8
- * DEM tiles, so fetching (and decoding) each tile once and reading every
9
- * point out of it in memory is both fewer round-trips and what the per-cell
10
- * volume integrator (volumetrics.ts) builds on.
11
- *
12
- * This module is the DOM-TOUCHING half (fetch + canvas decode); the pixel
13
- * math — bilinear sampling with tile-seam handling — lives in
14
- * volumetrics.ts's `sampleBilinear`, which is pure and shared with the
15
- * volumetrics worker (decoded tiles postMessage across; canvases don't).
16
- */
17
1
  import type { LngLat } from "./geodesy";
18
2
  import type { TerrainIR } from "./terrain";
19
3
  import { type HeightfieldTiles } from "./volumetrics";