@nika-js/onlymap 0.5.3 → 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.
@@ -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;
@@ -1,4 +1,4 @@
1
- import { ac as _t, ad as Ct } from "./index-BoAq5XsU.js";
1
+ import { ae as _t, af as Ct } from "./index-G3hmIs2P.js";
2
2
  function Yt(e, r, t = 2, i, o = "xy") {
3
3
  const s = r && r.length, l = s ? r[0] * t : e.length;
4
4
  let c = Ut(e, 0, l, t, !0, i && i[0], o);