@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,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `buffer` — the coastal vignette (docs/design/carto-substrate.md §5).
|
|
3
|
+
*
|
|
4
|
+
* A cartographic ORNAMENT, not an analytic product. The distinction is the
|
|
5
|
+
* same one shaded relief settled: a vignette is measured by eye, a 500 m
|
|
6
|
+
* setback is a number somebody acts on. The first is in scope; the second is a
|
|
7
|
+
* non-goal, and the validator says so rather than letting an author discover
|
|
8
|
+
* it from a wrong answer.
|
|
9
|
+
*
|
|
10
|
+
* `repeat` and `fade` are what the feature is FOR. Once a signed distance
|
|
11
|
+
* field exists, N bands are N thresholds of one field — not N offset
|
|
12
|
+
* operations — so the classic engraved shoreline costs one transform.
|
|
13
|
+
*/
|
|
14
|
+
import { type Ring } from "./field";
|
|
15
|
+
export interface BufferOptions {
|
|
16
|
+
/** Band width in ground metres. Negative buffers inward. */
|
|
17
|
+
distanceMetres: number;
|
|
18
|
+
/** How many bands. 1 is a single outline; 5 is the engraved shoreline. */
|
|
19
|
+
repeat: number;
|
|
20
|
+
/** Fade the bands' opacity outward, as a `_bandOpacity` property per feature. */
|
|
21
|
+
fade: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Cells across the band width. The whole error budget is one cell, so this
|
|
24
|
+
* is the only accuracy knob — and refining it costs memory quadratically for
|
|
25
|
+
* accuracy linearly, which is why the design doc says to improve the SEEDING
|
|
26
|
+
* rather than the grid if it ever matters.
|
|
27
|
+
*/
|
|
28
|
+
cellsPerBand: number;
|
|
29
|
+
/** Hard ceiling on grid cells, so one enormous feature cannot wedge the tab. */
|
|
30
|
+
maxCells: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The grid-cell ceiling, and why it is where it is.
|
|
34
|
+
*
|
|
35
|
+
* `signedDistanceField` holds five arrays at once — `inside` and `outside`
|
|
36
|
+
* (1 byte each) plus `toInside`, `toOutside` and the result (8 bytes each) —
|
|
37
|
+
* which is **26 bytes per cell**. The first ceiling was 40 million, i.e. just
|
|
38
|
+
* over a GIGABYTE of typed arrays before marching squares allocates anything:
|
|
39
|
+
* the tab-wedging the ceiling exists to prevent rather than a guard against
|
|
40
|
+
* it. Four million cells is ~104 MB — large, survivable, and still far more
|
|
41
|
+
* resolution than a band whose whole error budget is one cell ever needs.
|
|
42
|
+
*/
|
|
43
|
+
export declare const BUFFER_MAX_CELLS = 4000000;
|
|
44
|
+
export declare function isPolygonalGeometry(type: unknown): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Buffer one feature's geometry into `repeat` bands.
|
|
47
|
+
*
|
|
48
|
+
* Works in the feature's own local metric frame for the same reason `simplify`
|
|
49
|
+
* does: a band authored in metres must be the same width at every latitude,
|
|
50
|
+
* and a degree of longitude is not a fixed distance.
|
|
51
|
+
*/
|
|
52
|
+
export declare function bufferGeometry(coords: unknown, opts: BufferOptions): {
|
|
53
|
+
rings: Ring[];
|
|
54
|
+
band: number;
|
|
55
|
+
}[];
|
|
56
|
+
/**
|
|
57
|
+
* Buffer every row into band features, OUTERMOST FIRST.
|
|
58
|
+
*
|
|
59
|
+
* Order is the whole visual effect: drawn in this order with a fill, the bands
|
|
60
|
+
* stack into the engraved shoreline of a nineteenth-century chart. Reversed,
|
|
61
|
+
* the widest band covers all the others and the sheet shows one flat halo.
|
|
62
|
+
*/
|
|
63
|
+
export declare function bufferRows(rows: readonly unknown[], opts: BufferOptions, onSkip?: (type: string) => void): unknown[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Grid } from "./field";
|
|
2
|
+
export interface ElevationDecoderSpec {
|
|
3
|
+
rScaler: number;
|
|
4
|
+
gScaler: number;
|
|
5
|
+
bScaler: number;
|
|
6
|
+
offset: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ContourOptions {
|
|
9
|
+
/** `{z}/{x}/{y}` DEM template. */
|
|
10
|
+
template: string;
|
|
11
|
+
decoder: ElevationDecoderSpec;
|
|
12
|
+
/** Tile zoom. Higher is sharper and quadratically more tiles. */
|
|
13
|
+
zoom: number;
|
|
14
|
+
/** `[west, south, east, north]`. */
|
|
15
|
+
bounds: [number, number, number, number];
|
|
16
|
+
/** Contour interval in metres. */
|
|
17
|
+
intervalMetres: number;
|
|
18
|
+
/** Ceiling on tiles fetched, so a careless zoom cannot issue a thousand requests. */
|
|
19
|
+
maxTiles: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Assemble the DEM tiles covering `bounds` into one height grid.
|
|
23
|
+
*
|
|
24
|
+
* The grid is in MERCATOR pixel space — x is longitude-linear and y is the
|
|
25
|
+
* Mercator ordinate — because that is the space the tiles are already in, and
|
|
26
|
+
* resampling them into anything else before contouring would put the
|
|
27
|
+
* resampler's own error into every isoline. The vertices come back out as
|
|
28
|
+
* lng/lat, where the y conversion undoes the ordinate exactly.
|
|
29
|
+
*/
|
|
30
|
+
export declare function assembleHeightGrid(opts: ContourOptions): Promise<{
|
|
31
|
+
heights: Float32Array;
|
|
32
|
+
covered: Uint8Array;
|
|
33
|
+
grid: Grid;
|
|
34
|
+
toLngLat: (x: number, y: number) => [number, number];
|
|
35
|
+
} | null>;
|
|
36
|
+
/** A contour level's features, as GeoJSON LineStrings carrying their own elevation. */
|
|
37
|
+
export declare function contourFromDem(opts: ContourOptions): Promise<unknown[]>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { coordinateCentre } from "./geometry";
|
|
2
|
+
export interface DotDensityOptions {
|
|
3
|
+
/** Row property holding the count to scatter. */
|
|
4
|
+
field: string;
|
|
5
|
+
/** Units of that field per dot. 1000 people per dot, say. */
|
|
6
|
+
per: number;
|
|
7
|
+
seed: number;
|
|
8
|
+
/** Hard ceiling per feature, so one bad row cannot emit a million points. */
|
|
9
|
+
maxPerFeature: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Scatter one feature. Returns Point features carrying the source row's own
|
|
13
|
+
* properties, so every accessor the author already wrote — colour by party,
|
|
14
|
+
* tooltip by county name — keeps working against the dots.
|
|
15
|
+
*/
|
|
16
|
+
export declare function scatterFeature(row: unknown, index: number, opts: DotDensityOptions): unknown[];
|
|
17
|
+
export declare function scatterRows(rows: readonly unknown[], opts: DotDensityOptions): unknown[];
|
|
18
|
+
/** Re-exported for the tests that check the frame's origin choice is irrelevant here. */
|
|
19
|
+
export { coordinateCentre };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared machinery behind `buffer` and `contour`
|
|
3
|
+
* (docs/design/carto-substrate.md §5): rasterize, distance-transform,
|
|
4
|
+
* iso-contour. One piece of code, because a buffer of *d* is exactly "the
|
|
5
|
+
* *d* isoline of a signed distance field", and an isoline is what `contour`
|
|
6
|
+
* wants anyway.
|
|
7
|
+
*
|
|
8
|
+
* **Why a field and not a clipper.** An exact polygon offsetter has zero error
|
|
9
|
+
* and unbounded failure modes on precisely this input — self-intersections,
|
|
10
|
+
* slivers, collapse. A distance field has bounded, MEASURED, sub-visual error
|
|
11
|
+
* and cannot self-intersect, because it never performs polygon arithmetic. It
|
|
12
|
+
* also adds no dependency and needs no licence review. The line this library
|
|
13
|
+
* already drew for relief applies again: a coastal vignette is an ornament
|
|
14
|
+
* measured by eye; a 500 m setback is a number somebody acts on. The first is
|
|
15
|
+
* in scope and the second is a non-goal.
|
|
16
|
+
*/
|
|
17
|
+
export interface Grid {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
/** World units per cell — the whole error budget is proportional to this. */
|
|
21
|
+
cell: number;
|
|
22
|
+
/** World coordinate of cell (0, 0)'s CENTRE. */
|
|
23
|
+
originX: number;
|
|
24
|
+
originY: number;
|
|
25
|
+
}
|
|
26
|
+
export type Ring = number[][];
|
|
27
|
+
/**
|
|
28
|
+
* Even-odd scanline fill of a polygon (outer ring plus holes) into a byte mask.
|
|
29
|
+
*
|
|
30
|
+
* Even-odd rather than nonzero because GeoJSON does not guarantee ring winding,
|
|
31
|
+
* so a hole wound the same way as its outer would fill solid under nonzero. The
|
|
32
|
+
* same reason the serializer emits `fill-rule="evenodd"`.
|
|
33
|
+
*
|
|
34
|
+
* Samples at cell CENTRES. A feature thinner than a cell therefore vanishes —
|
|
35
|
+
* stated rather than fixed: at 300 dpi a cell is 0.085 mm, below a printable
|
|
36
|
+
* hairline, but it is a silent change to the data and the caller should know.
|
|
37
|
+
*/
|
|
38
|
+
export declare function rasterizeRings(rings: readonly Ring[], grid: Grid): Uint8Array;
|
|
39
|
+
/** Distance in CELLS from every cell to the nearest set cell in `mask`. */
|
|
40
|
+
export declare function distanceTransform(mask: Uint8Array, width: number, height: number): Float64Array;
|
|
41
|
+
/**
|
|
42
|
+
* A SIGNED field: positive outside the shape, negative inside.
|
|
43
|
+
*
|
|
44
|
+
* Built by transforming from BOTH SIDES and subtracting — which is what makes
|
|
45
|
+
* a buffer a threshold rather than an operation. `field <= d` is the outward
|
|
46
|
+
* buffer, `field <= -d` the inward one, and `repeat` is several thresholds of
|
|
47
|
+
* one field rather than several offsets of one polygon.
|
|
48
|
+
*
|
|
49
|
+
* **The half-cell correction is not cosmetic.** A cell centre `t` outside the
|
|
50
|
+
* boundary has its nearest INSIDE cell centre about `t + ½` away, and its
|
|
51
|
+
* nearest outside centre at zero — so the raw difference is `t + ½` on one side
|
|
52
|
+
* and `−(t + ½)` on the other. Left uncorrected the zero crossing still lands
|
|
53
|
+
* in the right place (the biases cancel across the boundary), but every level
|
|
54
|
+
* ABOVE zero — which is every buffer anyone actually asks for — sits half a
|
|
55
|
+
* cell too far out. It showed up as a maximum vertex error of exactly 1.000
|
|
56
|
+
* cell widths, and "exactly" is the tell: noise is never round.
|
|
57
|
+
*
|
|
58
|
+
* An earlier version seeded only the inside boundary cells instead. That is
|
|
59
|
+
* cheaper and biased the whole field inward, which is the same class of error
|
|
60
|
+
* with none of the cancellation.
|
|
61
|
+
*/
|
|
62
|
+
export declare function signedDistanceField(rings: readonly Ring[], grid: Grid): Float64Array;
|
|
63
|
+
/**
|
|
64
|
+
* Iso-contour a scalar field at `level`, returning closed rings in world
|
|
65
|
+
* coordinates.
|
|
66
|
+
*
|
|
67
|
+
* Standard marching squares with the saddle resolved by the cell's own mean,
|
|
68
|
+
* which is the choice that keeps a contour from crossing itself. Segments are
|
|
69
|
+
* emitted first and then chained into rings — chaining rather than walking,
|
|
70
|
+
* because a field can carry several disjoint contours at one level and a
|
|
71
|
+
* walker has to be told where to start each time.
|
|
72
|
+
*
|
|
73
|
+
* Measured contribution to the error: about a THOUSANDTH of a cell on a
|
|
74
|
+
* distance field, because such a field is locally linear and linear
|
|
75
|
+
* interpolation reconstructs that almost exactly. Virtually all the error in
|
|
76
|
+
* the pipeline is the rasterization step.
|
|
77
|
+
*/
|
|
78
|
+
export declare function marchingSquares(field: Float64Array | Float32Array, grid: Grid, level: number, covered?: Uint8Array): Ring[];
|
|
79
|
+
/** A grid covering `rings` plus `pad` world units of margin, at `cell` resolution. */
|
|
80
|
+
export declare function gridFor(rings: readonly Ring[], cell: number, pad: number): Grid | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type Position = number[];
|
|
2
|
+
export type Ring = Position[];
|
|
3
|
+
/** An equirectangular frame about one latitude: metres east/north of an arbitrary origin. */
|
|
4
|
+
export interface MetricFrame {
|
|
5
|
+
toMetres(p: Position): [number, number];
|
|
6
|
+
toLngLat(x: number, y: number): [number, number];
|
|
7
|
+
}
|
|
8
|
+
export declare function metricFrame(lng0: number, lat0: number): MetricFrame;
|
|
9
|
+
export declare function isRing(c: unknown): c is Ring;
|
|
10
|
+
/** Centre of a geometry's coordinate extent — the local frame's origin, and cheap enough to take per feature. */
|
|
11
|
+
export declare function coordinateCentre(coords: unknown): [number, number] | null;
|
|
12
|
+
/**
|
|
13
|
+
* Rebuild a coordinate tree, handing every innermost RING to `fn`. Returns a
|
|
14
|
+
* new tree; the input is never mutated, because the Data Layer keeps source
|
|
15
|
+
* arrays reference-stable and a transform that edited them in place would
|
|
16
|
+
* make a second chain entry operate on the first one's output.
|
|
17
|
+
*/
|
|
18
|
+
export declare function mapRings(coords: unknown, fn: (ring: Ring) => Ring): unknown;
|
|
19
|
+
/** Whether a ring is closed (first position equals last) — a polygon ring is, a LineString is not. */
|
|
20
|
+
export declare function isClosed(ring: Ring): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<om-transform>` — the lazy half (spec: cartographic substrate, Part B).
|
|
3
|
+
*
|
|
4
|
+
* Everything here is a pure function of `(geometry, params, metresPerMm)`:
|
|
5
|
+
* no DOM, no deck, no map state. That is what makes the chain cacheable by
|
|
6
|
+
* data identity plus params, testable headless, and safe to move to a worker
|
|
7
|
+
* later without changing a line of the primitives.
|
|
8
|
+
*
|
|
9
|
+
* `src/transform-stage.ts` is the eager counterpart — it decides WHEN to call
|
|
10
|
+
* this, and holds the cache.
|
|
11
|
+
*/
|
|
12
|
+
import type { Shape } from "../expr";
|
|
13
|
+
import { TRANSFORM_TYPES, type TransformSpec } from "../transform-stage";
|
|
14
|
+
/** `[west, south, east, north]`, as JSON or four bare numbers. */
|
|
15
|
+
export declare function parseBounds(raw: string | undefined): [number, number, number, number] | null;
|
|
16
|
+
/**
|
|
17
|
+
* Run the authored chain in order. A step that cannot run is skipped LOUDLY
|
|
18
|
+
* and the rest of the chain still runs — one bad tolerance should not cost
|
|
19
|
+
* the author the smoothing below it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function runTransforms(rows: readonly unknown[], shape: Shape, specs: readonly TransformSpec[], metresPerMm: number | null, warnLabel: string): Promise<unknown[]>;
|
|
22
|
+
export { TRANSFORM_TYPES };
|
|
23
|
+
export { simplifyGeometry, simplifyRing } from "./simplify";
|
|
24
|
+
export { smoothGeometry, chaikinRing } from "./smooth";
|
|
25
|
+
export { scatterRows, scatterFeature } from "./dot-density";
|
|
26
|
+
export { bufferRows, bufferGeometry } from "./buffer";
|
|
27
|
+
export { contourFromDem, assembleHeightGrid } from "./contour";
|
|
28
|
+
export { signedDistanceField, marchingSquares, rasterizeRings, distanceTransform, gridFor } from "./field";
|
|
29
|
+
export { metricFrame, coordinateCentre, mapRings } from "./geometry";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `simplify` — Douglas-Peucker on a metric frame, tolerance in ground metres.
|
|
3
|
+
*
|
|
4
|
+
* Iterative rather than recursive: a densely-digitized coastline ring is
|
|
5
|
+
* routinely 50,000 vertices, and the recursive form stack-overflows on the
|
|
6
|
+
* degenerate inputs (a near-straight run) that real data is full of.
|
|
7
|
+
*/
|
|
8
|
+
import { type Ring } from "./geometry";
|
|
9
|
+
export declare function simplifyRing(ring: Ring, toleranceMetres: number, lng0: number, lat0: number): Ring;
|
|
10
|
+
export declare function simplifyGeometry(coords: unknown, toleranceMetres: number): unknown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `smooth` — Chaikin corner cutting. One iteration removes the loudest "web
|
|
3
|
+
* map" tell (a coastline that is visibly a chain of straight segments);
|
|
4
|
+
* three is about where the shape stops being the shape.
|
|
5
|
+
*
|
|
6
|
+
* Purely topological, so it needs no metric frame and no reference scale:
|
|
7
|
+
* every new vertex is a convex combination of two old ones, which is the
|
|
8
|
+
* same point whether the numbers are degrees or metres.
|
|
9
|
+
*/
|
|
10
|
+
import { type Ring } from "./geometry";
|
|
11
|
+
export declare function chaikinRing(ring: Ring, iterations: number): Ring;
|
|
12
|
+
export declare function smoothGeometry(coords: unknown, iterations: number): unknown;
|
|
@@ -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
|
@@ -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, k as pr, l as mr } from "./raster-pipeline-
|
|
2
|
-
import {
|
|
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-B_gY9-5f.js";
|
|
2
|
+
import { c as gr } from "./index-CBYDP-_0.js";
|
|
3
3
|
import $t from "./index-CW1n5LdO.js";
|
|
4
4
|
var Et;
|
|
5
5
|
function h(e, t, n) {
|
package/docs/cartograph.md
CHANGED
|
@@ -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.
|
|
26
|
-
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.
|
|
25
|
+
<script type="module" src="https://unpkg.com/@nika-js/onlymap@0.10.1/dist/cartograph.standalone.js"></script>
|
|
26
|
+
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.10.1/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
|
-
|
|
404
|
-
|
|
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).
|