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

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 (228) 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 +533 -108
  37. package/dist/dist.min.js +70 -70
  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 +32 -0
  41. package/dist/gpu-core/compiled-gpu-graph.d.ts +4 -0
  42. package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
  43. package/dist/gpu-core/compiled-gpu-graph.js +39 -1
  44. package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
  45. package/dist/gpu-core/gpu-command-graph.cjs +19 -7
  46. package/dist/gpu-core/gpu-command-graph.d.ts +11 -4
  47. package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
  48. package/dist/gpu-core/gpu-command-graph.js +24 -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 +1 -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 +2 -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-texture-plan.d.ts +3 -2
  82. package/dist/gpu-core/gpu-texture-plan.d.ts.map +1 -1
  83. package/dist/gpu-core/gpu-texture-plan.js.map +1 -1
  84. package/dist/gpu-core/index.cjs +6 -0
  85. package/dist/gpu-core/index.cjs.map +3 -3
  86. package/dist/gpu-core/index.d.ts +4 -0
  87. package/dist/gpu-core/index.d.ts.map +1 -1
  88. package/dist/gpu-core/index.js +2 -0
  89. package/dist/gpu-core/index.js.map +1 -1
  90. package/dist/gpu-data/cpu-data.cjs +60 -0
  91. package/dist/gpu-data/cpu-data.d.ts +28 -0
  92. package/dist/gpu-data/cpu-data.d.ts.map +1 -0
  93. package/dist/gpu-data/cpu-data.js +41 -0
  94. package/dist/gpu-data/cpu-data.js.map +1 -0
  95. package/dist/gpu-data/cpu-gpu-vector-transfer.cjs +93 -0
  96. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts +9 -0
  97. package/dist/gpu-data/cpu-gpu-vector-transfer.d.ts.map +1 -0
  98. package/dist/gpu-data/cpu-gpu-vector-transfer.js +82 -0
  99. package/dist/gpu-data/cpu-gpu-vector-transfer.js.map +1 -0
  100. package/dist/gpu-data/cpu-vector.cjs +42 -0
  101. package/dist/gpu-data/cpu-vector.d.ts +17 -0
  102. package/dist/gpu-data/cpu-vector.d.ts.map +1 -0
  103. package/dist/gpu-data/cpu-vector.js +21 -0
  104. package/dist/gpu-data/cpu-vector.js.map +1 -0
  105. package/dist/gpu-data/index.cjs +13 -2
  106. package/dist/gpu-data/index.cjs.map +3 -3
  107. package/dist/gpu-data/index.d.ts +3 -0
  108. package/dist/gpu-data/index.d.ts.map +1 -1
  109. package/dist/gpu-data/index.js +3 -0
  110. package/dist/gpu-data/index.js.map +1 -1
  111. package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
  112. package/dist/gpu-graph/index.cjs +3 -0
  113. package/dist/gpu-graph/index.cjs.map +3 -3
  114. package/dist/gpu-graph/index.d.ts +2 -0
  115. package/dist/gpu-graph/index.d.ts.map +1 -1
  116. package/dist/gpu-graph/index.js +1 -0
  117. package/dist/gpu-graph/index.js.map +1 -1
  118. package/dist/gpu-graph-algorithms/benchmarks.cjs.map +1 -1
  119. package/dist/gpu-physics/index.cjs.map +1 -1
  120. package/dist/gpu-project/coordinate-projection-graph.cjs +59 -0
  121. package/dist/gpu-project/coordinate-projection-graph.d.ts +23 -0
  122. package/dist/gpu-project/coordinate-projection-graph.d.ts.map +1 -0
  123. package/dist/gpu-project/coordinate-projection-graph.js +40 -0
  124. package/dist/gpu-project/coordinate-projection-graph.js.map +1 -0
  125. package/dist/gpu-project/cpu-geoarrow.cjs +112 -0
  126. package/dist/gpu-project/cpu-geoarrow.d.ts +10 -0
  127. package/dist/gpu-project/cpu-geoarrow.d.ts.map +1 -0
  128. package/dist/gpu-project/cpu-geoarrow.js +103 -0
  129. package/dist/gpu-project/cpu-geoarrow.js.map +1 -0
  130. package/dist/gpu-project/cpu-geometry-pipelines.cjs +134 -0
  131. package/dist/gpu-project/cpu-geometry-pipelines.d.ts +18 -0
  132. package/dist/gpu-project/cpu-geometry-pipelines.d.ts.map +1 -0
  133. package/dist/gpu-project/cpu-geometry-pipelines.js +114 -0
  134. package/dist/gpu-project/cpu-geometry-pipelines.js.map +1 -0
  135. package/dist/gpu-project/cpu-projection-operation.cjs +54 -0
  136. package/dist/gpu-project/cpu-projection-operation.d.ts +14 -0
  137. package/dist/gpu-project/cpu-projection-operation.d.ts.map +1 -0
  138. package/dist/gpu-project/cpu-projection-operation.js +37 -0
  139. package/dist/gpu-project/cpu-projection-operation.js.map +1 -0
  140. package/dist/gpu-project/geoarrow.cjs +36 -0
  141. package/dist/gpu-project/geoarrow.cjs.map +6 -0
  142. package/dist/gpu-project/geoarrow.d.ts +3 -0
  143. package/dist/gpu-project/geoarrow.d.ts.map +1 -0
  144. package/dist/gpu-project/geoarrow.js +7 -0
  145. package/dist/gpu-project/geoarrow.js.map +1 -0
  146. package/dist/gpu-project/graph.cjs +27 -0
  147. package/dist/gpu-project/graph.cjs.map +6 -0
  148. package/dist/gpu-project/graph.d.ts +2 -0
  149. package/dist/gpu-project/graph.d.ts.map +1 -0
  150. package/dist/gpu-project/graph.js +6 -0
  151. package/dist/gpu-project/graph.js.map +1 -0
  152. package/dist/gpu-project/index.cjs +3 -0
  153. package/dist/gpu-project/index.cjs.map +3 -3
  154. package/dist/gpu-project/index.d.ts +1 -0
  155. package/dist/gpu-project/index.d.ts.map +1 -1
  156. package/dist/gpu-project/index.js +1 -0
  157. package/dist/gpu-project/index.js.map +1 -1
  158. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +24 -2
  159. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +2 -0
  160. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
  161. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +29 -2
  162. package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
  163. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.cjs +9 -0
  164. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts +2 -0
  165. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.d.ts.map +1 -1
  166. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js +10 -0
  167. package/dist/gpu-simple-graph/gpu-simple-graph-lowering.js.map +1 -1
  168. package/dist/gpu-simple-graph/gpu-simple-graph.cjs +126 -10
  169. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +36 -11
  170. package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
  171. package/dist/gpu-simple-graph/gpu-simple-graph.js +137 -12
  172. package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
  173. package/dist/gpu-simple-graph/index.cjs.map +3 -3
  174. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.cjs +23 -0
  175. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +6 -0
  176. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
  177. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js +25 -0
  178. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.js.map +1 -1
  179. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.cjs +7 -0
  180. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts +2 -0
  181. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.d.ts.map +1 -1
  182. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js +7 -0
  183. package/dist/gpu-simple-graph/operation/gpu-vector-evaluator.js.map +1 -1
  184. package/dist/gpu-simple-graph/operations/webgl/index.cjs.map +1 -1
  185. package/dist/gpu-simple-graph/operations/webgpu/index.cjs.map +1 -1
  186. package/dist/index.cjs +3 -0
  187. package/dist/index.cjs.map +3 -3
  188. package/dist/index.d.ts +2 -0
  189. package/dist/index.d.ts.map +1 -1
  190. package/dist/index.js +1 -0
  191. package/dist/index.js.map +1 -1
  192. package/package.json +17 -6
  193. package/src/arrow/cpu/arrow-coordinate-projection.ts +18 -0
  194. package/src/arrow/cpu/arrow-cpu-pipelines.ts +9 -0
  195. package/src/arrow/cpu/arrow-cpu-vector-adapters.ts +153 -0
  196. package/src/arrow/geoarrow/arrow-geoarrow-adapter.ts +23 -493
  197. package/src/arrow/geoarrow/arrow-geoarrow-conversion.ts +5 -3
  198. package/src/arrow/geoarrow/arrow-polygon-tessellation.ts +1 -1
  199. package/src/arrow/index.ts +11 -0
  200. package/src/gpu-core/compiled-gpu-graph.ts +55 -1
  201. package/src/gpu-core/gpu-command-graph.ts +27 -7
  202. package/src/gpu-core/gpu-cpu-execution.ts +345 -0
  203. package/src/gpu-core/gpu-cpu-operation.ts +65 -0
  204. package/src/gpu-core/gpu-expression-operation.ts +1 -1
  205. package/src/gpu-core/gpu-expression-plan.ts +5 -3
  206. package/src/gpu-core/gpu-graph.ts +3 -3
  207. package/src/gpu-core/gpu-operation.ts +9 -7
  208. package/src/gpu-core/gpu-render-operation.ts +42 -0
  209. package/src/gpu-core/gpu-texture-plan.ts +3 -2
  210. package/src/gpu-core/index.ts +10 -0
  211. package/src/gpu-data/cpu-data.ts +62 -0
  212. package/src/gpu-data/cpu-gpu-vector-transfer.ts +107 -0
  213. package/src/gpu-data/cpu-vector.ts +31 -0
  214. package/src/gpu-data/index.ts +5 -0
  215. package/src/gpu-graph/index.ts +8 -0
  216. package/src/gpu-project/coordinate-projection-graph.ts +59 -0
  217. package/src/gpu-project/cpu-geoarrow.ts +135 -0
  218. package/src/gpu-project/cpu-geometry-pipelines.ts +159 -0
  219. package/src/gpu-project/cpu-projection-operation.ts +49 -0
  220. package/src/gpu-project/geoarrow.ts +11 -0
  221. package/src/gpu-project/graph.ts +10 -0
  222. package/src/gpu-project/index.ts +2 -0
  223. package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +39 -2
  224. package/src/gpu-simple-graph/gpu-simple-graph-lowering.ts +11 -0
  225. package/src/gpu-simple-graph/gpu-simple-graph.ts +163 -19
  226. package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +22 -0
  227. package/src/gpu-simple-graph/operation/gpu-vector-evaluator.ts +7 -0
  228. package/src/index.ts +8 -0
