@nika-js/onlymap 0.12.1 → 0.13.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 (60) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +1 -1
  3. package/dist/{basemap-BK25o5OE.js → basemap-BxqFTBzX.js} +2 -2
  4. package/dist/build-D4iI8O9b.js +208 -0
  5. package/dist/cartograph.js +43 -41
  6. package/dist/cartograph.standalone.js +3 -1
  7. package/dist/client-BYFePLZV.js +6878 -0
  8. package/dist/{geoparquet-CLydPm2f.js → geoparquet-BV32P0nI.js} +1 -1
  9. package/dist/{globe-view-ChuX60M5.js → globe-view-B_X6obse.js} +6 -6
  10. package/dist/{hillshade-DD8WFrvf.js → hillshade-9VS_t-Ks.js} +79 -67
  11. package/dist/hillshade.d.ts +7 -0
  12. package/dist/html-data.d.ts +1 -1
  13. package/dist/{index-CvrH6mbS.js → index-BR_5FIN1.js} +3 -3
  14. package/dist/{index-DIzzRLKr.js → index-Bct9VWxi.js} +1 -1
  15. package/dist/index-CbFw6P0B.js +4449 -0
  16. package/dist/{index-C2CKUsom.js → index-D3P6Cfbr.js} +38 -38
  17. package/dist/{index-CMKrghNb.js → index-D40H3fpl.js} +54 -54
  18. package/dist/{index-CgVFHEdM.js → index-Di1LK4JT.js} +3 -3
  19. package/dist/{index-Bs69fn8a.js → index-IDWDfgTC.js} +33429 -30673
  20. package/dist/{index-Dvwr1Y3o.js → index-JewSBOjJ.js} +49 -49
  21. package/dist/{index-CdAf0bLj.js → index-eSuCj2Bn.js} +42 -42
  22. package/dist/layer-registry.d.ts +1 -0
  23. package/dist/{lerc-mAijS40k.js → lerc-C42a0ISa.js} +1 -1
  24. package/dist/onlymap.standalone.js +60636 -51605
  25. package/dist/onlymapjs.js +47 -47
  26. package/dist/plane-gpu/gpu-layer-types.d.ts +35 -0
  27. package/dist/plane-gpu/plane-basemap.d.ts +10461 -0
  28. package/dist/plane-gpu/plane-gpu-view.d.ts +90 -0
  29. package/dist/plane-gpu/projection-params.d.ts +47 -0
  30. package/dist/plane-layers.d.ts +2 -0
  31. package/dist/plane-seam.d.ts +48 -0
  32. package/dist/plane-tileset.d.ts +23 -2
  33. package/dist/plane-vector/build.d.ts +107 -0
  34. package/dist/plane-vector/client.d.ts +18 -0
  35. package/dist/plane-vector/cut-ends-extension.d.ts +30 -0
  36. package/dist/plane-vector/plane-mvt-layer.d.ts +10412 -0
  37. package/dist/plane-vector/tile-cut.d.ts +45 -0
  38. package/dist/plane-vector/worker.d.ts +15 -0
  39. package/dist/plane-warp.d.ts +12 -1
  40. package/dist/{post-process-effect-rwFDi8di.js → post-process-effect-ktcgAjmv.js} +11 -11
  41. package/dist/programmatic.d.ts +6 -0
  42. package/dist/projection.d.ts +51 -0
  43. package/dist/{raster-CXIqf83L.js → raster-CIxg_M_1.js} +3 -3
  44. package/dist/{raster-pipeline-CfSg2Re7.js → raster-pipeline-BODPC9vJ.js} +1 -1
  45. package/dist/react/om-map.d.ts +4 -0
  46. package/dist/react.js +259 -252
  47. package/dist/runtime-core.d.ts +84 -2
  48. package/dist/{text-on-path-B08PekFz.js → text-on-path-LZL6NfwZ.js} +74 -66
  49. package/dist/version.d.ts +1 -1
  50. package/dist/{zarr-CUn2udOc.js → zarr-D19fNIZt.js} +2 -2
  51. package/docs/cartograph.md +2 -2
  52. package/docs/cartography.md +59 -3
  53. package/docs/testing.md +2 -1
  54. package/llms.txt +2 -2
  55. package/onlymapjs.attributes.json +1 -0
  56. package/onlymapjs.html-data.json +15 -1
  57. package/package.json +3 -2
  58. package/skills/onlymapjs/SKILL.md +2 -2
  59. package/skills/onlymapjs/references/syntax.md +7 -6
  60. package/dist/index-BHRpKnGi.js +0 -4883
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Cutting a vector tile's geometry to the tile's own edge, in lng/lat — the
3
+ * plane vector-tile build's first step (build.ts).
4
+ *
5
+ * Vector tiles carry a buffer past each edge; neighbours overlap there, and a
6
+ * renderer must draw each tile only up to its edge. Cutting the geometry makes
7
+ * the edge EXACT: both neighbours cut the same source segments by the same
8
+ * arithmetic, putting the crossing exactly on the edge coordinate.
9
+ *
10
+ * - A polygon's run along the edge gets extra points on a lattice that depends
11
+ * only on the edge, never on the tile, so the two sides hand the rasteriser
12
+ * identical vertices and its own rules make the fill seam watertight. (A
13
+ * per-fragment clip in lng/lat, the first design, left a few dozen pixels a
14
+ * view claimed by neither neighbour.)
15
+ * - A line ends at the crossing, flagged as a CUT end; drawn flat there
16
+ * (cut-ends-extension.ts), its two halves meet without overlapping.
17
+ * - A point belongs to the tile whose half-open extent holds it.
18
+ */
19
+ import type { LngLatBounds } from "../plane-tiles";
20
+ type P = number[];
21
+ /** One tile edge: the axis it bounds (0 lng, 1 lat), its value, and which side is inside (+1 above, -1 below). */
22
+ export type Edge = [axis: 0 | 1, value: number, side: 1 | -1];
23
+ /** Sutherland–Hodgman, one edge at a time. Rings are open (no repeated first point). The crossing is exact on the edge coordinate, so both neighbours agree on it. */
24
+ export declare function clipRing(ring: P[], edges: Edge[]): P[];
25
+ /**
26
+ * One tile's cutter, for the plane vector-tile build (build.ts):
27
+ * the edges and the lattice are the tile's, built once and shared by every
28
+ * feature in it.
29
+ */
30
+ export interface TileCutter {
31
+ /** A polygon's rings cut to the tile (closed rings, lattice-densified along the edge), or null when its outer ring is gone. */
32
+ polygon(rings: P[][]): P[][] | null;
33
+ /** A line's pieces inside the tile, each marking which of its ends is a cut. */
34
+ line(line: P[]): LinePiece[];
35
+ /** Whether a point is in the tile: half-open, so a point on a shared edge belongs to one tile. */
36
+ contains(p: P): boolean;
37
+ }
38
+ /** A line's piece inside a tile. A CUT end lies on the tile edge, where the neighbour's piece of the same line begins. */
39
+ export interface LinePiece {
40
+ points: P[];
41
+ startCut: boolean;
42
+ endCut: boolean;
43
+ }
44
+ export declare function tileCutter(b: LngLatBounds, project?: (lng: number, lat: number) => number[]): TileCutter;
45
+ export {};
@@ -0,0 +1,15 @@
1
+ import { type BuildOptions, type TileIndex } from "./build";
2
+ /** A plane a worker can rebuild: proj4's own source, or one of projection.ts's closed forms. */
3
+ export interface PlaneSpec {
4
+ proj4Source?: string | object;
5
+ builtin?: string;
6
+ /** The plane's origin in absolute plane coordinates (PlaneFrame.origin). */
7
+ origin: [number, number];
8
+ }
9
+ export interface BuildRequest {
10
+ id: number;
11
+ buffer: ArrayBuffer;
12
+ index: TileIndex;
13
+ options: BuildOptions;
14
+ plane: PlaneSpec;
15
+ }
@@ -22,7 +22,7 @@
22
22
  * that. `maxDeviationMetres` is the measurement itself, exported because the
