@math.gl/geoarrow 5.0.0-alpha.2 → 5.0.0-alpha.3

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 (54) hide show
  1. package/README.md +45 -15
  2. package/dist/builder-entry.cjs +561 -0
  3. package/dist/builder-entry.cjs.map +6 -0
  4. package/dist/builder-entry.d.ts +4 -0
  5. package/dist/builder-entry.d.ts.map +1 -0
  6. package/dist/builder-entry.js +5 -0
  7. package/dist/builder-entry.js.map +1 -0
  8. package/dist/builder.d.ts +12 -1
  9. package/dist/builder.d.ts.map +1 -1
  10. package/dist/builder.js +112 -10
  11. package/dist/builder.js.map +1 -1
  12. package/dist/codecs.d.ts.map +1 -1
  13. package/dist/codecs.js +205 -7
  14. package/dist/codecs.js.map +1 -1
  15. package/dist/index.cjs +904 -120
  16. package/dist/index.cjs.map +2 -2
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/kernels.d.ts +8 -3
  22. package/dist/kernels.d.ts.map +1 -1
  23. package/dist/kernels.js +610 -107
  24. package/dist/kernels.js.map +1 -1
  25. package/dist/layout.d.ts.map +1 -1
  26. package/dist/layout.js +28 -5
  27. package/dist/layout.js.map +1 -1
  28. package/dist/tessellation-entry.cjs +427 -0
  29. package/dist/tessellation-entry.cjs.map +6 -0
  30. package/dist/tessellation-entry.d.ts +4 -0
  31. package/dist/tessellation-entry.d.ts.map +1 -0
  32. package/dist/tessellation-entry.js +5 -0
  33. package/dist/tessellation-entry.js.map +1 -0
  34. package/dist/types.d.ts +37 -3
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js.map +1 -1
  37. package/dist/wkb-entry.cjs +1005 -0
  38. package/dist/wkb-entry.cjs.map +6 -0
  39. package/dist/wkb-entry.d.ts +3 -0
  40. package/dist/wkb-entry.d.ts.map +1 -0
  41. package/dist/wkb-entry.js +6 -0
  42. package/dist/wkb-entry.js.map +1 -0
  43. package/dist/worker.cjs +4 -0
  44. package/dist/worker.cjs.map +1 -1
  45. package/package.json +21 -6
  46. package/src/builder-entry.ts +18 -0
  47. package/src/builder.ts +133 -19
  48. package/src/codecs.ts +251 -9
  49. package/src/index.ts +1 -0
  50. package/src/kernels.ts +811 -133
  51. package/src/layout.ts +38 -13
  52. package/src/tessellation-entry.ts +7 -0
  53. package/src/types.ts +23 -4
  54. package/src/wkb-entry.ts +11 -0