@@ -18,386 +18,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
18
18
  var arrow_geoarrow_adapter_exports = {};
19
19
  __export(arrow_geoarrow_adapter_exports, {
20
20
  getGeoArrowRowViewFromArrowVector: () => getGeoArrowRowViewFromArrowVector,
21
- inferGeoArrowCoordinateLayoutFromArrowType: () => inferGeoArrowCoordinateLayoutFromArrowType,
22
- inferGeoArrowDimensionFromArrowType: () => inferGeoArrowDimensionFromArrowType,
23
- inferGeoArrowEncodingFromArrowType: () => inferGeoArrowEncodingFromArrowType,
21
+ inferGeoArrowCoordinateLayoutFromArrowType: () => import_geoarrow2.inferGeoArrowCoordinateLayoutFromArrowType,
22
+ inferGeoArrowDimensionFromArrowType: () => import_geoarrow2.inferGeoArrowDimensionFromArrowType,
23
+ inferGeoArrowEncodingFromArrowType: () => import_geoarrow2.inferGeoArrowEncodingFromArrowType,
24
24
  iterateGeoArrowBatchesFromArrowVector: () => iterateGeoArrowBatchesFromArrowVector,
25
- makeArrowVectorFromGeoArrowColumn: () => makeArrowVectorFromGeoArrowColumn,
25
+ makeArrowVectorFromGeoArrowColumn: () => import_geoarrow2.makeArrowVectorFromGeoArrowColumn,
26
26
  makeGeoArrowColumnFromArrowVector: () => makeGeoArrowColumnFromArrowVector
27
27
  });
