@kepler.gl/table 3.3.0-alpha.17 → 3.3.0-alpha.19

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 (46) hide show
  1. package/dist/cjs/dataset-ops/aggregations.js +8 -1
  2. package/dist/cjs/dataset-ops/column-edit.js +5 -1
  3. package/dist/cjs/dataset-ops/column-edit.spec.js +44 -4
  4. package/dist/cjs/dataset-ops/geometry.js +5 -2
  5. package/dist/cjs/dataset-ops/group-by.js +44 -9
  6. package/dist/cjs/dataset-ops/join.js +83 -6
  7. package/dist/cjs/dataset-ops/normalize-bigint-columns.js +58 -0
  8. package/dist/cjs/dataset-ops/proto-dataset.js +6 -3
  9. package/dist/cjs/dataset-ops/spatial-join.js +34 -10
  10. package/dist/cjs/dataset-ops/suitability.js +3 -2
  11. package/dist/cjs/dataset-ops.spec.js +893 -6
  12. package/dist/cjs/dataset-utils.js +59 -14
  13. package/dist/cjs/gpu-filter-utils.js +9 -6
  14. package/dist/cjs/index.js +74 -2
  15. package/dist/cjs/kepler-table.js +101 -44
  16. package/dist/cjs/tileset/zarr-axis.js +178 -0
  17. package/dist/cjs/tileset/zarr-runtime.js +29 -0
  18. package/dist/cjs/tileset/zarr-utils.js +2168 -0
  19. package/dist/cjs/tileset/zarr-utils.spec.js +1622 -0
  20. package/dist/dataset-ops/normalize-bigint-columns.d.ts +7 -0
  21. package/dist/dataset-ops/proto-dataset.d.ts +3 -1
  22. package/dist/esm/dataset-ops/aggregations.js +8 -1
  23. package/dist/esm/dataset-ops/column-edit.js +5 -1
  24. package/dist/esm/dataset-ops/column-edit.spec.js +42 -2
  25. package/dist/esm/dataset-ops/geometry.js +5 -2
  26. package/dist/esm/dataset-ops/group-by.js +43 -8
  27. package/dist/esm/dataset-ops/join.js +83 -6
  28. package/dist/esm/dataset-ops/normalize-bigint-columns.js +51 -0
  29. package/dist/esm/dataset-ops/proto-dataset.js +6 -3
  30. package/dist/esm/dataset-ops/spatial-join.js +34 -10
  31. package/dist/esm/dataset-ops/suitability.js +3 -2
  32. package/dist/esm/dataset-ops.spec.js +894 -5
  33. package/dist/esm/dataset-utils.js +59 -14
  34. package/dist/esm/gpu-filter-utils.js +10 -7
  35. package/dist/esm/index.js +5 -1
  36. package/dist/esm/kepler-table.js +102 -45
  37. package/dist/esm/tileset/zarr-axis.js +167 -0
  38. package/dist/esm/tileset/zarr-runtime.js +22 -0
  39. package/dist/esm/tileset/zarr-utils.js +2144 -0
  40. package/dist/esm/tileset/zarr-utils.spec.js +1623 -0
  41. package/dist/index.d.ts +4 -0
  42. package/dist/kepler-table.d.ts +4 -4
  43. package/dist/tileset/zarr-axis.d.ts +23 -0
  44. package/dist/tileset/zarr-runtime.d.ts +4 -0
  45. package/dist/tileset/zarr-utils.d.ts +200 -0
  46. package/package.json +12 -7
package/dist/index.d.ts CHANGED
@@ -6,4 +6,8 @@ export * from './tileset/wms-utils';
6
6
  export * from './tileset/tileset-utils';
7
7
  export * from './tileset/vector-tile-utils';
8
8
  export * from './tileset/raster-tile-utils';
9
+ export { getZarrMetadata, getZarrTimeDomain, getZarrVariable, openZarrNode, selectZarrVariable } from './tileset/zarr-utils';
10
+ export type { ZarrMetadataProgress } from './tileset/zarr-utils';
9
11
  export * from './dataset-ops';