package/src/layout.ts CHANGED
@@ -298,7 +298,7 @@ function visitUnionRowCoordinates(
298
298
  const valueOffset = union.valueOffsets[physicalIndex];
299
299
  const child = union.children.find(candidate => candidate.typeId === typeId);
300
300
  if (!child) return;
301
- const encoding = getEncodingFromChildName(child.name);
301
+ const encoding = child.encoding || getEncodingFromChildName(child.name);
302
302
  if (encoding === 'geoarrow.geometrycollection' && child.data.kind === 'list') {
303
303
  const [first, last] = getListRange(child.data, valueOffset);
304
304
  if (child.data.child.kind === 'dense-union') {
@@ -386,7 +386,11 @@ function materializeUnionRow(
386
386
  const valueOffset = union.valueOffsets[physicalIndex];
387
387
  const child = union.children.find(candidate => candidate.typeId === typeId);
388
388
  if (!child || valueOffset < 0 || valueOffset >= child.data.length) return null;
389
- return materializeGeometryRow(child.data, valueOffset, getEncodingFromChildName(child.name));
389
+ return materializeGeometryRow(
390
+ child.data,
391
+ valueOffset,
392
+ child.encoding || getEncodingFromChildName(child.name)
393
+ );
390
394
  }
391
395
 
392
396
  function getEncodingFromChildName(name: string): GeoArrowEncoding {
@@ -538,15 +542,26 @@ function validateArray(
538
542
  break;
539
543
  }
540
544
  case 'serialized': {
541
- validateOffsets(
542
- array.offsets,
543
- array.offset || 0,
544
- array.length,
545
- array.values.length,
546
- array.offsetBase,
547
- path,
548
- issues
549
- );
545
+ if (array.views) {
546
+ const requiredWords = ((array.offset || 0) + array.length) * 4;
547
+ if (requiredWords > array.views.length) {
548
+ issues.push({
549
+ code: 'invalid-length',
550
+ path,
551
+ message: 'Serialized view records are too short.'
552
+ });
553
+ }
554
+ } else {
555
+ validateOffsets(
556
+ array.offsets,
557
+ array.offset || 0,
558
+ array.length,
559
+ array.values.length,
560
+ array.offsetBase,
561
+ path,
562
+ issues
563
+ );
564
+ }
550
565
  break;
551
566
  }
552
567
  }
@@ -711,12 +726,20 @@ function validateUnionLayouts(
711
726
  for (const child of union.children) {
712
727
  let encoding: GeoArrowEncoding;
713
728
  try {
714
- encoding = getEncodingFromChildName(child.name);
729
+ encoding = child.encoding || getEncodingFromChildName(child.name);
715
730
  } catch (error) {
716
731
  addInvalidLayout(`${path}.${child.name}`, (error as Error).message, issues);
717
732
  continue;
718
733
  }
719
- validateGeometryLayout(child.data, encoding, column, `${path}.${child.name}`, issues);
734
+ const childColumn =
735
+ child.dimension || child.coordinateLayout
736
+ ? {
737
+ ...column,
738
+ dimension: child.dimension || column.dimension,
739
+ coordinateLayout: child.coordinateLayout || column.coordinateLayout
740
+ }
741
+ : column;
742
+ validateGeometryLayout(child.data, encoding, childColumn, `${path}.${child.name}`, issues);
720
743
  }
721
744
  }
722
745
 
@@ -814,6 +837,8 @@ function collectArrayBuffers(array: GeoArrowArray, buffers: Set<ArrayBuffer>): v
814
837
  case 'serialized':
815
838
  addBuffer(array.offsets.buffer, buffers);
816
839
  addBuffer(array.values.buffer, buffers);
840
+ if (array.views) addBuffer(array.views.buffer, buffers);
841
+ for (const data of array.dataBuffers || []) addBuffer(data.buffer, buffers);
817
842
  break;
818
843
  }
819
844
  }
@@ -0,0 +1,7 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ /** Optional polygon tessellation subpath. */
6
+ export type {GeoArrowTessellation, TessellateGeoArrowPolygonsOptions} from './tessellate';
7
+ export {tessellateGeoArrowPolygons} from './tessellate';
package/src/types.ts CHANGED
@@ -4,7 +4,19 @@
4
4
 
5
5
  import type {SpatialReference} from '@math.gl/crs';
6
6
  import type {TypedArray} from '@math.gl/types';
7
- import type {WellKnownGeometry} from '@math.gl/wkb';
7
+ /** Minimal tagged geometry shape used only by compatibility builders.
8
+ *
9
+ * The physical GeoArrow APIs never create these values. Keeping the structural type here avoids
10
+ * making the descriptor package depend on the WKB format package.
11
+ */
12
+ export type GeoArrowGeometryValue =
13
+ | {type: 'Point'; coordinates: readonly number[]}
14
+ | {type: 'LineString'; coordinates: readonly (readonly number[])[]}
15
+ | {type: 'Polygon'; coordinates: readonly (readonly (readonly number[])[])[]}
16
+ | {type: 'MultiPoint'; coordinates: readonly (readonly number[])[]}
17
+ | {type: 'MultiLineString'; coordinates: readonly (readonly (readonly number[])[])[]}
18
+ | {type: 'MultiPolygon'; coordinates: readonly (readonly (readonly (readonly number[])[])[])[]}
19
+ | {type: 'GeometryCollection'; geometries: readonly GeoArrowGeometryValue[]};
8
20
 
9
21
  /** GeoArrow concrete, mixed, bounding-box, and serialized encodings. */
10
22
  export type GeoArrowEncoding =
@@ -96,6 +108,12 @@ export type GeoArrowBox = GeoArrowStruct;
96
108
  export type GeoArrowDenseUnionChild = Readonly<{
97
109
  name: string;
98
110
  typeId: number;
111
+ /** Child-specific physical encoding (required for mixed-dimensional unions). */
112
+ encoding?: GeoArrowEncoding;
113
+ /** Child-specific semantic dimension. Falls back to the column dimension for legacy data. */
114
+ dimension?: GeoArrowDimension;
115
+ /** Child-specific coordinate layout. Falls back to the column layout for legacy data. */
116
+ coordinateLayout?: GeoArrowCoordinateLayout | null;
99
117
  data: GeoArrowArray;
100
118
  }>;
101
119
 
@@ -117,6 +135,10 @@ export type GeoArrowSerialized = GeoArrowArrayBase &
117
135
  encoding: 'binary' | 'utf8';
118
136
  offsets: GeoArrowOffsets;
119
137
  values: Uint8Array;
138
+ /** Optional Arrow BinaryView-style records (four uint32 words per row). */
139
+ views?: Uint32Array;
140
+ /** Borrowed out-of-line buffers referenced by BinaryView records. */
141
+ dataBuffers?: readonly Uint8Array[];
120
142
  /** Index of logical row zero in `offsets`. */
121
143
  offset?: number;
122
144
  /** Value subtracted from offsets before indexing `values`. */
@@ -143,9 +165,6 @@ export type GeoArrowColumn = Readonly<{
143
165
  metadata?: Readonly<Record<string, unknown>>;
144
166
  }>;
145
167
 
146
- /** Materialized geometry value used at codec and builder boundaries. */
147
- export type GeoArrowGeometryValue = WellKnownGeometry;
148
-
149
168
  /** Coordinate callback used by mapping kernels. */
150
169
  export type GeoArrowCoordinateMapper = (
151
170
  coordinate: readonly number[],
@@ -0,0 +1,11 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ /** Optional serialized-format bridge. The parser implementation lives in @math.gl/wkb. */
6
+ export {
7
+ decodeGeoArrowWKB,
8
+ decodeGeoArrowWKT,
9
+ encodeGeoArrowWKB,
10
+ encodeGeoArrowWKT
11
+ } from './codecs';