23
23
  * phase gate re-runs it rather than trusting the table in the design doc.
24
24
  */
25
- import type { LngLatPair, PlaneFrame } from "./projection";
25
+ import { type LngLatPair, type PlaneFrame } from "./projection";
26
26
  /** A tile's geographic extent, in the order deck's `tile.boundingBox` gives it. */
27
27
  export interface TileBoundsLngLat {
28
28
  west: number;
@@ -37,9 +37,20 @@ export interface WarpMesh {
37
37
  indices: Uint32Array;
38
38
  vertexCount: number;
39
39
  }
40
+ /** Web Mercator's y for a latitude, in radians-scaled units (only ratios matter here). */
41
+ export declare const mercatorY: (lat: number) => number;
42
+ export declare const latitudeOf: (y: number) => number;
40
43
  /**
41
44
  * Build the mesh for one tile. `n` is the number of CELLS per axis, so the
42
45
  * grid has (n+1)² vertices and the classic un-subdivided quad is `n = 1`.
46
+ *
47
+ * A tile can reach past where its projection is defined — a Transverse
48
+ * Mercator far from its meridian, a conic beyond its pole — and those
49
+ * vertices project to NaN or Infinity, which deck refuses for the whole
50
+ * layer ("Illegal attribute generated for positions"). So a cell with any
51
+ * such corner is left out and its vertices zeroed: the tile draws the part
52
+ * the projection can place. Common after a live `crs` switch, which
53
+ * re-meshes every cached tile for the new plane.
43
54
  */
44
55
  export declare function buildWarpMesh(bounds: TileBoundsLngLat, frame: PlaneFrame, n: number): WarpMesh;
45
56
  /**
@@ -1,4 +1,4 @@
1
- import { aw as m, ax as h, ay as P, az as S, aA as C } from "./index-Bs69fn8a.js";
1
+ import { aC as m, aD as h, aE as P, aF as S, aG as C } from "./index-IDWDfgTC.js";
2
2
  const x = (
3
3
  /* wgsl */
4
4
  `struct VertexInputs {
@@ -67,14 +67,14 @@ ${t.source}` }), super(e, {
67
67
  const _ = `layout(std140) uniform screenUniforms {
68
68
  vec2 texSize;
69
69
  } screen;
70
- `, A = {
70
+ `, F = {
71
71
  name: "screen",
72
72
  fs: _,
73
73
  uniformTypes: {
74
74
  texSize: "vec2<f32>"
75
75
  }
76
76
  };
77
- class F extends S {
77
+ class A extends S {
78
78
  constructor(e, t) {
79
79
  super(e, t);
80
80
  const { module: r, fs: s, id: i } = t, o = {
@@ -89,7 +89,7 @@ class F extends S {
89
89
  blendColorOperation: "add",
90
90
  blendAlphaOperation: "add"
91
91
  };
92
- this.model = new E(e, { id: i, fs: s, modules: [r, A], parameters: o });
92
+ this.model = new E(e, { id: i, fs: s, modules: [r, F], parameters: o });
93
93
  }
94
94
  render(e) {
95
95
  this._renderPass(this.device, e);
@@ -159,8 +159,8 @@ class R {
159
159
  }
160
160
  function T(n, e, t) {
161
161
  return e.passes.map((r, s) => {
162
- const i = b(e, r), o = `${t}-${s}`;
163
- return new F(n, { id: o, module: e, fs: i });
162
+ const i = y(e, r), o = `${t}-${s}`;
163
+ return new A(n, { id: o, module: e, fs: i });
164
164
  });
165
165
  }
166
166
  const d = `#version 300 es
@@ -171,24 +171,24 @@ in vec2 coordinate;
171
171
  in vec2 uv;
172
172
 
173
173
  out vec4 fragColor;
174
- `, w = (n) => `${d}
174
+ `, b = (n) => `${d}
175
175
  void main() {
176
176
  fragColor = texture(texSrc, coordinate);
177
177
  fragColor = ${n}(fragColor, screen.texSize, coordinate);
178
178
  }
179
- `, y = (n) => `${d}
179
+ `, w = (n) => `${d}
180
180
  void main() {
181
181
  fragColor = ${n}(texSrc, screen.texSize, coordinate);
182
182
  }
183
183
  `;
184
- function b(n, e) {
184
+ function y(n, e) {
185
185
  if (e.filter) {
186
186
  const t = typeof e.filter == "string" ? e.filter : `${n.name}_filterColor_ext`;
187
- return w(t);
187
+ return b(t);
188
188
  }
189
189
  if (e.sampler) {
190
190
  const t = typeof e.sampler == "string" ? e.sampler : `${n.name}_sampleColor`;
191
- return y(t);
191
+ return w(t);
192
192
  }
193
193
  return "";
194
194
  }
@@ -109,6 +109,10 @@ export interface MapControllerOptions {
109
109
  basemapKey?: string;
110
110
  /** `"globe"` draws the Earth as a sphere (preview; needs a `basemap`) — the `projection` attribute's twin. Live via `setProjection`. */
111
111
  projection?: "globe" | "mercator";
112
+ /** Draw the whole map in a real projection's plane (`"EPSG:5070"`, a national grid) — the `crs` attribute's twin; standalone (no basemap) only. Live via `setCrs`. */
113
+ crs?: string;
114
+ /** A `+proj=` definition for a CRS nothing bundles — the `crs-def` attribute's twin. */
115
+ crsDef?: string;
112
116
  /** Set false to opt out of the compact attribution control (render your own credits). */
113
117
  attribution?: boolean;
114
118
  /** Headless mode (spec: "Consumer Testing Surface") — no renderer, real projection math; for jsdom/happy-dom tests. */
@@ -334,6 +338,8 @@ export declare class MapController {
334
338
  setBasemap(basemap: string | null): void;
335
339
  /** Live globe switch (docs/design/globe.md) — `"globe"` or `"mercator"`; camera and layers carry over. */
336
340
  setProjection(projection: "globe" | "mercator" | null): void;
341
+ /** Live projection switch (docs/design/gpu-projection.md) — a CRS code for a plane, or null for Web Mercator; camera and layers carry over with no reload. */
342
+ setCrs(crs: string | null, crsDef?: string | null): void;
337
343
  /** Scene lighting (spec: "Scene Lighting") — swap the LightingEffect live; null restores deck's default lights. */
338
344
  setLighting(options: LightingOptions | null): void;
339
345
  /** Resolved scene-lighting IR (test inspection) — null = deck default lights. */
@@ -55,6 +55,20 @@ export interface Projection {
55
55
  forward(lngLat: LngLatPair): PlaneXY;
56
56
  /** plane → lng/lat. */
57
57
  inverse(xy: PlaneXY): LngLatPair;
58
+ /**
59
+ * The `+proj=` string this projection was built from, when it was built
60
+ * from one — what decides whether the shader can draw the plane
61
+ * (docs/design/gpu-projection.md). Absent for closed forms, WKT/PROJJSON
62
+ * and registered Projection objects, which the CPU path draws.
63
+ */
64
+ definition?: string;
65
+ /**
66
+ * What proj4 built this projection from — a `+proj=` string, WKT or a
67
+ * PROJJSON object — so a Web Worker can build the identical converter
68
+ * (plane-vector/worker.ts). Absent for closed forms and registered
69
+ * Projection objects, which are functions and cannot cross to one.
70
+ */
71
+ proj4Source?: string | object;
58
72
  }
59
73
  /** 2πa/360 — one degree of longitude at the equator. */
60
74
  export declare const METRES_PER_EQUATORIAL_DEGREE: number;
@@ -82,6 +96,21 @@ export declare function builtinProjection(crs: string | null | undefined): Proje
82
96
  * supply one should not need this file changed.
83
97
  */
84
98
  export declare function registerCrs(code: string, def: string | Projection): void;
99
+ /**
100
+ * The bundled codes whose system is geographic (`geographic: true` in the
101
+ * table), listed so validation can tell without loading the table;
102
+ * projection.test.ts holds this equal to the table.
103
+ */
104
+ export declare const GEOGRAPHIC_CODES: ReadonlySet<number>;
105
+ /**
106
+ * Whether a `crs` (with its `crs-def`) is a GEOGRAPHIC system — degrees on
107
+ * both axes — as far as can be told without resolving it: the built-in
108
+ * plate carrée codes, the bundled geographic entries, a registered definition
109
+ * or projection in degrees, or an authored definition that says so (a
110
+ * `+proj=longlat` string, a WKT `GEOGCS`/`GEOGCRS`, a PROJJSON GeographicCRS).
111
+ * Such a system draws as plate carrée: one scale in degrees on both axes.
112
+ */
113
+ export declare function isGeographicCrs(crs: string | null | undefined, def?: string | null): boolean;
85
114
  /** Registered codes, for diagnostics and validation messages. */
86
115
  export declare function registeredCrsCodes(): string[];
87
116
  /** Formulaic UTM — the zones no table can enumerate. */
@@ -96,9 +125,19 @@ export interface CrsConfig {
96
125
  online?: boolean;
97
126
  /** Replaces `fetch` for the lookup (tests, proxies). */
98
127
  fetch?: (url: string) => Promise<Response>;
128
+ /**
129
+ * Draw a projected map's plane in the shader when its CRS allows
130
+ * (docs/design/gpu-projection.md) — layers keep their lng/lat and a `crs`
131
+ * switch between such planes re-projects nothing on the CPU. On by default;
132
+ * `false` puts every projected map on the CPU path. Read when a map's plane
133
+ * resolves, so set it before maps mount.
134
+ */
135
+ gpuProjection?: boolean;
99
136
  }
100
137
  /** `OmMap.configureCrs({ online: false })` for air-gapped or privacy-strict hosts. */
101
138
  export declare function configureCrs(config: CrsConfig): void;
139
+ /** Whether eligible planes are drawn in the shader — `configureCrs({ gpuProjection })`. */
140
+ export declare function crsGpuProjectionEnabled(): boolean;
102
141
  /** Whether a resolution failure could have been an online miss — what the error message has to say. */
103
142
  export declare function crsOnlineEnabled(): boolean;
104
143
  /** Test seam: forget online results and restore the default config. */
@@ -158,4 +197,16 @@ export interface PlaneFrame {
158
197
  stride?: number;
159
198
  }): Float64Array;
160
199
  }
200
+ /**
201
+ * Whether a point's plane position is the projection's own for it: projected
202
+ * and brought back, it returns where it started. Past a projection's domain the
203
+ * forward arithmetic often keeps returning finite, correctly oriented numbers —
204
+ * a Transverse Mercator 90° from its meridian lays the far side of the world
205
+ * on top of the near one — and only the inverse, which answers in its
206
+ * principal range, tells the two apart. `back` is the inverse of the forward
207
+ * result. A thousandth of a degree absorbs an inverse's own iteration error.
208
+ */
209
+ export declare function placesFaithfully(lng: number, lat: number, back: ArrayLike<number>): boolean;
210
+ /** `placesFaithfully` for a frame's own plane position of a point; an inverse that throws (proj4's can) is a refusal. */
211
+ export declare function placedFaithfully(frame: PlaneFrame, lngLat: LngLatPair, xy: PlaneXY): boolean;
161
212
  export declare function planeFrame(projection: Projection, originLngLat: LngLatPair): PlaneFrame;
@@ -1,7 +1,7 @@
1
- import { c as se, t as $e, i as Ct, a as ke, s as Lt, C as It, b as Gt, F as vt, A as Et, d as Ft, R as ye, e as At, p as jt, m as Rt, f as Mt, g as We, h as Ut, r as le, j as Ot, k as xt, l as Kt, n as Dt } from "./raster-pipeline-CfSg2Re7.js";
1
+ import { c as se, t as $e, i as Ct, a as ke, s as Lt, C as It, b as Gt, F as vt, A as Et, d as Ft, R as ye, e as At, p as jt, m as Rt, f as Mt, g as We, h as Ut, r as le, j as Ot, k as xt, l as Kt, n as Dt } from "./raster-pipeline-BODPC9vJ.js";
2
2
  import { N as Nt, c as zt } from "./hillshade-apron-Bem3DWyJ.js";
3
3
  import { r as Bt } from "./hillshade-shader-DI2uLSNU.js";
4
- import { bN as _t, bO as $t } from "./index-Bs69fn8a.js";
4
+ import { bT as _t, bU as $t } from "./index-IDWDfgTC.js";
5
5
  import we from "./index-CW1n5LdO.js";
6
6
  function kt(e, t) {
7
7
  const n = e.length / 3, r = new Uint8ClampedArray(n * 4), o = 0, i = n, a = n * 2;
@@ -1072,7 +1072,7 @@ j.set(f.Zstd, () => import("./zstd-jXobGRcq.js").then((e) => e.decode));
1072
1072
  j.set(f.Jpeg, () => Promise.resolve(ce));
1073
1073
  j.set(f.Jpeg6, () => Promise.resolve(ce));
1074
1074
  j.set(f.Webp, () => Promise.resolve(ce));
1075
- j.set(f.Lerc, () => import("./lerc-mAijS40k.js").then((e) => e.decode));
1075
+ j.set(f.Lerc, () => import("./lerc-C42a0ISa.js").then((e) => e.decode));
1076
1076
  async function ue(e, t, n) {
1077
1077
  const r = j.get(t);
1078
1078
  if (!r)
@@ -1,5 +1,5 @@
1
1
  import { w as he } from "./mgrs-BY9bIvp4.js";
2
- import { ad as de, bF as fe, bG as re, c as oe, bH as me, G as pe, bI as ge, aL as Z, bJ as ve, N as be, bK as xe, bL as Pe, bM as Te, a3 as ie } from "./index-Bs69fn8a.js";
2
+ import { ad as de, bL as fe, bM as re, c as oe, bN as me, G as pe, bO as ge, aR as Z, bP as ve, N as be, bQ as xe, bR as Pe, bS as Te, a4 as ie } from "./index-IDWDfgTC.js";
3
3
  import { p as ye, a as Le, h as we } from "./hillshade-shader-DI2uLSNU.js";
4
4
  function Oe(n, e, t) {
5
5
  const { projectedCorners: s } = e, { topLeft: r, topRight: o, bottomRight: i, bottomLeft: a } = s, c = t(r[0], r[1]), u = t(o[0], o[1]), l = t(i[0], i[1]), d = t(a[0], a[1]), f = [
@@ -11,6 +11,10 @@ export interface OmMapProps {
11
11
  basemap?: string;
12
12
  /** `"globe"` draws the Earth as a sphere (preview; needs a `basemap`). Changing it switches live. */
13
13
  projection?: "globe" | "mercator";
14
+ /** Draw the whole map in a real projection's plane — the `crs` attribute's twin (standalone, no basemap). Changing it switches live, with no reload. */
15
+ crs?: string;
16
+ /** A `+proj=` definition for a CRS nothing bundles — the `crs-def` attribute's twin. */
17
+ crsDef?: string;
14
18
  /** Publishable provider key for keyed presets (maptiler-*) — or call configureBasemap once instead. */
15
19
  basemapKey?: string;
16
20
  /** Set false to opt out of the compact attribution control. */