@luma.gl/graph 10.0.0-alpha.10 → 10.0.0-alpha.12

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 (240) hide show
  1. package/dist/arrow/cpu/arrow-coordinate-projection.cjs +30 -0
  2. package/dist/arrow/cpu/arrow-coordinate-projection.d.ts +5 -0
  3. package/dist/arrow/cpu/arrow-coordinate-projection.d.ts.map +1 -0
  4. package/dist/arrow/cpu/arrow-coordinate-projection.js +9 -0
  5. package/dist/arrow/cpu/arrow-coordinate-projection.js.map +1 -0
  6. package/dist/arrow/cpu/arrow-cpu-pipelines.cjs +31 -0
  7. package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts +2 -0
  8. package/dist/arrow/cpu/arrow-cpu-pipelines.d.ts.map +1 -0
  9. package/dist/arrow/cpu/arrow-cpu-pipelines.js +5 -0
  10. package/dist/arrow/cpu/arrow-cpu-pipelines.js.map +1 -0
  11. package/dist/arrow/cpu/arrow-cpu-vector-adapters.cjs +99 -0
  12. package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts +9 -0
  13. package/dist/arrow/cpu/arrow-cpu-vector-adapters.d.ts.map +1 -0
  14. package/dist/arrow/cpu/arrow-cpu-vector-adapters.js +100 -0
  15. package/dist/arrow/cpu/arrow-cpu-vector-adapters.js.map +1 -0
  16. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.cjs +10 -371
  17. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts +9 -28
  18. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts.map +1 -1
  19. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js +5 -381
  20. package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js.map +1 -1
  21. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.cjs +11 -11
  22. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts +2 -0
  23. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts.map +1 -1
  24. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js +3 -3
  25. package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js.map +1 -1
  26. package/dist/arrow/geoarrow/arrow-polygon-tessellation.cjs +2 -2
  27. package/dist/arrow/geoarrow/arrow-polygon-tessellation.js +1 -1
  28. package/dist/arrow/geoarrow/arrow-polygon-tessellation.js.map +1 -1
  29. package/dist/arrow/index.cjs +17 -2
  30. package/dist/arrow/index.cjs.map +3 -3
  31. package/dist/arrow/index.d.ts +3 -0
  32. package/dist/arrow/index.d.ts.map +1 -1
  33. package/dist/arrow/index.js +3 -0
  34. package/dist/arrow/index.js.map +1 -1
  35. package/dist/arrow/internal.cjs.map +2 -2
  36. package/dist/dist.dev.js +1233 -442
  37. package/dist/dist.min.js +126 -108
  38. package/dist/experimental/index.cjs.map +1 -1
  39. package/dist/experimental/simulation/index.cjs.map +1 -1
  40. package/dist/gpu-core/compiled-gpu-graph.cjs +47 -0
  41. package/dist/gpu-core/compiled-gpu-graph.d.ts +5 -0
  42. package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
  43. package/dist/gpu-core/compiled-gpu-graph.js +54 -1
  44. package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
  45. package/dist/gpu-core/gpu-command-graph.cjs +28 -7
  46. package/dist/gpu-core/gpu-command-graph.d.ts +13 -4
  47. package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
  48. package/dist/gpu-core/gpu-command-graph.js +33 -7
  49. package/dist/gpu-core/gpu-command-graph.js.map +1 -1
  50. package/dist/gpu-core/gpu-cpu-execution.cjs +279 -0
  51. package/dist/gpu-core/gpu-cpu-execution.d.ts +22 -0
  52. package/dist/gpu-core/gpu-cpu-execution.d.ts.map +1 -0
  53. package/dist/gpu-core/gpu-cpu-execution.js +294 -0
  54. package/dist/gpu-core/gpu-cpu-execution.js.map +1 -0
  55. package/dist/gpu-core/gpu-cpu-operation.cjs +54 -0
  56. package/dist/gpu-core/gpu-cpu-operation.d.ts +40 -0
  57. package/dist/gpu-core/gpu-cpu-operation.d.ts.map +1 -0
  58. package/dist/gpu-core/gpu-cpu-operation.js +35 -0
  59. package/dist/gpu-core/gpu-cpu-operation.js.map +1 -0
  60. package/dist/gpu-core/gpu-expression-operation.cjs +2 -2
  61. package/dist/gpu-core/gpu-expression-operation.d.ts +1 -1
  62. package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -1
  63. package/dist/gpu-core/gpu-expression-operation.js +1 -1
  64. package/dist/gpu-core/gpu-expression-operation.js.map +1 -1
  65. package/dist/gpu-core/gpu-expression-plan.cjs +5 -1
  66. package/dist/gpu-core/gpu-expression-plan.d.ts +3 -2
  67. package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
  68. package/dist/gpu-core/gpu-expression-plan.js +7 -1
  69. package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
  70. package/dist/gpu-core/gpu-graph.d.ts +2 -2
  71. package/dist/gpu-core/gpu-graph.d.ts.map +1 -1
  72. package/dist/gpu-core/gpu-graph.js.map +1 -1
  73. package/dist/gpu-core/gpu-operation.d.ts +4 -4
  74. package/dist/gpu-core/gpu-operation.d.ts.map +1 -1
  75. package/dist/gpu-core/gpu-operation.js.map +1 -1
  76. package/dist/gpu-core/gpu-render-operation.cjs +39 -0
  77. package/dist/gpu-core/gpu-render-operation.d.ts +21 -0
  78. package/dist/gpu-core/gpu-render-operation.d.ts.map +1 -0
  79. package/dist/gpu-core/gpu-render-operation.js +22 -0
  80. package/dist/gpu-core/gpu-render-operation.js.map +1 -0
  81. package/dist/gpu-core/gpu-shader-pass-kernel.cjs +267 -0
  82. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts +29 -0
  83. package/dist/gpu-core/gpu-shader-pass-kernel.d.ts.map +1 -0
  84. package/dist/gpu-core/gpu-shader-pass-kernel.js +260 -0
  85. package/dist/gpu-core/gpu-shader-pass-kernel.js.map +1 -0
  86. package/dist/gpu-core/gpu-shader-pass-operation.cjs +85 -0
  87. package/dist/gpu-core/gpu-shader-pass-operation.d.ts +32 -0
  88. package/dist/gpu-core/gpu-shader-pass-operation.d.ts.map +1 -0
  89. package/dist/gpu-core/gpu-shader-pass-operation.js +74 -0
  90. package/dist/gpu-core/gpu-shader-pass-operation.js.map +1 -0
  91. package/dist/gpu-core/gpu-texture-plan.d.ts +3 -2
  92. package/dist/gpu-core/gpu-texture-plan.d.ts.map +1 -1
  93. package/dist/gpu-core/gpu-texture-plan.js.map +1 -1
  94. package/dist/gpu-core/index.cjs +9 -0
  95. package/dist/gpu-core/index.cjs.map +3 -3
  96. package/dist/gpu-core/index.d.ts +6 -0
  97. package/dist/gpu-core/index.d.ts.map +1 -1
  98. package/dist/gpu-core/index.js +3 -0
  99. package/dist/gpu-core/index.js.map +1 -1
  100. package/dist/gpu-data/cpu-data.cjs +60 -0
  101. package/dist/gpu-data/cpu-data.d.ts +28 -0
  102. package/dist/gpu-data/cpu-data.d.ts.map +1 -0
  103. package/dist/gpu-data/cpu-data.js +41 -0
  104. package/dist/gpu-data/cpu-data.js.map +1 -0
  105. package/dist/gpu-data/cpu-gpu-vector-transfer.cjs +93 -0
  106. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts +9 -0
  107. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts.map +1 -0
  108. package/dist/gpu-data/cpu-gpu-vector-transfer.js +82 -0
  109. package/dist/gpu-data/cpu-gpu-vector-transfer.js.map +1 -0
  110. package/dist/gpu-data/cpu-vector.cjs +42 -0
  111. package/dist/gpu-data/cpu-vector.d.ts +17 -0
  112. package/dist/gpu-data/cpu-vector.d.ts.map +1 -0
  113. package/dist/gpu-data/cpu-vector.js +21 -0
  114. package/dist/gpu-data/cpu-vector.js.map +1 -0
  115. package/dist/gpu-data/index.cjs +13 -2
  116. package/dist/gpu-data/index.cjs.map +3 -3
  117. package/dist/gpu-data/index.d.ts +3 -0
  118. package/dist/gpu-data/index.d.ts.map +1 -1
  119. package/dist/gpu-data/index.js +3 -0
  120. package/dist/gpu-data/index.js.map +1 -1
  121. package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
  122. package/dist/gpu-graph/index.cjs +3 -0
  123. package/dist/gpu-graph/index.cjs.map +3 -3
  124. package/dist/gpu-graph/index.d.ts +2 -0
  125. package/dist/gpu-graph/index.d.ts.map +1 -1
  126. package/dist/gpu-graph/index.js +1 -0
  127. package/dist/gpu-graph/index.js.map +1 -1
  128. package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
  129. package/dist/gpu-physics/index.cjs.map +1 -1
  130. package/dist/gpu-project/coordinate-projection-graph.cjs +59 -0
  131. package/dist/gpu-project/coordinate-projection-graph.d.ts +23 -0
  132. package/dist/gpu-project/coordinate-projection-graph.d.ts.map +1 -0
  133. package/dist/gpu-project/coordinate-projection-graph.js +40 -0
  134. package/dist/gpu-project/coordinate-projection-graph.js.map +1 -0
  135. package/dist/gpu-project/cpu-geoarrow.cjs +112 -0
  136. package/dist/gpu-project/cpu-geoarrow.d.ts +10 -0
  137. package/dist/gpu-project/cpu-geoarrow.d.ts.map +1 -0
  138. package/dist/gpu-project/cpu-geoarrow.js +103 -0
  139. package/dist/gpu-project/cpu-geoarrow.js.map +1 -0
  140. package/dist/gpu-project/cpu-geometry-pipelines.cjs +134 -0
  141. package/dist/gpu-project/cpu-geometry-pipelines.d.ts +18 -0
  142. package/dist/gpu-project/cpu-geometry-pipelines.d.ts.map +1 -0
  143. package/dist/gpu-project/cpu-geometry-pipelines.js +114 -0
  144. package/dist/gpu-project/cpu-geometry-pipelines.js.map +1 -0
  145. package/dist/gpu-project/cpu-projection-operation.cjs +54 -0
  146. package/dist/gpu-project/cpu-projection-operation.d.ts +14 -0
  147. package/dist/gpu-project/cpu-projection-operation.d.ts.map +1 -0
  148. package/dist/gpu-project/cpu-projection-operation.js +37 -0
  149. package/dist/gpu-project/cpu-projection-operation.js.map +1 -0
  150. package/dist/gpu-project/geoarrow.cjs +36 -0
  151. package/dist/gpu-project/geoarrow.cjs.map +6 -0
  152. package/dist/gpu-project/geoarrow.d.ts +3 -0
  153. package/dist/gpu-project/geoarrow.d.ts.map +1 -0
  154. package/dist/gpu-project/geoarrow.js +7 -0
  155. package/dist/gpu-project/geoarrow.js.map +1 -0
  156. package/dist/gpu-project/graph.cjs +27 -0
  157. package/dist/gpu-project/graph.cjs.map +6 -0
  158. package/dist/gpu-project/graph.d.ts +2 -0
  159. package/dist/gpu-project/graph.d.ts.map +1 -0
  160. package/dist/gpu-project/graph.js +6 -0
  161. package/dist/gpu-project/graph.js.map +1 -0
  162. package/dist/gpu-project/index.cjs +3 -0
  163. package/dist/gpu-project/index.cjs.map +3 -3
  164. package/dist/gpu-project/index.d.ts +1 -0
  165. package/dist/gpu-project/index.d.ts.map +1 -1
  166. package/dist/gpu-project/index.js +1 -0
  167. package/dist/gpu-project/index.js.map +1 -1
  168. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +75 -5
  169. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +5 -1
  170. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
  171. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +86 -6
  172. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
  173. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.cjs +9 -0
  174. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts +2 -0
  175. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts.map +1 -1
  176. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js +10 -0
  177. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js.map +1 -1
  178. package/dist/gpu-simple-graph/gpu-simple-graph.cjs +126 -10
  179. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +36 -11
  180. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
  181. package/dist/gpu-simple-graph/gpu-simple-graph.js +137 -12
  182. package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
  183. package/dist/gpu-simple-graph/index.cjs.map +3 -3
  184. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +23 -0
  185. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +6 -0
  186. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
  187. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +25 -0
  188. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -1
  189. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.cjs +7 -0
  190. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts +2 -0
  191. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts.map +1 -1
  192. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js +7 -0
  193. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js.map +1 -1
  194. package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +1 -1
  195. package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +1 -1
  196. package/dist/index.cjs +6 -0
  197. package/dist/index.cjs.map +3 -3
  198. package/dist/index.d.ts +4 -0
  199. package/dist/index.d.ts.map +1 -1
  200. package/dist/index.js +2 -0
  201. package/dist/index.js.map +1 -1
  202. package/package.json +17 -6
  203. package/src/arrow/cpu/arrow-coordinate-projection.ts +18 -0
  204. package/src/arrow/cpu/arrow-cpu-pipelines.ts +9 -0
  205. package/src/arrow/cpu/arrow-cpu-vector-adapters.ts +153 -0
  206. package/src/arrow/geoarrow/arrow-geoarrow-adapter.ts +23 -493
  207. package/src/arrow/geoarrow/arrow-geoarrow-conversion.ts +5 -3
  208. package/src/arrow/geoarrow/arrow-polygon-tessellation.ts +1 -1
  209. package/src/arrow/index.ts +11 -0
  210. package/src/gpu-core/compiled-gpu-graph.ts +73 -1
  211. package/src/gpu-core/gpu-command-graph.ts +37 -7
  212. package/src/gpu-core/gpu-cpu-execution.ts +345 -0
  213. package/src/gpu-core/gpu-cpu-operation.ts +65 -0
  214. package/src/gpu-core/gpu-expression-operation.ts +1 -1
  215. package/src/gpu-core/gpu-expression-plan.ts +11 -3
  216. package/src/gpu-core/gpu-graph.ts +3 -3
  217. package/src/gpu-core/gpu-operation.ts +9 -7
  218. package/src/gpu-core/gpu-render-operation.ts +42 -0
  219. package/src/gpu-core/gpu-shader-pass-kernel.ts +307 -0
  220. package/src/gpu-core/gpu-shader-pass-operation.ts +103 -0
  221. package/src/gpu-core/gpu-texture-plan.ts +3 -2
  222. package/src/gpu-core/index.ts +12 -0
  223. package/src/gpu-data/cpu-data.ts +62 -0
  224. package/src/gpu-data/cpu-gpu-vector-transfer.ts +107 -0
  225. package/src/gpu-data/cpu-vector.ts +31 -0
  226. package/src/gpu-data/index.ts +5 -0
  227. package/src/gpu-graph/index.ts +8 -0
  228. package/src/gpu-project/coordinate-projection-graph.ts +59 -0
  229. package/src/gpu-project/cpu-geoarrow.ts +135 -0
  230. package/src/gpu-project/cpu-geometry-pipelines.ts +159 -0
  231. package/src/gpu-project/cpu-projection-operation.ts +49 -0
  232. package/src/gpu-project/geoarrow.ts +11 -0
  233. package/src/gpu-project/graph.ts +10 -0
  234. package/src/gpu-project/index.ts +2 -0
  235. package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +97 -6
  236. package/src/gpu-simple-graph/gpu-simple-graph-lowering.ts +11 -0
  237. package/src/gpu-simple-graph/gpu-simple-graph.ts +163 -19
  238. package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +22 -0
  239. package/src/gpu-simple-graph/operation/gpu-vector-evaluator.ts +7 -0
  240. package/src/index.ts +10 -0
