@nika-js/onlymap 0.5.2 → 0.5.6
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/README.md +17 -5
- package/THIRD-PARTY-LICENSES.md +93 -0
- package/dist/{Arrow.dom-BNjbQ9jb.js → Arrow.dom-BFGShwSA.js} +854 -1427
- package/dist/{LercDecode.es-ReXBgmrK.js → LercDecode.es-5mr_B7pP.js} +1 -1
- package/dist/{basemap-DF_rK3Aa.js → basemap-DJjFEgA9.js} +1 -1
- package/dist/builder-CqJZRFaq.js +580 -0
- package/dist/date-format.d.ts +18 -0
- package/dist/draw-controller.d.ts +10 -1
- package/dist/flatgeobuf-Cx0IwxhV.js +6332 -0
- package/dist/geodesy.d.ts +47 -0
- package/dist/geoparquet-AL10HAyd.js +35 -0
- package/dist/geoparquet.d.ts +33 -0
- package/dist/html-data.d.ts +2 -2
- package/dist/{index-DWXl9Ykk.js → index-BQaxwlV3.js} +1 -1
- package/dist/index-BYbMtNVH.js +2301 -0
- package/dist/{index-B87QAKKr.js → index-BtPO4p2v.js} +2 -2
- package/dist/index-CgPV7QlM.js +4019 -0
- package/dist/{index-BYW4X7IK.js → index-DqE9di9E.js} +1 -1
- package/dist/{index-ytnYzWRW.js → index-G3hmIs2P.js} +47016 -46502
- package/dist/{index-DcFZsjQm.js → index-iwo3R3LT.js} +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/{lerc-C_VBg2kh.js → lerc-Dx3uB2j-.js} +2 -2
- package/dist/measure-controller.d.ts +41 -0
- package/dist/onlymap.standalone.js +108100 -94902
- package/dist/onlymapjs.js +82 -67
- package/dist/{raster-Unx9530f.js → raster-BPn_dJpK.js} +2 -2
- package/dist/units.d.ts +40 -0
- package/dist/validation.d.ts +10 -0
- package/dist/version.d.ts +1 -1
- package/llms.txt +8 -5
- package/onlymapjs.html-data.json +141 -62
- package/package.json +4 -1
- package/skills/onlymapjs/SKILL.md +4 -1
- package/skills/onlymapjs/references/syntax.md +103 -19
- package/skills/onlymapjs/references/testing.md +11 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geodesy (spec: issue #20 "Measure widget — geodesic distance and area").
|
|
3
|
+
*
|
|
4
|
+
* Pure spherical math on a sphere of the WGS84 MEAN radius (2a + b)/3 =
|
|
5
|
+
* 6 371 008.7714 m. A sphere, not the ellipsoid: documented accuracy vs. the
|
|
6
|
+
* true WGS84 geodesic is ≤ 0.56% worst case (near-meridional lines), typically
|
|
7
|
+
* < 0.3%. Deliberately NOT Vincenty (fails to converge near antipodes) and NOT
|
|
8
|
+
* a Karney/GeographicLib port (overkill for v1) — but every signature takes the
|
|
9
|
+
* radius, so an ellipsoidal `geodesic="ellipsoidal"` opt-in can slot in later
|
|
10
|
+
* without touching callers. Haversine uses GL's numerically-guarded form
|
|
11
|
+
* `2R·asin(min(1, √h))`. Area is the Chamberlain–Duquette line integral (the
|
|
12
|
+
* JPL formulation Turf's area uses), returning |signed area| so self-
|
|
13
|
+
* intersecting lobes cancel.
|
|
14
|
+
*/
|
|
15
|
+
/** WGS84 mean radius (2a + b)/3, with a = 6378137 m, 1/f = 298.257223563. */
|
|
16
|
+
export declare const WGS84_MEAN_RADIUS_M = 6371008.7714;
|
|
17
|
+
/** The sphere radius (m) current measurements resolve against. */
|
|
18
|
+
export declare function getMeasureRadiusMeters(): number;
|
|
19
|
+
/** Override the measure radius (e.g. a non-Earth body). Non-positive values reset to WGS84. */
|
|
20
|
+
export declare function setMeasureRadiusMeters(radiusMeters: number): void;
|
|
21
|
+
export type LngLat = [number, number];
|
|
22
|
+
/** Haversine great-circle distance in meters (guarded `2R·asin(min(1, √h))`). */
|
|
23
|
+
export declare function distanceMeters(a: LngLat, b: LngLat, radius?: number): number;
|
|
24
|
+
/** Total haversine length of a polyline in meters (0 for < 2 points). */
|
|
25
|
+
export declare function pathLengthMeters(points: LngLat[], radius?: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* Spherical polygon area in m² via the Chamberlain–Duquette line integral (the
|
|
28
|
+
* exact index form Turf's `ringArea` uses, so results match Turf's fixtures).
|
|
29
|
+
* Returns the ABSOLUTE value; ring winding and self-intersection lobes cancel.
|
|
30
|
+
* Pass the OPEN ring (a trailing duplicate of the first point is tolerated).
|
|
31
|
+
*/
|
|
32
|
+
export declare function ringAreaMeters2(ring: LngLat[], radius?: number): number;
|
|
33
|
+
/** Perimeter of a ring in meters (closes the ring implicitly). */
|
|
34
|
+
export declare function ringPerimeterMeters(ring: LngLat[], radius?: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* Does this ring wind around a pole? The Chamberlain–Duquette integral
|
|
37
|
+
* misreports a pole-enclosing ring, so the widget refuses an area for one.
|
|
38
|
+
* Test: sum the per-edge longitude steps normalized to (−180, 180]; a ring that
|
|
39
|
+
* does NOT enclose a pole nets ~0, one that circles a pole nets ~±360.
|
|
40
|
+
*/
|
|
41
|
+
export declare function ringEnclosesPole(ring: LngLat[]): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Great-circle midpoint of a segment — antimeridian-safe (converts to Cartesian
|
|
44
|
+
* so a segment crossing ±180° gets its label on the shorter arc, not the middle
|
|
45
|
+
* of the wrong way round). Returns [lng (normalized to (−180, 180]), lat].
|
|
46
|
+
*/
|
|
47
|
+
export declare function midpoint(a: LngLat, b: LngLat): LngLat;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { r as p, n as d } from "./index-G3hmIs2P.js";
|
|
2
|
+
function g(t) {
|
|
3
|
+
if (t == null) return !0;
|
|
4
|
+
const e = t, n = e.id?.code;
|
|
5
|
+
return n != null ? n === 84 || n === 4326 || n === "CRS84" || n === "4326" : typeof e.name == "string" && /^\s*(ogc:)?(wgs\s*84|crs\s*84|wgs84)\s*$/i.test(e.name);
|
|
6
|
+
}
|
|
7
|
+
function y(t) {
|
|
8
|
+
const e = t;
|
|
9
|
+
return typeof e?.name == "string" && e.name ? `"${e.name}"` : e?.id?.code != null ? `${e.id.authority ?? "?"}:${e.id.code}` : "a non-CRS84 CRS";
|
|
10
|
+
}
|
|
11
|
+
function h(t, e, n) {
|
|
12
|
+
const o = e.primary_column;
|
|
13
|
+
if (!o)
|
|
14
|
+
throw new Error(`data="${n}": GeoParquet "geo" metadata names no primary_column — can't tell which column is geometry.`);
|
|
15
|
+
const c = e.columns?.[o]?.crs;
|
|
16
|
+
if (!g(c))
|
|
17
|
+
throw new Error(
|
|
18
|
+
`data="${n}": GeoParquet CRS ${y(c)} isn't CRS84/EPSG:4326 — reprojection isn't supported yet (deck.gl renders lng/lat). Reproject first, e.g. ogr2ogr -t_srs EPSG:4326 out.parquet in.parquet.`
|
|
19
|
+
);
|
|
20
|
+
if (t.length === 0)
|
|
21
|
+
return console.warn(`[onlymapjs] data="${n}": GeoParquet has no rows — empty layer.`), [];
|
|
22
|
+
const u = t.map((r) => r[o]);
|
|
23
|
+
if (u.every((r) => r != null && r.type === "Point")) {
|
|
24
|
+
const r = t.map(({ [o]: i, ...m }) => m), a = p(r), s = u.map((i) => i.coordinates ?? void 0);
|
|
25
|
+
return { length: t.length, columns: { ...a?.columns ?? {}, [o]: s } };
|
|
26
|
+
}
|
|
27
|
+
const l = t.map(({ [o]: r, ...a }) => {
|
|
28
|
+
const s = a.id;
|
|
29
|
+
return { type: "Feature", ...s != null ? { id: s } : {}, geometry: r ?? null, properties: a };
|
|
30
|
+
});
|
|
31
|
+
return d({ type: "FeatureCollection", features: l });
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
h as geoParquetToLayerData
|
|
35
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GeoParquet (spec: issue #14). Decodes with hyparquet — a pure-JS, zero-dep
|
|
3
|
+
* Parquet reader — plus hyparquet-compressors for snappy/gzip/zstd (its zstd
|
|
4
|
+
* IS the same `fzstd` the Arrow path already bundles; no second codec ships).
|
|
5
|
+
* hyparquet reads the GeoParquet `geo` file metadata and decodes the WKB
|
|
6
|
+
* primary geometry column to GeoJSON geometry itself, so no WKB decoder is
|
|
7
|
+
* ours to maintain.
|
|
8
|
+
*
|
|
9
|
+
* What IS ours: `geo` metadata validation, a CRS84 guard (deck.gl renders in
|
|
10
|
+
* lng/lat — a projected file would land in the ocean, so a non-CRS84 CRS is a
|
|
11
|
+
* loud structured error until the reprojection workstream lands, NOT a silent
|
|
12
|
+
* skip the way GL does it), and the Arrow geometry rule from
|
|
13
|
+
* `arrowTableToLayerData` — all-Point tables transpose to columnar (zero row
|
|
14
|
+
* materialization on the render path), while lines/polygons/mixed become
|
|
15
|
+
* GeoJSON feature rows that every geometry consumer speaks.
|
|
16
|
+
*/
|
|
17
|
+
import type { LayerData } from "./ir";
|
|
18
|
+
/** The parsed GeoParquet `geo` file-metadata value (a JSON string in key_value_metadata). */
|
|
19
|
+
export interface GeoParquetMetadata {
|
|
20
|
+
primary_column?: string;
|
|
21
|
+
columns?: Record<string, {
|
|
22
|
+
encoding?: string;
|
|
23
|
+
geometry_types?: string[];
|
|
24
|
+
crs?: unknown;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* hyparquet rows (geometry already decoded to GeoJSON) → LayerData, applying
|
|
29
|
+
* the CRS guard and the Arrow all-Point-columnar / lines-polys-feature-rows
|
|
30
|
+
* split. `rows` is consumed after the geo-metadata gate in data-layer's
|
|
31
|
+
* PARQUET_FORMAT.
|
|
32
|
+
*/
|
|
33
|
+
export declare function geoParquetToLayerData(rows: Record<string, unknown>[], geo: GeoParquetMetadata, url: string): LayerData;
|
package/dist/html-data.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ interface TagData {
|
|
|
15
15
|
}[];
|
|
16
16
|
}
|
|
17
17
|
/** Hand-authored action list — validated against hasAction() in html-data.test.ts. */
|
|
18
|
-
export declare const BUILTIN_ACTIONS: readonly ["toggle-layer", "zoom-in", "zoom-out", "filter-layer", "highlight-feature", "fade", "pulse", "populate", "trace", "story-play", "story-pause", "story-seek", "fly-to", "zoom-to-feature", "show-overlay", "hide-overlay", "show-tooltip", "hide-tooltip", "draw-mode", "draw-commit", "draw-cancel", "draw-delete", "draw-clear", "draw-config", "draw-save", "set-basemap", "set-lighting", "set-terrain", "set-widgets-visible", "undo", "redo"];
|
|
18
|
+
export declare const BUILTIN_ACTIONS: readonly ["toggle-layer", "zoom-in", "zoom-out", "filter-layer", "highlight-feature", "fade", "pulse", "populate", "trace", "story-play", "story-pause", "story-seek", "fly-to", "zoom-to-feature", "show-overlay", "hide-overlay", "show-tooltip", "hide-tooltip", "draw-mode", "draw-commit", "draw-cancel", "draw-delete", "draw-clear", "draw-config", "draw-save", "measure-mode", "measure-clear", "measure-units", "set-basemap", "set-lighting", "set-terrain", "set-widgets-visible", "undo", "redo"];
|
|
19
19
|
/** Hand-authored widget types — validated against the widget registry in html-data.test.ts. */
|
|
20
|
-
export declare const BUILTIN_WIDGETS: readonly ["legend", "layer-switcher", "zoom-controls", "scale-bar", "attribution", "filter", "vega-lite", "player", "draw", "basemap-switcher", "lighting", "undo-redo", "widgets-toggle"];
|
|
20
|
+
export declare const BUILTIN_WIDGETS: readonly ["legend", "layer-switcher", "zoom-controls", "scale-bar", "attribution", "filter", "vega-lite", "player", "draw", "measure", "basemap-switcher", "lighting", "undo-redo", "widgets-toggle"];
|
|
21
21
|
export declare function buildHtmlCustomData(): {
|
|
22
22
|
version: number;
|
|
23
23
|
tags: TagData[];
|