@loaders.gl/arrow 4.3.0-alpha.8 → 4.3.0-beta.2

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 (132) hide show
  1. package/dist/arrow-loader.d.ts +6 -38
  2. package/dist/arrow-loader.d.ts.map +1 -1
  3. package/dist/arrow-loader.js +2 -29
  4. package/dist/arrow-worker.js +2654 -1710
  5. package/dist/arrow-writer.d.ts +1 -1
  6. package/dist/arrow-writer.d.ts.map +1 -1
  7. package/dist/arrow-writer.js +2 -2
  8. package/dist/dist.dev.js +1863 -1768
  9. package/dist/dist.min.js +5 -5
  10. package/dist/exports/arrow-loader.d.ts +34 -0
  11. package/dist/exports/arrow-loader.d.ts.map +1 -0
  12. package/dist/exports/arrow-loader.js +30 -0
  13. package/dist/exports/geoarrow-loader.d.ts +27 -0
  14. package/dist/exports/geoarrow-loader.d.ts.map +1 -0
  15. package/dist/exports/geoarrow-loader.js +13 -0
  16. package/dist/geoarrow-loader.d.ts +3 -27
  17. package/dist/geoarrow-loader.d.ts.map +1 -1
  18. package/dist/geoarrow-loader.js +2 -12
  19. package/dist/geoarrow-writer.d.ts +2 -2
  20. package/dist/geoarrow-writer.d.ts.map +1 -1
  21. package/dist/geoarrow-writer.js +2 -2
  22. package/dist/index.cjs +426 -387
  23. package/dist/index.cjs.map +4 -4
  24. package/dist/index.d.ts +14 -13
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +16 -12
  27. package/dist/lib/encoders/encode-arrow.d.ts.map +1 -0
  28. package/dist/lib/encoders/encode-geoarrow.d.ts.map +1 -0
  29. package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -0
  30. package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +1 -0
  31. package/dist/lib/geoarrow/get-arrow-bounds.d.ts.map +1 -0
  32. package/dist/lib/parsers/parse-arrow.d.ts +9 -0
  33. package/dist/lib/parsers/parse-arrow.d.ts.map +1 -0
  34. package/dist/{parsers/parse-arrow-in-batches.js → lib/parsers/parse-arrow.js} +7 -3
  35. package/dist/lib/parsers/parse-geoarrow.d.ts +9 -0
  36. package/dist/lib/parsers/parse-geoarrow.d.ts.map +1 -0
  37. package/dist/{parsers/parse-geoarrow-sync.js → lib/parsers/parse-geoarrow.js} +9 -3
  38. package/dist/{schema → lib/tables}/convert-arrow-schema.d.ts +4 -0
  39. package/dist/lib/tables/convert-arrow-schema.d.ts.map +1 -0
  40. package/dist/{schema → lib/tables}/convert-arrow-schema.js +8 -0
  41. package/dist/lib/tables/convert-arrow-to-table.d.ts +15 -0
  42. package/dist/lib/tables/convert-arrow-to-table.d.ts.map +1 -0
  43. package/dist/lib/tables/convert-arrow-to-table.js +104 -0
  44. package/dist/lib/tables/convert-table-to-arrow.d.ts +16 -0
  45. package/dist/lib/tables/convert-table-to-arrow.d.ts.map +1 -0
  46. package/dist/lib/tables/convert-table-to-arrow.js +56 -0
  47. package/dist/lib/types.d.ts.map +1 -0
  48. package/dist/{lib → schema}/arrow-table-batch.d.ts +2 -1
  49. package/dist/schema/arrow-table-batch.d.ts.map +1 -0
  50. package/dist/{lib → schema}/arrow-table-batch.js +1 -0
  51. package/dist/{lib/arrow-table.d.ts → schema/arrow-table-type.d.ts} +3 -1
  52. package/dist/schema/arrow-table-type.d.ts.map +1 -0
  53. package/dist/triangulate-on-worker.js +1 -1
  54. package/dist/triangulation-worker.js +13 -5
  55. package/dist/workers/triangulation-worker.js +1 -1
  56. package/package.json +11 -7
  57. package/src/arrow-loader.ts +6 -57
  58. package/src/arrow-writer.ts +1 -2
  59. package/src/exports/arrow-loader.ts +49 -0
  60. package/src/exports/geoarrow-loader.ts +24 -0
  61. package/src/geoarrow-loader.ts +6 -22
  62. package/src/geoarrow-writer.ts +1 -1
  63. package/src/index.ts +23 -23
  64. package/src/{parsers/parse-arrow-in-batches.ts → lib/parsers/parse-arrow.ts} +11 -5
  65. package/src/lib/parsers/parse-geoarrow.ts +32 -0
  66. package/src/{schema → lib/tables}/convert-arrow-schema.ts +10 -0
  67. package/src/lib/tables/convert-arrow-to-table.ts +144 -0
  68. package/src/lib/tables/convert-table-to-arrow.ts +72 -0
  69. package/src/{lib → schema}/arrow-table-batch.ts +2 -1
  70. package/src/{lib/arrow-table.ts → schema/arrow-table-type.ts} +2 -0
  71. package/src/workers/triangulation-worker.ts +1 -1
  72. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +0 -1
  73. package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +0 -1
  74. package/dist/geoarrow/get-arrow-bounds.d.ts.map +0 -1
  75. package/dist/lib/arrow-table-batch.d.ts.map +0 -1
  76. package/dist/lib/arrow-table.d.ts.map +0 -1
  77. package/dist/lib/encode-arrow.d.ts.map +0 -1
  78. package/dist/lib/encode-geoarrow.d.ts.map +0 -1
  79. package/dist/parsers/parse-arrow-in-batches.d.ts +0 -6
  80. package/dist/parsers/parse-arrow-in-batches.d.ts.map +0 -1
  81. package/dist/parsers/parse-arrow-sync.d.ts +0 -6
  82. package/dist/parsers/parse-arrow-sync.d.ts.map +0 -1
  83. package/dist/parsers/parse-arrow-sync.js +0 -32
  84. package/dist/parsers/parse-geoarrow-in-batches.d.ts +0 -6
  85. package/dist/parsers/parse-geoarrow-in-batches.d.ts.map +0 -1
  86. package/dist/parsers/parse-geoarrow-in-batches.js +0 -10
  87. package/dist/parsers/parse-geoarrow-sync.d.ts +0 -6
  88. package/dist/parsers/parse-geoarrow-sync.d.ts.map +0 -1
  89. package/dist/schema/arrow-type-utils.d.ts +0 -5
  90. package/dist/schema/arrow-type-utils.d.ts.map +0 -1
  91. package/dist/schema/arrow-type-utils.js +0 -51
  92. package/dist/schema/convert-arrow-schema.d.ts.map +0 -1
  93. package/dist/tables/convert-arrow-to-columnar-table.d.ts +0 -8
  94. package/dist/tables/convert-arrow-to-columnar-table.d.ts.map +0 -1
  95. package/dist/tables/convert-arrow-to-columnar-table.js +0 -24
  96. package/dist/tables/convert-arrow-to-geojson-table.d.ts +0 -16
  97. package/dist/tables/convert-arrow-to-geojson-table.d.ts.map +0 -1
  98. package/dist/tables/convert-arrow-to-geojson-table.js +0 -54
  99. package/dist/tables/convert-columnar-to-row-table.d.ts +0 -7
  100. package/dist/tables/convert-columnar-to-row-table.d.ts.map +0 -1
  101. package/dist/tables/convert-columnar-to-row-table.js +0 -25
  102. package/dist/tables/convert-table-to-arrow.d.ts +0 -42
  103. package/dist/tables/convert-table-to-arrow.d.ts.map +0 -1
  104. package/dist/tables/convert-table-to-arrow.js +0 -59
  105. package/dist/types.d.ts.map +0 -1
  106. package/src/parsers/parse-arrow-sync.ts +0 -44
  107. package/src/parsers/parse-geoarrow-in-batches.ts +0 -16
  108. package/src/parsers/parse-geoarrow-sync.ts +0 -23
  109. package/src/schema/arrow-type-utils.ts +0 -55
  110. package/src/tables/convert-arrow-to-columnar-table.ts +0 -31
  111. package/src/tables/convert-arrow-to-geojson-table.ts +0 -66
  112. package/src/tables/convert-columnar-to-row-table.ts +0 -31
  113. package/src/tables/convert-table-to-arrow.ts +0 -61
  114. /package/dist/lib/{encode-arrow.d.ts → encoders/encode-arrow.d.ts} +0 -0
  115. /package/dist/lib/{encode-arrow.js → encoders/encode-arrow.js} +0 -0
  116. /package/dist/lib/{encode-geoarrow.d.ts → encoders/encode-geoarrow.d.ts} +0 -0
  117. /package/dist/lib/{encode-geoarrow.js → encoders/encode-geoarrow.js} +0 -0
  118. /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.d.ts +0 -0
  119. /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.js +0 -0
  120. /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.d.ts +0 -0
  121. /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.js +0 -0
  122. /package/dist/{geoarrow → lib/geoarrow}/get-arrow-bounds.d.ts +0 -0
  123. /package/dist/{geoarrow → lib/geoarrow}/get-arrow-bounds.js +0 -0
  124. /package/dist/{types.d.ts → lib/types.d.ts} +0 -0
  125. /package/dist/{types.js → lib/types.js} +0 -0
  126. /package/dist/{lib/arrow-table.js → schema/arrow-table-type.js} +0 -0
  127. /package/src/lib/{encode-arrow.ts → encoders/encode-arrow.ts} +0 -0
  128. /package/src/lib/{encode-geoarrow.ts → encoders/encode-geoarrow.ts} +0 -0
  129. /package/src/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.ts +0 -0
  130. /package/src/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.ts +0 -0
  131. /package/src/{geoarrow → lib/geoarrow}/get-arrow-bounds.ts +0 -0
  132. /package/src/{types.ts → lib/types.ts} +0 -0