@@ -2,88 +2,37 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
- import type {
6
- GeoArrowBatchView,
7
- GeoArrowRowView,
8
- GeoArrowArray,
9
- GeoArrowColumn,
10
- GeoArrowCoordinateLayout,
11
- GeoArrowDenseUnion,
12
- GeoArrowDimension,
13
- GeoArrowEncoding,
14
- GeoArrowNumericArray,
15
- GeoArrowOffsets,
16
- GeoArrowValidity
17
- } from '@math.gl/geospatial/geoarrow';
5
+ import type {DataType, Vector} from 'apache-arrow';
6
+ import {
7
+ makeGeoArrowColumnFromArrowVector as makeGeoArrowColumn,
8
+ type MakeGeoArrowColumnFromArrowVectorOptions
9
+ } from '@math.gl/arrow/geoarrow';
18
10
  import {
19
11
  getGeoArrowRowView,
20
12
  iterateGeoArrowBatches,
21
- mergeGeoArrowDimensions
22
- } from '@math.gl/geospatial/geoarrow';
23
- import {
24
- Binary,
25
- BufferType,
26
- Data,
27
- DataType,
28
- DenseUnion,
29
- Field,
30
- FixedSizeList,
31
- Float32,
32
- Float64,
33
- Int8,
34
- Int16,
35
- Int32,
36
- Int64,
37
- List,
38
- Struct,
39
- Uint8,
40
- Uint16,
41
- Uint32,
42
- Uint64,
43
- Utf8,
44
- Vector,
45
- vectorFromArray,
46
- type DataType as ArrowDataType
47
- } from 'apache-arrow';
48
-
49
- /** Options for adapting one Apache Arrow vector to math.gl's runtime-neutral GeoArrow ABI. */
50
- export type MakeGeoArrowColumnFromArrowVectorOptions = {
51
- /** GeoArrow extension encoding. Inferred from the physical type when omitted. */
52
- encoding?: GeoArrowEncoding;
53
- /** Semantic coordinate dimension. Inferred from coordinate field names when omitted. */
54
- dimension?: GeoArrowDimension;
55
- /** Coordinate organization. Inferred from the physical type when omitted. */
56
- coordinateLayout?: GeoArrowCoordinateLayout | null;
57
- /** Opaque extension metadata retained on the descriptor envelope. */
58
- metadata?: Readonly<Record<string, unknown>>;
59
- };
60
-
61
- /**
62
- * Adapts Apache Arrow physical buffers to the borrowed descriptor ABI used by
63
- * `@math.gl/geospatial/geoarrow`.
64
- */
65
- export function makeGeoArrowColumnFromArrowVector<T extends ArrowDataType>(
13
+ type GeoArrowBatchView,
14
+ type GeoArrowColumn,
15
+ type GeoArrowRowView
16
+ } from '@math.gl/arrow/geoarrow-utils';
17
+
18
+ export type {MakeGeoArrowColumnFromArrowVectorOptions} from '@math.gl/arrow/geoarrow';
19
+ export {
20
+ makeArrowVectorFromGeoArrowColumn,
21
+ inferGeoArrowEncodingFromArrowType,
22
+ inferGeoArrowDimensionFromArrowType,
23
+ inferGeoArrowCoordinateLayoutFromArrowType
24
+ } from '@math.gl/arrow/geoarrow';
25
+
26
+ /** Adapts borrowed Arrow buffers using math.gl's shared GeoArrow adapter. */
27
+ export function makeGeoArrowColumnFromArrowVector<T extends DataType>(
66
28
  vector: Vector<T>,
67
29
  options: MakeGeoArrowColumnFromArrowVectorOptions = {}
68
30
  ): GeoArrowColumn {
69
- const encoding = options.encoding ?? inferGeoArrowEncodingFromArrowType(vector.type);
70
- const dimension = options.dimension ?? inferGeoArrowDimensionFromArrowType(vector.type);
71
- const coordinateLayout =
72
- options.coordinateLayout === undefined
73
- ? inferGeoArrowCoordinateLayoutFromArrowType(vector.type)
74
- : options.coordinateLayout;
75
-
76
- return {
77
- encoding,
78
- dimension,
79
- coordinateLayout,
80
- chunks: vector.data.map(data => makeGeoArrowArrayFromArrowData(data)),
81
- metadata: options.metadata
82
- };
31
+ return makeGeoArrowColumn(vector, options);
83
32
  }