28
28
  module.exports = __toCommonJS(arrow_geoarrow_adapter_exports);
29
- var import_geoarrow = require("@math.gl/geospatial/geoarrow");
30
- var import_apache_arrow = require("apache-arrow");
29
+ var import_geoarrow = require("@math.gl/arrow/geoarrow");
30
+ var import_geoarrow_utils = require("@math.gl/arrow/geoarrow-utils");
31
+ var import_geoarrow2 = require("@math.gl/arrow/geoarrow");
31
32
  function makeGeoArrowColumnFromArrowVector(vector, options = {}) {
32
- const encoding = options.encoding ?? inferGeoArrowEncodingFromArrowType(vector.type);
33
- const dimension = options.dimension ?? inferGeoArrowDimensionFromArrowType(vector.type);
34
- const coordinateLayout = options.coordinateLayout === void 0 ? inferGeoArrowCoordinateLayoutFromArrowType(vector.type) : options.coordinateLayout;
35
- return {
36
- encoding,
37
- dimension,
38
- coordinateLayout,
39
- chunks: vector.data.map((data) => makeGeoArrowArrayFromArrowData(data)),
40
- metadata: options.metadata
41
- };
33
+ return (0, import_geoarrow.makeGeoArrowColumnFromArrowVector)(vector, options);
42
34
  }
43
35
  function iterateGeoArrowBatchesFromArrowVector(vector, options = {}) {
44
- return (0, import_geoarrow.iterateGeoArrowBatches)(makeGeoArrowColumnFromArrowVector(vector, options));
36
+ return (0, import_geoarrow_utils.iterateGeoArrowBatches)(makeGeoArrowColumnFromArrowVector(vector, options));
45
37
  }