package/dist/index.cjs CHANGED
@@ -37,19 +37,21 @@ __export(dist_exports, {
37
37
  GeoArrowWorkerLoader: () => GeoArrowWorkerLoader,
38
38
  TriangulationWorker: () => TriangulationWorker,
39
39
  VECTOR_TYPES: () => VECTOR_TYPES,
40
- convertArrowToGeoJSONTable: () => convertArrowToGeoJSONTable,
40
+ convertArrowToSchema: () => convertArrowToSchema,
41
+ convertArrowToTable: () => convertArrowToTable,
42
+ convertSchemaToArrow: () => convertSchemaToArrow,
43
+ convertTableToArrow: () => convertTableToArrow,
41
44
  deserializeArrowField: () => deserializeArrowField,
42
45
  deserializeArrowMetadata: () => deserializeArrowMetadata,
43
46
  deserializeArrowSchema: () => deserializeArrowSchema,
44
47
  deserializeArrowType: () => deserializeArrowType,
45
- getArrowType: () => getArrowType,
46
48
  getBinaryGeometriesFromArrow: () => getBinaryGeometriesFromArrow,
47
49
  getBinaryGeometryTemplate: () => getBinaryGeometryTemplate,
48
50
  getMeanCentersFromBinaryGeometries: () => getMeanCentersFromBinaryGeometries,
49
51
  getTriangleIndices: () => getTriangleIndices,
50
52
  hardClone: () => hardClone,
51
53
  parseGeoArrowOnWorker: () => parseGeoArrowOnWorker,
52
- parseGeometryFromArrow: () => parseGeometryFromArrow2,
54
+ parseGeometryFromArrow: () => parseGeometryFromArrow,
53
55
  serializeArrowField: () => serializeArrowField,
54
56
  serializeArrowMetadata: () => serializeArrowMetadata,
55
57
  serializeArrowSchema: () => serializeArrowSchema,
@@ -58,9 +60,15 @@ __export(dist_exports, {
58
60
  updateBoundsFromGeoArrowSamples: () => updateBoundsFromGeoArrowSamples
59
61
  });
60
62
  module.exports = __toCommonJS(dist_exports);
61
- var import_schema3 = require("@loaders.gl/schema");
62
63
 
63
- // dist/lib/arrow-table-batch.js
64
+ // dist/lib/types.js
65
+ var VECTOR_TYPES;
66
+ (function(VECTOR_TYPES2) {
67
+ VECTOR_TYPES2[VECTOR_TYPES2["FLOAT"] = 0] = "FLOAT";
68
+ VECTOR_TYPES2[VECTOR_TYPES2["DATE"] = 1] = "DATE";
69
+ })(VECTOR_TYPES || (VECTOR_TYPES = {}));
70
+
71
+ // dist/schema/arrow-table-batch.js
64
72
  var import_schema = require("@loaders.gl/schema");
65
73
  var arrow = __toESM(require("apache-arrow"), 1);
66
74
  var ArrowTableBatchAggregator = class extends import_schema.ColumnarTableBatchAggregator {
@@ -118,60 +126,50 @@ function getArrowVectors(arrowSchema, data) {
118
126
  return arrowVectors;
119
127
  }
120
128
 
121
- // dist/schema/arrow-type-utils.js
122
- var arrow2 = __toESM(require("apache-arrow"), 1);
123
- function getArrowType(array) {
124
- switch (array.constructor) {
125
- case Int8Array:
126
- return new arrow2.Int8();
127
- case Uint8Array:
128
- return new arrow2.Uint8();
129
- case Int16Array:
130
- return new arrow2.Int16();
131
- case Uint16Array:
132
- return new arrow2.Uint16();
133
- case Int32Array:
134
- return new arrow2.Int32();
135
- case Uint32Array:
136
- return new arrow2.Uint32();
137
- case Float32Array:
138
- return new arrow2.Float32();
139
- case Float64Array:
140
- return new arrow2.Float64();
141
- default:
142
- throw new Error("array type not supported");
129
+ // dist/index.js
130
+ var import_schema4 = require("@loaders.gl/schema");
131
+
132
+ // dist/exports/arrow-loader.js
133
+ var VERSION = true ? "4.3.0-beta.1" : "latest";
134
+ var ArrowWorkerLoader = {
135
+ dataType: null,
136
+ batchType: null,
137
+ name: "Apache Arrow",
138
+ id: "arrow",
139
+ module: "arrow",
140
+ version: VERSION,
141
+ // worker: true,
142
+ category: "table",
143
+ extensions: ["arrow", "feather"],
144
+ mimeTypes: [
145
+ "application/vnd.apache.arrow.file",
146
+ "application/vnd.apache.arrow.stream",
147
+ "application/octet-stream"
148
+ ],
149
+ binary: true,
150
+ tests: ["ARROW"],
151
+ options: {
152
+ arrow: {
153
+ shape: "columnar-table"
154
+ }
143
155
  }
144
- }
156
+ };
145
157
 
146
- // dist/types.js
147
- var VECTOR_TYPES;
148
- (function(VECTOR_TYPES2) {
149
- VECTOR_TYPES2[VECTOR_TYPES2["FLOAT"] = 0] = "FLOAT";
150
- VECTOR_TYPES2[VECTOR_TYPES2["DATE"] = 1] = "DATE";
151
- })(VECTOR_TYPES || (VECTOR_TYPES = {}));
158
+ // dist/lib/parsers/parse-arrow.js
159
+ var arrow3 = __toESM(require("apache-arrow"), 1);
152
160
 
153
- // dist/parsers/parse-arrow-sync.js
161
+ // dist/lib/tables/convert-arrow-to-table.js
154
162
  var import_schema2 = require("@loaders.gl/schema");
155
- var arrow4 = __toESM(require("apache-arrow"), 1);
163
+ var import_gis2 = require("@loaders.gl/gis");
156
164
 
157
- // dist/tables/convert-arrow-to-columnar-table.js
158
- function convertArrowToColumnarTable(table) {
159
- const arrowTable = table.data;
160
- const columnarTable = {};
161
- for (const field of arrowTable.schema.fields) {
162
- const arrowColumn = arrowTable.getChild(field.name);
163
- const values = arrowColumn == null ? void 0 : arrowColumn.toArray();
164
- columnarTable[field.name] = values;
165
- }
166
- return {
167
- shape: "columnar-table",
168
- schema: table.schema,
169
- data: columnarTable
170
- };
165
+ // dist/lib/tables/convert-arrow-schema.js
166
+ var arrow2 = __toESM(require("apache-arrow"), 1);
167
+ function convertArrowToSchema(arrowSchema) {
168
+ return serializeArrowSchema(arrowSchema);
169
+ }
170
+ function convertSchemaToArrow(schema) {
171
+ return deserializeArrowSchema(schema);
171
172
  }
172
-
173
- // dist/schema/convert-arrow-schema.js
174
- var arrow3 = __toESM(require("apache-arrow"), 1);
175
173
  function serializeArrowSchema(arrowSchema) {
176
174
  return {
177
175
  fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
@@ -179,7 +177,7 @@ function serializeArrowSchema(arrowSchema) {
179
177
  };
180
178
  }
181
179
  function deserializeArrowSchema(schema) {
182
- return new arrow3.Schema(schema.fields.map((field) => deserializeArrowField(field)), deserializeArrowMetadata(schema.metadata));
180
+ return new arrow2.Schema(schema.fields.map((field) => deserializeArrowField(field)), deserializeArrowMetadata(schema.metadata));
183
181
  }
184
182
  function serializeArrowMetadata(arrowMetadata) {
185
183
  return Object.fromEntries(arrowMetadata);
@@ -196,56 +194,56 @@ function serializeArrowField(field) {
196
194
  };
197
195
  }
198
196
  function deserializeArrowField(field) {
199
- return new arrow3.Field(field.name, deserializeArrowType(field.type), field.nullable, deserializeArrowMetadata(field.metadata));
197
+ return new arrow2.Field(field.name, deserializeArrowType(field.type), field.nullable, deserializeArrowMetadata(field.metadata));
200
198
  }
201
199
  function serializeArrowType(arrowType) {
202
200
  switch (arrowType.constructor) {
203
- case arrow3.Null:
201
+ case arrow2.Null:
204
202
  return "null";
205
- case arrow3.Binary:
203
+ case arrow2.Binary:
206
204
  return "binary";
207
- case arrow3.Bool:
205
+ case arrow2.Bool:
208
206
  return "bool";
209
- case arrow3.Int:
207
+ case arrow2.Int:
210
208
  const intType = arrowType;
211
209
  return `${intType.isSigned ? "u" : ""}int${intType.bitWidth}`;
212
- case arrow3.Int8:
210
+ case arrow2.Int8:
213
211
  return "int8";
214
- case arrow3.Int16:
212
+ case arrow2.Int16:
215
213
  return "int16";
216
- case arrow3.Int32:
214
+ case arrow2.Int32:
217
215
  return "int32";
218
- case arrow3.Int64:
216
+ case arrow2.Int64:
219
217
  return "int64";
220
- case arrow3.Uint8:
218
+ case arrow2.Uint8:
221
219
  return "uint8";
222
- case arrow3.Uint16:
220
+ case arrow2.Uint16:
223
221
  return "uint16";
224
- case arrow3.Uint32:
222
+ case arrow2.Uint32:
225
223
  return "uint32";
226
- case arrow3.Uint64:
224
+ case arrow2.Uint64:
227
225
  return "uint64";
228
- case arrow3.Float:
226
+ case arrow2.Float:
229
227
  const precision = arrowType.precision;
230
228
  switch (precision) {
231
- case arrow3.Precision.HALF:
229
+ case arrow2.Precision.HALF:
232
230
  return "float16";
233
- case arrow3.Precision.SINGLE:
231
+ case arrow2.Precision.SINGLE:
234
232
  return "float32";
235
- case arrow3.Precision.DOUBLE:
233
+ case arrow2.Precision.DOUBLE:
236
234
  return "float64";
237
235
  default:
238
236
  return "float16";
239
237
  }
240
- case arrow3.Float16:
238
+ case arrow2.Float16:
241
239
  return "float16";
242
- case arrow3.Float32:
240
+ case arrow2.Float32:
243
241
  return "float32";
244
- case arrow3.Float64:
242
+ case arrow2.Float64:
245
243
  return "float64";
246
- case arrow3.Utf8:
244
+ case arrow2.Utf8:
247
245
  return "utf8";
248
- case arrow3.Decimal:
246
+ case arrow2.Decimal:
249
247
  const decimal = arrowType;
250
248
  return {
251
249
  type: "decimal",
@@ -253,93 +251,93 @@ function serializeArrowType(arrowType) {
253
251
  precision: decimal.precision,
254
252
  scale: decimal.scale
255
253
  };
256
- case arrow3.Date_:
254
+ case arrow2.Date_:
257
255
  const dateUnit = arrowType.unit;
258
- return dateUnit === arrow3.DateUnit.DAY ? "date-day" : "date-millisecond";
259
- case arrow3.DateDay:
256
+ return dateUnit === arrow2.DateUnit.DAY ? "date-day" : "date-millisecond";
257
+ case arrow2.DateDay:
260
258
  return "date-day";
261
- case arrow3.DateMillisecond:
259
+ case arrow2.DateMillisecond:
262
260
  return "date-millisecond";
263
- case arrow3.Time:
261
+ case arrow2.Time:
264
262
  const timeUnit = arrowType.unit;
265
263
  switch (timeUnit) {
266
- case arrow3.TimeUnit.SECOND:
264
+ case arrow2.TimeUnit.SECOND:
267
265
  return "time-second";
268
- case arrow3.TimeUnit.MILLISECOND:
266
+ case arrow2.TimeUnit.MILLISECOND:
269
267
  return "time-millisecond";
270
- case arrow3.TimeUnit.MICROSECOND:
268
+ case arrow2.TimeUnit.MICROSECOND:
271
269
  return "time-microsecond";
272
- case arrow3.TimeUnit.NANOSECOND:
270
+ case arrow2.TimeUnit.NANOSECOND:
273
271
  return "time-nanosecond";
274
272
  default:
275
273
  return "time-second";
276
274
  }
277
- case arrow3.TimeMillisecond:
275
+ case arrow2.TimeMillisecond:
278
276
  return "time-millisecond";
279
- case arrow3.TimeSecond:
277
+ case arrow2.TimeSecond:
280
278
  return "time-second";
281
- case arrow3.TimeMicrosecond:
279
+ case arrow2.TimeMicrosecond:
282
280
  return "time-microsecond";
283
- case arrow3.TimeNanosecond:
281
+ case arrow2.TimeNanosecond:
284
282
  return "time-nanosecond";
285
- case arrow3.Timestamp:
283
+ case arrow2.Timestamp:
286
284
  const timeStampUnit = arrowType.unit;
287
285
  switch (timeStampUnit) {
288
- case arrow3.TimeUnit.SECOND:
286
+ case arrow2.TimeUnit.SECOND:
289
287
  return "timestamp-second";
290
- case arrow3.TimeUnit.MILLISECOND:
288
+ case arrow2.TimeUnit.MILLISECOND:
291
289
  return "timestamp-millisecond";
292
- case arrow3.TimeUnit.MICROSECOND:
290
+ case arrow2.TimeUnit.MICROSECOND:
293
291
  return "timestamp-microsecond";
294
- case arrow3.TimeUnit.NANOSECOND:
292
+ case arrow2.TimeUnit.NANOSECOND:
295
293
  return "timestamp-nanosecond";
296
294
  default:
297
295
  return "timestamp-second";
298
296
  }
299
- case arrow3.TimestampSecond:
297
+ case arrow2.TimestampSecond:
300
298
  return "timestamp-second";
301
- case arrow3.TimestampMillisecond:
299
+ case arrow2.TimestampMillisecond:
302
300
  return "timestamp-millisecond";
303
- case arrow3.TimestampMicrosecond:
301
+ case arrow2.TimestampMicrosecond:
304
302
  return "timestamp-microsecond";
305
- case arrow3.TimestampNanosecond:
303
+ case arrow2.TimestampNanosecond:
306
304
  return "timestamp-nanosecond";
307
- case arrow3.Interval:
305
+ case arrow2.Interval:
308
306
  const intervalUnit = arrowType.unit;
309
307
  switch (intervalUnit) {
310
- case arrow3.IntervalUnit.DAY_TIME:
308
+ case arrow2.IntervalUnit.DAY_TIME:
311
309
  return "interval-daytime";
312
- case arrow3.IntervalUnit.YEAR_MONTH:
310
+ case arrow2.IntervalUnit.YEAR_MONTH:
313
311
  return "interval-yearmonth";
314
312
  default:
315
313
  return "interval-daytime";
316
314
  }
317
- case arrow3.IntervalDayTime:
315
+ case arrow2.IntervalDayTime:
318
316
  return "interval-daytime";
319
- case arrow3.IntervalYearMonth:
317
+ case arrow2.IntervalYearMonth:
320
318
  return "interval-yearmonth";
321
- case arrow3.Map_:
319
+ case arrow2.Map_:
322
320
  const mapType = arrowType;
323
321
  return {
324
322
  type: "map",
325
323
  keysSorted: mapType.keysSorted,
326
324
  children: mapType.children.map((arrowField) => serializeArrowField(arrowField))
327
325
  };
328
- case arrow3.List:
326
+ case arrow2.List:
329
327
  const listType = arrowType;
330
328
  const listField = listType.valueField;
331
329
  return {
332
330
  type: "list",
333
331
  children: [serializeArrowField(listField)]
334
332
  };
335
- case arrow3.FixedSizeList:
333
+ case arrow2.FixedSizeList:
336
334
  const fixedSizeList = arrowType;
337
335
  return {
338
336
  type: "fixed-size-list",
339
337
  listSize: fixedSizeList.listSize,
340
338
  children: [serializeArrowField(fixedSizeList.children[0])]
341
339
  };
342
- case arrow3.Struct:
340
+ case arrow2.Struct:
343
341
  const structType = arrowType;
344
342
  return {
345
343
  type: "struct",
@@ -353,114 +351,312 @@ function deserializeArrowType(dataType) {
353
351
  if (typeof dataType === "object") {
354
352
  switch (dataType.type) {
355
353
  case "decimal":
356
- return new arrow3.Decimal(dataType.precision, dataType.scale, dataType.bitWidth);
354
+ return new arrow2.Decimal(dataType.precision, dataType.scale, dataType.bitWidth);
357
355
  case "map":
358
356
  let children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));
359
- return new arrow3.Map_(children, dataType.keysSorted);
357
+ return new arrow2.Map_(children, dataType.keysSorted);
360
358
  case "list":
361
359
  const field = deserializeArrowField(dataType.children[0]);
362
- return new arrow3.List(field);
360
+ return new arrow2.List(field);
363
361
  case "fixed-size-list":
364
362
  const child = deserializeArrowField(dataType.children[0]);
365
- return new arrow3.FixedSizeList(dataType.listSize, child);
363
+ return new arrow2.FixedSizeList(dataType.listSize, child);
366
364
  case "struct":
367
365
  children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));
368
- return new arrow3.Struct(children);
366
+ return new arrow2.Struct(children);
369
367
  default:
370
368
  throw new Error("array type not supported");
371
369
  }
372
370
  }
373
371
  switch (dataType) {
374
372
  case "null":
375
- return new arrow3.Null();
373
+ return new arrow2.Null();
376
374
  case "binary":
377
- return new arrow3.Binary();
375
+ return new arrow2.Binary();
378
376
  case "bool":
379
- return new arrow3.Bool();
377
+ return new arrow2.Bool();
380
378
  case "int8":
381
- return new arrow3.Int8();
379
+ return new arrow2.Int8();
382
380
  case "int16":
383
- return new arrow3.Int16();
381
+ return new arrow2.Int16();
384
382
  case "int32":
385
- return new arrow3.Int32();
383
+ return new arrow2.Int32();
386
384
  case "int64":
387
- return new arrow3.Int64();
385
+ return new arrow2.Int64();
388
386
  case "uint8":
389
- return new arrow3.Uint8();
387
+ return new arrow2.Uint8();
390
388
  case "uint16":
391
- return new arrow3.Uint16();
389
+ return new arrow2.Uint16();
392
390
  case "uint32":
393
- return new arrow3.Uint32();
391
+ return new arrow2.Uint32();
394
392
  case "uint64":
395
- return new arrow3.Uint64();
393
+ return new arrow2.Uint64();
396
394
  case "float16":
397
- return new arrow3.Float16();
395
+ return new arrow2.Float16();
398
396
  case "float32":
399
- return new arrow3.Float32();
397
+ return new arrow2.Float32();
400
398
  case "float64":
401
- return new arrow3.Float64();
399
+ return new arrow2.Float64();
402
400
  case "utf8":
403
- return new arrow3.Utf8();
401
+ return new arrow2.Utf8();
404
402
  case "date-day":
405
- return new arrow3.DateDay();
403
+ return new arrow2.DateDay();
406
404
  case "date-millisecond":
407
- return new arrow3.DateMillisecond();
405
+ return new arrow2.DateMillisecond();
408
406
  case "time-second":
409
- return new arrow3.TimeSecond();
407
+ return new arrow2.TimeSecond();
410
408
  case "time-millisecond":
411
- return new arrow3.TimeMillisecond();
409
+ return new arrow2.TimeMillisecond();
412
410
  case "time-microsecond":
413
- return new arrow3.TimeMicrosecond();
411
+ return new arrow2.TimeMicrosecond();
414
412
  case "time-nanosecond":
415
- return new arrow3.TimeNanosecond();
413
+ return new arrow2.TimeNanosecond();
416
414
  case "timestamp-second":
417
- return new arrow3.TimestampSecond();
415
+ return new arrow2.TimestampSecond();
418
416
  case "timestamp-millisecond":
419
- return new arrow3.TimestampMillisecond();
417
+ return new arrow2.TimestampMillisecond();
420
418
  case "timestamp-microsecond":
421
- return new arrow3.TimestampMicrosecond();
419
+ return new arrow2.TimestampMicrosecond();
422
420
  case "timestamp-nanosecond":
423
- return new arrow3.TimestampNanosecond();
421
+ return new arrow2.TimestampNanosecond();
424
422
  case "interval-daytime":
425
- return new arrow3.IntervalDayTime();
423
+ return new arrow2.IntervalDayTime();
426
424
  case "interval-yearmonth":
427
- return new arrow3.IntervalYearMonth();
425
+ return new arrow2.IntervalYearMonth();
428
426
  default:
429
427
  throw new Error("array type not supported");
430
428
  }
431
429
  }
432
430
 
433
- // dist/parsers/parse-arrow-sync.js
434
- function parseArrowSync(arrayBuffer, options) {
435
- const apacheArrowTable = arrow4.tableFromIPC([new Uint8Array(arrayBuffer)]);
436
- const arrowTable = {
437
- shape: "arrow-table",
438
- schema: serializeArrowSchema(apacheArrowTable.schema),
439
- data: apacheArrowTable
431
+ // dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.js
432
+ var import_gis = require("@loaders.gl/gis");
433
+ var import_wkt = require("@loaders.gl/wkt");
434
+ function parseGeometryFromArrow(arrowCellValue, encoding) {
435
+ encoding = encoding == null ? void 0 : encoding.toLowerCase();
436
+ if (!encoding || !arrowCellValue) {
437
+ return null;
438
+ }
439
+ let geometry;
440
+ switch (encoding) {
441
+ case "geoarrow.multipolygon":
442
+ geometry = arrowMultiPolygonToFeature(arrowCellValue);
443
+ break;
444
+ case "geoarrow.polygon":
445
+ geometry = arrowPolygonToFeature(arrowCellValue);
446
+ break;
447
+ case "geoarrow.multipoint":
448
+ geometry = arrowMultiPointToFeature(arrowCellValue);
449
+ break;
450
+ case "geoarrow.point":
451
+ geometry = arrowPointToFeature(arrowCellValue);
452
+ break;
453
+ case "geoarrow.multilinestring":
454
+ geometry = arrowMultiLineStringToFeature(arrowCellValue);
455
+ break;
456
+ case "geoarrow.linestring":
457
+ geometry = arrowLineStringToFeature(arrowCellValue);
458
+ break;
459
+ case "geoarrow.wkb":
460
+ geometry = arrowWKBToFeature(arrowCellValue);
461
+ break;
462
+ case "geoarrow.wkt":
463
+ geometry = arrowWKTToFeature(arrowCellValue);
464
+ break;
465
+ default: {
466
+ throw Error(`GeoArrow encoding not supported ${encoding}`);
467
+ }
468
+ }
469
+ return geometry;
470
+ }
471
+ function arrowWKBToFeature(arrowCellValue) {
472
+ var _a, _b;
473
+ const arrayBuffer = arrowCellValue.buffer.slice(arrowCellValue.byteOffset, arrowCellValue.byteOffset + arrowCellValue.byteLength);
474
+ const binaryGeometry = (_b = (_a = import_wkt.WKBLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer);
475
+ const geometry = (0, import_gis.binaryToGeometry)(binaryGeometry);
476
+ return geometry;
477
+ }
478
+ function arrowWKTToFeature(arrowCellValue) {
479
+ var _a, _b;
480
+ const string = arrowCellValue;
481
+ return (_b = (_a = import_wkt.WKTLoader).parseTextSync) == null ? void 0 : _b.call(_a, string);
482
+ }
483
+ function arrowMultiPolygonToFeature(arrowMultiPolygon) {
484
+ const multiPolygon = [];
485
+ for (let m = 0; m < arrowMultiPolygon.length; m++) {
486
+ const arrowPolygon = arrowMultiPolygon.get(m);
487
+ const polygon = [];
488
+ for (let i = 0; arrowPolygon && i < (arrowPolygon == null ? void 0 : arrowPolygon.length); i++) {
489
+ const arrowRing = arrowPolygon == null ? void 0 : arrowPolygon.get(i);
490
+ const ring = [];
491
+ for (let j = 0; arrowRing && j < arrowRing.length; j++) {
492
+ const arrowCoord = arrowRing.get(j);
493
+ const coord = Array.from(arrowCoord);
494
+ ring.push(coord);
495
+ }
496
+ polygon.push(ring);
497
+ }
498
+ multiPolygon.push(polygon);
499
+ }
500
+ const geometry = {
501
+ type: "MultiPolygon",
502
+ coordinates: multiPolygon
440
503
  };
441
- const shape = (options == null ? void 0 : options.shape) || "arrow-table";
504
+ return geometry;
505
+ }
506
+ function arrowPolygonToFeature(arrowPolygon) {
507
+ const polygon = [];
508
+ for (let i = 0; arrowPolygon && i < arrowPolygon.length; i++) {
509
+ const arrowRing = arrowPolygon.get(i);
510
+ const ring = [];
511
+ for (let j = 0; arrowRing && j < arrowRing.length; j++) {
512
+ const arrowCoord = arrowRing.get(j);
513
+ const coords = Array.from(arrowCoord);
514
+ ring.push(coords);
515
+ }
516
+ polygon.push(ring);
517
+ }
518
+ const geometry = {
519
+ type: "Polygon",
520
+ coordinates: polygon
521
+ };
522
+ return geometry;
523
+ }
524
+ function arrowMultiPointToFeature(arrowMultiPoint) {
525
+ const multiPoint = [];
526
+ for (let i = 0; arrowMultiPoint && i < arrowMultiPoint.length; i++) {
527
+ const arrowPoint = arrowMultiPoint.get(i);
528
+ if (arrowPoint) {
529
+ const coord = Array.from(arrowPoint);
530
+ multiPoint.push(coord);
531
+ }
532
+ }
533
+ return {
534
+ type: "MultiPoint",
535
+ coordinates: multiPoint
536
+ };
537
+ }
538
+ function arrowPointToFeature(arrowPoint) {
539
+ const point = Array.from(arrowPoint);
540
+ return {
541
+ type: "Point",
542
+ coordinates: point
543
+ };
544
+ }
545
+ function arrowMultiLineStringToFeature(arrowMultiLineString) {
546
+ const multiLineString = [];
547
+ for (let i = 0; arrowMultiLineString && i < arrowMultiLineString.length; i++) {
548
+ const arrowLineString = arrowMultiLineString.get(i);
549
+ const lineString = [];
550
+ for (let j = 0; arrowLineString && j < arrowLineString.length; j++) {
551
+ const arrowCoord = arrowLineString.get(j);
552
+ if (arrowCoord) {
553
+ const coords = Array.from(arrowCoord);
554
+ lineString.push(coords);
555
+ }
556
+ }
557
+ multiLineString.push(lineString);
558
+ }
559
+ return {
560
+ type: "MultiLineString",
561
+ coordinates: multiLineString
562
+ };
563
+ }
564
+ function arrowLineStringToFeature(arrowLineString) {
565
+ const lineString = [];
566
+ for (let i = 0; arrowLineString && i < arrowLineString.length; i++) {
567
+ const arrowCoord = arrowLineString.get(i);
568
+ if (arrowCoord) {
569
+ const coords = Array.from(arrowCoord);
570
+ lineString.push(coords);
571
+ }
572
+ }
573
+ return {
574
+ type: "LineString",
575
+ coordinates: lineString
576
+ };
577
+ }
578
+
579
+ // dist/lib/tables/convert-arrow-to-table.js
580
+ function convertArrowToTable(arrowTable, shape) {
442
581
  switch (shape) {
443
582
  case "arrow-table":
444
- return arrowTable;
583
+ return convertArrowToArrowTable(arrowTable);
584
+ case "array-row-table":
585
+ return convertArrowToArrayRowTable(arrowTable);
586
+ case "object-row-table":
587
+ return convertArrowToObjectRowTable(arrowTable);
445
588
  case "columnar-table":
446
589
  return convertArrowToColumnarTable(arrowTable);
447
- case "object-row-table":
448
- let columnarTable = convertArrowToColumnarTable(arrowTable);
449
- return (0, import_schema2.convertTable)(columnarTable, "object-row-table");
450
- case "array-row-table":
451
- columnarTable = convertArrowToColumnarTable(arrowTable);
452
- return (0, import_schema2.convertTable)(columnarTable, "array-row-table");
590
+ case "geojson-table":
591
+ return convertArrowToGeoJSONTable(arrowTable);
453
592
  default:
454
593
  throw new Error(shape);
455
594
  }
456
595
  }
596
+ function convertArrowToArrowTable(arrowTable) {
597
+ return {
598
+ shape: "arrow-table",
599
+ schema: convertArrowToSchema(arrowTable.schema),
600
+ data: arrowTable
601
+ };
602
+ }
603
+ function convertArrowToArrayRowTable(arrowTable) {
604
+ const columnarTable = convertArrowToColumnarTable(arrowTable);
605
+ return (0, import_schema2.convertTable)(columnarTable, "array-row-table");
606
+ }
607
+ function convertArrowToObjectRowTable(arrowTable) {
608
+ const columnarTable = convertArrowToColumnarTable(arrowTable);
609
+ return (0, import_schema2.convertTable)(columnarTable, "object-row-table");
610
+ }
611
+ function convertArrowToColumnarTable(arrowTable) {
612
+ const columns = {};
613
+ for (const field of arrowTable.schema.fields) {
614
+ const arrowColumn = arrowTable.getChild(field.name);
615
+ const values = arrowColumn == null ? void 0 : arrowColumn.toArray();
616
+ columns[field.name] = values;
617
+ }
618
+ const schema = convertArrowToSchema(arrowTable.schema);
619
+ return {
620
+ shape: "columnar-table",
621
+ schema,
622
+ data: columns
623
+ };
624
+ }
625
+ function convertArrowToGeoJSONTable(arrowTable) {
626
+ var _a;
627
+ const schema = convertArrowToSchema(arrowTable.schema);
628
+ const geometryColumns = (0, import_gis2.getGeometryColumnsFromSchema)(schema);
629
+ const encoding = geometryColumns.geometry.encoding;
630
+ const features = [];
631
+ const propertyColumnNames = arrowTable.schema.fields.map((field) => field.name).filter((name) => !(name in geometryColumns));
632
+ const propertiesTable = arrowTable.select(propertyColumnNames);
633
+ const arrowGeometryColumn = arrowTable.getChild("geometry");
634
+ for (let row = 0; row < arrowTable.numRows; row++) {
635
+ const arrowGeometry = arrowGeometryColumn == null ? void 0 : arrowGeometryColumn.get(row);
636
+ const feature = parseGeometryFromArrow(arrowGeometry, encoding);
637
+ if (feature) {
638
+ const properties = ((_a = propertiesTable.get(row)) == null ? void 0 : _a.toJSON()) || {};
639
+ features.push({ type: "Feature", geometry: feature, properties });
640
+ }
641
+ }
642
+ return {
643
+ shape: "geojson-table",
644
+ type: "FeatureCollection",
645
+ schema,
646
+ features
647
+ };
648
+ }
457
649
 
458
- // dist/parsers/parse-arrow-in-batches.js
459
- var arrow5 = __toESM(require("apache-arrow"), 1);
650
+ // dist/lib/parsers/parse-arrow.js
651
+ function parseArrowSync(arrayBuffer, options) {
652
+ const shape = (options == null ? void 0 : options.shape) || "arrow-table";
653
+ const arrowTable = arrow3.tableFromIPC([new Uint8Array(arrayBuffer)]);
654
+ return convertArrowToTable(arrowTable, shape);
655
+ }
460
656
  function parseArrowInBatches(asyncIterator, options) {
461
657
  async function* makeArrowAsyncIterator() {
462
658
  var _a, _b;
463
- const readers = arrow5.RecordBatchReader.readAll(asyncIterator);
659
+ const readers = arrow3.RecordBatchReader.readAll(asyncIterator);
464
660
  for await (const reader of readers) {
465
661
  for await (const recordBatch of reader) {
466
662
  if (((_a = options == null ? void 0 : options.arrow) == null ? void 0 : _a.batchDebounceMs) !== void 0 && ((_b = options == null ? void 0 : options.arrow) == null ? void 0 : _b.batchDebounceMs) > 0) {
@@ -472,7 +668,7 @@ function parseArrowInBatches(asyncIterator, options) {
472
668
  const arrowTabledBatch = {
473
669
  shape: "arrow-table",
474
670
  batchType: "data",
475
- data: new arrow5.Table([recordBatch]),
671
+ data: new arrow3.Table([recordBatch]),
476
672
  length: recordBatch.data.length
477
673
  };
478
674
  yield arrowTabledBatch;
@@ -484,30 +680,6 @@ function parseArrowInBatches(asyncIterator, options) {
484
680
  }
485
681
 
486
682
  // dist/arrow-loader.js
487
- var VERSION = true ? "4.3.0-alpha.7" : "latest";
488
- var ArrowWorkerLoader = {
489
- dataType: null,
490
- batchType: null,
491
- name: "Apache Arrow",
492
- id: "arrow",
493
- module: "arrow",
494
- version: VERSION,
495
- // worker: true,
496
- category: "table",
497
- extensions: ["arrow", "feather"],
498
- mimeTypes: [
499
- "application/vnd.apache.arrow.file",
500
- "application/vnd.apache.arrow.stream",
501
- "application/octet-stream"
502
- ],
503
- binary: true,
504
- tests: ["ARROW"],
505
- options: {
506
- arrow: {
507
- shape: "columnar-table"
508
- }
509
- }
510
- };
511
683
  var ArrowLoader = {
512
684
  ...ArrowWorkerLoader,
513
685
  parse: async (arraybuffer, options) => parseArrowSync(arraybuffer, options == null ? void 0 : options.arrow),
@@ -515,30 +687,30 @@ var ArrowLoader = {
515
687
  parseInBatches: parseArrowInBatches
516
688
  };
517
689
 
518
- // dist/lib/encode-arrow.js
519
- var arrow6 = __toESM(require("apache-arrow"), 1);
690
+ // dist/lib/encoders/encode-arrow.js
691
+ var arrow4 = __toESM(require("apache-arrow"), 1);
520
692
  function encodeArrowSync(data) {
521
693
  const vectors = {};
522
694
  for (const arrayData of data) {
523
695
  const arrayVector = createVector(arrayData.array, arrayData.type);
524
696
  vectors[arrayData.name] = arrayVector;
525
697
  }
526
- const table = new arrow6.Table(vectors);
527
- const arrowBuffer = arrow6.tableToIPC(table);
698
+ const table = new arrow4.Table(vectors);
699
+ const arrowBuffer = arrow4.tableToIPC(table);
528
700
  return arrowBuffer;
529
701
  }
530
702
  function createVector(array, type) {
531
703
  switch (type) {
532
704
  case VECTOR_TYPES.DATE:
533
- return arrow6.vectorFromArray(array);
705
+ return arrow4.vectorFromArray(array);
534
706
  case VECTOR_TYPES.FLOAT:
535
707
  default:
536
- return arrow6.vectorFromArray(array);
708
+ return arrow4.vectorFromArray(array);
537
709
  }
538
710
  }
539
711
 
540
712
  // dist/arrow-writer.js
541
- var VERSION2 = true ? "4.3.0-alpha.7" : "latest";
713
+ var VERSION2 = true ? "4.3.0-beta.1" : "latest";
542
714
  var ArrowWriter = {
543
715
  name: "Apache Arrow",
544
716
  id: "arrow",
@@ -560,60 +732,31 @@ var ArrowWriter = {
560
732
  }
561
733
  };
562
734
 
563
- // dist/tables/convert-arrow-to-geojson-table.js
564
- var import_arrow = require("@loaders.gl/arrow");
565
- var import_gis = require("@loaders.gl/gis");
566
- function convertArrowToGeoJSONTable(table) {
567
- var _a;
568
- const arrowTable = table.data;
569
- const schema = (0, import_arrow.serializeArrowSchema)(arrowTable.schema);
570
- const geometryColumns = (0, import_gis.getGeometryColumnsFromSchema)(schema);
571
- const encoding = geometryColumns.geometry.encoding;
572
- const features = [];
573
- const propertyColumnNames = arrowTable.schema.fields.map((field) => field.name).filter((name) => !(name in geometryColumns));
574
- const propertiesTable = arrowTable.select(propertyColumnNames);
575
- const arrowGeometryColumn = arrowTable.getChild("geometry");
576
- for (let row = 0; row < arrowTable.numRows; row++) {
577
- const arrowGeometry = arrowGeometryColumn == null ? void 0 : arrowGeometryColumn.get(row);
578
- const feature = (0, import_arrow.parseGeometryFromArrow)(arrowGeometry, encoding);
579
- if (feature) {
580
- const properties = ((_a = propertiesTable.get(row)) == null ? void 0 : _a.toJSON()) || {};
581
- features.push({ type: "Feature", geometry: feature, properties });
735
+ // dist/exports/geoarrow-loader.js
736
+ var GeoArrowWorkerLoader = {
737
+ ...ArrowWorkerLoader,
738
+ options: {
739
+ arrow: {
740
+ shape: "arrow-table"
582
741
  }
583
742
  }
584
- return {
585
- shape: "geojson-table",
586
- type: "FeatureCollection",
587
- schema: table.schema,
588
- features
589
- };
590
- }
743
+ };
591
744
 
592
- // dist/parsers/parse-geoarrow-sync.js
745
+ // dist/lib/parsers/parse-geoarrow.js
593
746
  function parseGeoArrowSync(arrayBuffer, options) {
594
747
  const table = parseArrowSync(arrayBuffer, { shape: "arrow-table" });
595
748
  switch (options == null ? void 0 : options.shape) {
596
749
  case "geojson-table":
597
- return convertArrowToGeoJSONTable(table);
750
+ return convertArrowToTable(table.data, "geojson-table");
598
751
  default:
599
752
  return table;
600
753
  }
601
754
  }
602
-
603
- // dist/parsers/parse-geoarrow-in-batches.js
604
755
  function parseGeoArrowInBatches(asyncIterator) {
605
756
  return parseArrowInBatches(asyncIterator);
606
757
  }
607
758
 
608
759
  // dist/geoarrow-loader.js
609
- var GeoArrowWorkerLoader = {
610
- ...ArrowWorkerLoader,
611
- options: {
612
- arrow: {
613
- shape: "arrow-table"
614
- }
615
- }
616
- };
617
760
  var GeoArrowLoader = {
618
761
  ...GeoArrowWorkerLoader,
619
762
  parse: async (arraybuffer, options) => parseGeoArrowSync(arraybuffer, options == null ? void 0 : options.arrow),
@@ -621,10 +764,54 @@ var GeoArrowLoader = {
621
764
  parseInBatches: parseGeoArrowInBatches
622
765
  };
623
766
 
624
- // dist/geoarrow/convert-geoarrow-to-binary-geometry.js
767
+ // dist/lib/tables/convert-table-to-arrow.js
768
+ var arrow5 = __toESM(require("apache-arrow"), 1);
769
+ var import_schema3 = require("@loaders.gl/schema");
770
+ function convertTableToArrow(table, options) {
771
+ switch (table.shape) {
772
+ case "arrow-table":
773
+ return table.data;
774
+ case "columnar-table":
775
+ default:
776
+ const arrowBatchIterator = makeTableToArrowBatchesIterator(table, options);
777
+ return new arrow5.Table(arrowBatchIterator);
778
+ }
779
+ }
780
+ function* makeTableToArrowBatchesIterator(table, options) {
781
+ const arrowSchema = deserializeArrowSchema(table.schema);
782
+ const length = (0, import_schema3.getTableLength)(table);
783
+ const numColumns = (0, import_schema3.getTableNumCols)(table);
784
+ const batchSize = (options == null ? void 0 : options.batchSize) || length;
785
+ const builders = arrowSchema == null ? void 0 : arrowSchema.fields.map((arrowField) => arrow5.makeBuilder(arrowField));
786
+ const structField = new arrow5.Struct(arrowSchema.fields);
787
+ let batchLength = 0;
788
+ for (let rowIndex = 0; rowIndex < length; rowIndex++) {
789
+ for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {
790
+ const value = (0, import_schema3.getTableCellAt)(table, rowIndex, columnIndex);
791
+ const builder = builders[columnIndex];
792
+ builder.append(value);
793
+ batchLength++;
794
+ if (batchLength >= batchSize) {
795
+ const datas = builders.map((builder2) => builder2.flush());
796
+ const structData = new arrow5.Data(structField, 0, batchLength, 0, void 0, datas);
797
+ yield new arrow5.RecordBatch(arrowSchema, structData);
798
+ batchLength = 0;
799
+ }
800
+ }
801
+ }
802
+ if (batchLength > 0) {
803
+ const datas = builders.map((builder) => builder.flush());
804
+ const structData = new arrow5.Data(structField, 0, batchLength, 0, void 0, datas);
805
+ yield new arrow5.RecordBatch(arrowSchema, structData);
806
+ batchLength = 0;
807
+ }
808
+ builders.map((builder) => builder.finish());
809
+ }
810
+
811
+ // dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.js
625
812
  var import_polygon = require("@math.gl/polygon");
626
813
 
627
- // dist/geoarrow/get-arrow-bounds.js
814
+ // dist/lib/geoarrow/get-arrow-bounds.js
628
815
  function updateBoundsFromGeoArrowSamples(flatCoords, nDim, bounds, sampleSize = 100) {
629
816
  const numberOfFeatures = flatCoords.length / nDim;
630
817
  const sampleStep = Math.max(Math.floor(numberOfFeatures / sampleSize), 1);
@@ -648,7 +835,7 @@ function updateBoundsFromGeoArrowSamples(flatCoords, nDim, bounds, sampleSize =
648
835
  return newBounds;
649
836
  }
650
837
 
651
- // dist/geoarrow/convert-geoarrow-to-binary-geometry.js
838
+ // dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.js
652
839
  var BinaryGeometryType;
653
840
  (function(BinaryGeometryType2) {
654
841
  BinaryGeometryType2["points"] = "points";
@@ -936,159 +1123,11 @@ function getBinaryPointsFromChunk(chunk, geoEncoding) {
936
1123
  };
937
1124
  }
938
1125
 
939
- // dist/geoarrow/convert-geoarrow-to-geojson-geometry.js
940
- var import_gis2 = require("@loaders.gl/gis");
941
- var import_wkt = require("@loaders.gl/wkt");
942
- function parseGeometryFromArrow2(arrowCellValue, encoding) {
943
- encoding = encoding == null ? void 0 : encoding.toLowerCase();
944
- if (!encoding || !arrowCellValue) {
945
- return null;
946
- }
947
- let geometry;
948
- switch (encoding) {
949
- case "geoarrow.multipolygon":
950
- geometry = arrowMultiPolygonToFeature(arrowCellValue);
951
- break;
952
- case "geoarrow.polygon":
953
- geometry = arrowPolygonToFeature(arrowCellValue);
954
- break;
955
- case "geoarrow.multipoint":
956
- geometry = arrowMultiPointToFeature(arrowCellValue);
957
- break;
958
- case "geoarrow.point":
959
- geometry = arrowPointToFeature(arrowCellValue);
960
- break;
961
- case "geoarrow.multilinestring":
962
- geometry = arrowMultiLineStringToFeature(arrowCellValue);
963
- break;
964
- case "geoarrow.linestring":
965
- geometry = arrowLineStringToFeature(arrowCellValue);
966
- break;
967
- case "geoarrow.wkb":
968
- geometry = arrowWKBToFeature(arrowCellValue);
969
- break;
970
- case "geoarrow.wkt":
971
- geometry = arrowWKTToFeature(arrowCellValue);
972
- break;
973
- default: {
974
- throw Error(`GeoArrow encoding not supported ${encoding}`);
975
- }
976
- }
977
- return geometry;
978
- }
979
- function arrowWKBToFeature(arrowCellValue) {
980
- var _a, _b;
981
- const arrayBuffer = arrowCellValue.buffer.slice(arrowCellValue.byteOffset, arrowCellValue.byteOffset + arrowCellValue.byteLength);
982
- const binaryGeometry = (_b = (_a = import_wkt.WKBLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer);
983
- const geometry = (0, import_gis2.binaryToGeometry)(binaryGeometry);
984
- return geometry;
985
- }
986
- function arrowWKTToFeature(arrowCellValue) {
987
- var _a, _b;
988
- const string = arrowCellValue;
989
- return (_b = (_a = import_wkt.WKTLoader).parseTextSync) == null ? void 0 : _b.call(_a, string);
990
- }
991
- function arrowMultiPolygonToFeature(arrowMultiPolygon) {
992
- const multiPolygon = [];
993
- for (let m = 0; m < arrowMultiPolygon.length; m++) {
994
- const arrowPolygon = arrowMultiPolygon.get(m);
995
- const polygon = [];
996
- for (let i = 0; arrowPolygon && i < (arrowPolygon == null ? void 0 : arrowPolygon.length); i++) {
997
- const arrowRing = arrowPolygon == null ? void 0 : arrowPolygon.get(i);
998
- const ring = [];
999
- for (let j = 0; arrowRing && j < arrowRing.length; j++) {
1000
- const arrowCoord = arrowRing.get(j);
1001
- const coord = Array.from(arrowCoord);
1002
- ring.push(coord);
1003
- }
1004
- polygon.push(ring);
1005
- }
1006
- multiPolygon.push(polygon);
1007
- }
1008
- const geometry = {
1009
- type: "MultiPolygon",
1010
- coordinates: multiPolygon
1011
- };
1012
- return geometry;
1013
- }
1014
- function arrowPolygonToFeature(arrowPolygon) {
1015
- const polygon = [];
1016
- for (let i = 0; arrowPolygon && i < arrowPolygon.length; i++) {
1017
- const arrowRing = arrowPolygon.get(i);
1018
- const ring = [];
1019
- for (let j = 0; arrowRing && j < arrowRing.length; j++) {
1020
- const arrowCoord = arrowRing.get(j);
1021
- const coords = Array.from(arrowCoord);
1022
- ring.push(coords);
1023
- }
1024
- polygon.push(ring);
1025
- }
1026
- const geometry = {
1027
- type: "Polygon",
1028
- coordinates: polygon
1029
- };
1030
- return geometry;
1031
- }
1032
- function arrowMultiPointToFeature(arrowMultiPoint) {
1033
- const multiPoint = [];
1034
- for (let i = 0; arrowMultiPoint && i < arrowMultiPoint.length; i++) {
1035
- const arrowPoint = arrowMultiPoint.get(i);
1036
- if (arrowPoint) {
1037
- const coord = Array.from(arrowPoint);
1038
- multiPoint.push(coord);
1039
- }
1040
- }
1041
- return {
1042
- type: "MultiPoint",
1043
- coordinates: multiPoint
1044
- };
1045
- }
1046
- function arrowPointToFeature(arrowPoint) {
1047
- const point = Array.from(arrowPoint);
1048
- return {
1049
- type: "Point",
1050
- coordinates: point
1051
- };
1052
- }
1053
- function arrowMultiLineStringToFeature(arrowMultiLineString) {
1054
- const multiLineString = [];
1055
- for (let i = 0; arrowMultiLineString && i < arrowMultiLineString.length; i++) {
1056
- const arrowLineString = arrowMultiLineString.get(i);
1057
- const lineString = [];
1058
- for (let j = 0; arrowLineString && j < arrowLineString.length; j++) {
1059
- const arrowCoord = arrowLineString.get(j);
1060
- if (arrowCoord) {
1061
- const coords = Array.from(arrowCoord);
1062
- lineString.push(coords);
1063
- }
1064
- }
1065
- multiLineString.push(lineString);
1066
- }
1067
- return {
1068
- type: "MultiLineString",
1069
- coordinates: multiLineString
1070
- };
1071
- }
1072
- function arrowLineStringToFeature(arrowLineString) {
1073
- const lineString = [];
1074
- for (let i = 0; arrowLineString && i < arrowLineString.length; i++) {
1075
- const arrowCoord = arrowLineString.get(i);
1076
- if (arrowCoord) {
1077
- const coords = Array.from(arrowCoord);
1078
- lineString.push(coords);
1079
- }
1080
- }
1081
- return {
1082
- type: "LineString",
1083
- coordinates: lineString
1084
- };
1085
- }
1086
-
1087
1126
  // dist/workers/hard-clone.js
1088
- var arrow7 = __toESM(require("apache-arrow"), 1);
1127
+ var arrow6 = __toESM(require("apache-arrow"), 1);
1089
1128
  function hardClone(data, force = false) {
1090
1129
  if ("data" in data) {
1091
- return new arrow7.Vector(data.data.map((data2) => hardClone(data2, force)));
1130
+ return new arrow6.Vector(data.data.map((data2) => hardClone(data2, force)));
1092
1131
  }
1093
1132
  const clonedChildren = [];
1094
1133
  for (const childData of data.children) {
@@ -1099,12 +1138,12 @@ function hardClone(data, force = false) {
1099
1138
  clonedDictionary = hardClone(data.dictionary, force);
1100
1139
  }
1101
1140
  const clonedBuffers = {
1102
- [arrow7.BufferType.OFFSET]: cloneBuffer(data.buffers[arrow7.BufferType.OFFSET], force),
1103
- [arrow7.BufferType.DATA]: cloneBuffer(data.buffers[arrow7.BufferType.DATA], force),
1104
- [arrow7.BufferType.VALIDITY]: cloneBuffer(data.buffers[arrow7.BufferType.VALIDITY], force),
1105
- [arrow7.BufferType.TYPE]: cloneBuffer(data.buffers[arrow7.BufferType.TYPE], force)
1141
+ [arrow6.BufferType.OFFSET]: cloneBuffer(data.buffers[arrow6.BufferType.OFFSET], force),
1142
+ [arrow6.BufferType.DATA]: cloneBuffer(data.buffers[arrow6.BufferType.DATA], force),
1143
+ [arrow6.BufferType.VALIDITY]: cloneBuffer(data.buffers[arrow6.BufferType.VALIDITY], force),
1144
+ [arrow6.BufferType.TYPE]: cloneBuffer(data.buffers[arrow6.BufferType.TYPE], force)
1106
1145
  };
1107
- return new arrow7.Data(
1146
+ return new arrow6.Data(
1108
1147
  data.type,
1109
1148
  data.offset,
1110
1149
  data.length,
@@ -1131,7 +1170,7 @@ function cloneBuffer(arr, force) {
1131
1170
 
1132
1171
  // dist/triangulate-on-worker.js
1133
1172
  var import_worker_utils = require("@loaders.gl/worker-utils");
1134
- var VERSION3 = true ? "4.3.0-alpha.7" : "latest";
1173
+ var VERSION3 = true ? "4.3.0-beta.1" : "latest";
1135
1174
  var TriangulationWorker = {
1136
1175
  id: "triangulation",
1137
1176
  name: "Triangulate",
@@ -1147,5 +1186,5 @@ function parseGeoArrowOnWorker(data, options = {}) {
1147
1186
  }
1148
1187
 
1149
1188
  // dist/index.js
1150
- import_schema3.TableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;
1189
+ import_schema4.TableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;
1151
1190
  //# sourceMappingURL=index.cjs.map