@loaders.gl/arrow 4.3.0-alpha.7 → 4.3.0-beta.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 +6 -38
- package/dist/arrow-loader.d.ts.map +1 -1
- package/dist/arrow-loader.js +2 -29
- package/dist/arrow-worker.js +2654 -1710
- package/dist/arrow-writer.d.ts +1 -1
- package/dist/arrow-writer.d.ts.map +1 -1
- package/dist/arrow-writer.js +2 -2
- package/dist/dist.dev.js +1873 -1833
- package/dist/dist.min.js +5 -5
- package/dist/exports/arrow-loader.d.ts +34 -0
- package/dist/exports/arrow-loader.d.ts.map +1 -0
- package/dist/exports/arrow-loader.js +30 -0
- package/dist/exports/geoarrow-loader.d.ts +27 -0
- package/dist/exports/geoarrow-loader.d.ts.map +1 -0
- package/dist/exports/geoarrow-loader.js +13 -0
- package/dist/geoarrow-loader.d.ts +3 -27
- package/dist/geoarrow-loader.d.ts.map +1 -1
- package/dist/geoarrow-loader.js +2 -12
- package/dist/geoarrow-writer.d.ts +2 -2
- package/dist/geoarrow-writer.d.ts.map +1 -1
- package/dist/geoarrow-writer.js +2 -2
- package/dist/index.cjs +426 -387
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +14 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -12
- package/dist/lib/encoders/encode-arrow.d.ts.map +1 -0
- package/dist/lib/encoders/encode-geoarrow.d.ts.map +1 -0
- package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -0
- package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +1 -0
- package/dist/lib/geoarrow/get-arrow-bounds.d.ts.map +1 -0
- package/dist/lib/parsers/parse-arrow.d.ts +9 -0
- package/dist/lib/parsers/parse-arrow.d.ts.map +1 -0
- package/dist/{parsers/parse-arrow-in-batches.js → lib/parsers/parse-arrow.js} +7 -3
- package/dist/lib/parsers/parse-geoarrow.d.ts +9 -0
- package/dist/lib/parsers/parse-geoarrow.d.ts.map +1 -0
- package/dist/{parsers/parse-geoarrow-sync.js → lib/parsers/parse-geoarrow.js} +9 -3
- package/dist/{schema → lib/tables}/convert-arrow-schema.d.ts +4 -0
- package/dist/lib/tables/convert-arrow-schema.d.ts.map +1 -0
- package/dist/{schema → lib/tables}/convert-arrow-schema.js +8 -0
- package/dist/lib/tables/convert-arrow-to-table.d.ts +15 -0
- package/dist/lib/tables/convert-arrow-to-table.d.ts.map +1 -0
- package/dist/lib/tables/convert-arrow-to-table.js +104 -0
- package/dist/lib/tables/convert-table-to-arrow.d.ts +16 -0
- package/dist/lib/tables/convert-table-to-arrow.d.ts.map +1 -0
- package/dist/lib/tables/convert-table-to-arrow.js +56 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/{lib → schema}/arrow-table-batch.d.ts +2 -1
- package/dist/schema/arrow-table-batch.d.ts.map +1 -0
- package/dist/{lib → schema}/arrow-table-batch.js +1 -0
- package/dist/{lib/arrow-table.d.ts → schema/arrow-table-type.d.ts} +3 -1
- package/dist/schema/arrow-table-type.d.ts.map +1 -0
- package/dist/triangulate-on-worker.js +1 -1
- package/dist/triangulation-worker.js +25 -72
- package/dist/workers/triangulation-worker.js +1 -1
- package/package.json +12 -8
- package/src/arrow-loader.ts +6 -57
- package/src/arrow-writer.ts +1 -2
- package/src/exports/arrow-loader.ts +49 -0
- package/src/exports/geoarrow-loader.ts +24 -0
- package/src/geoarrow-loader.ts +6 -22
- package/src/geoarrow-writer.ts +1 -1
- package/src/index.ts +23 -23
- package/src/{parsers/parse-arrow-in-batches.ts → lib/parsers/parse-arrow.ts} +11 -5
- package/src/lib/parsers/parse-geoarrow.ts +32 -0
- package/src/{schema → lib/tables}/convert-arrow-schema.ts +10 -0
- package/src/lib/tables/convert-arrow-to-table.ts +144 -0
- package/src/lib/tables/convert-table-to-arrow.ts +72 -0
- package/src/{lib → schema}/arrow-table-batch.ts +2 -1
- package/src/{lib/arrow-table.ts → schema/arrow-table-type.ts} +2 -0
- package/src/workers/triangulation-worker.ts +1 -1
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +0 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +0 -1
- package/dist/geoarrow/get-arrow-bounds.d.ts.map +0 -1
- package/dist/lib/arrow-table-batch.d.ts.map +0 -1
- package/dist/lib/arrow-table.d.ts.map +0 -1
- package/dist/lib/encode-arrow.d.ts.map +0 -1
- package/dist/lib/encode-geoarrow.d.ts.map +0 -1
- package/dist/parsers/parse-arrow-in-batches.d.ts +0 -6
- package/dist/parsers/parse-arrow-in-batches.d.ts.map +0 -1
- package/dist/parsers/parse-arrow-sync.d.ts +0 -6
- package/dist/parsers/parse-arrow-sync.d.ts.map +0 -1
- package/dist/parsers/parse-arrow-sync.js +0 -32
- package/dist/parsers/parse-geoarrow-in-batches.d.ts +0 -6
- package/dist/parsers/parse-geoarrow-in-batches.d.ts.map +0 -1
- package/dist/parsers/parse-geoarrow-in-batches.js +0 -10
- package/dist/parsers/parse-geoarrow-sync.d.ts +0 -6
- package/dist/parsers/parse-geoarrow-sync.d.ts.map +0 -1
- package/dist/schema/arrow-type-utils.d.ts +0 -5
- package/dist/schema/arrow-type-utils.d.ts.map +0 -1
- package/dist/schema/arrow-type-utils.js +0 -51
- package/dist/schema/convert-arrow-schema.d.ts.map +0 -1
- package/dist/tables/convert-arrow-to-columnar-table.d.ts +0 -8
- package/dist/tables/convert-arrow-to-columnar-table.d.ts.map +0 -1
- package/dist/tables/convert-arrow-to-columnar-table.js +0 -24
- package/dist/tables/convert-arrow-to-geojson-table.d.ts +0 -16
- package/dist/tables/convert-arrow-to-geojson-table.d.ts.map +0 -1
- package/dist/tables/convert-arrow-to-geojson-table.js +0 -54
- package/dist/tables/convert-columnar-to-row-table.d.ts +0 -7
- package/dist/tables/convert-columnar-to-row-table.d.ts.map +0 -1
- package/dist/tables/convert-columnar-to-row-table.js +0 -25
- package/dist/tables/convert-table-to-arrow.d.ts +0 -42
- package/dist/tables/convert-table-to-arrow.d.ts.map +0 -1
- package/dist/tables/convert-table-to-arrow.js +0 -59
- package/dist/types.d.ts.map +0 -1
- package/src/parsers/parse-arrow-sync.ts +0 -44
- package/src/parsers/parse-geoarrow-in-batches.ts +0 -16
- package/src/parsers/parse-geoarrow-sync.ts +0 -23
- package/src/schema/arrow-type-utils.ts +0 -55
- package/src/tables/convert-arrow-to-columnar-table.ts +0 -31
- package/src/tables/convert-arrow-to-geojson-table.ts +0 -66
- package/src/tables/convert-columnar-to-row-table.ts +0 -31
- package/src/tables/convert-table-to-arrow.ts +0 -61
- /package/dist/lib/{encode-arrow.d.ts → encoders/encode-arrow.d.ts} +0 -0
- /package/dist/lib/{encode-arrow.js → encoders/encode-arrow.js} +0 -0
- /package/dist/lib/{encode-geoarrow.d.ts → encoders/encode-geoarrow.d.ts} +0 -0
- /package/dist/lib/{encode-geoarrow.js → encoders/encode-geoarrow.js} +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.d.ts +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.js +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.d.ts +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.js +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/get-arrow-bounds.d.ts +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/get-arrow-bounds.js +0 -0
- /package/dist/{types.d.ts → lib/types.d.ts} +0 -0
- /package/dist/{types.js → lib/types.js} +0 -0
- /package/dist/{lib/arrow-table.js → schema/arrow-table-type.js} +0 -0
- /package/src/lib/{encode-arrow.ts → encoders/encode-arrow.ts} +0 -0
- /package/src/lib/{encode-geoarrow.ts → encoders/encode-geoarrow.ts} +0 -0
- /package/src/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.ts +0 -0
- /package/src/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.ts +0 -0
- /package/src/{geoarrow → lib/geoarrow}/get-arrow-bounds.ts +0 -0
- /package/src/{types.ts → lib/types.ts} +0 -0
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { parseArrowSync } from "./parse-arrow
|
|
5
|
-
import {
|
|
4
|
+
import { parseArrowSync, parseArrowInBatches } from "./parse-arrow.js";
|
|
5
|
+
import { convertArrowToTable } from "../tables/convert-arrow-to-table.js";
|
|
6
6
|
// Parses arrow to a columnar table
|
|
7
7
|
export function parseGeoArrowSync(arrayBuffer, options) {
|
|
8
8
|
// | BinaryGeometry
|
|
9
9
|
const table = parseArrowSync(arrayBuffer, { shape: 'arrow-table' });
|
|
10
10
|
switch (options?.shape) {
|
|
11
11
|
case 'geojson-table':
|
|
12
|
-
return
|
|
12
|
+
return convertArrowToTable(table.data, 'geojson-table');
|
|
13
13
|
default:
|
|
14
14
|
return table;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
*/
|
|
19
|
+
export function parseGeoArrowInBatches(asyncIterator) {
|
|
20
|
+
// | BinaryGeometry
|
|
21
|
+
return parseArrowInBatches(asyncIterator);
|
|
22
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { DataType, Field, Schema, SchemaMetadata } from '@loaders.gl/schema';
|
|
2
2
|
import * as arrow from 'apache-arrow';
|
|
3
3
|
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
4
|
+
export declare function convertArrowToSchema(arrowSchema: arrow.Schema): Schema;
|
|
5
|
+
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
6
|
+
export declare function convertSchemaToArrow(schema: Schema): arrow.Schema;
|
|
7
|
+
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
4
8
|
export declare function serializeArrowSchema(arrowSchema: arrow.Schema): Schema;
|
|
5
9
|
/** Convert a serialized Schema (plain data) to an Apache Arrow Schema (class instance) */
|
|
6
10
|
export declare function deserializeArrowSchema(schema: Schema): arrow.Schema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-arrow-schema.d.ts","sourceRoot":"","sources":["../../../src/lib/tables/convert-arrow-schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAEtE;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAEjE;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAKtE;AAED,0FAA0F;AAC1F,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAKnE;AAED,gHAAgH;AAChH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,cAAc,CAEzF;AAED,mHAAmH;AACnH,wBAAgB,wBAAwB,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAEvF;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAO7D;AAED,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAO/D;AAED,+EAA+E;AAE/E,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAuJtE;AAED,+EAA+E;AAE/E,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAgFvE"}
|
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import * as arrow from 'apache-arrow';
|
|
5
5
|
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
6
|
+
export function convertArrowToSchema(arrowSchema) {
|
|
7
|
+
return serializeArrowSchema(arrowSchema);
|
|
8
|
+
}
|
|
9
|
+
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
10
|
+
export function convertSchemaToArrow(schema) {
|
|
11
|
+
return deserializeArrowSchema(schema);
|
|
12
|
+
}
|
|
13
|
+
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
6
14
|
export function serializeArrowSchema(arrowSchema) {
|
|
7
15
|
return {
|
|
8
16
|
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
|
+
import type { Table, ArrayRowTable, ColumnarTable, ObjectRowTable, GeoJSONTable } from '@loaders.gl/schema';
|
|
3
|
+
import type { ArrowTable } from "../../schema/arrow-table-type.js";
|
|
4
|
+
/**
|
|
5
|
+
* Convert an Apache Arrow table to a loaders.gl Table
|
|
6
|
+
* @note Currently does not convert schema
|
|
7
|
+
*/
|
|
8
|
+
export declare function convertArrowToTable(arrow: arrow.Table, shape: 'arrow-table'): ArrowTable;
|
|
9
|
+
export declare function convertArrowToTable(arrow: arrow.Table, shape: 'columnar-table'): ColumnarTable;
|
|
10
|
+
export declare function convertArrowToTable(arrow: arrow.Table, shape: 'object-row-table'): ObjectRowTable;
|
|
11
|
+
export declare function convertArrowToTable(arrow: arrow.Table, shape: 'array-row-table'): ArrayRowTable;
|
|
12
|
+
export declare function convertArrowToTable(arrow: arrow.Table, shape: 'geojson-table'): GeoJSONTable;
|
|
13
|
+
export declare function convertArrowToTable(arrow: arrow.Table, shape: 'columnar-table'): ColumnarTable;
|
|
14
|
+
export declare function convertArrowToTable(arrow: arrow.Table, shape: Table['shape']): Table;
|
|
15
|
+
//# sourceMappingURL=convert-arrow-to-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-arrow-to-table.d.ts","sourceRoot":"","sources":["../../../src/lib/tables/convert-arrow-to-table.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EACV,KAAK,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EAEb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,UAAU,EAAC,yCAAsC;AAO9D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,GAAG,UAAU,CAAC;AAC1F,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,gBAAgB,GAAG,aAAa,CAAC;AAChG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,kBAAkB,GAAG,cAAc,CAAC;AACnG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,iBAAiB,GAAG,aAAa,CAAC;AACjG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,eAAe,GAAG,YAAY,CAAC;AAC9F,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,gBAAgB,GAAG,aAAa,CAAC;AAChG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { convertTable } from '@loaders.gl/schema';
|
|
5
|
+
import { getGeometryColumnsFromSchema } from '@loaders.gl/gis';
|
|
6
|
+
import { convertArrowToSchema } from "../tables/convert-arrow-schema.js";
|
|
7
|
+
import { parseGeometryFromArrow } from "../geoarrow/convert-geoarrow-to-geojson-geometry.js";
|
|
8
|
+
/**
|
|
9
|
+
* Convert an Apache Arrow table to a loaders.gl Table
|
|
10
|
+
* @note Currently does not convert schema
|
|
11
|
+
*/
|
|
12
|
+
export function convertArrowToTable(arrowTable, shape) {
|
|
13
|
+
switch (shape) {
|
|
14
|
+
case 'arrow-table':
|
|
15
|
+
return convertArrowToArrowTable(arrowTable);
|
|
16
|
+
case 'array-row-table':
|
|
17
|
+
return convertArrowToArrayRowTable(arrowTable);
|
|
18
|
+
case 'object-row-table':
|
|
19
|
+
return convertArrowToObjectRowTable(arrowTable);
|
|
20
|
+
case 'columnar-table':
|
|
21
|
+
return convertArrowToColumnarTable(arrowTable);
|
|
22
|
+
case 'geojson-table':
|
|
23
|
+
return convertArrowToGeoJSONTable(arrowTable);
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(shape);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wrap an apache arrow table in a loaders.gl table wrapper.
|
|
30
|
+
* From this additional conversions are available.
|
|
31
|
+
* @param arrowTable
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
function convertArrowToArrowTable(arrowTable) {
|
|
35
|
+
return {
|
|
36
|
+
shape: 'arrow-table',
|
|
37
|
+
schema: convertArrowToSchema(arrowTable.schema),
|
|
38
|
+
data: arrowTable
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function convertArrowToArrayRowTable(arrowTable) {
|
|
42
|
+
const columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
43
|
+
return convertTable(columnarTable, 'array-row-table');
|
|
44
|
+
}
|
|
45
|
+
function convertArrowToObjectRowTable(arrowTable) {
|
|
46
|
+
const columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
47
|
+
return convertTable(columnarTable, 'object-row-table');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Convert an Apache Arrow table to a ColumnarTable
|
|
51
|
+
* @note Currently does not convert schema
|
|
52
|
+
*/
|
|
53
|
+
function convertArrowToColumnarTable(arrowTable) {
|
|
54
|
+
// TODO - avoid calling `getColumn` on columns we are not interested in?
|
|
55
|
+
// Add options object?
|
|
56
|
+
const columns = {};
|
|
57
|
+
for (const field of arrowTable.schema.fields) {
|
|
58
|
+
// This (is intended to) coalesce all record batches into a single typed array
|
|
59
|
+
const arrowColumn = arrowTable.getChild(field.name);
|
|
60
|
+
const values = arrowColumn?.toArray();
|
|
61
|
+
columns[field.name] = values;
|
|
62
|
+
}
|
|
63
|
+
const schema = convertArrowToSchema(arrowTable.schema);
|
|
64
|
+
return {
|
|
65
|
+
shape: 'columnar-table',
|
|
66
|
+
schema,
|
|
67
|
+
data: columns
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Convert an Apache Arrow table to a GeoJSONTable
|
|
72
|
+
* @note Currently does not convert schema
|
|
73
|
+
*/
|
|
74
|
+
function convertArrowToGeoJSONTable(arrowTable) {
|
|
75
|
+
const schema = convertArrowToSchema(arrowTable.schema);
|
|
76
|
+
const geometryColumns = getGeometryColumnsFromSchema(schema);
|
|
77
|
+
// get encoding from geometryColumns['geometry']
|
|
78
|
+
const encoding = geometryColumns.geometry.encoding;
|
|
79
|
+
const features = [];
|
|
80
|
+
// Remove geometry columns
|
|
81
|
+
const propertyColumnNames = arrowTable.schema.fields
|
|
82
|
+
.map((field) => field.name)
|
|
83
|
+
// TODO - this deletes all geometry columns
|
|
84
|
+
.filter((name) => !(name in geometryColumns));
|
|
85
|
+
const propertiesTable = arrowTable.select(propertyColumnNames);
|
|
86
|
+
const arrowGeometryColumn = arrowTable.getChild('geometry');
|
|
87
|
+
for (let row = 0; row < arrowTable.numRows; row++) {
|
|
88
|
+
// get the geometry value from arrow geometry column
|
|
89
|
+
// Note that type can vary
|
|
90
|
+
const arrowGeometry = arrowGeometryColumn?.get(row);
|
|
91
|
+
// parse arrow geometry to geojson feature
|
|
92
|
+
const feature = parseGeometryFromArrow(arrowGeometry, encoding);
|
|
93
|
+
if (feature) {
|
|
94
|
+
const properties = propertiesTable.get(row)?.toJSON() || {};
|
|
95
|
+
features.push({ type: 'Feature', geometry: feature, properties });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
shape: 'geojson-table',
|
|
100
|
+
type: 'FeatureCollection',
|
|
101
|
+
schema,
|
|
102
|
+
features
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
|
+
import { Table } from '@loaders.gl/schema';
|
|
3
|
+
/**
|
|
4
|
+
* * Convert a loaders.gl Table to an Apache Arrow Table
|
|
5
|
+
* @param mesh
|
|
6
|
+
* @param metadata
|
|
7
|
+
* @param batchSize
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertTableToArrow(table: Table, options?: {
|
|
11
|
+
batchSize?: number;
|
|
12
|
+
}): arrow.Table;
|
|
13
|
+
export declare function makeTableToArrowBatchesIterator(table: Table, options?: {
|
|
14
|
+
batchSize?: number;
|
|
15
|
+
}): IterableIterator<arrow.RecordBatch>;
|
|
16
|
+
//# sourceMappingURL=convert-table-to-arrow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-table-to-arrow.d.ts","sourceRoot":"","sources":["../../../src/lib/tables/convert-table-to-arrow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,KAAK,EAAkD,MAAM,oBAAoB,CAAC;AAG1F;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,KAAK,CAAC,KAAK,CAe7F;AAED,wBAAiB,+BAA+B,CAC9C,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAC,GAC7B,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,CAoCrC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import * as arrow from 'apache-arrow';
|
|
5
|
+
import { getTableLength, getTableNumCols, getTableCellAt } from '@loaders.gl/schema';
|
|
6
|
+
import { deserializeArrowSchema } from "../tables/convert-arrow-schema.js";
|
|
7
|
+
/**
|
|
8
|
+
* * Convert a loaders.gl Table to an Apache Arrow Table
|
|
9
|
+
* @param mesh
|
|
10
|
+
* @param metadata
|
|
11
|
+
* @param batchSize
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export function convertTableToArrow(table, options) {
|
|
15
|
+
switch (table.shape) {
|
|
16
|
+
case 'arrow-table':
|
|
17
|
+
return table.data;
|
|
18
|
+
case 'columnar-table':
|
|
19
|
+
// TODO - optimized implementation is possible
|
|
20
|
+
// return convertColumnarTableToArrow(table, options);
|
|
21
|
+
// fall through
|
|
22
|
+
default:
|
|
23
|
+
const arrowBatchIterator = makeTableToArrowBatchesIterator(table, options);
|
|
24
|
+
return new arrow.Table(arrowBatchIterator);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function* makeTableToArrowBatchesIterator(table, options) {
|
|
28
|
+
const arrowSchema = deserializeArrowSchema(table.schema);
|
|
29
|
+
const length = getTableLength(table);
|
|
30
|
+
const numColumns = getTableNumCols(table);
|
|
31
|
+
const batchSize = options?.batchSize || length;
|
|
32
|
+
const builders = arrowSchema?.fields.map((arrowField) => arrow.makeBuilder(arrowField));
|
|
33
|
+
const structField = new arrow.Struct(arrowSchema.fields);
|
|
34
|
+
let batchLength = 0;
|
|
35
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
36
|
+
for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {
|
|
37
|
+
const value = getTableCellAt(table, rowIndex, columnIndex);
|
|
38
|
+
const builder = builders[columnIndex];
|
|
39
|
+
builder.append(value);
|
|
40
|
+
batchLength++;
|
|
41
|
+
if (batchLength >= batchSize) {
|
|
42
|
+
const datas = builders.map((builder) => builder.flush());
|
|
43
|
+
const structData = new arrow.Data(structField, 0, batchLength, 0, undefined, datas);
|
|
44
|
+
yield new arrow.RecordBatch(arrowSchema, structData);
|
|
45
|
+
batchLength = 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (batchLength > 0) {
|
|
50
|
+
const datas = builders.map((builder) => builder.flush());
|
|
51
|
+
const structData = new arrow.Data(structField, 0, batchLength, 0, undefined, datas);
|
|
52
|
+
yield new arrow.RecordBatch(arrowSchema, structData);
|
|
53
|
+
batchLength = 0;
|
|
54
|
+
}
|
|
55
|
+
builders.map((builder) => builder.finish());
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,CAAC;AAElG,KAAK,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC;AAEnD,KAAK,UAAU,GAAG,aAAa,GAAG,eAAe,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;AAEnD,oBAAY,YAAY;IACtB,KAAK,IAAA;IACL,IAAI,IAAA;CACL"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ColumnarTableBatchAggregator } from '@loaders.gl/schema';
|
|
2
|
-
import type { ArrowTableBatch } from "./arrow-table.js";
|
|
2
|
+
import type { ArrowTableBatch } from "./arrow-table-type.js";
|
|
3
3
|
import * as arrow from 'apache-arrow';
|
|
4
|
+
/** @note Should be part of @loaders.gl/schema - kept separate to avoid hard arrow dependency */
|
|
4
5
|
export declare class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
|
|
5
6
|
arrowSchema: arrow.Schema | null;
|
|
6
7
|
constructor(schema: any, options: any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-table-batch.d.ts","sourceRoot":"","sources":["../../src/schema/arrow-table-batch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,4BAA4B,EAAC,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAC,eAAe,EAAC,8BAA2B;AACxD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,gGAAgG;AAChG,qBAAa,yBAA0B,SAAQ,4BAA4B;IACzE,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;gBAErB,MAAM,KAAA,EAAE,OAAO,KAAA;IAK3B,QAAQ,IAAI,eAAe,GAAG,IAAI;CA4BnC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { ColumnarTableBatchAggregator } from '@loaders.gl/schema';
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
|
+
/** @note Should be part of @loaders.gl/schema - kept separate to avoid hard arrow dependency */
|
|
6
7
|
export class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
|
|
7
8
|
arrowSchema;
|
|
8
9
|
constructor(schema, options) {
|
|
@@ -3,6 +3,7 @@ import type * as arrow from 'apache-arrow';
|
|
|
3
3
|
/**
|
|
4
4
|
* A table organized as an Apache Arrow table
|
|
5
5
|
* @note This is a variant of the type from loaders.gl/schema
|
|
6
|
+
* @note Should be part of @loaders.gl/schema - kept separate to avoid hard arrow dependency
|
|
6
7
|
*/
|
|
7
8
|
export type ArrowTable = {
|
|
8
9
|
shape: 'arrow-table';
|
|
@@ -12,6 +13,7 @@ export type ArrowTable = {
|
|
|
12
13
|
/**
|
|
13
14
|
* Batch for a table organized as an Apache Arrow table
|
|
14
15
|
* @note This is a variant of the type from loaders.gl/schema
|
|
16
|
+
* @note Should be part of @loaders.gl/schema - kept separate to avoid hard arrow dependency
|
|
15
17
|
*/
|
|
16
18
|
export type ArrowTableBatch = Batch & {
|
|
17
19
|
shape: 'arrow-table';
|
|
@@ -20,4 +22,4 @@ export type ArrowTableBatch = Batch & {
|
|
|
20
22
|
data: arrow.Table;
|
|
21
23
|
length: number;
|
|
22
24
|
};
|
|
23
|
-
//# sourceMappingURL=arrow-table.d.ts.map
|
|
25
|
+
//# sourceMappingURL=arrow-table-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-table-type.d.ts","sourceRoot":"","sources":["../../src/schema/arrow-table-type.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,KAAK,EAAE,MAAM,EAAC,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG;IACpC,KAAK,EAAE,aAAa,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { processOnWorker } from '@loaders.gl/worker-utils';
|
|
5
5
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
6
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
-
const VERSION = typeof "4.3.0-alpha.
|
|
7
|
+
const VERSION = typeof "4.3.0-alpha.8" !== 'undefined' ? "4.3.0-alpha.8" : 'latest';
|
|
8
8
|
/**
|
|
9
9
|
* Worker for tessellating geometries. Normally called through triangulateOnWorker
|
|
10
10
|
*/
|
|
@@ -67,16 +67,24 @@
|
|
|
67
67
|
if (!Symbol.asyncIterator)
|
|
68
68
|
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
69
69
|
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
70
|
-
return i =
|
|
70
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
|
|
71
71
|
return this;
|
|
72
72
|
}, i;
|
|
73
|
-
function
|
|
74
|
-
|
|
73
|
+
function awaitReturn(f) {
|
|
74
|
+
return function(v) {
|
|
75
|
+
return Promise.resolve(v).then(f, reject);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function verb(n, f) {
|
|
79
|
+
if (g[n]) {
|
|
75
80
|
i[n] = function(v) {
|
|
76
81
|
return new Promise(function(a, b) {
|
|
77
82
|
q.push([n, v, a, b]) > 1 || resume(n, v);
|
|
78
83
|
});
|
|
79
84
|
};
|
|
85
|
+
if (f)
|
|
86
|
+
i[n] = f(i[n]);
|
|
87
|
+
}
|
|
80
88
|
}
|
|
81
89
|
function resume(n, v) {
|
|
82
90
|
try {
|
|
@@ -11940,52 +11948,6 @@ return true;`);
|
|
|
11940
11948
|
});
|
|
11941
11949
|
}
|
|
11942
11950
|
|
|
11943
|
-
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
11944
|
-
function _typeof(obj) {
|
|
11945
|
-
"@babel/helpers - typeof";
|
|
11946
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
11947
|
-
return typeof obj2;
|
|
11948
|
-
} : function(obj2) {
|
|
11949
|
-
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
11950
|
-
}, _typeof(obj);
|
|
11951
|
-
}
|
|
11952
|
-
|
|
11953
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
11954
|
-
function _toPrimitive(input, hint) {
|
|
11955
|
-
if (_typeof(input) !== "object" || input === null)
|
|
11956
|
-
return input;
|
|
11957
|
-
var prim = input[Symbol.toPrimitive];
|
|
11958
|
-
if (prim !== void 0) {
|
|
11959
|
-
var res = prim.call(input, hint || "default");
|
|
11960
|
-
if (_typeof(res) !== "object")
|
|
11961
|
-
return res;
|
|
11962
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
11963
|
-
}
|
|
11964
|
-
return (hint === "string" ? String : Number)(input);
|
|
11965
|
-
}
|
|
11966
|
-
|
|
11967
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
11968
|
-
function _toPropertyKey(arg) {
|
|
11969
|
-
var key = _toPrimitive(arg, "string");
|
|
11970
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
11971
|
-
}
|
|
11972
|
-
|
|
11973
|
-
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
11974
|
-
function _defineProperty(obj, key, value) {
|
|
11975
|
-
key = _toPropertyKey(key);
|
|
11976
|
-
if (key in obj) {
|
|
11977
|
-
Object.defineProperty(obj, key, {
|
|
11978
|
-
value,
|
|
11979
|
-
enumerable: true,
|
|
11980
|
-
configurable: true,
|
|
11981
|
-
writable: true
|
|
11982
|
-
});
|
|
11983
|
-
} else {
|
|
11984
|
-
obj[key] = value;
|
|
11985
|
-
}
|
|
11986
|
-
return obj;
|
|
11987
|
-
}
|
|
11988
|
-
|
|
11989
11951
|
// ../../node_modules/@math.gl/polygon/dist/polygon-utils.js
|
|
11990
11952
|
var DimIndex = {
|
|
11991
11953
|
x: 0,
|
|
@@ -11993,11 +11955,7 @@ return true;`);
|
|
|
11993
11955
|
z: 2
|
|
11994
11956
|
};
|
|
11995
11957
|
function getPolygonSignedArea(points, options2 = {}) {
|
|
11996
|
-
const {
|
|
11997
|
-
start = 0,
|
|
11998
|
-
end = points.length,
|
|
11999
|
-
plane = "xy"
|
|
12000
|
-
} = options2;
|
|
11958
|
+
const { start = 0, end = points.length, plane = "xy" } = options2;
|
|
12001
11959
|
const dim = options2.size || 2;
|
|
12002
11960
|
let area2 = 0;
|
|
12003
11961
|
const i0 = DimIndex[plane[0]];
|
|
@@ -12051,12 +12009,7 @@ return true;`);
|
|
|
12051
12009
|
let i;
|
|
12052
12010
|
let last;
|
|
12053
12011
|
if (area2 === void 0) {
|
|
12054
|
-
area2 = getPolygonSignedArea(data, {
|
|
12055
|
-
start,
|
|
12056
|
-
end,
|
|
12057
|
-
size: dim,
|
|
12058
|
-
plane
|
|
12059
|
-
});
|
|
12012
|
+
area2 = getPolygonSignedArea(data, { start, end, size: dim, plane });
|
|
12060
12013
|
}
|
|
12061
12014
|
let i0 = DimIndex[plane[0]];
|
|
12062
12015
|
let i1 = DimIndex[plane[1]];
|
|
@@ -12391,7 +12344,10 @@ return true;`);
|
|
|
12391
12344
|
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
12392
12345
|
}
|
|
12393
12346
|
function isValidDiagonal(a, b) {
|
|
12394
|
-
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) &&
|
|
12347
|
+
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
|
|
12348
|
+
(locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
|
|
12349
|
+
(area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
|
|
12350
|
+
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
|
|
12395
12351
|
}
|
|
12396
12352
|
function area(p, q, r) {
|
|
12397
12353
|
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
@@ -12484,22 +12440,19 @@ return true;`);
|
|
|
12484
12440
|
}
|
|
12485
12441
|
var Vertex = class {
|
|
12486
12442
|
constructor(i, x, y) {
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
|
-
|
|
12493
|
-
_defineProperty(this, "prevZ", null);
|
|
12494
|
-
_defineProperty(this, "nextZ", null);
|
|
12495
|
-
_defineProperty(this, "steiner", false);
|
|
12443
|
+
this.prev = null;
|
|
12444
|
+
this.next = null;
|
|
12445
|
+
this.z = 0;
|
|
12446
|
+
this.prevZ = null;
|
|
12447
|
+
this.nextZ = null;
|
|
12448
|
+
this.steiner = false;
|
|
12496
12449
|
this.i = i;
|
|
12497
12450
|
this.x = x;
|
|
12498
12451
|
this.y = y;
|
|
12499
12452
|
}
|
|
12500
12453
|
};
|
|
12501
12454
|
|
|
12502
|
-
// src/geoarrow/get-arrow-bounds.ts
|
|
12455
|
+
// src/lib/geoarrow/get-arrow-bounds.ts
|
|
12503
12456
|
function updateBoundsFromGeoArrowSamples(flatCoords, nDim, bounds, sampleSize = 100) {
|
|
12504
12457
|
const numberOfFeatures = flatCoords.length / nDim;
|
|
12505
12458
|
const sampleStep = Math.max(Math.floor(numberOfFeatures / sampleSize), 1);
|
|
@@ -12523,7 +12476,7 @@ return true;`);
|
|
|
12523
12476
|
return newBounds;
|
|
12524
12477
|
}
|
|
12525
12478
|
|
|
12526
|
-
// src/geoarrow/convert-geoarrow-to-binary-geometry.ts
|
|
12479
|
+
// src/lib/geoarrow/convert-geoarrow-to-binary-geometry.ts
|
|
12527
12480
|
function getBinaryGeometryTemplate() {
|
|
12528
12481
|
return {
|
|
12529
12482
|
globalFeatureIds: { value: new Uint32Array(0), size: 1 },
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import * as arrow from 'apache-arrow';
|
|
5
5
|
import { createWorker } from '@loaders.gl/worker-utils';
|
|
6
|
-
import { getTriangleIndices, getBinaryGeometriesFromArrow } from "../geoarrow/convert-geoarrow-to-binary-geometry.js";
|
|
6
|
+
import { getTriangleIndices, getBinaryGeometriesFromArrow } from "../lib/geoarrow/convert-geoarrow-to-binary-geometry.js";
|
|
7
7
|
createWorker(async (data, options = {}) => {
|
|
8
8
|
const input = data;
|
|
9
9
|
const operation = input?.operation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/arrow",
|
|
3
|
-
"version": "4.3.0-
|
|
3
|
+
"version": "4.3.0-beta.1",
|
|
4
4
|
"description": "Simple columnar table loader for the Apache Arrow format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"import": "./dist/index.js",
|
|
34
34
|
"require": "./dist/index.cjs"
|
|
35
|
+
},
|
|
36
|
+
"./exports/*": {
|
|
37
|
+
"types": "./dist/exports/*.d.ts",
|
|
38
|
+
"import": "./dist/exports/*.js"
|
|
35
39
|
}
|
|
36
40
|
},
|
|
37
41
|
"sideEffects": false,
|
|
@@ -53,16 +57,16 @@
|
|
|
53
57
|
"build-worker2": "esbuild src/workers/arrow-worker.ts --bundle --outfile=dist/arrow-worker.js --platform=browser --external:{stream}"
|
|
54
58
|
},
|
|
55
59
|
"dependencies": {
|
|
56
|
-
"@loaders.gl/gis": "4.3.0-
|
|
57
|
-
"@loaders.gl/loader-utils": "4.3.0-
|
|
58
|
-
"@loaders.gl/schema": "4.3.0-
|
|
59
|
-
"@loaders.gl/wkt": "4.3.0-
|
|
60
|
-
"@loaders.gl/worker-utils": "4.3.0-
|
|
61
|
-
"@math.gl/polygon": "4.
|
|
60
|
+
"@loaders.gl/gis": "4.3.0-beta.1",
|
|
61
|
+
"@loaders.gl/loader-utils": "4.3.0-beta.1",
|
|
62
|
+
"@loaders.gl/schema": "4.3.0-beta.1",
|
|
63
|
+
"@loaders.gl/wkt": "4.3.0-beta.1",
|
|
64
|
+
"@loaders.gl/worker-utils": "4.3.0-beta.1",
|
|
65
|
+
"@math.gl/polygon": "^4.1.0",
|
|
62
66
|
"apache-arrow": ">= 15.0.0"
|
|
63
67
|
},
|
|
64
68
|
"peerDependencies": {
|
|
65
69
|
"@loaders.gl/core": "^4.0.0"
|
|
66
70
|
},
|
|
67
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "992d24e7d4e3015a91fa1cbfe87ee7dc1b333322"
|
|
68
72
|
}
|
package/src/arrow-loader.ts
CHANGED
|
@@ -2,59 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
ArrowTableBatch,
|
|
9
|
-
ColumnarTable,
|
|
10
|
-
ObjectRowTable
|
|
11
|
-
} from '@loaders.gl/schema';
|
|
12
|
-
import type {ArrowTable} from './lib/arrow-table';
|
|
13
|
-
import {parseArrowSync} from './parsers/parse-arrow-sync';
|
|
14
|
-
import {parseArrowInBatches} from './parsers/parse-arrow-in-batches';
|
|
5
|
+
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {Table, ArrowTableBatch} from '@loaders.gl/schema';
|
|
7
|
+
import {parseArrowSync, parseArrowInBatches} from './lib/parsers/parse-arrow';
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
19
|
-
|
|
20
|
-
/** ArrowLoader options */
|
|
21
|
-
export type ArrowLoaderOptions = LoaderOptions & {
|
|
22
|
-
/** ArrowLoader options */
|
|
23
|
-
arrow?: {
|
|
24
|
-
/** Shape of returned data */
|
|
25
|
-
shape: 'arrow-table' | 'columnar-table' | 'array-row-table' | 'object-row-table';
|
|
26
|
-
/** Debounce time between batches (prevent excessive numbers of small batches) */
|
|
27
|
-
batchDebounceMs?: number;
|
|
28
|
-
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
29
|
-
workerUrl?: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/** ArrowJS table loader */
|
|
34
|
-
export const ArrowWorkerLoader = {
|
|
35
|
-
dataType: null as unknown as ArrowTable,
|
|
36
|
-
batchType: null as never,
|
|
37
|
-
|
|
38
|
-
name: 'Apache Arrow',
|
|
39
|
-
id: 'arrow',
|
|
40
|
-
module: 'arrow',
|
|
41
|
-
version: VERSION,
|
|
42
|
-
// worker: true,
|
|
43
|
-
category: 'table',
|
|
44
|
-
extensions: ['arrow', 'feather'],
|
|
45
|
-
mimeTypes: [
|
|
46
|
-
'application/vnd.apache.arrow.file',
|
|
47
|
-
'application/vnd.apache.arrow.stream',
|
|
48
|
-
'application/octet-stream'
|
|
49
|
-
],
|
|
50
|
-
binary: true,
|
|
51
|
-
tests: ['ARROW'],
|
|
52
|
-
options: {
|
|
53
|
-
arrow: {
|
|
54
|
-
shape: 'columnar-table'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} as const satisfies Loader<ArrowTable, never, ArrowLoaderOptions>;
|
|
9
|
+
import type {ArrowLoaderOptions} from './exports/arrow-loader';
|
|
10
|
+
import {ArrowWorkerLoader} from './exports/arrow-loader';
|
|
58
11
|
|
|
59
12
|
/** ArrowJS table loader */
|
|
60
13
|
export const ArrowLoader = {
|
|
@@ -64,8 +17,4 @@ export const ArrowLoader = {
|
|
|
64
17
|
parseSync: (arraybuffer: ArrayBuffer, options?: ArrowLoaderOptions) =>
|
|
65
18
|
parseArrowSync(arraybuffer, options?.arrow),
|
|
66
19
|
parseInBatches: parseArrowInBatches
|
|
67
|
-
} as const satisfies LoaderWithParser<
|
|
68
|
-
ArrowTable | ColumnarTable | ObjectRowTable | ArrayRowTable,
|
|
69
|
-
ArrowTableBatch,
|
|
70
|
-
ArrowLoaderOptions
|
|
71
|
-
>;
|
|
20
|
+
} as const satisfies LoaderWithParser<Table, ArrowTableBatch, ArrowLoaderOptions>;
|
package/src/arrow-writer.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// import type {} from '@loaders.gl/loader-utils';
|
|
2
2
|
|
|
3
3
|
import type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';
|
|
4
|
-
import {ColumnarTable} from './lib/encode-arrow';
|
|
5
|
-
import {encodeArrowSync} from './lib/encode-arrow';
|
|
4
|
+
import {ColumnarTable, encodeArrowSync} from './lib/encoders/encode-arrow';
|
|
6
5
|
|
|
7
6
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
7
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|