46
38
  function getGeoArrowRowViewFromArrowVector(vector, rowIndex, options = {}) {
47
- return (0, import_geoarrow.getGeoArrowRowView)(makeGeoArrowColumnFromArrowVector(vector, options), rowIndex);
48
- }
49
- function makeArrowVectorFromGeoArrowColumn(column) {
50
- return new import_apache_arrow.Vector(column.chunks.map((chunk) => makeArrowDataFromGeoArrowArray(chunk, column.dimension, column.coordinateLayout)));
51
- }
52
- function inferGeoArrowEncodingFromArrowType(type) {
53
- if (import_apache_arrow.DataType.isDenseUnion(type))
54
- return "geoarrow.geometry";
55
- if (import_apache_arrow.DataType.isBinary(type))
56
- return "geoarrow.wkb";
57
- if (import_apache_arrow.DataType.isUtf8(type))
58
- return "geoarrow.wkt";
59
- const nesting = getArrowListNesting(type);
60
- switch (nesting) {
61
- case 0:
62
- return "geoarrow.point";
63
- case 1:
64
- return "geoarrow.linestring";
65
- case 2:
66
- return "geoarrow.polygon";
67
- case 3:
68
- return "geoarrow.multipolygon";
69
- default:
70
- throw new Error(`Cannot infer GeoArrow encoding from Arrow type ${type.toString()}`);
71
- }
72
- }
73
- function inferGeoArrowDimensionFromArrowType(type) {
74
- var _a;
75
- if (import_apache_arrow.DataType.isFixedSizeList(type)) {
76
- const dimensionName = (_a = type.children[0]) == null ? void 0 : _a.name.toLowerCase();
77
- if (isGeoArrowDimension(dimensionName))
78
- return dimensionName;
79
- switch (type.listSize) {
80
- case 2:
81
- return "xy";
82
- case 3:
83
- return "xyz";
84
- case 4:
85
- return "xyzm";
86
- default:
87
- throw new Error(`GeoArrow coordinates require 2, 3, or 4 values, received ${type.listSize}`);
88
- }
89
- }
90
- if (import_apache_arrow.DataType.isStruct(type)) {
91
- const names = type.children.map((field) => field.name.toLowerCase());
92
- if (names[0] === "x" && names[1] === "y") {
93
- if (names[2] === "m")
94
- return "xym";
95
- if (names[2] === "z" && names[3] === "m")
96
- return "xyzm";
97
- if (names[2] === "z")
98
- return "xyz";
99
- return "xy";
100
- }
101
- }
102
- if (import_apache_arrow.DataType.isList(type)) {
103
- return inferGeoArrowDimensionFromArrowType(type.children[0].type);
104
- }
105
- if (import_apache_arrow.DataType.isDenseUnion(type)) {
106
- return type.children.reduce((dimension, field) => (0, import_geoarrow.mergeGeoArrowDimensions)(dimension, inferGeoArrowDimensionFromArrowType(field.type)), "xy");
107
- }
108
- throw new Error(`Cannot infer GeoArrow dimension from Arrow type ${type.toString()}`);
109
- }
110
- function inferGeoArrowCoordinateLayoutFromArrowType(type) {
111
- if (import_apache_arrow.DataType.isFixedSizeList(type))
112
- return "interleaved";
113
- if (import_apache_arrow.DataType.isStruct(type))
114
- return "separated";
115
- if (import_apache_arrow.DataType.isList(type)) {
116
- return inferGeoArrowCoordinateLayoutFromArrowType(type.children[0].type);
117
- }
118
- if (import_apache_arrow.DataType.isDenseUnion(type)) {
119
- for (const field of type.children) {
120
- const layout = inferGeoArrowCoordinateLayoutFromArrowType(field.type);
121
- if (layout)
122
- return layout;
123
- }
124
- }
125
- return null;
126
- }
127
- function makeGeoArrowArrayFromArrowData(data) {
128
- const validity = makeGeoArrowValidity(data);
129
- if (import_apache_arrow.DataType.isFixedSizeList(data.type)) {
130
- return {
131
- kind: "fixed-size-list",
132
- length: data.length,
133
- size: data.type.listSize,
134
- child: makeGeoArrowArrayFromArrowData(data.children[0]),
135
- validity
136
- };
137
- }
138
- if (import_apache_arrow.DataType.isList(data.type)) {
139
- return {
140
- kind: "list",
141
- length: data.length,
142
- offsets: data.valueOffsets,
143
- child: makeGeoArrowArrayFromArrowData(data.children[0]),
144
- validity
145
- };
146
- }
147
- if (import_apache_arrow.DataType.isStruct(data.type)) {
148
- const children = {};
149
- for (let childIndex = 0; childIndex < data.type.children.length; childIndex++) {
150
- children[data.type.children[childIndex].name] = makeGeoArrowArrayFromArrowData(data.children[childIndex]);
151
- }
152
- return { kind: "struct", length: data.length, children, validity };
153
- }
154
- if (import_apache_arrow.DataType.isDenseUnion(data.type)) {
155
- const unionType = data.type;
156
- return {
157
- kind: "dense-union",
158
- length: data.length,
159
- typeIds: data.typeIds,
160
- valueOffsets: data.valueOffsets,
161
- children: unionType.children.map((field, childIndex) => ({
162
- name: field.name,
163
- typeId: unionType.typeIds[childIndex],
164
- encoding: inferGeoArrowEncodingFromUnionChild(field),
165
- dimension: inferGeoArrowDimensionFromArrowType(field.type),
166
- coordinateLayout: inferGeoArrowCoordinateLayoutFromArrowType(field.type),
167
- data: makeGeoArrowArrayFromArrowData(data.children[childIndex])
168
- })),
169
- validity
170
- };
171
- }
172
- if (import_apache_arrow.DataType.isBinary(data.type) || import_apache_arrow.DataType.isUtf8(data.type)) {
173
- return {
174
- kind: "serialized",
175
- encoding: import_apache_arrow.DataType.isBinary(data.type) ? "binary" : "utf8",
176
- length: data.length,
177
- offsets: data.valueOffsets,
178
- values: data.values,
179
- validity
180
- };
181
- }
182
- if (import_apache_arrow.DataType.isInt(data.type) || import_apache_arrow.DataType.isFloat(data.type)) {
183
- return {
184
- kind: "primitive",
185
- length: data.length,
186
- values: data.values,
187
- validity
188
- };
189
- }
190
- throw new Error(`Unsupported GeoArrow physical Arrow type ${data.type.toString()}`);
191
- }
192
- function makeGeoArrowValidity(data) {
193
- if (data.nullCount <= 0 || !data.nullBitmap || data.nullBitmap.length === 0)
194
- return void 0;
195
- return { values: data.nullBitmap, bitOffset: data.offset };
196
- }
197
- function makeArrowDataFromGeoArrowArray(array, dimension, coordinateLayout) {
198
- const validity = makeCompactValidity(array.validity, array.length);
199
- const nullCount = validity ? -1 : 0;
200
- const validityBuffers = validity ? { [import_apache_arrow.BufferType.VALIDITY]: validity } : {};
201
- switch (array.kind) {
202
- case "primitive": {
203
- const values = makePackedPrimitiveValues(array);
204
- const type = getArrowTypeForValues(values);
205
- return new import_apache_arrow.Data(type, 0, array.length, nullCount, {
206
- ...validityBuffers,
207
- [import_apache_arrow.BufferType.DATA]: values
208
- });
209
- }
210
- case "fixed-size-list": {
211
- const child = makeArrowDataFromGeoArrowArray(array.child, dimension, coordinateLayout);
212
- const childStart = (array.offset ?? 0) * array.size;
213
- const slicedChild = childStart === 0 && child.length === array.length * array.size ? child : child.slice(childStart, array.length * array.size);
214
- const type = new import_apache_arrow.FixedSizeList(array.size, new import_apache_arrow.Field(dimension, slicedChild.type, false));
215
- return new import_apache_arrow.Data(type, 0, array.length, nullCount, validityBuffers, [slicedChild]);
216
- }
217
- case "list": {
218
- if (array.offsets instanceof BigInt64Array) {
219
- throw new Error("Apache Arrow JS does not expose LargeList in this supported version");
220
- }
221
- const child = makeArrowDataFromGeoArrowArray(array.child, dimension, coordinateLayout);
222
- const offsets = makeArrowOffsets(array.offsets, array.offset, array.length, array.offsetBase);
223
- const type = new import_apache_arrow.List(new import_apache_arrow.Field("values", child.type, true));
224
- return new import_apache_arrow.Data(type, 0, array.length, nullCount, { ...validityBuffers, [import_apache_arrow.BufferType.OFFSET]: offsets }, [child]);
225
- }
226
- case "struct": {
227
- const fields = [];
228
- const children = [];
229
- for (const [name, childArray] of Object.entries(array.children)) {
230
- let child = makeArrowDataFromGeoArrowArray(childArray, dimension, coordinateLayout);
231
- const childOffset = array.offset ?? 0;
232
- if (childOffset > 0 || child.length !== array.length) {
233
- child = child.slice(childOffset, array.length);
234
- }
235
- fields.push(new import_apache_arrow.Field(name, child.type, true));
236
- children.push(child);
237
- }
238
- return new import_apache_arrow.Data(new import_apache_arrow.Struct(fields), 0, array.length, nullCount, validityBuffers, children);
239
- }
240
- case "dense-union":
241
- return makeArrowDenseUnionData(array, dimension, coordinateLayout);
242
- case "serialized": {
243
- if (array.offsets instanceof BigInt64Array) {
244
- throw new Error("Large GeoArrow serialized output is not supported by this adapter");
245
- }
246
- const offsets = makeArrowOffsets(array.offsets, array.offset, array.length, array.offsetBase);
247
- const type = array.encoding === "binary" ? new import_apache_arrow.Binary() : new import_apache_arrow.Utf8();
248
- return new import_apache_arrow.Data(type, 0, array.length, nullCount, {
249
- ...validityBuffers,
250
- [import_apache_arrow.BufferType.OFFSET]: offsets,
251
- [import_apache_arrow.BufferType.DATA]: array.values
252
- });
253
- }
254
- }
255
- }
256
- function makeArrowDenseUnionData(array, dimension, coordinateLayout) {
257
- const offset = array.offset ?? 0;
258
- const typeIds = array.typeIds.slice(offset, offset + array.length);
259
- const valueOffsets = array.valueOffsets.slice(offset, offset + array.length);
260
- const children = array.children.map((child) => makeArrowDataFromGeoArrowArray(child.data, child.dimension ?? dimension, child.coordinateLayout === void 0 ? coordinateLayout : child.coordinateLayout));
261
- if (array.validity && array.children.length > 0) {
262
- const nullChildIndex = 0;
263
- const nullChild = children[nullChildIndex];
264
- const nullValueOffset = nullChild.length;
265
- children[nullChildIndex] = appendNullToArrowData(nullChild);
266
- for (let rowIndex = 0; rowIndex < array.length; rowIndex++) {
267
- if (!isGeoArrowValueValid(array.validity, rowIndex)) {
268
- typeIds[rowIndex] = array.children[nullChildIndex].typeId;
269
- valueOffsets[rowIndex] = nullValueOffset;
270
- }
271
- }
272
- }
273
- const fields = array.children.map((child, childIndex) => new import_apache_arrow.Field(child.name, children[childIndex].type, true));
274
- const type = new import_apache_arrow.DenseUnion(Int32Array.from(array.children.map((child) => child.typeId)), fields);
275
- return new import_apache_arrow.Data(type, 0, array.length, 0, { [import_apache_arrow.BufferType.TYPE]: Int8Array.from(typeIds), [import_apache_arrow.BufferType.OFFSET]: valueOffsets }, children);
276
- }
277
- function appendNullToArrowData(data) {
278
- const vector = new import_apache_arrow.Vector([data]);
279
- const values = [];
280
- for (let index = 0; index < vector.length; index++) {
281
- values.push(materializeArrowValue(vector.get(index)));
282
- }
283
- values.push(null);
284
- return (0, import_apache_arrow.vectorFromArray)(values, data.type).data[0];
285
- }
286
- function materializeArrowValue(value) {
287
- if (value === null || value === void 0)
288
- return null;
289
- if (ArrayBuffer.isView(value)) {
290
- return Array.from(value);
291
- }
292
- if (Array.isArray(value))
293
- return value.map(materializeArrowValue);
294
- if (isArrowVectorLike(value)) {
295
- const values = [];
296
- for (let index = 0; index < value.length; index++) {
297
- values.push(materializeArrowValue(value.get(index)));
298
- }
299
- return values;
300
- }
301
- return value;
302
- }
303
- function isArrowVectorLike(value) {
304
- return Boolean(value && typeof value === "object" && "length" in value && "get" in value && typeof value.get === "function");
305
- }
306
- function makePackedPrimitiveValues(array) {
307
- const offset = array.offset ?? 0;
308
- const stride = array.stride ?? 1;
309
- if (stride === 1) {
310
- return array.values.subarray(offset, offset + array.length);
311
- }
312
- const ValuesConstructor = array.values.constructor;
313
- const values = new ValuesConstructor(array.length);
314
- for (let index = 0; index < array.length; index++) {
315
- values[index] = array.values[offset + index * stride];
316
- }
317
- return values;
318
- }
319
- function getArrowTypeForValues(values) {
320
- if (values instanceof Int8Array)
321
- return new import_apache_arrow.Int8();
322
- if (values instanceof Uint8Array || values instanceof Uint8ClampedArray)
323
- return new import_apache_arrow.Uint8();
324
- if (values instanceof Int16Array)
325
- return new import_apache_arrow.Int16();
326
- if (values instanceof Uint16Array)
327
- return new import_apache_arrow.Uint16();
328
- if (values instanceof Int32Array)
329
- return new import_apache_arrow.Int32();
330
- if (values instanceof Uint32Array)
331
- return new import_apache_arrow.Uint32();
332
- if (values instanceof BigInt64Array)
333
- return new import_apache_arrow.Int64();
334
- if (values instanceof BigUint64Array)
335
- return new import_apache_arrow.Uint64();
336
- if (values instanceof Float32Array)
337
- return new import_apache_arrow.Float32();
338
- if (values instanceof Float64Array)
339
- return new import_apache_arrow.Float64();
340
- throw new Error(`Unsupported GeoArrow primitive values ${values.constructor.name}`);
341
- }
342
- function makeArrowOffsets(offsets, offset = 0, length, offsetBase = 0) {
343
- const source = offsets.subarray(offset, offset + length + 1);
344
- if (offsetBase === 0)
345
- return source;
346
- const normalized = new Int32Array(source.length);
347
- for (let index = 0; index < source.length; index++) {
348
- normalized[index] = Number(source[index]) - Number(offsetBase);
349
- }
350
- return normalized;
351
- }
352
- function makeCompactValidity(validity, length) {
353
- if (!validity)
354
- return void 0;
355
- const bitOffset = validity.bitOffset ?? 0;
356
- const values = new Uint8Array(Math.ceil(length / 8));
357
- let nullCount = 0;
358
- for (let index = 0; index < length; index++) {
359
- if (isGeoArrowValueValid(validity, index)) {
360
- values[index >> 3] |= 1 << (index & 7);
361
- } else {
362
- nullCount++;
363
- }
364
- }
365
- return nullCount > 0 || bitOffset > 0 ? values : void 0;
366
- }
367
- function isGeoArrowValueValid(validity, index) {
368
- const bitIndex = (validity.bitOffset ?? 0) + index;
369
- return Boolean(validity.values[bitIndex >> 3] & 1 << (bitIndex & 7));
370
- }
371
- function inferGeoArrowEncodingFromUnionChild(field) {
372
- const normalizedName = field.name.replace(/[^a-z]/gi, "").toLowerCase();
373
- const names = {
374
- point: "geoarrow.point",
375
- linestring: "geoarrow.linestring",
376
- polygon: "geoarrow.polygon",
377
- multipoint: "geoarrow.multipoint",
378
- multilinestring: "geoarrow.multilinestring",
379
- multipolygon: "geoarrow.multipolygon",
380
- geometrycollection: "geoarrow.geometrycollection"
381
- };
382
- for (const [name, encoding] of Object.entries(names)) {
383
- if (normalizedName.startsWith(name))
384
- return encoding;
385
- }
386
- return inferGeoArrowEncodingFromArrowType(field.type);
387
- }
388
- function getArrowListNesting(type) {
389
- let nesting = 0;
390
- let currentType = type;
391
- while (import_apache_arrow.DataType.isList(currentType)) {
392
- nesting++;
393
- currentType = currentType.children[0].type;
394
- }
395
- if (import_apache_arrow.DataType.isFixedSizeList(currentType) || import_apache_arrow.DataType.isStruct(currentType))
396
- return nesting;
397
- throw new Error(`GeoArrow type does not terminate in coordinates: ${type.toString()}`);
398
- }
399
- function isGeoArrowDimension(value) {
400
- return value === "xy" || value === "xyz" || value === "xym" || value === "xyzm";
39
+ return (0, import_geoarrow_utils.getGeoArrowRowView)(makeGeoArrowColumnFromArrowVector(vector, options), rowIndex);
401
40
  }