12
+ export { getZarrAxis, getZarrAxisDimensions, getZarrForecastAxes, isExplicitZarrAxis, formatZarrCoordinate } from './tileset/zarr-axis';
13
+ export type { ZarrAxis, ZarrAxisFrame } from './tileset/zarr-axis';
@@ -114,19 +114,19 @@ declare class KeplerTable<F extends Field = Field> {
114
114
  */
115
115
  update(data: ProtoDataset['data']): Promise<this>;
116
116
  /**
117
- * Append column-ordered rows in place. No-op for Arrow/DuckDB (no `append`).
118
- * Accessors stay bound: the container instance is not replaced.
117
+ * Append column-ordered rows in place. Accessors stay bound: the container
118
+ * instance is not replaced. No-op when the container has no `append`.
119
119
  * @returns false when the payload is rejected and the table is unchanged.
120
120
  */
121
121
  appendRows(rows: any[][]): boolean;
122
122
  /**
123
123
  * Replace rows that share `keyField` and append the rest. Last incoming row
124
- * wins for a repeated key. No-op for Arrow/DuckDB.
124
+ * wins for a repeated key. No-op when the container has no `append`/`replace`.
125
125
  * @returns false when the payload is rejected and the table is unchanged.
126
126
  */
127
127
  upsertRows(rows: any[][], keyField: string): boolean;
128
128
  /**
129
- * Remove rows by index in place. No-op for Arrow/DuckDB (no `remove`).
129
+ * Remove rows by index in place. No-op when the container has no `remove`.
130
130
  * @returns false when any index is invalid and the table is unchanged.
131
131
  */
132
132
  removeRows(indexes: number[]): boolean;
@@ -0,0 +1,23 @@
1
+ import type { ZarrAxisConfig, ZarrDimensionInfo, ZarrVariableInfo } from '@kepler.gl/constants';
2
+ export type ZarrAxisFrame = {
3
+ /** Numeric slider position; categorical/duplicate values use ordinal positions. */
4
+ value: number;
5
+ label: string;
6
+ /** Original array indices, independent of axis sorting and display labels. */
7
+ selection: Record<string, number>;
8
+ };
9
+ export type ZarrAxis = {
10
+ label: string;
11
+ dimensions: string[];
12
+ frames: ZarrAxisFrame[];
13
+ error?: string;
14
+ };
15
+ export declare function isExplicitZarrAxis(axis?: ZarrAxisConfig): boolean;
16
+ export declare function getZarrAxisDimensions(axis?: ZarrAxisConfig): string[];
17
+ export declare function getZarrForecastAxes(variable: ZarrVariableInfo): ZarrAxisConfig[];
18
+ export declare function formatZarrCoordinate(dimension: ZarrDimensionInfo, index: number): string;
19
+ /**
20
+ * A small, per-variable table of playable slices. Never expands unrelated
21
+ * dimensions (ensemble, band, scenario, etc.) or raster pixels into rows.
22
+ */
23
+ export declare function getZarrAxis(variable: ZarrVariableInfo | null | undefined, config?: ZarrAxisConfig, pins?: Record<string, number>): ZarrAxis;
@@ -0,0 +1,4 @@
1
+ export declare function loadZarrRuntime(): Promise<{
2
+ zarr: typeof import("zarrita");
3
+ parseGeoZarrMetadata: typeof import("@developmentseed/geozarr")["parseGeoZarrMetadata"];
4
+ }>;
@@ -0,0 +1,200 @@
1
+ import type * as zarr from 'zarrita';
2
+ import type { ZarrDatasetMetadata, ZarrDimensionInfo, ZarrVariableInfo } from '@kepler.gl/constants';
3
+ export type CfTimeUnits = {
4
+ /** Milliseconds represented by one coordinate step. */
5
+ stepMs: number;
6
+ /** Epoch milliseconds of coordinate value zero. */
7
+ originMs: number;
8
+ };
9
+ type AnyAttrs = Record<string, unknown>;
10
+ type StoreContents = {
11
+ path: string;
12
+ kind: 'array' | 'group';
13
+ }[];
14
+ type ListableStore = zarr.Readable & {
15
+ contents?: () => StoreContents;
16
+ signal?: AbortSignal;
17
+ };
18
+ /**
19
+ * Node kinds by normalized path, built from the store's consolidated metadata.
20
+ *
21
+ * Zarr over plain HTTP has no directory listing, so without this every guess at
22
+ * a coordinate or grid-mapping path costs a round trip that usually 404s. When
23
+ * the store publishes a listing we consult it instead of probing. Null means
24
+ * the store has no consolidated metadata and probing is the only option.
25
+ */
26
+ type StoreIndex = Map<string, 'array' | 'group'> | null;
27
+ /**
28
+ * Parse a CF `units` string of the form `"<unit> since <timestamp>"`.
29
+ *
30
+ * Returns null for units that are not fixed-length (months, years) or for a
31
+ * timestamp the runtime cannot parse, so callers can fall back to treating the
32
+ * dimension as non-temporal instead of producing nonsense dates.
33
+ */
34
+ export declare function parseCfTimeUnits(units?: string | null): CfTimeUnits | null;
35
+ /**
36
+ * Decode CF-encoded time coordinates into epoch milliseconds.
37
+ *
38
+ * Returns null when the units are missing, not fixed-length, or the calendar is
39
+ * one of the synthetic CF calendars (`360_day`, `noleap`, ...) that cannot be
40
+ * represented on a real timeline.
41
+ */
42
+ export declare function decodeCfTime(values: ArrayLike<number | bigint> | null | undefined, units?: string | null, calendar?: string | null): number[] | null;
43
+ /**
44
+ * Animation domain for a decoded time dimension, or null when the dimension
45
+ * carries fewer than two usable timestamps.
46
+ */
47
+ export declare function getZarrTimeDomain(dimension?: ZarrDimensionInfo | null): {
48
+ domain: [number, number];
49
+ timeSteps: number[];
50
+ } | null;
51
+ /** Find a variable by path, falling back to the dataset's active variable. */
52
+ export declare function getZarrVariable(metadata?: Partial<ZarrDatasetMetadata> | null, variablePath?: string): ZarrVariableInfo | undefined;
53
+ /**
54
+ * Switch the active variable of an already-fetched dataset metadata. Pure, so
55
+ * the layer can react to the variable dropdown without refetching the store.
56
+ */
57
+ export declare function selectZarrVariable(metadata: ZarrDatasetMetadata, variablePath: string): ZarrDatasetMetadata;
58
+ export type ZarrMetadataProgress = {
59
+ phase: 'connecting' | 'downloading' | 'processing';
60
+ loadedBytes: number;
61
+ /** Total for completed and active downloads, when every active size is known. */
62
+ totalBytes?: number;
63
+ };
64
+ /**
65
+ * Open a Zarr store, preferring consolidated metadata so variable discovery
66
+ * costs one request instead of one per node. Memoized per URL because the
67
+ * dataset refresh and the layer open the same store. Cancellable metadata
68
+ * previews use their own store so aborting a preview cannot affect a layer.
69
+ */
70
+ export declare function openZarrStore(url: string): Promise<ListableStore>;
71
+ /**
72
+ * Open the node that backs a variable: a multiscale group, or the array itself
73
+ * for a single-resolution dataset. This is what `ZarrLayer` takes as its `node`
74
+ * prop, already resolved so the layer does not need a `variable` path.
75
+ */
76
+ export declare function openZarrNode(url: string, variablePath?: string): Promise<zarr.Array<zarr.DataType, zarr.Readable> | zarr.Group<zarr.Readable>>;
77
+ /** Drop a cached store so a refresh re-reads the consolidated metadata. */
78
+ export declare function clearZarrStoreCache(url?: string): void;
79
+ /**
80
+ * Dimension names for a zarr array. Zarr v3 stores them in `dimension_names`;
81
+ * xarray-written v2 stores put them in the `_ARRAY_DIMENSIONS` attribute.
82
+ */
83
+ export declare function getZarrDimensionNames(arr: {
84
+ dimensionNames?: (string | null)[];
85
+ attrs?: AnyAttrs;
86
+ shape: number[];
87
+ }): string[] | null;
88
+ /**
89
+ * Resolve a coordinate array to a concrete path using the store listing, with
90
+ * no network access. Returns null when the store has no listing (the caller
91
+ * must probe) or when no candidate exists.
92
+ */
93
+ export declare function resolveCoordinatePath(index: StoreIndex, variablePath: string, name: string): string | null;
94
+ /**
95
+ * GDAL writes its six-element `GeoTransform` as a space-separated string in
96
+ * `[c, a, b, f, d, e]` order. `@developmentseed/affine` wants `[a, b, c, d, e, f]`.
97
+ */
98
+ export declare function parseGdalGeoTransform(value: unknown): number[] | null;
99
+ export type AxisSpacing = {
100
+ first: number;
101
+ step: number;
102
+ };
103
+ /**
104
+ * Build an affine from the spacing of two cell-center axes. The affine maps the
105
+ * outer edge of the first cell, so each origin is stepped back by half a cell.
106
+ */
107
+ export declare function affineFromCellCenters(x: AxisSpacing, y: AxisSpacing): number[];
108
+ /**
109
+ * Derive a constant step from a cell-center coordinate array, rejecting any grid
110
+ * the affine would misrepresent. Every coordinate is checked rather than just
111
+ * the last, because an axis that drifts in the middle yet lands on the expected
112
+ * endpoint would otherwise yield a silently wrong georeference.
113
+ */
114
+ export declare function axisSpacingFromValues(raw: ArrayLike<number | bigint>): AxisSpacing | null;
115
+ /**
116
+ * Level paths of an OME-NGFF style `multiscales` attribute, finest first.
117
+ *
118
+ * `ndpyramid` and `xarray-multiscale` write a pyramid this way: a list of
119
+ * multiscale descriptors, each holding a `datasets` array of child paths. The
120
+ * zarr-conventions form the GeoZarr parser reads is instead an object with a
121
+ * `layout`, so the two have to be told apart and the OME form rewritten.
122
+ */
123
+ export declare function parseOmeMultiscaleLevels(attrs: AnyAttrs): string[] | null;
124
+ /**
125
+ * Whether `multiscales` describes a web-mercator tile pyramid.
126
+ *
127
+ * This is what `ndpyramid`'s `pyramid_reproject` writes and what CarbonPlan
128
+ * publishes: every level is reprojected to EPSG:3857 and covers the whole world
129
+ * in `pixels_per_tile * 2 ** level` pixels. Knowing that lets the renderer tie
130
+ * the level it draws to the map zoom, which is how such a pyramid is meant to
131
+ * be read.
132
+ */
133
+ export declare function isWebMercatorPyramid(attrs: AnyAttrs): boolean;
134
+ /**
135
+ * Order pyramid levels finest first, which is what the renderer expects.
136
+ *
137
+ * OME-NGFF asks for that order in the declaration, but a web-mercator pyramid —
138
+ * what `ndpyramid`'s `pyramid_reproject` writes, and what CarbonPlan publishes —
139
+ * numbers its levels by zoom, so `0` is the coarsest. Sorting by resolution
140
+ * rather than trusting the declared order reads either convention right.
141
+ */
142
+ export declare function orderLevelsFinestFirst<T extends {
143
+ shape: number[];
144
+ }>(levels: T[]): T[];
145
+ /**
146
+ * Names of the data arrays a pyramid level holds.
147
+ *
148
+ * An OME-NGFF level path points straight at the array, so there is nothing to
149
+ * name and the result is a single empty string. `ndpyramid` instead writes an
150
+ * xarray dataset per level, so the level is a group and each array inside it is
151
+ * a separate variable sharing the same pyramid.
152
+ */
153
+ export declare function multiscaleVariableNames(index: StoreIndex, levelPath: string): string[];
154
+ /**
155
+ * Rewrite per-level grids into the `multiscales.layout` the GeoZarr parser
156
+ * reads. Levels stay finest-first, which is the order it expects.
157
+ */
158
+ export declare function buildMultiscaleAttrs(base: AnyAttrs, levels: {
159
+ asset: string;
160
+ transform: number[];
161
+ shape: number[];
162
+ }[]): AnyAttrs;
163
+ type CoordinateResult = {
164
+ dimension: ZarrDimensionInfo;
165
+ isCfTime: boolean;
166
+ };
167
+ /** Decode coordinates without losing categorical labels or duration/calendar metadata. */
168
+ export declare function decodeZarrCoordinate(name: string, size: number, raw: ArrayLike<unknown> | Iterable<unknown>, attrs: AnyAttrs): CoordinateResult;
169
+ /**
170
+ * Stores often repeat a variable across scenario groups, e.g. `FUTUR/evap_total`
171
+ * and `HISTO/evap_total`. Listing those by array name alone shows the same label
172
+ * several times, so prepend the fewest leading path segments that tell them
173
+ * apart. Names that are already unique are left alone.
174
+ */
175
+ export declare function assignVariableDisplayNames<T extends {
176
+ path: string;
177
+ name: string;
178
+ displayName: string;
179
+ }>(variables: T[]): T[];
180
+ /**
181
+ * Prefix matching everything below a matched node, so its resolution levels are
182
+ * not offered as variables of their own. When the root matched, every remaining
183
+ * path is one of its children.
184
+ */
185
+ export declare function childPrefix(path: string): string;
186
+ /**
187
+ * Discover every renderable variable in a store.
188
+ *
189
+ * Nodes that declare the GeoZarr `spatial` and `geo-proj` conventions are used
190
+ * as-is. Very little published data does yet, so an array that does not declare
191
+ * them is still accepted when its CF/GDAL metadata is enough to derive the same
192
+ * information. Children of a matched node are skipped so resolution levels are
193
+ * not offered as separate variables.
194
+ */
195
+ export declare function getZarrMetadata(url: string, options?: {
196
+ variable?: string;
197
+ signal?: AbortSignal;
198
+ onProgress?: (progress: ZarrMetadataProgress) => void;
199
+ }): Promise<ZarrDatasetMetadata>;
200
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kepler.gl/table",
3
3
  "author": "Shan He <shan@uber.com>",
4
- "version": "3.3.0-alpha.17",
4
+ "version": "3.3.0-alpha.19",
5
5
  "description": "kepler.gl constants used by kepler.gl components, actions and reducers",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.js",
@@ -28,24 +28,29 @@
28
28
  "dist"
29
29
  ],
