@loaders.gl/arrow 4.3.1 → 4.4.0-alpha.1
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.
- package/dist/arrow-loader.d.ts +1 -1
- package/dist/arrow-worker.js +638 -1292
- package/dist/arrow-writer.js +1 -1
- package/dist/dist.dev.js +2140 -3383
- package/dist/dist.min.js +5 -5
- package/dist/exports/arrow-format.d.ts +12 -0
- package/dist/exports/arrow-format.d.ts.map +1 -0
- package/dist/exports/arrow-format.js +18 -0
- package/dist/exports/arrow-loader.d.ts +1 -1
- package/dist/exports/arrow-loader.d.ts.map +1 -1
- package/dist/exports/arrow-loader.js +1 -1
- package/dist/exports/geoarrow-loader.d.ts +1 -1
- package/dist/exports/geoarrow-loader.d.ts.map +1 -1
- package/dist/geoarrow-loader.d.ts +1 -2
- package/dist/geoarrow-loader.d.ts.map +1 -1
- package/dist/geoarrow-writer.d.ts +3 -3
- package/dist/geoarrow-writer.d.ts.map +1 -1
- package/dist/geoarrow-writer.js +1 -1
- package/dist/index.cjs +39 -952
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -14
- package/dist/lib/parsers/parse-arrow.d.ts +1 -2
- package/dist/lib/parsers/parse-arrow.d.ts.map +1 -1
- package/dist/lib/parsers/parse-arrow.js +1 -1
- package/dist/lib/parsers/parse-geoarrow.d.ts +1 -2
- package/dist/lib/parsers/parse-geoarrow.d.ts.map +1 -1
- package/dist/lib/parsers/parse-geoarrow.js +2 -2
- package/dist/triangulate-on-worker.d.ts +2 -1
- package/dist/triangulate-on-worker.d.ts.map +1 -1
- package/dist/triangulate-on-worker.js +1 -1
- package/dist/triangulation-worker.js +212 -154
- package/dist/workers/triangulation-worker.js +2 -2
- package/package.json +10 -9
- package/src/exports/arrow-format.ts +21 -0
- package/src/exports/arrow-loader.ts +1 -1
- package/src/exports/geoarrow-loader.ts +1 -2
- package/src/geoarrow-loader.ts +6 -2
- package/src/geoarrow-writer.ts +1 -1
- package/src/index.ts +2 -42
- package/src/lib/parsers/parse-arrow.ts +2 -3
- package/src/lib/parsers/parse-geoarrow.ts +8 -4
- package/src/triangulate-on-worker.ts +2 -1
- package/src/workers/triangulation-worker.ts +3 -3
- package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.d.ts +0 -74
- package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +0 -1
- package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.js +0 -377
- package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts +0 -13
- package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +0 -1
- package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.js +0 -176
- package/dist/lib/geoarrow/get-arrow-bounds.d.ts +0 -11
- package/dist/lib/geoarrow/get-arrow-bounds.d.ts.map +0 -1
- package/dist/lib/geoarrow/get-arrow-bounds.js +0 -34
- package/dist/lib/tables/convert-arrow-schema.d.ts +0 -23
- package/dist/lib/tables/convert-arrow-schema.d.ts.map +0 -1
- package/dist/lib/tables/convert-arrow-schema.js +0 -280
- package/dist/lib/tables/convert-arrow-to-table.d.ts +0 -15
- package/dist/lib/tables/convert-arrow-to-table.d.ts.map +0 -1
- package/dist/lib/tables/convert-arrow-to-table.js +0 -104
- package/dist/lib/tables/convert-table-to-arrow.d.ts +0 -16
- package/dist/lib/tables/convert-table-to-arrow.d.ts.map +0 -1
- package/dist/lib/tables/convert-table-to-arrow.js +0 -56
- package/dist/schema/arrow-table-batch.d.ts +0 -10
- package/dist/schema/arrow-table-batch.d.ts.map +0 -1
- package/dist/schema/arrow-table-batch.js +0 -67
- package/dist/schema/arrow-table-type.d.ts +0 -25
- package/dist/schema/arrow-table-type.d.ts.map +0 -1
- package/dist/schema/arrow-table-type.js +0 -4
- package/src/lib/geoarrow/convert-geoarrow-to-binary-geometry.ts +0 -494
- package/src/lib/geoarrow/convert-geoarrow-to-geojson-geometry.ts +0 -207
- package/src/lib/geoarrow/get-arrow-bounds.ts +0 -41
- package/src/lib/tables/convert-arrow-schema.ts +0 -301
- package/src/lib/tables/convert-arrow-to-table.ts +0 -144
- package/src/lib/tables/convert-table-to-arrow.ts +0 -72
- package/src/schema/arrow-table-batch.ts +0 -82
- package/src/schema/arrow-table-type.ts +0 -30
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// dist/index.js
|
|
31
31
|
var dist_exports = {};
|
|
32
32
|
__export(dist_exports, {
|
|
33
|
+
ArrowFormat: () => ArrowFormat,
|
|
33
34
|
ArrowLoader: () => ArrowLoader,
|
|
34
35
|
ArrowWorkerLoader: () => ArrowWorkerLoader,
|
|
35
36
|
ArrowWriter: () => ArrowWriter,
|
|
@@ -37,27 +38,9 @@ __export(dist_exports, {
|
|
|
37
38
|
GeoArrowWorkerLoader: () => GeoArrowWorkerLoader,
|
|
38
39
|
TriangulationWorker: () => TriangulationWorker,
|
|
39
40
|
VECTOR_TYPES: () => VECTOR_TYPES,
|
|
40
|
-
convertArrowToSchema: () => convertArrowToSchema,
|
|
41
|
-
convertArrowToTable: () => convertArrowToTable,
|
|
42
|
-
convertSchemaToArrow: () => convertSchemaToArrow,
|
|
43
|
-
convertTableToArrow: () => convertTableToArrow,
|
|
44
|
-
deserializeArrowField: () => deserializeArrowField,
|
|
45
|
-
deserializeArrowMetadata: () => deserializeArrowMetadata,
|
|
46
|
-
deserializeArrowSchema: () => deserializeArrowSchema,
|
|
47
|
-
deserializeArrowType: () => deserializeArrowType,
|
|
48
|
-
getBinaryGeometriesFromArrow: () => getBinaryGeometriesFromArrow,
|
|
49
|
-
getBinaryGeometryTemplate: () => getBinaryGeometryTemplate,
|
|
50
|
-
getMeanCentersFromBinaryGeometries: () => getMeanCentersFromBinaryGeometries,
|
|
51
|
-
getTriangleIndices: () => getTriangleIndices,
|
|
52
41
|
hardClone: () => hardClone,
|
|
53
42
|
parseGeoArrowOnWorker: () => parseGeoArrowOnWorker,
|
|
54
|
-
|
|
55
|
-
serializeArrowField: () => serializeArrowField,
|
|
56
|
-
serializeArrowMetadata: () => serializeArrowMetadata,
|
|
57
|
-
serializeArrowSchema: () => serializeArrowSchema,
|
|
58
|
-
serializeArrowType: () => serializeArrowType,
|
|
59
|
-
triangulateOnWorker: () => triangulateOnWorker,
|
|
60
|
-
updateBoundsFromGeoArrowSamples: () => updateBoundsFromGeoArrowSamples
|
|
43
|
+
triangulateOnWorker: () => triangulateOnWorker
|
|
61
44
|
});
|
|
62
45
|
module.exports = __toCommonJS(dist_exports);
|
|
63
46
|
|
|
@@ -68,69 +51,24 @@ var VECTOR_TYPES;
|
|
|
68
51
|
VECTOR_TYPES2[VECTOR_TYPES2["DATE"] = 1] = "DATE";
|
|
69
52
|
})(VECTOR_TYPES || (VECTOR_TYPES = {}));
|
|
70
53
|
|
|
71
|
-
// dist/
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const recordBatch = new arrow.RecordBatch(this.arrowSchema, arrow.makeData({
|
|
86
|
-
type: new arrow.Struct(this.arrowSchema.fields),
|
|
87
|
-
children: arrowVectors.map(({ data }) => data[0])
|
|
88
|
-
}));
|
|
89
|
-
return {
|
|
90
|
-
shape: "arrow-table",
|
|
91
|
-
batchType: "data",
|
|
92
|
-
data: new arrow.Table([recordBatch]),
|
|
93
|
-
length: batch.length
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
54
|
+
// dist/exports/arrow-format.js
|
|
55
|
+
var ArrowFormat = {
|
|
56
|
+
name: "Apache Arrow",
|
|
57
|
+
id: "arrow",
|
|
58
|
+
module: "arrow",
|
|
59
|
+
category: "table",
|
|
60
|
+
extensions: ["arrow", "feather"],
|
|
61
|
+
mimeTypes: [
|
|
62
|
+
"application/vnd.apache.arrow.file",
|
|
63
|
+
"application/vnd.apache.arrow.stream",
|
|
64
|
+
"application/octet-stream"
|
|
65
|
+
],
|
|
66
|
+
binary: true,
|
|
67
|
+
tests: ["ARROW"]
|
|
98
68
|
};
|
|
99
|
-
function getArrowSchema(schema) {
|
|
100
|
-
const arrowFields = [];
|
|
101
|
-
for (const key in schema) {
|
|
102
|
-
const field = schema[key];
|
|
103
|
-
if (field.type === Float32Array) {
|
|
104
|
-
const metadata = /* @__PURE__ */ new Map();
|
|
105
|
-
const arrowField = new arrow.Field(field.name, new arrow.Float32(), field.nullable, metadata);
|
|
106
|
-
arrowFields.push(arrowField);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (arrowFields.length === 0) {
|
|
110
|
-
throw new Error("No arrow convertible fields");
|
|
111
|
-
}
|
|
112
|
-
return new arrow.Schema(arrowFields);
|
|
113
|
-
}
|
|
114
|
-
function getArrowVectors(arrowSchema, data) {
|
|
115
|
-
const arrowVectors = [];
|
|
116
|
-
for (const field of arrowSchema.fields) {
|
|
117
|
-
const vector = data[field.name];
|
|
118
|
-
if (vector instanceof Float32Array) {
|
|
119
|
-
const arrowVector = arrow.makeVector(vector);
|
|
120
|
-
arrowVectors.push(arrowVector);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (arrowSchema.fields.length !== arrowVectors.length) {
|
|
124
|
-
throw new Error("Some columns not arrow convertible");
|
|
125
|
-
}
|
|
126
|
-
return arrowVectors;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// dist/index.js
|
|
130
|
-
var import_schema4 = require("@loaders.gl/schema");
|
|
131
69
|
|
|
132
70
|
// dist/exports/arrow-loader.js
|
|
133
|
-
var VERSION = true ? "4.
|
|
71
|
+
var VERSION = true ? "4.4.0-alpha.0" : "latest";
|
|
134
72
|
var ArrowWorkerLoader = {
|
|
135
73
|
dataType: null,
|
|
136
74
|
batchType: null,
|
|
@@ -156,507 +94,17 @@ var ArrowWorkerLoader = {
|
|
|
156
94
|
};
|
|
157
95
|
|
|
158
96
|
// dist/lib/parsers/parse-arrow.js
|
|
159
|
-
var
|
|
160
|
-
|
|
161
|
-
// dist/lib/tables/convert-arrow-to-table.js
|
|
162
|
-
var import_schema2 = require("@loaders.gl/schema");
|
|
163
|
-
var import_gis2 = require("@loaders.gl/gis");
|
|
164
|
-
|
|
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);
|
|
172
|
-
}
|
|
173
|
-
function serializeArrowSchema(arrowSchema) {
|
|
174
|
-
return {
|
|
175
|
-
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
176
|
-
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
function deserializeArrowSchema(schema) {
|
|
180
|
-
return new arrow2.Schema(schema.fields.map((field) => deserializeArrowField(field)), deserializeArrowMetadata(schema.metadata));
|
|
181
|
-
}
|
|
182
|
-
function serializeArrowMetadata(arrowMetadata) {
|
|
183
|
-
return Object.fromEntries(arrowMetadata);
|
|
184
|
-
}
|
|
185
|
-
function deserializeArrowMetadata(metadata) {
|
|
186
|
-
return metadata ? new Map(Object.entries(metadata)) : /* @__PURE__ */ new Map();
|
|
187
|
-
}
|
|
188
|
-
function serializeArrowField(field) {
|
|
189
|
-
return {
|
|
190
|
-
name: field.name,
|
|
191
|
-
type: serializeArrowType(field.type),
|
|
192
|
-
nullable: field.nullable,
|
|
193
|
-
metadata: serializeArrowMetadata(field.metadata)
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function deserializeArrowField(field) {
|
|
197
|
-
return new arrow2.Field(field.name, deserializeArrowType(field.type), field.nullable, deserializeArrowMetadata(field.metadata));
|
|
198
|
-
}
|
|
199
|
-
function serializeArrowType(arrowType) {
|
|
200
|
-
switch (arrowType.constructor) {
|
|
201
|
-
case arrow2.Null:
|
|
202
|
-
return "null";
|
|
203
|
-
case arrow2.Binary:
|
|
204
|
-
return "binary";
|
|
205
|
-
case arrow2.Bool:
|
|
206
|
-
return "bool";
|
|
207
|
-
case arrow2.Int:
|
|
208
|
-
const intType = arrowType;
|
|
209
|
-
return `${intType.isSigned ? "u" : ""}int${intType.bitWidth}`;
|
|
210
|
-
case arrow2.Int8:
|
|
211
|
-
return "int8";
|
|
212
|
-
case arrow2.Int16:
|
|
213
|
-
return "int16";
|
|
214
|
-
case arrow2.Int32:
|
|
215
|
-
return "int32";
|
|
216
|
-
case arrow2.Int64:
|
|
217
|
-
return "int64";
|
|
218
|
-
case arrow2.Uint8:
|
|
219
|
-
return "uint8";
|
|
220
|
-
case arrow2.Uint16:
|
|
221
|
-
return "uint16";
|
|
222
|
-
case arrow2.Uint32:
|
|
223
|
-
return "uint32";
|
|
224
|
-
case arrow2.Uint64:
|
|
225
|
-
return "uint64";
|
|
226
|
-
case arrow2.Float:
|
|
227
|
-
const precision = arrowType.precision;
|
|
228
|
-
switch (precision) {
|
|
229
|
-
case arrow2.Precision.HALF:
|
|
230
|
-
return "float16";
|
|
231
|
-
case arrow2.Precision.SINGLE:
|
|
232
|
-
return "float32";
|
|
233
|
-
case arrow2.Precision.DOUBLE:
|
|
234
|
-
return "float64";
|
|
235
|
-
default:
|
|
236
|
-
return "float16";
|
|
237
|
-
}
|
|
238
|
-
case arrow2.Float16:
|
|
239
|
-
return "float16";
|
|
240
|
-
case arrow2.Float32:
|
|
241
|
-
return "float32";
|
|
242
|
-
case arrow2.Float64:
|
|
243
|
-
return "float64";
|
|
244
|
-
case arrow2.Utf8:
|
|
245
|
-
return "utf8";
|
|
246
|
-
case arrow2.Decimal:
|
|
247
|
-
const decimal = arrowType;
|
|
248
|
-
return {
|
|
249
|
-
type: "decimal",
|
|
250
|
-
bitWidth: decimal.bitWidth,
|
|
251
|
-
precision: decimal.precision,
|
|
252
|
-
scale: decimal.scale
|
|
253
|
-
};
|
|
254
|
-
case arrow2.Date_:
|
|
255
|
-
const dateUnit = arrowType.unit;
|
|
256
|
-
return dateUnit === arrow2.DateUnit.DAY ? "date-day" : "date-millisecond";
|
|
257
|
-
case arrow2.DateDay:
|
|
258
|
-
return "date-day";
|
|
259
|
-
case arrow2.DateMillisecond:
|
|
260
|
-
return "date-millisecond";
|
|
261
|
-
case arrow2.Time:
|
|
262
|
-
const timeUnit = arrowType.unit;
|
|
263
|
-
switch (timeUnit) {
|
|
264
|
-
case arrow2.TimeUnit.SECOND:
|
|
265
|
-
return "time-second";
|
|
266
|
-
case arrow2.TimeUnit.MILLISECOND:
|
|
267
|
-
return "time-millisecond";
|
|
268
|
-
case arrow2.TimeUnit.MICROSECOND:
|
|
269
|
-
return "time-microsecond";
|
|
270
|
-
case arrow2.TimeUnit.NANOSECOND:
|
|
271
|
-
return "time-nanosecond";
|
|
272
|
-
default:
|
|
273
|
-
return "time-second";
|
|
274
|
-
}
|
|
275
|
-
case arrow2.TimeMillisecond:
|
|
276
|
-
return "time-millisecond";
|
|
277
|
-
case arrow2.TimeSecond:
|
|
278
|
-
return "time-second";
|
|
279
|
-
case arrow2.TimeMicrosecond:
|
|
280
|
-
return "time-microsecond";
|
|
281
|
-
case arrow2.TimeNanosecond:
|
|
282
|
-
return "time-nanosecond";
|
|
283
|
-
case arrow2.Timestamp:
|
|
284
|
-
const timeStampUnit = arrowType.unit;
|
|
285
|
-
switch (timeStampUnit) {
|
|
286
|
-
case arrow2.TimeUnit.SECOND:
|
|
287
|
-
return "timestamp-second";
|
|
288
|
-
case arrow2.TimeUnit.MILLISECOND:
|
|
289
|
-
return "timestamp-millisecond";
|
|
290
|
-
case arrow2.TimeUnit.MICROSECOND:
|
|
291
|
-
return "timestamp-microsecond";
|
|
292
|
-
case arrow2.TimeUnit.NANOSECOND:
|
|
293
|
-
return "timestamp-nanosecond";
|
|
294
|
-
default:
|
|
295
|
-
return "timestamp-second";
|
|
296
|
-
}
|
|
297
|
-
case arrow2.TimestampSecond:
|
|
298
|
-
return "timestamp-second";
|
|
299
|
-
case arrow2.TimestampMillisecond:
|
|
300
|
-
return "timestamp-millisecond";
|
|
301
|
-
case arrow2.TimestampMicrosecond:
|
|
302
|
-
return "timestamp-microsecond";
|
|
303
|
-
case arrow2.TimestampNanosecond:
|
|
304
|
-
return "timestamp-nanosecond";
|
|
305
|
-
case arrow2.Interval:
|
|
306
|
-
const intervalUnit = arrowType.unit;
|
|
307
|
-
switch (intervalUnit) {
|
|
308
|
-
case arrow2.IntervalUnit.DAY_TIME:
|
|
309
|
-
return "interval-daytime";
|
|
310
|
-
case arrow2.IntervalUnit.YEAR_MONTH:
|
|
311
|
-
return "interval-yearmonth";
|
|
312
|
-
default:
|
|
313
|
-
return "interval-daytime";
|
|
314
|
-
}
|
|
315
|
-
case arrow2.IntervalDayTime:
|
|
316
|
-
return "interval-daytime";
|
|
317
|
-
case arrow2.IntervalYearMonth:
|
|
318
|
-
return "interval-yearmonth";
|
|
319
|
-
case arrow2.Map_:
|
|
320
|
-
const mapType = arrowType;
|
|
321
|
-
return {
|
|
322
|
-
type: "map",
|
|
323
|
-
keysSorted: mapType.keysSorted,
|
|
324
|
-
children: mapType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
325
|
-
};
|
|
326
|
-
case arrow2.List:
|
|
327
|
-
const listType = arrowType;
|
|
328
|
-
const listField = listType.valueField;
|
|
329
|
-
return {
|
|
330
|
-
type: "list",
|
|
331
|
-
children: [serializeArrowField(listField)]
|
|
332
|
-
};
|
|
333
|
-
case arrow2.FixedSizeList:
|
|
334
|
-
const fixedSizeList = arrowType;
|
|
335
|
-
return {
|
|
336
|
-
type: "fixed-size-list",
|
|
337
|
-
listSize: fixedSizeList.listSize,
|
|
338
|
-
children: [serializeArrowField(fixedSizeList.children[0])]
|
|
339
|
-
};
|
|
340
|
-
case arrow2.Struct:
|
|
341
|
-
const structType = arrowType;
|
|
342
|
-
return {
|
|
343
|
-
type: "struct",
|
|
344
|
-
children: structType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
345
|
-
};
|
|
346
|
-
default:
|
|
347
|
-
throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
function deserializeArrowType(dataType) {
|
|
351
|
-
if (typeof dataType === "object") {
|
|
352
|
-
switch (dataType.type) {
|
|
353
|
-
case "decimal":
|
|
354
|
-
return new arrow2.Decimal(dataType.precision, dataType.scale, dataType.bitWidth);
|
|
355
|
-
case "map":
|
|
356
|
-
let children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));
|
|
357
|
-
return new arrow2.Map_(children, dataType.keysSorted);
|
|
358
|
-
case "list":
|
|
359
|
-
const field = deserializeArrowField(dataType.children[0]);
|
|
360
|
-
return new arrow2.List(field);
|
|
361
|
-
case "fixed-size-list":
|
|
362
|
-
const child = deserializeArrowField(dataType.children[0]);
|
|
363
|
-
return new arrow2.FixedSizeList(dataType.listSize, child);
|
|
364
|
-
case "struct":
|
|
365
|
-
children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));
|
|
366
|
-
return new arrow2.Struct(children);
|
|
367
|
-
default:
|
|
368
|
-
throw new Error("array type not supported");
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
switch (dataType) {
|
|
372
|
-
case "null":
|
|
373
|
-
return new arrow2.Null();
|
|
374
|
-
case "binary":
|
|
375
|
-
return new arrow2.Binary();
|
|
376
|
-
case "bool":
|
|
377
|
-
return new arrow2.Bool();
|
|
378
|
-
case "int8":
|
|
379
|
-
return new arrow2.Int8();
|
|
380
|
-
case "int16":
|
|
381
|
-
return new arrow2.Int16();
|
|
382
|
-
case "int32":
|
|
383
|
-
return new arrow2.Int32();
|
|
384
|
-
case "int64":
|
|
385
|
-
return new arrow2.Int64();
|
|
386
|
-
case "uint8":
|
|
387
|
-
return new arrow2.Uint8();
|
|
388
|
-
case "uint16":
|
|
389
|
-
return new arrow2.Uint16();
|
|
390
|
-
case "uint32":
|
|
391
|
-
return new arrow2.Uint32();
|
|
392
|
-
case "uint64":
|
|
393
|
-
return new arrow2.Uint64();
|
|
394
|
-
case "float16":
|
|
395
|
-
return new arrow2.Float16();
|
|
396
|
-
case "float32":
|
|
397
|
-
return new arrow2.Float32();
|
|
398
|
-
case "float64":
|
|
399
|
-
return new arrow2.Float64();
|
|
400
|
-
case "utf8":
|
|
401
|
-
return new arrow2.Utf8();
|
|
402
|
-
case "date-day":
|
|
403
|
-
return new arrow2.DateDay();
|
|
404
|
-
case "date-millisecond":
|
|
405
|
-
return new arrow2.DateMillisecond();
|
|
406
|
-
case "time-second":
|
|
407
|
-
return new arrow2.TimeSecond();
|
|
408
|
-
case "time-millisecond":
|
|
409
|
-
return new arrow2.TimeMillisecond();
|
|
410
|
-
case "time-microsecond":
|
|
411
|
-
return new arrow2.TimeMicrosecond();
|
|
412
|
-
case "time-nanosecond":
|
|
413
|
-
return new arrow2.TimeNanosecond();
|
|
414
|
-
case "timestamp-second":
|
|
415
|
-
return new arrow2.TimestampSecond();
|
|
416
|
-
case "timestamp-millisecond":
|
|
417
|
-
return new arrow2.TimestampMillisecond();
|
|
418
|
-
case "timestamp-microsecond":
|
|
419
|
-
return new arrow2.TimestampMicrosecond();
|
|
420
|
-
case "timestamp-nanosecond":
|
|
421
|
-
return new arrow2.TimestampNanosecond();
|
|
422
|
-
case "interval-daytime":
|
|
423
|
-
return new arrow2.IntervalDayTime();
|
|
424
|
-
case "interval-yearmonth":
|
|
425
|
-
return new arrow2.IntervalYearMonth();
|
|
426
|
-
default:
|
|
427
|
-
throw new Error("array type not supported");
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
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
|
|
503
|
-
};
|
|
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) {
|
|
581
|
-
switch (shape) {
|
|
582
|
-
case "arrow-table":
|
|
583
|
-
return convertArrowToArrowTable(arrowTable);
|
|
584
|
-
case "array-row-table":
|
|
585
|
-
return convertArrowToArrayRowTable(arrowTable);
|
|
586
|
-
case "object-row-table":
|
|
587
|
-
return convertArrowToObjectRowTable(arrowTable);
|
|
588
|
-
case "columnar-table":
|
|
589
|
-
return convertArrowToColumnarTable(arrowTable);
|
|
590
|
-
case "geojson-table":
|
|
591
|
-
return convertArrowToGeoJSONTable(arrowTable);
|
|
592
|
-
default:
|
|
593
|
-
throw new Error(shape);
|
|
594
|
-
}
|
|
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
|
-
}
|
|
649
|
-
|
|
650
|
-
// dist/lib/parsers/parse-arrow.js
|
|
97
|
+
var arrow = __toESM(require("apache-arrow"), 1);
|
|
98
|
+
var import_schema_utils = require("@loaders.gl/schema-utils");
|
|
651
99
|
function parseArrowSync(arrayBuffer, options) {
|
|
652
100
|
const shape = (options == null ? void 0 : options.shape) || "arrow-table";
|
|
653
|
-
const arrowTable =
|
|
654
|
-
return convertArrowToTable(arrowTable, shape);
|
|
101
|
+
const arrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);
|
|
102
|
+
return (0, import_schema_utils.convertArrowToTable)(arrowTable, shape);
|
|
655
103
|
}
|
|
656
104
|
function parseArrowInBatches(asyncIterator, options) {
|
|
657
105
|
async function* makeArrowAsyncIterator() {
|
|
658
106
|
var _a, _b;
|
|
659
|
-
const readers =
|
|
107
|
+
const readers = arrow.RecordBatchReader.readAll(asyncIterator);
|
|
660
108
|
for await (const reader of readers) {
|
|
661
109
|
for await (const recordBatch of reader) {
|
|
662
110
|
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) {
|
|
@@ -668,7 +116,7 @@ function parseArrowInBatches(asyncIterator, options) {
|
|
|
668
116
|
const arrowTabledBatch = {
|
|
669
117
|
shape: "arrow-table",
|
|
670
118
|
batchType: "data",
|
|
671
|
-
data: new
|
|
119
|
+
data: new arrow.Table([recordBatch]),
|
|
672
120
|
length: recordBatch.data.length
|
|
673
121
|
};
|
|
674
122
|
yield arrowTabledBatch;
|
|
@@ -688,29 +136,29 @@ var ArrowLoader = {
|
|
|
688
136
|
};
|
|
689
137
|
|
|
690
138
|
// dist/lib/encoders/encode-arrow.js
|
|
691
|
-
var
|
|
139
|
+
var arrow2 = __toESM(require("apache-arrow"), 1);
|
|
692
140
|
function encodeArrowSync(data) {
|
|
693
141
|
const vectors = {};
|
|
694
142
|
for (const arrayData of data) {
|
|
695
143
|
const arrayVector = createVector(arrayData.array, arrayData.type);
|
|
696
144
|
vectors[arrayData.name] = arrayVector;
|
|
697
145
|
}
|
|
698
|
-
const table = new
|
|
699
|
-
const arrowBuffer =
|
|
146
|
+
const table = new arrow2.Table(vectors);
|
|
147
|
+
const arrowBuffer = arrow2.tableToIPC(table);
|
|
700
148
|
return arrowBuffer;
|
|
701
149
|
}
|
|
702
150
|
function createVector(array, type) {
|
|
703
151
|
switch (type) {
|
|
704
152
|
case VECTOR_TYPES.DATE:
|
|
705
|
-
return
|
|
153
|
+
return arrow2.vectorFromArray(array);
|
|
706
154
|
case VECTOR_TYPES.FLOAT:
|
|
707
155
|
default:
|
|
708
|
-
return
|
|
156
|
+
return arrow2.vectorFromArray(array);
|
|
709
157
|
}
|
|
710
158
|
}
|
|
711
159
|
|
|
712
160
|
// dist/arrow-writer.js
|
|
713
|
-
var VERSION2 = true ? "4.
|
|
161
|
+
var VERSION2 = true ? "4.4.0-alpha.0" : "latest";
|
|
714
162
|
var ArrowWriter = {
|
|
715
163
|
name: "Apache Arrow",
|
|
716
164
|
id: "arrow",
|
|
@@ -743,11 +191,12 @@ var GeoArrowWorkerLoader = {
|
|
|
743
191
|
};
|
|
744
192
|
|
|
745
193
|
// dist/lib/parsers/parse-geoarrow.js
|
|
194
|
+
var import_gis = require("@loaders.gl/gis");
|
|
746
195
|
function parseGeoArrowSync(arrayBuffer, options) {
|
|
747
196
|
const table = parseArrowSync(arrayBuffer, { shape: "arrow-table" });
|
|
748
197
|
switch (options == null ? void 0 : options.shape) {
|
|
749
198
|
case "geojson-table":
|
|
750
|
-
return
|
|
199
|
+
return (0, import_gis.convertGeoArrowToTable)(table.data, "geojson-table");
|
|
751
200
|
default:
|
|
752
201
|
return table;
|
|
753
202
|
}
|
|
@@ -764,370 +213,11 @@ var GeoArrowLoader = {
|
|
|
764
213
|
parseInBatches: parseGeoArrowInBatches
|
|
765
214
|
};
|
|
766
215
|
|
|
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
|
|
812
|
-
var import_polygon = require("@math.gl/polygon");
|
|
813
|
-
|
|
814
|
-
// dist/lib/geoarrow/get-arrow-bounds.js
|
|
815
|
-
function updateBoundsFromGeoArrowSamples(flatCoords, nDim, bounds, sampleSize = 100) {
|
|
816
|
-
const numberOfFeatures = flatCoords.length / nDim;
|
|
817
|
-
const sampleStep = Math.max(Math.floor(numberOfFeatures / sampleSize), 1);
|
|
818
|
-
const newBounds = [...bounds];
|
|
819
|
-
for (let i = 0; i < numberOfFeatures; i += sampleStep) {
|
|
820
|
-
const lng = flatCoords[i * nDim];
|
|
821
|
-
const lat = flatCoords[i * nDim + 1];
|
|
822
|
-
if (lng < newBounds[0]) {
|
|
823
|
-
newBounds[0] = lng;
|
|
824
|
-
}
|
|
825
|
-
if (lat < newBounds[1]) {
|
|
826
|
-
newBounds[1] = lat;
|
|
827
|
-
}
|
|
828
|
-
if (lng > newBounds[2]) {
|
|
829
|
-
newBounds[2] = lng;
|
|
830
|
-
}
|
|
831
|
-
if (lat > newBounds[3]) {
|
|
832
|
-
newBounds[3] = lat;
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
return newBounds;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
// dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.js
|
|
839
|
-
var BinaryGeometryType;
|
|
840
|
-
(function(BinaryGeometryType2) {
|
|
841
|
-
BinaryGeometryType2["points"] = "points";
|
|
842
|
-
BinaryGeometryType2["lines"] = "lines";
|
|
843
|
-
BinaryGeometryType2["polygons"] = "polygons";
|
|
844
|
-
})(BinaryGeometryType || (BinaryGeometryType = {}));
|
|
845
|
-
function getBinaryGeometryTemplate() {
|
|
846
|
-
return {
|
|
847
|
-
globalFeatureIds: { value: new Uint32Array(0), size: 1 },
|
|
848
|
-
positions: { value: new Float32Array(0), size: 2 },
|
|
849
|
-
properties: [],
|
|
850
|
-
numericProps: {},
|
|
851
|
-
featureIds: { value: new Uint32Array(0), size: 1 }
|
|
852
|
-
};
|
|
853
|
-
}
|
|
854
|
-
function getBinaryGeometriesFromArrow(geoColumn, geoEncoding, options) {
|
|
855
|
-
const featureTypes = {
|
|
856
|
-
polygon: geoEncoding === "geoarrow.multipolygon" || geoEncoding === "geoarrow.polygon",
|
|
857
|
-
point: geoEncoding === "geoarrow.multipoint" || geoEncoding === "geoarrow.point",
|
|
858
|
-
line: geoEncoding === "geoarrow.multilinestring" || geoEncoding === "geoarrow.linestring"
|
|
859
|
-
};
|
|
860
|
-
const chunks = (options == null ? void 0 : options.chunkIndex) !== void 0 && (options == null ? void 0 : options.chunkIndex) >= 0 ? [geoColumn.data[options == null ? void 0 : options.chunkIndex]] : geoColumn.data;
|
|
861
|
-
let bounds = [Infinity, Infinity, -Infinity, -Infinity];
|
|
862
|
-
let globalFeatureIdOffset = (options == null ? void 0 : options.chunkOffset) || 0;
|
|
863
|
-
const binaryGeometries = [];
|
|
864
|
-
chunks.forEach((chunk) => {
|
|
865
|
-
const { featureIds, flatCoordinateArray, nDim, geomOffset, triangles } = getBinaryGeometriesFromChunk(chunk, geoEncoding, options);
|
|
866
|
-
const globalFeatureIds = new Uint32Array(featureIds.length);
|
|
867
|
-
for (let i = 0; i < featureIds.length; i++) {
|
|
868
|
-
globalFeatureIds[i] = featureIds[i] + globalFeatureIdOffset;
|
|
869
|
-
}
|
|
870
|
-
const binaryContent = {
|
|
871
|
-
globalFeatureIds: { value: globalFeatureIds, size: 1 },
|
|
872
|
-
positions: {
|
|
873
|
-
value: flatCoordinateArray,
|
|
874
|
-
size: nDim
|
|
875
|
-
},
|
|
876
|
-
featureIds: { value: featureIds, size: 1 },
|
|
877
|
-
// eslint-disable-next-line no-loop-func
|
|
878
|
-
properties: [...Array(chunk.length).keys()].map((i) => ({
|
|
879
|
-
index: i + globalFeatureIdOffset
|
|
880
|
-
}))
|
|
881
|
-
};
|
|
882
|
-
globalFeatureIdOffset += chunk.length;
|
|
883
|
-
binaryGeometries.push({
|
|
884
|
-
shape: "binary-feature-collection",
|
|
885
|
-
points: {
|
|
886
|
-
type: "Point",
|
|
887
|
-
...getBinaryGeometryTemplate(),
|
|
888
|
-
...featureTypes.point ? binaryContent : {}
|
|
889
|
-
},
|
|
890
|
-
lines: {
|
|
891
|
-
type: "LineString",
|
|
892
|
-
...getBinaryGeometryTemplate(),
|
|
893
|
-
...featureTypes.line ? binaryContent : {},
|
|
894
|
-
pathIndices: { value: featureTypes.line ? geomOffset : new Uint16Array(0), size: 1 }
|
|
895
|
-
},
|
|
896
|
-
polygons: {
|
|
897
|
-
type: "Polygon",
|
|
898
|
-
...getBinaryGeometryTemplate(),
|
|
899
|
-
...featureTypes.polygon ? binaryContent : {},
|
|
900
|
-
polygonIndices: {
|
|
901
|
-
// use geomOffset as polygonIndices same as primitivePolygonIndices since we are using earcut to get triangule indices
|
|
902
|
-
value: featureTypes.polygon ? geomOffset : new Uint16Array(0),
|
|
903
|
-
size: 1
|
|
904
|
-
},
|
|
905
|
-
primitivePolygonIndices: {
|
|
906
|
-
value: featureTypes.polygon ? geomOffset : new Uint16Array(0),
|
|
907
|
-
size: 1
|
|
908
|
-
},
|
|
909
|
-
...triangles ? { triangles: { value: triangles, size: 1 } } : {}
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
bounds = updateBoundsFromGeoArrowSamples(flatCoordinateArray, nDim, bounds);
|
|
913
|
-
});
|
|
914
|
-
return {
|
|
915
|
-
binaryGeometries,
|
|
916
|
-
bounds,
|
|
917
|
-
featureTypes,
|
|
918
|
-
...(options == null ? void 0 : options.calculateMeanCenters) ? { meanCenters: getMeanCentersFromBinaryGeometries(binaryGeometries) } : {}
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
function getMeanCentersFromBinaryGeometries(binaryGeometries) {
|
|
922
|
-
const globalMeanCenters = [];
|
|
923
|
-
binaryGeometries.forEach((binaryGeometry) => {
|
|
924
|
-
var _a;
|
|
925
|
-
let binaryGeometryType = null;
|
|
926
|
-
if (binaryGeometry.points && binaryGeometry.points.positions.value.length > 0) {
|
|
927
|
-
binaryGeometryType = BinaryGeometryType.points;
|
|
928
|
-
} else if (binaryGeometry.lines && binaryGeometry.lines.positions.value.length > 0) {
|
|
929
|
-
binaryGeometryType = BinaryGeometryType.lines;
|
|
930
|
-
} else if (binaryGeometry.polygons && binaryGeometry.polygons.positions.value.length > 0) {
|
|
931
|
-
binaryGeometryType = BinaryGeometryType.polygons;
|
|
932
|
-
}
|
|
933
|
-
const binaryContent = binaryGeometryType ? binaryGeometry[binaryGeometryType] : null;
|
|
934
|
-
if (binaryContent && binaryGeometryType !== null) {
|
|
935
|
-
const featureIds = binaryContent.featureIds.value;
|
|
936
|
-
const flatCoordinateArray = binaryContent.positions.value;
|
|
937
|
-
const nDim = binaryContent.positions.size;
|
|
938
|
-
const primitivePolygonIndices = binaryContent.type === "Polygon" ? (_a = binaryContent.primitivePolygonIndices) == null ? void 0 : _a.value : void 0;
|
|
939
|
-
const meanCenters = getMeanCentersFromGeometry(featureIds, flatCoordinateArray, nDim, binaryGeometryType, primitivePolygonIndices);
|
|
940
|
-
meanCenters.forEach((center) => {
|
|
941
|
-
globalMeanCenters.push(center);
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
});
|
|
945
|
-
return globalMeanCenters;
|
|
946
|
-
}
|
|
947
|
-
function getMeanCentersFromGeometry(featureIds, flatCoordinateArray, nDim, geometryType, primitivePolygonIndices) {
|
|
948
|
-
const meanCenters = [];
|
|
949
|
-
const vertexCount = flatCoordinateArray.length;
|
|
950
|
-
let vertexIndex = 0;
|
|
951
|
-
let coordIdx = 0;
|
|
952
|
-
let primitiveIdx = 0;
|
|
953
|
-
while (vertexIndex < vertexCount) {
|
|
954
|
-
const featureId = featureIds[vertexIndex / nDim];
|
|
955
|
-
const center = [0, 0];
|
|
956
|
-
let vertexCountInFeature = 0;
|
|
957
|
-
while (vertexIndex < vertexCount && featureIds[coordIdx] === featureId) {
|
|
958
|
-
if (geometryType === BinaryGeometryType.polygons && (primitivePolygonIndices == null ? void 0 : primitivePolygonIndices[primitiveIdx]) === coordIdx) {
|
|
959
|
-
vertexIndex += nDim;
|
|
960
|
-
primitiveIdx++;
|
|
961
|
-
} else {
|
|
962
|
-
center[0] += flatCoordinateArray[vertexIndex];
|
|
963
|
-
center[1] += flatCoordinateArray[vertexIndex + 1];
|
|
964
|
-
vertexIndex += nDim;
|
|
965
|
-
vertexCountInFeature++;
|
|
966
|
-
}
|
|
967
|
-
coordIdx += 1;
|
|
968
|
-
}
|
|
969
|
-
center[0] /= vertexCountInFeature;
|
|
970
|
-
center[1] /= vertexCountInFeature;
|
|
971
|
-
meanCenters.push(center);
|
|
972
|
-
}
|
|
973
|
-
return meanCenters;
|
|
974
|
-
}
|
|
975
|
-
function getBinaryGeometriesFromChunk(chunk, geoEncoding, options) {
|
|
976
|
-
switch (geoEncoding) {
|
|
977
|
-
case "geoarrow.point":
|
|
978
|
-
case "geoarrow.multipoint":
|
|
979
|
-
return getBinaryPointsFromChunk(chunk, geoEncoding);
|
|
980
|
-
case "geoarrow.linestring":
|
|
981
|
-
case "geoarrow.multilinestring":
|
|
982
|
-
return getBinaryLinesFromChunk(chunk, geoEncoding);
|
|
983
|
-
case "geoarrow.polygon":
|
|
984
|
-
case "geoarrow.multipolygon":
|
|
985
|
-
return getBinaryPolygonsFromChunk(chunk, geoEncoding, options);
|
|
986
|
-
default:
|
|
987
|
-
throw Error("invalid geoarrow encoding");
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
function getTriangleIndices(polygonIndices, primitivePolygonIndices, flatCoordinateArray, nDim) {
|
|
991
|
-
try {
|
|
992
|
-
let primitiveIndex = 0;
|
|
993
|
-
const triangles = [];
|
|
994
|
-
for (let i = 0; i < polygonIndices.length - 1; i++) {
|
|
995
|
-
const startIdx = polygonIndices[i];
|
|
996
|
-
const endIdx = polygonIndices[i + 1];
|
|
997
|
-
const slicedFlatCoords = flatCoordinateArray.subarray(startIdx * nDim, endIdx * nDim);
|
|
998
|
-
const holeIndices = [];
|
|
999
|
-
while (primitivePolygonIndices[primitiveIndex] < endIdx) {
|
|
1000
|
-
if (primitivePolygonIndices[primitiveIndex] > startIdx) {
|
|
1001
|
-
holeIndices.push(primitivePolygonIndices[primitiveIndex] - startIdx);
|
|
1002
|
-
}
|
|
1003
|
-
primitiveIndex++;
|
|
1004
|
-
}
|
|
1005
|
-
const triangleIndices = (0, import_polygon.earcut)(slicedFlatCoords, holeIndices.length > 0 ? holeIndices : void 0, nDim);
|
|
1006
|
-
if (triangleIndices.length === 0) {
|
|
1007
|
-
throw Error("earcut failed e.g. invalid polygon");
|
|
1008
|
-
}
|
|
1009
|
-
for (let j = 0; j < triangleIndices.length; j++) {
|
|
1010
|
-
triangles.push(triangleIndices[j] + startIdx);
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
const trianglesUint32 = new Uint32Array(triangles.length);
|
|
1014
|
-
for (let i = 0; i < triangles.length; i++) {
|
|
1015
|
-
trianglesUint32[i] = triangles[i];
|
|
1016
|
-
}
|
|
1017
|
-
return trianglesUint32;
|
|
1018
|
-
} catch (error) {
|
|
1019
|
-
return null;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
function getBinaryPolygonsFromChunk(chunk, geoEncoding, options) {
|
|
1023
|
-
const isMultiPolygon = geoEncoding === "geoarrow.multipolygon";
|
|
1024
|
-
const polygonData = isMultiPolygon ? chunk.children[0] : chunk;
|
|
1025
|
-
const polygonOffset = polygonData.valueOffsets;
|
|
1026
|
-
const partData = isMultiPolygon ? chunk.valueOffsets.map((i) => polygonOffset.at(i) || i) : chunk.valueOffsets;
|
|
1027
|
-
const ringData = polygonData.children[0];
|
|
1028
|
-
const pointData = ringData.children[0];
|
|
1029
|
-
const coordData = pointData.children[0];
|
|
1030
|
-
const nDim = pointData.stride;
|
|
1031
|
-
const geomOffset = ringData.valueOffsets;
|
|
1032
|
-
const flatCoordinateArray = coordData.values;
|
|
1033
|
-
const geometryIndicies = new Uint16Array(polygonOffset.length);
|
|
1034
|
-
for (let i = 0; i < polygonOffset.length; i++) {
|
|
1035
|
-
geometryIndicies[i] = geomOffset[polygonOffset[i]];
|
|
1036
|
-
}
|
|
1037
|
-
const numOfVertices = flatCoordinateArray.length / nDim;
|
|
1038
|
-
const featureIds = new Uint32Array(numOfVertices);
|
|
1039
|
-
for (let i = 0; i < partData.length - 1; i++) {
|
|
1040
|
-
const startIdx = geomOffset[partData[i]];
|
|
1041
|
-
const endIdx = geomOffset[partData[i + 1]];
|
|
1042
|
-
for (let j = startIdx; j < endIdx; j++) {
|
|
1043
|
-
featureIds[j] = i;
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
const triangles = (options == null ? void 0 : options.triangulate) ? getTriangleIndices(geometryIndicies, geomOffset, flatCoordinateArray, nDim) : null;
|
|
1047
|
-
return {
|
|
1048
|
-
featureIds,
|
|
1049
|
-
nDim,
|
|
1050
|
-
flatCoordinateArray,
|
|
1051
|
-
geomOffset,
|
|
1052
|
-
geometryIndicies,
|
|
1053
|
-
...(options == null ? void 0 : options.triangulate) && triangles ? { triangles } : {}
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
function getBinaryLinesFromChunk(chunk, geoEncoding) {
|
|
1057
|
-
const isMultiLineString = geoEncoding === "geoarrow.multilinestring";
|
|
1058
|
-
const lineData = isMultiLineString ? chunk.children[0] : chunk;
|
|
1059
|
-
const pointData = lineData.children[0];
|
|
1060
|
-
const coordData = pointData.children[0];
|
|
1061
|
-
const nDim = pointData.stride;
|
|
1062
|
-
const geomOffset = lineData.valueOffsets;
|
|
1063
|
-
const flatCoordinateArray = coordData.values;
|
|
1064
|
-
const geometryIndicies = new Uint16Array(0);
|
|
1065
|
-
const numOfVertices = flatCoordinateArray.length / nDim;
|
|
1066
|
-
const featureIds = new Uint32Array(numOfVertices);
|
|
1067
|
-
if (isMultiLineString) {
|
|
1068
|
-
const partData = chunk.valueOffsets;
|
|
1069
|
-
for (let i = 0; i < partData.length - 1; i++) {
|
|
1070
|
-
const startIdx = geomOffset[partData[i]];
|
|
1071
|
-
const endIdx = geomOffset[partData[i + 1]];
|
|
1072
|
-
for (let j = startIdx; j < endIdx; j++) {
|
|
1073
|
-
featureIds[j] = i;
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
} else {
|
|
1077
|
-
for (let i = 0; i < chunk.length; i++) {
|
|
1078
|
-
const startIdx = geomOffset[i];
|
|
1079
|
-
const endIdx = geomOffset[i + 1];
|
|
1080
|
-
for (let j = startIdx; j < endIdx; j++) {
|
|
1081
|
-
featureIds[j] = i;
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
return {
|
|
1086
|
-
featureIds,
|
|
1087
|
-
flatCoordinateArray,
|
|
1088
|
-
nDim,
|
|
1089
|
-
geomOffset,
|
|
1090
|
-
geometryIndicies
|
|
1091
|
-
};
|
|
1092
|
-
}
|
|
1093
|
-
function getBinaryPointsFromChunk(chunk, geoEncoding) {
|
|
1094
|
-
const isMultiPoint = geoEncoding === "geoarrow.multipoint";
|
|
1095
|
-
const pointData = isMultiPoint ? chunk.children[0] : chunk;
|
|
1096
|
-
const coordData = pointData.children[0];
|
|
1097
|
-
const nDim = pointData.stride;
|
|
1098
|
-
const flatCoordinateArray = coordData.values;
|
|
1099
|
-
const geometryIndicies = new Uint16Array(0);
|
|
1100
|
-
const geomOffset = new Int32Array(0);
|
|
1101
|
-
const numOfVertices = flatCoordinateArray.length / nDim;
|
|
1102
|
-
const featureIds = new Uint32Array(numOfVertices);
|
|
1103
|
-
if (isMultiPoint) {
|
|
1104
|
-
const partData = chunk.valueOffsets;
|
|
1105
|
-
for (let i = 0; i < partData.length - 1; i++) {
|
|
1106
|
-
const startIdx = partData[i];
|
|
1107
|
-
const endIdx = partData[i + 1];
|
|
1108
|
-
for (let j = startIdx; j < endIdx; j++) {
|
|
1109
|
-
featureIds[j] = i;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
} else {
|
|
1113
|
-
for (let i = 0; i < chunk.length; i++) {
|
|
1114
|
-
featureIds[i] = i;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
return {
|
|
1118
|
-
featureIds,
|
|
1119
|
-
flatCoordinateArray,
|
|
1120
|
-
nDim,
|
|
1121
|
-
geomOffset,
|
|
1122
|
-
geometryIndicies
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
216
|
// dist/workers/hard-clone.js
|
|
1127
|
-
var
|
|
217
|
+
var arrow3 = __toESM(require("apache-arrow"), 1);
|
|
1128
218
|
function hardClone(data, force = false) {
|
|
1129
219
|
if ("data" in data) {
|
|
1130
|
-
return new
|
|
220
|
+
return new arrow3.Vector(data.data.map((data2) => hardClone(data2, force)));
|
|
1131
221
|
}
|
|
1132
222
|
const clonedChildren = [];
|
|
1133
223
|
for (const childData of data.children) {
|
|
@@ -1138,12 +228,12 @@ function hardClone(data, force = false) {
|
|
|
1138
228
|
clonedDictionary = hardClone(data.dictionary, force);
|
|
1139
229
|
}
|
|
1140
230
|
const clonedBuffers = {
|
|
1141
|
-
[
|
|
1142
|
-
[
|
|
1143
|
-
[
|
|
1144
|
-
[
|
|
231
|
+
[arrow3.BufferType.OFFSET]: cloneBuffer(data.buffers[arrow3.BufferType.OFFSET], force),
|
|
232
|
+
[arrow3.BufferType.DATA]: cloneBuffer(data.buffers[arrow3.BufferType.DATA], force),
|
|
233
|
+
[arrow3.BufferType.VALIDITY]: cloneBuffer(data.buffers[arrow3.BufferType.VALIDITY], force),
|
|
234
|
+
[arrow3.BufferType.TYPE]: cloneBuffer(data.buffers[arrow3.BufferType.TYPE], force)
|
|
1145
235
|
};
|
|
1146
|
-
return new
|
|
236
|
+
return new arrow3.Data(
|
|
1147
237
|
data.type,
|
|
1148
238
|
data.offset,
|
|
1149
239
|
data.length,
|
|
@@ -1170,7 +260,7 @@ function cloneBuffer(arr, force) {
|
|
|
1170
260
|
|
|
1171
261
|
// dist/triangulate-on-worker.js
|
|
1172
262
|
var import_worker_utils = require("@loaders.gl/worker-utils");
|
|
1173
|
-
var VERSION3 = true ? "4.
|
|
263
|
+
var VERSION3 = true ? "4.4.0-alpha.0" : "latest";
|
|
1174
264
|
var TriangulationWorker = {
|
|
1175
265
|
id: "triangulation",
|
|
1176
266
|
name: "Triangulate",
|
|
@@ -1184,7 +274,4 @@ function triangulateOnWorker(data, options = {}) {
|
|
|
1184
274
|
function parseGeoArrowOnWorker(data, options = {}) {
|
|
1185
275
|
return (0, import_worker_utils.processOnWorker)(TriangulationWorker, { ...data, operation: "parse-geoarrow" }, options);
|
|
1186
276
|
}
|
|
1187
|
-
|
|
1188
|
-
// dist/index.js
|
|
1189
|
-
import_schema4.TableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;
|
|
1190
277
|
//# sourceMappingURL=index.cjs.map
|