402
41
  // Annotate the CommonJS export names for ESM import in node:
403
42
  0 && (module.exports = {
@@ -1,31 +1,12 @@
1
- import type { GeoArrowBatchView, GeoArrowRowView, GeoArrowColumn, GeoArrowCoordinateLayout, GeoArrowDimension, GeoArrowEncoding } from '@math.gl/geospatial/geoarrow';
2
- import { Vector, type DataType as ArrowDataType } from 'apache-arrow';
3
- /** Options for adapting one Apache Arrow vector to math.gl's runtime-neutral GeoArrow ABI. */
4
- export type MakeGeoArrowColumnFromArrowVectorOptions = {
5
- /** GeoArrow extension encoding. Inferred from the physical type when omitted. */
6
- encoding?: GeoArrowEncoding;
7
- /** Semantic coordinate dimension. Inferred from coordinate field names when omitted. */
8
- dimension?: GeoArrowDimension;
9
- /** Coordinate organization. Inferred from the physical type when omitted. */
10
- coordinateLayout?: GeoArrowCoordinateLayout | null;
11
- /** Opaque extension metadata retained on the descriptor envelope. */
12
- metadata?: Readonly<Record<string, unknown>>;
13
- };
14
- /**
15
- * Adapts Apache Arrow physical buffers to the borrowed descriptor ABI used by
16
- * `@math.gl/geospatial/geoarrow`.
17
- */
18
- export declare function makeGeoArrowColumnFromArrowVector<T extends ArrowDataType>(vector: Vector<T>, options?: MakeGeoArrowColumnFromArrowVectorOptions): GeoArrowColumn;
1
+ import type { DataType, Vector } from 'apache-arrow';
2
+ import { type MakeGeoArrowColumnFromArrowVectorOptions } from '@math.gl/arrow/geoarrow';
3
+ import { type GeoArrowBatchView, type GeoArrowColumn, type GeoArrowRowView } from '@math.gl/arrow/geoarrow-utils';
4
+ export type { MakeGeoArrowColumnFromArrowVectorOptions } from '@math.gl/arrow/geoarrow';
5
+ export { makeArrowVectorFromGeoArrowColumn, inferGeoArrowEncodingFromArrowType, inferGeoArrowDimensionFromArrowType, inferGeoArrowCoordinateLayoutFromArrowType } from '@math.gl/arrow/geoarrow';
6
+ /** Adapts borrowed Arrow buffers using math.gl's shared GeoArrow adapter. */
7
+ export declare function makeGeoArrowColumnFromArrowVector<T extends DataType>(vector: Vector<T>, options?: MakeGeoArrowColumnFromArrowVectorOptions): GeoArrowColumn;
19
8
  /** Iterates borrowed batch views while retaining Arrow chunk boundaries and buffers. */
20
- export declare function iterateGeoArrowBatchesFromArrowVector<T extends ArrowDataType>(vector: Vector<T>, options?: MakeGeoArrowColumnFromArrowVectorOptions): IterableIterator<GeoArrowBatchView>;
9
+ export declare function iterateGeoArrowBatchesFromArrowVector<T extends DataType>(vector: Vector<T>, options?: MakeGeoArrowColumnFromArrowVectorOptions): IterableIterator<GeoArrowBatchView>;
21
10
  /** Gets a borrowed row view by logical index across Arrow chunks. */
22
- export declare function getGeoArrowRowViewFromArrowVector<T extends ArrowDataType>(vector: Vector<T>, rowIndex: number, options?: MakeGeoArrowColumnFromArrowVectorOptions): GeoArrowRowView;
23
- /** Converts a math.gl GeoArrow descriptor back to an Apache Arrow vector. */
24
- export declare function makeArrowVectorFromGeoArrowColumn(column: GeoArrowColumn): Vector;
25
- /** Infers a native GeoArrow encoding from an Apache Arrow physical type. */
26
- export declare function inferGeoArrowEncodingFromArrowType(type: ArrowDataType): GeoArrowEncoding;
27
- /** Infers the semantic GeoArrow coordinate dimension from Arrow coordinate field names. */
28
- export declare function inferGeoArrowDimensionFromArrowType(type: ArrowDataType): GeoArrowDimension;
29
- /** Infers whether Arrow coordinate leaves are interleaved or separated. */
30
- export declare function inferGeoArrowCoordinateLayoutFromArrowType(type: ArrowDataType): GeoArrowCoordinateLayout | null;
11
+ export declare function getGeoArrowRowViewFromArrowVector<T extends DataType>(vector: Vector<T>, rowIndex: number, options?: MakeGeoArrowColumnFromArrowVectorOptions): GeoArrowRowView;
31
12
  //# sourceMappingURL=arrow-geoarrow-adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrow-geoarrow-adapter.d.ts","sourceRoot":"","sources":["../../../src/arrow/geoarrow/arrow-geoarrow-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EAEf,cAAc,EACd,wBAAwB,EAExB,iBAAiB,EACjB,gBAAgB,EAIjB,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAqBL,MAAM,EAEN,KAAK,QAAQ,IAAI,aAAa,EAC/B,MAAM,cAAc,CAAC;AAEtB,8FAA8F;AAC9F,MAAM,MAAM,wCAAwC,GAAG;IACrD,iFAAiF;IACjF,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,wFAAwF;IACxF,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IACnD,qEAAqE;IACrE,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,CAAC,SAAS,aAAa,EACvE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,GAAE,wCAA6C,GACrD,cAAc,CAehB;AAED,wFAAwF;AACxF,wBAAgB,qCAAqC,CAAC,CAAC,SAAS,aAAa,EAC3E,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,GAAE,wCAA6C,GACrD,gBAAgB,CAAC,iBAAiB,CAAC,CAErC;AAED,qEAAqE;AACrE,wBAAgB,iCAAiC,CAAC,CAAC,SAAS,aAAa,EACvE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,wCAA6C,GACrD,eAAe,CAEjB;AAED,6EAA6E;AAC7E,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAMhF;AAED,4EAA4E;AAC5E,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,aAAa,GAAG,gBAAgB,CAkBxF;AAED,2FAA2F;AAC3F,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,aAAa,GAAG,iBAAiB,CAqC1F;AAED,2EAA2E;AAC3E,wBAAgB,0CAA0C,CACxD,IAAI,EAAE,aAAa,GAClB,wBAAwB,GAAG,IAAI,CAajC"}
1
+ {"version":3,"file":"arrow-geoarrow-adapter.d.ts","sourceRoot":"","sources":["../../../src/arrow/geoarrow/arrow-geoarrow-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAEL,KAAK,wCAAwC,EAC9C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAC,wCAAwC,EAAC,MAAM,yBAAyB,CAAC;AACtF,OAAO,EACL,iCAAiC,EACjC,kCAAkC,EAClC,mCAAmC,EACnC,0CAA0C,EAC3C,MAAM,yBAAyB,CAAC;AAEjC,6EAA6E;AAC7E,wBAAgB,iCAAiC,CAAC,CAAC,SAAS,QAAQ,EAClE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,GAAE,wCAA6C,GACrD,cAAc,CAEhB;AAED,wFAAwF;AACxF,wBAAgB,qCAAqC,CAAC,CAAC,SAAS,QAAQ,EACtE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,GAAE,wCAA6C,GACrD,gBAAgB,CAAC,iBAAiB,CAAC,CAErC;AAED,qEAAqE;AACrE,wBAAgB,iCAAiC,CAAC,CAAC,SAAS,QAAQ,EAClE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,wCAA6C,GACrD,eAAe,CAEjB"}