30
30
  "dependencies": {
31
- "@kepler.gl/common-utils": "3.3.0-alpha.17",
32
- "@kepler.gl/constants": "3.3.0-alpha.17",
33
- "@kepler.gl/tasks-core": "3.3.0-alpha.17",
34
- "@kepler.gl/types": "3.3.0-alpha.17",
35
- "@kepler.gl/utils": "3.3.0-alpha.17",
31
+ "@developmentseed/geozarr": "0.7.0",
32
+ "@kepler.gl/common-utils": "3.3.0-alpha.19",
33
+ "@kepler.gl/constants": "3.3.0-alpha.19",
34
+ "@kepler.gl/tasks-core": "3.3.0-alpha.19",
35
+ "@kepler.gl/types": "3.3.0-alpha.19",
36
+ "@kepler.gl/utils": "3.3.0-alpha.19",
37
+ "@loaders.gl/core": "^4.4.1",
36
38
  "@loaders.gl/mvt": "^4.4.1",
37
39
  "@loaders.gl/pmtiles": "^4.4.1",
40
+ "@loaders.gl/wkt": "^4.4.1",
38
41
  "@turf/boolean-crosses": "^7.2.0",
39
42
  "@turf/boolean-equal": "^7.2.0",
40
43
  "@turf/boolean-intersects": "^7.2.0",
41
44
  "@turf/boolean-overlap": "^7.2.0",
42
45
  "@turf/boolean-touches": "^7.2.0",
46
+ "@turf/difference": "^7.2.0",
43
47
  "@types/d3-array": "^2.8.0",
44
48
  "d3-array": "^2.8.0",
45
49
  "es-toolkit": "^1.39.10",
46
50
  "global": "^4.3.0",
47
51
  "moment": "^2.10.6",
48
- "type-analyzer": "0.4.0"
52
+ "type-analyzer": "0.4.0",
53
+ "zarrita": "^0.7.3"
49
54
  },
50
55
  "nyc": {
51
56
  "sourceMap": false,