84
33
 
85
34
  /** Iterates borrowed batch views while retaining Arrow chunk boundaries and buffers. */
86
- export function iterateGeoArrowBatchesFromArrowVector<T extends ArrowDataType>(
35
+ export function iterateGeoArrowBatchesFromArrowVector<T extends DataType>(
87
36
  vector: Vector<T>,
88
37
  options: MakeGeoArrowColumnFromArrowVectorOptions = {}
89
38
  ): IterableIterator<GeoArrowBatchView> {
@@ -91,429 +40,10 @@ export function iterateGeoArrowBatchesFromArrowVector<T extends ArrowDataType>(
91
40
  }
92
41
 
93
42
  /** Gets a borrowed row view by logical index across Arrow chunks. */
94
- export function getGeoArrowRowViewFromArrowVector<T extends ArrowDataType>(
43
+ export function getGeoArrowRowViewFromArrowVector<T extends DataType>(
95
44
  vector: Vector<T>,
96
45
  rowIndex: number,
97
46
  options: MakeGeoArrowColumnFromArrowVectorOptions = {}
98
47
  ): GeoArrowRowView {
99
48
  return getGeoArrowRowView(makeGeoArrowColumnFromArrowVector(vector, options), rowIndex);
100
49
  }
101
-
102
- /** Converts a math.gl GeoArrow descriptor back to an Apache Arrow vector. */
103
- export function makeArrowVectorFromGeoArrowColumn(column: GeoArrowColumn): Vector {
104
- return new Vector(
105
- column.chunks.map(chunk =>
106
- makeArrowDataFromGeoArrowArray(chunk, column.dimension, column.coordinateLayout)
107
- )
108
- );
109
- }
110
-
111
- /** Infers a native GeoArrow encoding from an Apache Arrow physical type. */
112
- export function inferGeoArrowEncodingFromArrowType(type: ArrowDataType): GeoArrowEncoding {
113
- if (DataType.isDenseUnion(type)) return 'geoarrow.geometry';
114
- if (DataType.isBinary(type)) return 'geoarrow.wkb';
115
- if (DataType.isUtf8(type)) return 'geoarrow.wkt';
116
-
117
- const nesting = getArrowListNesting(type);
118
- switch (nesting) {
119
- case 0:
120
- return 'geoarrow.point';
121
- case 1:
122
- return 'geoarrow.linestring';
123
- case 2:
124
- return 'geoarrow.polygon';
125
- case 3:
126
- return 'geoarrow.multipolygon';
127
- default:
128
- throw new Error(`Cannot infer GeoArrow encoding from Arrow type ${type.toString()}`);
129
- }
130
- }
131
-
132
- /** Infers the semantic GeoArrow coordinate dimension from Arrow coordinate field names. */
133
- export function inferGeoArrowDimensionFromArrowType(type: ArrowDataType): GeoArrowDimension {
134
- if (DataType.isFixedSizeList(type)) {
135
- const dimensionName = type.children[0]?.name.toLowerCase();
136
- if (isGeoArrowDimension(dimensionName)) return dimensionName;
137
- switch (type.listSize) {
138
- case 2:
139
- return 'xy';
140
- case 3:
141
- return 'xyz';
142
- case 4:
143
- return 'xyzm';
144
- default:
145
- throw new Error(
146
- `GeoArrow coordinates require 2, 3, or 4 values, received ${type.listSize}`
147
- );
148
- }
149
- }
150
- if (DataType.isStruct(type)) {
151
- const names = type.children.map(field => field.name.toLowerCase());
152
- if (names[0] === 'x' && names[1] === 'y') {
153
- if (names[2] === 'm') return 'xym';
154
- if (names[2] === 'z' && names[3] === 'm') return 'xyzm';
155
- if (names[2] === 'z') return 'xyz';
156
- return 'xy';
157
- }
158
- }
159
- if (DataType.isList(type)) {
160
- return inferGeoArrowDimensionFromArrowType(type.children[0].type);
161
- }
162
- if (DataType.isDenseUnion(type)) {
163
- return type.children.reduce<GeoArrowDimension>(
164
- (dimension, field) =>
165
- mergeGeoArrowDimensions(dimension, inferGeoArrowDimensionFromArrowType(field.type)),
166
- 'xy'
167
- );
168
- }
169
- throw new Error(`Cannot infer GeoArrow dimension from Arrow type ${type.toString()}`);
170
- }
171
-
172
- /** Infers whether Arrow coordinate leaves are interleaved or separated. */
173
- export function inferGeoArrowCoordinateLayoutFromArrowType(
174
- type: ArrowDataType
175
- ): GeoArrowCoordinateLayout | null {
176
- if (DataType.isFixedSizeList(type)) return 'interleaved';
177
- if (DataType.isStruct(type)) return 'separated';
178
- if (DataType.isList(type)) {
179
- return inferGeoArrowCoordinateLayoutFromArrowType(type.children[0].type);
180
- }
181
- if (DataType.isDenseUnion(type)) {
182
- for (const field of type.children) {
183
- const layout = inferGeoArrowCoordinateLayoutFromArrowType(field.type);
184
- if (layout) return layout;
185
- }
186
- }
187
- return null;
188
- }
189
-
190
- function makeGeoArrowArrayFromArrowData(data: Data): GeoArrowArray {
191
- const validity = makeGeoArrowValidity(data);
192
- if (DataType.isFixedSizeList(data.type)) {
193
- return {
194
- kind: 'fixed-size-list',
195
- length: data.length,
196
- size: data.type.listSize,
197
- child: makeGeoArrowArrayFromArrowData(data.children[0]),
198
- validity
199
- };
200
- }
201
- if (DataType.isList(data.type)) {
202
- return {
203
- kind: 'list',
204
- length: data.length,
205
- offsets: data.valueOffsets as GeoArrowOffsets,
206
- child: makeGeoArrowArrayFromArrowData(data.children[0]),
207
- validity
208
- };
209
- }
210
- if (DataType.isStruct(data.type)) {
211
- const children: Record<string, GeoArrowArray> = {};
212
- for (let childIndex = 0; childIndex < data.type.children.length; childIndex++) {
213
- children[data.type.children[childIndex].name] = makeGeoArrowArrayFromArrowData(
214
- data.children[childIndex]
215
- );
216
- }
217
- return {kind: 'struct', length: data.length, children, validity};
218
- }
219
- if (DataType.isDenseUnion(data.type)) {
220
- const unionType = data.type;
221
- return {
222
- kind: 'dense-union',
223
- length: data.length,
224
- typeIds: data.typeIds as Int8Array | Uint8Array,
225
- valueOffsets: data.valueOffsets,
226
- children: unionType.children.map((field, childIndex) => ({
227
- name: field.name,
228
- typeId: unionType.typeIds[childIndex],
229
- encoding: inferGeoArrowEncodingFromUnionChild(field),
230
- dimension: inferGeoArrowDimensionFromArrowType(field.type),
231
- coordinateLayout: inferGeoArrowCoordinateLayoutFromArrowType(field.type),
232
- data: makeGeoArrowArrayFromArrowData(data.children[childIndex])
233
- })),
234
- validity
235
- };
236
- }
237
- if (DataType.isBinary(data.type) || DataType.isUtf8(data.type)) {
238
- return {
239
- kind: 'serialized',
240
- encoding: DataType.isBinary(data.type) ? 'binary' : 'utf8',
241
- length: data.length,
242
- offsets: data.valueOffsets as GeoArrowOffsets,
243
- values: data.values as Uint8Array,
244
- validity
245
- };
246
- }
247
- if (DataType.isInt(data.type) || DataType.isFloat(data.type)) {
248
- return {
249
- kind: 'primitive',
250
- length: data.length,
251
- values: data.values as GeoArrowNumericArray,
252
- validity
253
- };
254
- }
255
- throw new Error(`Unsupported GeoArrow physical Arrow type ${data.type.toString()}`);
256
- }
257
-
258
- function makeGeoArrowValidity(data: Data): GeoArrowValidity | undefined {
259
- if (data.nullCount <= 0 || !data.nullBitmap || data.nullBitmap.length === 0) return undefined;
260
- return {values: data.nullBitmap, bitOffset: data.offset};
261
- }
262
-
263
- function makeArrowDataFromGeoArrowArray(
264
- array: GeoArrowArray,
265
- dimension: GeoArrowDimension,
266
- coordinateLayout: GeoArrowCoordinateLayout | null
267
- ): Data {
268
- const validity = makeCompactValidity(array.validity, array.length);
269
- const nullCount = validity ? -1 : 0;
270
- const validityBuffers = validity ? {[BufferType.VALIDITY]: validity} : {};
271
-
272
- switch (array.kind) {
273
- case 'primitive': {
274
- const values = makePackedPrimitiveValues(array);
275
- const type = getArrowTypeForValues(values);
276
- return new Data(type, 0, array.length, nullCount, {
277
- ...validityBuffers,
278
- [BufferType.DATA]: values
279
- });
280
- }
281
- case 'fixed-size-list': {
282
- const child = makeArrowDataFromGeoArrowArray(array.child, dimension, coordinateLayout);
283
- const childStart = (array.offset ?? 0) * array.size;
284
- const slicedChild =
285
- childStart === 0 && child.length === array.length * array.size
286
- ? child
287
- : child.slice(childStart, array.length * array.size);
288
- const type = new FixedSizeList(array.size, new Field(dimension, slicedChild.type, false));
289
- return new Data(type, 0, array.length, nullCount, validityBuffers, [slicedChild]);
290
- }
291
- case 'list': {
292
- if (array.offsets instanceof BigInt64Array) {
293
- throw new Error('Apache Arrow JS does not expose LargeList in this supported version');
294
- }
295
- const child = makeArrowDataFromGeoArrowArray(array.child, dimension, coordinateLayout);
296
- const offsets = makeArrowOffsets(array.offsets, array.offset, array.length, array.offsetBase);
297
- const type = new List(new Field('values', child.type, true));
298
- return new Data(
299
- type,
300
- 0,
301
- array.length,
302
- nullCount,
303
- {...validityBuffers, [BufferType.OFFSET]: offsets},
304
- [child]
305
- );
306
- }
307
- case 'struct': {
308
- const fields: Field[] = [];
309
- const children: Data[] = [];
310
- for (const [name, childArray] of Object.entries(array.children)) {
311
- let child = makeArrowDataFromGeoArrowArray(childArray, dimension, coordinateLayout);
312
- const childOffset = array.offset ?? 0;
313
- if (childOffset > 0 || child.length !== array.length) {
314
- child = child.slice(childOffset, array.length);
315
- }
316
- fields.push(new Field(name, child.type, true));
317
- children.push(child);
318
- }
319
- return new Data(new Struct(fields), 0, array.length, nullCount, validityBuffers, children);
320
- }
321
- case 'dense-union':
322
- return makeArrowDenseUnionData(array, dimension, coordinateLayout);
323
- case 'serialized': {
324
- if (array.offsets instanceof BigInt64Array) {
325
- throw new Error('Large GeoArrow serialized output is not supported by this adapter');
326
- }
327
- const offsets = makeArrowOffsets(array.offsets, array.offset, array.length, array.offsetBase);
328
- const type = array.encoding === 'binary' ? new Binary() : new Utf8();
329
- return new Data(type, 0, array.length, nullCount, {
330
- ...validityBuffers,
331
- [BufferType.OFFSET]: offsets,
332
- [BufferType.DATA]: array.values
333
- });
334
- }
335
- }
336
- }
337
-
338
- function makeArrowDenseUnionData(
339
- array: GeoArrowDenseUnion,
340
- dimension: GeoArrowDimension,
341
- coordinateLayout: GeoArrowCoordinateLayout | null
342
- ): Data {
343
- const offset = array.offset ?? 0;
344
- const typeIds = array.typeIds.slice(offset, offset + array.length);
345
- const valueOffsets = array.valueOffsets.slice(offset, offset + array.length);
346
- const children = array.children.map(child =>
347
- makeArrowDataFromGeoArrowArray(
348
- child.data,
349
- child.dimension ?? dimension,
350
- child.coordinateLayout === undefined ? coordinateLayout : child.coordinateLayout
351
- )
352
- );
353
-
354
- if (array.validity && array.children.length > 0) {
355
- const nullChildIndex = 0;
356
- const nullChild = children[nullChildIndex];
357
- const nullValueOffset = nullChild.length;
358
- children[nullChildIndex] = appendNullToArrowData(nullChild);
359
- for (let rowIndex = 0; rowIndex < array.length; rowIndex++) {
360
- if (!isGeoArrowValueValid(array.validity, rowIndex)) {
361
- typeIds[rowIndex] = array.children[nullChildIndex].typeId;
362
- valueOffsets[rowIndex] = nullValueOffset;
363
- }
364
- }
365
- }
366
-
367
- const fields = array.children.map(
368
- (child, childIndex) => new Field(child.name, children[childIndex].type, true)
369
- );
370
- const type = new DenseUnion(Int32Array.from(array.children.map(child => child.typeId)), fields);
371
- return new Data(
372
- type,
373
- 0,
374
- array.length,
375
- 0,
376
- {[BufferType.TYPE]: Int8Array.from(typeIds), [BufferType.OFFSET]: valueOffsets},
377
- children
378
- );
379
- }
380
-
381
- function appendNullToArrowData(data: Data): Data {
382
- const vector = new Vector([data]);
383
- const values: unknown[] = [];
384
- for (let index = 0; index < vector.length; index++) {
385
- values.push(materializeArrowValue(vector.get(index)));
386
- }
387
- values.push(null);
388
- return vectorFromArray(values, data.type).data[0];
389
- }
390
-
391
- function materializeArrowValue(value: unknown): unknown {
392
- if (value === null || value === undefined) return null;
393
- if (ArrayBuffer.isView(value)) {
394
- return Array.from(value as unknown as ArrayLike<number | bigint>);
395
- }
396
- if (Array.isArray(value)) return value.map(materializeArrowValue);
397
- if (isArrowVectorLike(value)) {
398
- const values: unknown[] = [];
399
- for (let index = 0; index < value.length; index++) {
400
- values.push(materializeArrowValue(value.get(index)));
401
- }
402
- return values;
403
- }
404
- return value;
405
- }
406
-
407
- function isArrowVectorLike(
408
- value: unknown
409
- ): value is {length: number; get: (index: number) => unknown} {
410
- return Boolean(
411
- value &&
412
- typeof value === 'object' &&
413
- 'length' in value &&
414
- 'get' in value &&
415
- typeof (value as {get?: unknown}).get === 'function'
416
- );
417
- }
418
-
419
- function makePackedPrimitiveValues(
420
- array: Extract<GeoArrowArray, {kind: 'primitive'}>
421
- ): GeoArrowNumericArray {
422
- const offset = array.offset ?? 0;
423
- const stride = array.stride ?? 1;
424
- if (stride === 1) {
425
- return array.values.subarray(offset, offset + array.length) as GeoArrowNumericArray;
426
- }
427
- const ValuesConstructor = array.values.constructor as {
428
- new (length: number): GeoArrowNumericArray;
429
- };
430
- const values = new ValuesConstructor(array.length);
431
- for (let index = 0; index < array.length; index++) {
432
- values[index] = array.values[offset + index * stride] as never;
433
- }
434
- return values;
435
- }
436
-
437
- function getArrowTypeForValues(values: GeoArrowNumericArray): ArrowDataType {
438
- if (values instanceof Int8Array) return new Int8();
439
- if (values instanceof Uint8Array || values instanceof Uint8ClampedArray) return new Uint8();
440
- if (values instanceof Int16Array) return new Int16();
441
- if (values instanceof Uint16Array) return new Uint16();
442
- if (values instanceof Int32Array) return new Int32();
443
- if (values instanceof Uint32Array) return new Uint32();
444
- if (values instanceof BigInt64Array) return new Int64();
445
- if (values instanceof BigUint64Array) return new Uint64();
446
- if (values instanceof Float32Array) return new Float32();
447
- if (values instanceof Float64Array) return new Float64();
448
- throw new Error(`Unsupported GeoArrow primitive values ${(values as object).constructor.name}`);
449
- }
450
-
451
- function makeArrowOffsets(
452
- offsets: GeoArrowOffsets,
453
- offset = 0,
454
- length: number,
455
- offsetBase: number | bigint = 0
456
- ): Int32Array {
457
- const source = offsets.subarray(offset, offset + length + 1);
458
- if (offsetBase === 0) return source as Int32Array;
459
- const normalized = new Int32Array(source.length);
460
- for (let index = 0; index < source.length; index++) {
461
- normalized[index] = Number(source[index]) - Number(offsetBase);
462
- }
463
- return normalized;
464
- }
465
-
466
- function makeCompactValidity(
467
- validity: GeoArrowValidity | undefined,
468
- length: number
469
- ): Uint8Array | undefined {
470
- if (!validity) return undefined;
471
- const bitOffset = validity.bitOffset ?? 0;
472
- const values = new Uint8Array(Math.ceil(length / 8));
473
- let nullCount = 0;
474
- for (let index = 0; index < length; index++) {
475
- if (isGeoArrowValueValid(validity, index)) {
476
- values[index >> 3] |= 1 << (index & 7);
477
- } else {
478
- nullCount++;
479
- }
480
- }
481
- return nullCount > 0 || bitOffset > 0 ? values : undefined;
482
- }
483
-
484
- function isGeoArrowValueValid(validity: GeoArrowValidity, index: number): boolean {
485
- const bitIndex = (validity.bitOffset ?? 0) + index;
486
- return Boolean(validity.values[bitIndex >> 3] & (1 << (bitIndex & 7)));
487
- }
488
-
489
- function inferGeoArrowEncodingFromUnionChild(field: Field): GeoArrowEncoding {
490
- const normalizedName = field.name.replace(/[^a-z]/gi, '').toLowerCase();
491
- const names: Record<string, GeoArrowEncoding> = {
492
- point: 'geoarrow.point',
493
- linestring: 'geoarrow.linestring',
494
- polygon: 'geoarrow.polygon',
495
- multipoint: 'geoarrow.multipoint',
496
- multilinestring: 'geoarrow.multilinestring',
497
- multipolygon: 'geoarrow.multipolygon',
498
- geometrycollection: 'geoarrow.geometrycollection'
499
- };
500
- for (const [name, encoding] of Object.entries(names)) {
501
- if (normalizedName.startsWith(name)) return encoding;
502
- }
503
- return inferGeoArrowEncodingFromArrowType(field.type);
504
- }
505
-
506
- function getArrowListNesting(type: ArrowDataType): number {
507
- let nesting = 0;
508
- let currentType = type;
509
- while (DataType.isList(currentType)) {
510
- nesting++;
511
- currentType = currentType.children[0].type;
512
- }
513
- if (DataType.isFixedSizeList(currentType) || DataType.isStruct(currentType)) return nesting;
514
- throw new Error(`GeoArrow type does not terminate in coordinates: ${type.toString()}`);
515
- }
516
-
517
- function isGeoArrowDimension(value: string | undefined): value is GeoArrowDimension {
518
- return value === 'xy' || value === 'xyz' || value === 'xym' || value === 'xyzm';
519
- }
@@ -12,8 +12,8 @@ import {
12
12
  type GeoArrowDimension,
13
13
  type GeoArrowEncoding,
14
14
  type GeoArrowSerialized
15
- } from '@math.gl/geospatial/geoarrow';
16
- import {decodeGeoArrowWKB, decodeGeoArrowWKT} from '@math.gl/geospatial/geoarrow';
15
+ } from '@math.gl/arrow/geoarrow-utils';
16
+ import {decodeGeoArrowWKB, decodeGeoArrowWKT} from '@math.gl/arrow/geoarrow-utils';
17
17
  import {
18
18
  Data,
19
19
  DataType,
@@ -43,6 +43,8 @@ export type GeoArrowNativeEncoding =
43
43
  export type GeoArrowSerializedEncoding = 'geoarrow.wkb' | 'geoarrow.wkt';
44
44
 
45
45
  export type GeoArrowInterleaveOptions = {
46
+ /** Encoding for explicitly selected columns without GeoArrow extension metadata. */
47
+ encoding?: GeoArrowNativeEncoding;
46
48
  /** Optional single geometry column to convert. Defaults to native GeoArrow metadata columns. */
47
49
  geometryColumn?: string;
48
50
  /** Optional geometry columns to convert. Defaults to native GeoArrow metadata columns. */
@@ -110,7 +112,7 @@ export function convertGeoArrowTableToInterleaved<T extends TypeMap>(
110
112
  }
111
113
  const encoding = getFieldEncoding(field) as GeoArrowNativeEncoding | null;
112
114
  const column = makeGeoArrowColumnFromArrowVector(vector, {
113
- encoding: encoding ?? undefined,
115
+ encoding: encoding ?? options.encoding,
114
116
  metadata: getFieldExtensionMetadata(field)
115
117
  });
116
118
  const interleavedColumn = interleaveGeoArrowCoordinates(column);
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
- import {tessellateGeoArrowPolygons} from '@math.gl/geospatial/geoarrow';
5
+ import {tessellateGeoArrowPolygons} from '@math.gl/arrow/geoarrow-utils';
6
6
  import {
7
7
  DataType,
8
8
  DenseUnion,
@@ -202,3 +202,14 @@ export {
202
202
  type ArrowVertexFormatOptions,
203
203
  type ArrowBufferLayoutOptions
204
204
  } from './gpu/arrow-shader-layout';
205
+
206
+ export {
207
+ makeCPUVectorFromArrow,
208
+ makeArrowVectorFromCPUVector
209
+ } from './cpu/arrow-cpu-vector-adapters';
210
+ export {
211
+ projectCPUVector,
212
+ tessellateCPUVectorPolygons,
213
+ tessellateGeoArrowColumnToCPUVectors
214
+ } from './cpu/arrow-cpu-pipelines';
215
+ export {projectArrowCoordinates} from './cpu/arrow-coordinate-projection';