@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.
- 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 +1863 -1768
- 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 +13 -5
- package/dist/workers/triangulation-worker.js +1 -1
- package/package.json +11 -7
- 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-
|
|
7
|
+
const VERSION = typeof "4.3.0-beta.1" !== 'undefined' ? "4.3.0-beta.1" : '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 {
|
|
@@ -12444,7 +12452,7 @@ return true;`);
|
|
|
12444
12452
|
}
|
|
12445
12453
|
};
|
|
12446
12454
|
|
|
12447
|
-
// src/geoarrow/get-arrow-bounds.ts
|
|
12455
|
+
// src/lib/geoarrow/get-arrow-bounds.ts
|
|
12448
12456
|
function updateBoundsFromGeoArrowSamples(flatCoords, nDim, bounds, sampleSize = 100) {
|
|
12449
12457
|
const numberOfFeatures = flatCoords.length / nDim;
|
|
12450
12458
|
const sampleStep = Math.max(Math.floor(numberOfFeatures / sampleSize), 1);
|
|
@@ -12468,7 +12476,7 @@ return true;`);
|
|
|
12468
12476
|
return newBounds;
|
|
12469
12477
|
}
|
|
12470
12478
|
|
|
12471
|
-
// src/geoarrow/convert-geoarrow-to-binary-geometry.ts
|
|
12479
|
+
// src/lib/geoarrow/convert-geoarrow-to-binary-geometry.ts
|
|
12472
12480
|
function getBinaryGeometryTemplate() {
|
|
12473
12481
|
return {
|
|
12474
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.2",
|
|
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-
|
|
60
|
+
"@loaders.gl/gis": "4.3.0-beta.2",
|
|
61
|
+
"@loaders.gl/loader-utils": "4.3.0-beta.2",
|
|
62
|
+
"@loaders.gl/schema": "4.3.0-beta.2",
|
|
63
|
+
"@loaders.gl/wkt": "4.3.0-beta.2",
|
|
64
|
+
"@loaders.gl/worker-utils": "4.3.0-beta.2",
|
|
61
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": "a61003f2bb56acbdaef07a03bc39d4c7830afdcc"
|
|
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__'.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {ArrowTable} from '../schema/arrow-table-type';
|
|
7
|
+
|
|
8
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
9
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
10
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
11
|
+
|
|
12
|
+
/** ArrowLoader options */
|
|
13
|
+
export type ArrowLoaderOptions = LoaderOptions & {
|
|
14
|
+
/** ArrowLoader options */
|
|
15
|
+
arrow?: {
|
|
16
|
+
/** Shape of returned data */
|
|
17
|
+
shape: 'arrow-table' | 'columnar-table' | 'array-row-table' | 'object-row-table';
|
|
18
|
+
/** Debounce time between batches (prevent excessive numbers of small batches) */
|
|
19
|
+
batchDebounceMs?: number;
|
|
20
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
21
|
+
workerUrl?: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** ArrowJS table loader */
|
|
26
|
+
export const ArrowWorkerLoader = {
|
|
27
|
+
dataType: null as unknown as ArrowTable,
|
|
28
|
+
batchType: null as never,
|
|
29
|
+
|
|
30
|
+
name: 'Apache Arrow',
|
|
31
|
+
id: 'arrow',
|
|
32
|
+
module: 'arrow',
|
|
33
|
+
version: VERSION,
|
|
34
|
+
// worker: true,
|
|
35
|
+
category: 'table',
|
|
36
|
+
extensions: ['arrow', 'feather'],
|
|
37
|
+
mimeTypes: [
|
|
38
|
+
'application/vnd.apache.arrow.file',
|
|
39
|
+
'application/vnd.apache.arrow.stream',
|
|
40
|
+
'application/octet-stream'
|
|
41
|
+
],
|
|
42
|
+
binary: true,
|
|
43
|
+
tests: ['ARROW'],
|
|
44
|
+
options: {
|
|
45
|
+
arrow: {
|
|
46
|
+
shape: 'columnar-table'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} as const satisfies Loader<ArrowTable, never, ArrowLoaderOptions>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
6
|
+
import {ArrowWorkerLoader} from './arrow-loader';
|
|
7
|
+
import type {BinaryGeometry} from '@loaders.gl/schema';
|
|
8
|
+
import type {ArrowTable, ArrowTableBatch} from '../schema/arrow-table-type';
|
|
9
|
+
|
|
10
|
+
export type GeoArrowLoaderOptions = LoaderOptions & {
|
|
11
|
+
arrow?: {
|
|
12
|
+
shape?: 'arrow-table' | 'binary-geometry';
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** ArrowJS table loader */
|
|
17
|
+
export const GeoArrowWorkerLoader = {
|
|
18
|
+
...ArrowWorkerLoader,
|
|
19
|
+
options: {
|
|
20
|
+
arrow: {
|
|
21
|
+
shape: 'arrow-table'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} as const satisfies Loader<ArrowTable | BinaryGeometry, ArrowTableBatch, GeoArrowLoaderOptions>;
|
package/src/geoarrow-loader.ts
CHANGED
|
@@ -2,28 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
7
|
-
import type {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
export type GeoArrowLoaderOptions = LoaderOptions & {
|
|
13
|
-
arrow?: {
|
|
14
|
-
shape?: 'arrow-table' | 'binary-geometry';
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/** ArrowJS table loader */
|
|
19
|
-
export const GeoArrowWorkerLoader = {
|
|
20
|
-
...ArrowWorkerLoader,
|
|
21
|
-
options: {
|
|
22
|
-
arrow: {
|
|
23
|
-
shape: 'arrow-table'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
} as const satisfies Loader<ArrowTable | BinaryGeometry, never, GeoArrowLoaderOptions>;
|
|
5
|
+
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {GeoJSONTable, GeoJSONTableBatch} from '@loaders.gl/schema';
|
|
7
|
+
import type {ArrowTable, ArrowTableBatch} from './schema/arrow-table-type';
|
|
8
|
+
import {parseGeoArrowSync, parseGeoArrowInBatches} from './lib/parsers/parse-geoarrow';
|
|
9
|
+
import type {GeoArrowLoaderOptions} from './exports/geoarrow-loader';
|
|
10
|
+
import {GeoArrowWorkerLoader} from './exports/geoarrow-loader';
|
|
27
11
|
|
|
28
12
|
/**
|
|
29
13
|
* GeoArrowLoader loads an Apache Arrow table, parses GeoArrow type extension data
|
package/src/geoarrow-writer.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';
|
|
4
4
|
import {GeoJSONTable, BinaryGeometry} from '@loaders.gl/schema';
|
|
5
|
-
import {encodeGeoArrowSync} from './lib/encode-geoarrow';
|
|
5
|
+
import {encodeGeoArrowSync} from './lib/encoders/encode-geoarrow';
|
|
6
6
|
|
|
7
7
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
8
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|