@loaders.gl/core 5.0.0-beta.10 → 5.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SCAN-README.md +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs +1 -5
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts +4 -3
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js +2 -6
- package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
- package/dist/arrow-geometry/feature-table.cjs +2 -10
- package/dist/arrow-geometry/feature-table.cjs.map +2 -2
- package/dist/arrow-geometry/feature-table.d.ts +6 -5
- package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-table.js +5 -13
- package/dist/arrow-geometry/feature-table.js.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.cjs +1 -5
- package/dist/arrow-geometry/wkb-arrow-utils.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts +7 -7
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.js +4 -8
- package/dist/arrow-geometry/wkb-arrow-utils.js.map +1 -1
- package/dist/arrow-worker-transport.cjs +7 -75
- package/dist/arrow-worker-transport.cjs.map +1 -1
- package/dist/arrow-worker-transport.d.ts +3 -7
- package/dist/arrow-worker-transport.d.ts.map +1 -1
- package/dist/arrow-worker-transport.js +15 -89
- package/dist/arrow-worker-transport.js.map +1 -1
- package/dist/cluster-source.cjs +12 -12
- package/dist/cluster-source.cjs.map +1 -1
- package/dist/dist.dev.js +71 -60
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +87 -125
- package/dist/federated-table-scan-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.cjs +12 -12
- package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts +3 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.js +12 -14
- package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.cjs +4 -12
- package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts +5 -5
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.js +6 -14
- package/dist/geoarrow/convert-table-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +2 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +3 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js +2 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js.map +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs +10 -11
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-stream.js +9 -12
- package/dist/geoarrow/geoarrow-stream.js.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.cjs.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js +3 -3
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs.map +2 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +5 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
- package/dist/index.cjs +69 -54
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +2 -4
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/loader-options.d.ts +6 -0
- package/dist/lib/api/loader-options.d.ts.map +1 -1
- package/dist/lib/api/loader-options.js +48 -0
- package/dist/lib/api/loader-options.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +2 -5
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.js +6 -10
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +2 -5
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +2 -5
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +5 -8
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -1
- package/dist/lib/loader-utils/native-arrow.js +13 -31
- package/dist/lib/loader-utils/native-arrow.js.map +1 -1
- package/dist/loader-utils/index.cjs +27 -22
- package/dist/loader-utils/index.cjs.map +1 -1
- package/dist/loader-utils/index.d.ts +1 -1
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +6 -2
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +15 -12
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +36 -22
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +2 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -3
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +3 -5
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +4 -4
- package/dist/scan/arrow-execution/expressions.cjs.map +2 -2
- package/dist/scan/arrow-execution/expressions.d.ts +4 -4
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/arrow-execution/expressions.js +4 -4
- package/dist/scan/arrow-execution/expressions.js.map +1 -1
- package/dist/scan/arrow-query-worker-entry.cjs +121 -0
- package/dist/scan/arrow-query-worker-entry.cjs.map +7 -0
- package/dist/scan/arrow-query-worker-entry.d.ts +2 -0
- package/dist/scan/arrow-query-worker-entry.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker-entry.js +7 -0
- package/dist/scan/arrow-query-worker-entry.js.map +1 -0
- package/dist/scan/arrow-query-worker.cjs +197 -0
- package/dist/scan/arrow-query-worker.cjs.map +7 -0
- package/dist/scan/arrow-query-worker.d.ts +47 -0
- package/dist/scan/arrow-query-worker.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker.js +101 -0
- package/dist/scan/arrow-query-worker.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +12 -13
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +14 -15
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +5 -2
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +2 -1
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +2 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +2 -2
- package/dist/scan/parse-sql-predicate.cjs.map +2 -2
- package/dist/scan/parse-sql-predicate.js +1 -1
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-pushdown.cjs +6 -6
- package/dist/scan/query-pushdown.cjs.map +2 -2
- package/dist/scan/query-pushdown.d.ts +1 -1
- package/dist/scan/query-pushdown.d.ts.map +1 -1
- package/dist/scan/query-pushdown.js +3 -6
- package/dist/scan/query-pushdown.js.map +1 -1
- package/dist/scan/query-scales.cjs +140 -0
- package/dist/scan/query-scales.cjs.map +7 -0
- package/dist/scan/query-scales.d.ts +35 -0
- package/dist/scan/query-scales.d.ts.map +1 -0
- package/dist/scan/query-scales.js +120 -0
- package/dist/scan/query-scales.js.map +1 -0
- package/dist/scan/query.cjs +49 -45
- package/dist/scan/query.cjs.map +2 -2
- package/dist/scan/query.d.ts +7 -4
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +35 -52
- package/dist/scan/query.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +19 -13
- package/dist/scan/vector-table-scan-source.cjs.map +3 -3
- package/dist/scan/vector-table-scan-source.d.ts +3 -4
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +11 -12
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema/categories/category-mesh.d.ts +3 -10
- package/dist/schema/categories/category-mesh.d.ts.map +1 -1
- package/dist/schema/categories/category-mesh.js.map +1 -1
- package/dist/schema/categories/category-table.d.ts +2 -19
- package/dist/schema/categories/category-table.d.ts.map +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts.map +1 -1
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/types/batch.d.ts +0 -4
- package/dist/schema/types/batch.d.ts.map +1 -1
- package/dist/schema-utils/index.cjs +419 -502
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +4 -5
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +4 -5
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +4 -5
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +21 -18
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +6 -11
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js +8 -21
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts +4 -4
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js +13 -15
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts +2 -2
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts +2 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +3 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.js +5 -8
- package/dist/schema-utils/lib/table/batches/convert-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js +2 -6
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js +4 -24
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +3 -6
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js +6 -57
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.js +2 -2
- package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.js +2 -16
- package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +2 -2
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js +4 -4
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.d.ts +1 -3
- package/dist/schema-utils/lib/table/tables/table-types.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.js +0 -4
- package/dist/schema-utils/lib/table/tables/table-types.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +16 -10
- package/dist/vector-table-scan-source.cjs.map +2 -2
- package/dist/worker-utils/index.cjs +2 -2
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/package.json +23 -8
- package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -8
- package/src/arrow-geometry/feature-table.ts +8 -21
- package/src/arrow-geometry/wkb-arrow-utils.ts +8 -12
- package/src/arrow-worker-transport.ts +21 -120
- package/src/geoarrow/clustering/cluster-source.ts +16 -23
- package/src/geoarrow/convert-table-to-geoarrow.ts +11 -23
- package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +2 -2
- package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +2 -4
- package/src/geoarrow/geoarrow-stream.ts +15 -15
- package/src/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.ts +3 -3
- package/src/geoarrow/lib/table-converters/convert-geoarrow-table.ts +7 -5
- package/src/index.ts +1 -1
- package/src/lib/api/load.ts +2 -12
- package/src/lib/api/loader-options.ts +69 -0
- package/src/lib/api/parse-file.ts +2 -11
- package/src/lib/api/parse-in-batches.ts +8 -12
- package/src/lib/api/parse-sync.ts +3 -7
- package/src/lib/api/parse.ts +2 -6
- package/src/lib/loader-utils/native-arrow.ts +12 -38
- package/src/loader-utils/index.ts +0 -1
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +7 -6
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +64 -41
- package/src/loader-utils/lib/sources/table-source-collection.ts +2 -1
- package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -9
- package/src/loader-utils/loader-types.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +7 -7
- package/src/scan/arrow-query-worker-entry.ts +8 -0
- package/src/scan/arrow-query-worker.ts +158 -0
- package/src/scan/federated-table-scan-source.ts +15 -18
- package/src/scan/index.ts +7 -1
- package/src/scan/parse-sql-predicate.ts +1 -1
- package/src/scan/query-pushdown.ts +7 -7
- package/src/scan/query-scales.ts +199 -0
- package/src/scan/query.ts +68 -71
- package/src/scan/vector-table-scan-source.ts +16 -21
- package/src/schema/categories/category-mesh.ts +3 -11
- package/src/schema/categories/category-table.ts +2 -28
- package/src/schema/geometry/arrow-binary-features.ts +1 -1
- package/src/schema/index.ts +1 -3
- package/src/schema/types/batch.ts +0 -5
- package/src/schema-utils/index.ts +4 -10
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +33 -30
- package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +12 -38
- package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +15 -18
- package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +4 -13
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/arrow-api/arrow-like-table.ts +10 -9
- package/src/schema-utils/lib/table/batches/convert-batches.ts +5 -8
- package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +2 -6
- package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +5 -27
- package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +9 -72
- package/src/schema-utils/lib/table/tables/make-table.ts +2 -2
- package/src/schema-utils/lib/table/tables/table-accessors.ts +2 -22
- package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +6 -6
- package/src/schema-utils/lib/table/tables/table-types.ts +1 -7
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +0 -27
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +0 -23
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +0 -1
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +0 -54
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
6
|
import {
|
|
7
|
+
createRecordBatchWithMetadata,
|
|
8
|
+
getRecordBatchMetadata,
|
|
7
9
|
dehydrateArrowTable,
|
|
8
10
|
dehydrateArrowRecordBatch,
|
|
9
11
|
hydrateArrowTable,
|
|
@@ -14,7 +16,7 @@ import {
|
|
|
14
16
|
/** Per-batch metadata transferred alongside math.gl's column payload. */
|
|
15
17
|
type BatchMetadata = {
|
|
16
18
|
schema: Uint8Array;
|
|
17
|
-
metadata
|
|
19
|
+
metadata?: [string, string][];
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
type ArrowWorkerOptions = {
|
|
@@ -27,45 +29,6 @@ type ArrowWorkerColumns = {
|
|
|
27
29
|
arrowBatchMetadata?: BatchMetadata[];
|
|
28
30
|
};
|
|
29
31
|
|
|
30
|
-
/** Wire payload for callers that still carry format-specific side metadata. */
|
|
31
|
-
type ArrowWorkerEnvelope = ArrowWorkerColumns & {
|
|
32
|
-
transport: 'arrow-column-envelope';
|
|
33
|
-
metadata: Record<string, unknown>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/** Previous envelope accepted during hydration for workers built against older releases. */
|
|
37
|
-
type LegacyArrowWorkerEnvelope = ArrowWorkerColumns & {
|
|
38
|
-
shape: 'arrow-table';
|
|
39
|
-
[key: string]: unknown;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/** Serializes Arrow columns with owned buffers so transfers cannot detach retained parser state. */
|
|
43
|
-
export function serializeArrowWorkerTable(result: unknown): unknown {
|
|
44
|
-
if (!isArrowTableWrapper(result)) {
|
|
45
|
-
throw new Error('Workers require Arrow table output');
|
|
46
|
-
}
|
|
47
|
-
const {data, shape: _shape, ...metadata} = result;
|
|
48
|
-
// Headers, sidecar indexes, and mesh indices can also retain parser-owned binary buffers.
|
|
49
|
-
// Clone only this small envelope; the Arrow table always uses column-buffer transfer.
|
|
50
|
-
return {
|
|
51
|
-
transport: 'arrow-column-envelope',
|
|
52
|
-
metadata: structuredClone(metadata),
|
|
53
|
-
...serializeWorkerColumns(data, {copy: 'all'})
|
|
54
|
-
} satisfies ArrowWorkerEnvelope;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Hydrates the column-buffer worker protocol; other wire formats are rejected. */
|
|
58
|
-
export function deserializeArrowWorkerTable(result: unknown): any {
|
|
59
|
-
if (isArrowWorkerEnvelope(result)) {
|
|
60
|
-
return {...result.metadata, shape: 'arrow-table', data: hydrateWorkerTable(result)};
|
|
61
|
-
}
|
|
62
|
-
if (isLegacyArrowWorkerEnvelope(result)) {
|
|
63
|
-
const {arrowBatchMetadata: _snapshots, data: _columns, ...metadata} = result;
|
|
64
|
-
return {...metadata, data: hydrateWorkerTable(result)};
|
|
65
|
-
}
|
|
66
|
-
throw new Error('Workers require Arrow column transport');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
32
|
/** Serializes a native Arrow table or batch with owned column buffers for worker transport. */
|
|
70
33
|
export function serializeNativeArrowWorkerResult(
|
|
71
34
|
result: arrow.Table | arrow.RecordBatch,
|
|
@@ -101,47 +64,24 @@ export function deserializeNativeArrowWorkerResult(
|
|
|
101
64
|
return payload.transport === 'arrow-record-batch' ? data.batches[0] : data;
|
|
102
65
|
}
|
|
103
66
|
|
|
104
|
-
/**
|
|
67
|
+
/** Transfers native Arrow columns and passes other loader results through. */
|
|
105
68
|
export function serializeArrowWorkerResult(result: unknown, options?: unknown): unknown {
|
|
106
69
|
const workerOptions = options as ArrowWorkerOptions | undefined;
|
|
107
|
-
const
|
|
70
|
+
const copy =
|
|
108
71
|
workerOptions?.core?.workerTransferBufferCopy ?? workerOptions?.workerTransferBufferCopy;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
if (!isArrowTableWrapper(result)) {
|
|
113
|
-
return result;
|
|
114
|
-
}
|
|
115
|
-
const {data, shape: _shape, ...metadata} = result;
|
|
116
|
-
return {
|
|
117
|
-
transport: 'arrow-column-envelope',
|
|
118
|
-
metadata: structuredClone(metadata),
|
|
119
|
-
...serializeWorkerColumns(data, bufferCopyMode ? {copy: bufferCopyMode} : undefined)
|
|
120
|
-
} satisfies ArrowWorkerEnvelope;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/** Rehydrates any loaders.gl Arrow table wrapper returned from worker postMessage transport. */
|
|
124
|
-
export function deserializeArrowWorkerResult(result: unknown): any {
|
|
125
|
-
const transport = (result as {transport?: string} | null)?.transport;
|
|
126
|
-
if (transport === 'arrow-table-columns' || transport === 'arrow-record-batch') {
|
|
127
|
-
return deserializeNativeArrowWorkerResult(result);
|
|
128
|
-
}
|
|
129
|
-
return isArrowWorkerEnvelope(result) || isLegacyArrowWorkerEnvelope(result)
|
|
130
|
-
? deserializeArrowWorkerTable(result)
|
|
72
|
+
return result instanceof arrow.Table || result instanceof arrow.RecordBatch
|
|
73
|
+
? serializeNativeArrowWorkerResult(result, {copy: copy ?? 'all'})
|
|
131
74
|
: result;
|
|
132
75
|
}
|
|
133
76
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
typeof table.data === 'object' &&
|
|
143
|
-
'batches' in table.data
|
|
144
|
-
);
|
|
77
|
+
/** Restores native Arrow worker results and passes other loader results through. */
|
|
78
|
+
export function deserializeArrowWorkerResult<ResultType = unknown>(result: unknown): ResultType {
|
|
79
|
+
const transport = (result as {transport?: string} | null)?.transport;
|
|
80
|
+
return (
|
|
81
|
+
transport === 'arrow-table-columns' || transport === 'arrow-record-batch'
|
|
82
|
+
? deserializeNativeArrowWorkerResult(result)
|
|
83
|
+
: result
|
|
84
|
+
) as ResultType;
|
|
145
85
|
}
|
|
146
86
|
|
|
147
87
|
/** Recognizes a transferable Arrow columns descriptor. */
|
|
@@ -150,22 +90,6 @@ function hasArrowWorkerColumns(value: unknown): value is ArrowWorkerColumns {
|
|
|
150
90
|
return columns?.data?.transport === 'arrow-js' && Array.isArray(columns.data.batches);
|
|
151
91
|
}
|
|
152
92
|
|
|
153
|
-
/** Recognizes payloads carrying format-specific metadata. */
|
|
154
|
-
function isArrowWorkerEnvelope(value: unknown): value is ArrowWorkerEnvelope {
|
|
155
|
-
return (
|
|
156
|
-
(value as ArrowWorkerEnvelope | null)?.transport === 'arrow-column-envelope' &&
|
|
157
|
-
hasArrowWorkerColumns(value)
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** Recognizes wrapped column payloads from older workers. */
|
|
162
|
-
function isLegacyArrowWorkerEnvelope(value: unknown): value is LegacyArrowWorkerEnvelope {
|
|
163
|
-
return (
|
|
164
|
-
(value as LegacyArrowWorkerEnvelope | null)?.shape === 'arrow-table' &&
|
|
165
|
-
hasArrowWorkerColumns(value)
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
93
|
/** Serializes columns and independent batch metadata. */
|
|
170
94
|
function serializeWorkerColumns(
|
|
171
95
|
table: arrow.Table,
|
|
@@ -173,29 +97,14 @@ function serializeWorkerColumns(
|
|
|
173
97
|
): ArrowWorkerColumns {
|
|
174
98
|
return {
|
|
175
99
|
arrowBatchMetadata: snapshotBatchMetadata(table),
|
|
176
|
-
data:
|
|
100
|
+
data: dehydrateArrowTable(table, options)
|
|
177
101
|
};
|
|
178
102
|
}
|
|
179
103
|
|
|
180
|
-
/**
|
|
181
|
-
function dehydrateWorkerTable(
|
|
182
|
-
table: arrow.Table,
|
|
183
|
-
options?: SplitArrowBuffersOptions
|
|
184
|
-
): DehydratedArrowTable {
|
|
185
|
-
const payload = dehydrateArrowTable(table, options);
|
|
186
|
-
if (table.numCols === 0) {
|
|
187
|
-
for (const [index, batch] of table.batches.entries()) {
|
|
188
|
-
payload.batches[index].length = batch.numRows;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return payload;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/** Captures batch schemas and custom metadata before transferring column buffers. */
|
|
104
|
+
/** Captures batch schemas before transferring column buffers. */
|
|
195
105
|
function snapshotBatchMetadata(table: arrow.Table): BatchMetadata[] {
|
|
196
106
|
return table.batches.map(batch => ({
|
|
197
|
-
schema: arrow.tableToIPC(new arrow.Table(batch.schema, []))
|
|
198
|
-
metadata: Array.from(batch.metadata)
|
|
107
|
+
schema: arrow.tableToIPC(new arrow.Table(batch.schema, []))
|
|
199
108
|
}));
|
|
200
109
|
}
|
|
201
110
|
|
|
@@ -205,21 +114,13 @@ function hydrateWorkerTable(result: ArrowWorkerColumns): arrow.Table {
|
|
|
205
114
|
const table = hydrateArrowTable(data);
|
|
206
115
|
const batches = table.batches.map((batch, index) => {
|
|
207
116
|
const snapshot = arrowBatchMetadata?.[index];
|
|
208
|
-
|
|
209
|
-
?
|
|
117
|
+
return snapshot
|
|
118
|
+
? createRecordBatchWithMetadata(
|
|
210
119
|
arrow.tableFromIPC(snapshot.schema).schema,
|
|
211
120
|
batch.data,
|
|
212
|
-
new Map(snapshot.metadata)
|
|
121
|
+
snapshot.metadata ? new Map(snapshot.metadata) : getRecordBatchMetadata(batch)
|
|
213
122
|
)
|
|
214
123
|
: batch;
|
|
215
|
-
// Arrow JS derives the length of a struct from its children, which can be empty.
|
|
216
|
-
const rowCount = data.batches[index].length;
|
|
217
|
-
if (restored.numCols === 0 && restored.numRows !== rowCount) {
|
|
218
|
-
Object.defineProperty(restored, 'data', {
|
|
219
|
-
value: new arrow.Data(new arrow.Struct([]), 0, rowCount, 0, undefined, [])
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
return restored;
|
|
223
124
|
});
|
|
224
125
|
return new arrow.Table(table.schema, batches);
|
|
225
126
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import type {Table} from 'apache-arrow';
|
|
5
6
|
import {DataSource} from '@loaders.gl/core/loader-utils';
|
|
6
7
|
import type {
|
|
7
8
|
GetFeaturesParameters,
|
|
@@ -10,7 +11,6 @@ import type {
|
|
|
10
11
|
VectorSourceMetadata
|
|
11
12
|
} from '@loaders.gl/core/loader-utils';
|
|
12
13
|
import type {
|
|
13
|
-
ArrowTable,
|
|
14
14
|
Feature,
|
|
15
15
|
GeoArrowEncoding,
|
|
16
16
|
GeoJSONTable,
|
|
@@ -42,7 +42,7 @@ import {getRepresentativePoint, type RepresentativePointStrategy} from './get-re
|
|
|
42
42
|
* Complete materialized input; remote viewport subsets must be collected before indexing.
|
|
43
43
|
* @experimental
|
|
44
44
|
*/
|
|
45
|
-
export type ClusterSourceData = GeoJSONTable |
|
|
45
|
+
export type ClusterSourceData = GeoJSONTable | Table;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Cluster source construction options; inputs must use longitude/latitude.
|
|
@@ -99,30 +99,25 @@ export class ClusterSource extends DataSource<ClusterSourceData, {}> implements
|
|
|
99
99
|
super(data, {});
|
|
100
100
|
const positions: number[] = [];
|
|
101
101
|
const rowIndices: number[] = [];
|
|
102
|
-
if (
|
|
103
|
-
const columns = getGeometryColumnsFromSchema(data.
|
|
102
|
+
if (!('shape' in data)) {
|
|
103
|
+
const columns = getGeometryColumnsFromSchema(data.schema);
|
|
104
104
|
const columnNames = Object.keys(columns);
|
|
105
105
|
this.geometryColumn =
|
|
106
106
|
options.geometryColumn ?? (columnNames.length === 1 ? columnNames[0] : undefined);
|
|
107
107
|
this.geometryEncoding = this.geometryColumn
|
|
108
108
|
? columns[this.geometryColumn]?.encoding
|
|
109
109
|
: undefined;
|
|
110
|
-
if (
|
|
111
|
-
!this.geometryColumn ||
|
|
112
|
-
!this.geometryEncoding ||
|
|
113
|
-
!data.data.getChild(this.geometryColumn)
|
|
114
|
-
) {
|
|
110
|
+
if (!this.geometryColumn || !this.geometryEncoding || !data.getChild(this.geometryColumn)) {
|
|
115
111
|
throw new Error('ClusterSource requires an explicitly identified GeoArrow geometry column');
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
|
-
const geometryVector =
|
|
119
|
-
data.shape === 'arrow-table' ? data.data.getChild(this.geometryColumn!)! : null;
|
|
114
|
+
const geometryVector = !('shape' in data) ? data.getChild(this.geometryColumn!)! : null;
|
|
120
115
|
// Native point bounds read Arrow buffers directly, including chunks, slices and nulls.
|
|
121
116
|
const pointBounds =
|
|
122
117
|
geometryVector && this.geometryEncoding === 'geoarrow.point' && !options.getClusterPosition
|
|
123
118
|
? getGeoArrowRowBounds(geometryVector, this.geometryEncoding)
|
|
124
119
|
: null;
|
|
125
|
-
const rowCount =
|
|
120
|
+
const rowCount = !('shape' in data) ? data.numRows : data.features.length;
|
|
126
121
|
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
127
122
|
let position: readonly [number, number] | null;
|
|
128
123
|
if (pointBounds) {
|
|
@@ -144,12 +139,11 @@ export class ClusterSource extends DataSource<ClusterSourceData, {}> implements
|
|
|
144
139
|
if (['cluster', 'clusterId', 'pointCount', 'rowIndex', 'geometry'].includes(name)) {
|
|
145
140
|
throw new Error(`Reserved cluster property: ${name}`);
|
|
146
141
|
}
|
|
147
|
-
const column =
|
|
142
|
+
const column = !('shape' in data) ? data.getChild(aggregation.column) : null;
|
|
148
143
|
const values = rowIndices.map(rowIndex => {
|
|
149
|
-
const value =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
: data.features[rowIndex].properties?.[aggregation.column];
|
|
144
|
+
const value = !('shape' in data)
|
|
145
|
+
? column?.get(rowIndex)
|
|
146
|
+
: data.features[rowIndex].properties?.[aggregation.column];
|
|
153
147
|
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
154
148
|
throw new Error(`Cluster aggregation ${name} requires finite numeric values`);
|
|
155
149
|
return value;
|
|
@@ -239,22 +233,21 @@ export class ClusterSource extends DataSource<ClusterSourceData, {}> implements
|
|
|
239
233
|
|
|
240
234
|
/** Retrieves a member's original geometry and properties; Arrow rows are materialized on demand. */
|
|
241
235
|
getFeature(rowIndex: number): Feature<Geometry | null> {
|
|
242
|
-
const rowCount =
|
|
243
|
-
this.data.shape === 'arrow-table' ? this.data.data.numRows : this.data.features.length;
|
|
236
|
+
const rowCount = !('shape' in this.data) ? this.data.numRows : this.data.features.length;
|
|
244
237
|
if (!Number.isInteger(rowIndex) || rowIndex < 0 || rowIndex >= rowCount)
|
|
245
238
|
throw new Error('Invalid cluster source row');
|
|
246
|
-
if (this.data
|
|
247
|
-
const properties = {...this.data.
|
|
239
|
+
if ('shape' in this.data) return this.data.features[rowIndex];
|
|
240
|
+
const properties = {...this.data.get(rowIndex)!.toJSON()};
|
|
248
241
|
delete properties[this.geometryColumn!];
|
|
249
242
|
return {type: 'Feature', geometry: this.getGeometry(rowIndex), properties};
|
|
250
243
|
}
|
|
251
244
|
|
|
252
245
|
/** Decodes one geometry only when extraction or member retrieval needs it. */
|
|
253
246
|
private getGeometry(rowIndex: number): Geometry | null {
|
|
254
|
-
return this.data
|
|
247
|
+
return 'shape' in this.data
|
|
255
248
|
? this.data.features[rowIndex].geometry
|
|
256
249
|
: convertGeoArrowVectorCellToGeoJSON(
|
|
257
|
-
this.data.
|
|
250
|
+
this.data.getChild(this.geometryColumn!)!,
|
|
258
251
|
rowIndex,
|
|
259
252
|
this.geometryEncoding!
|
|
260
253
|
);
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
convertFeaturesToGeoArrowTable as convertGISFeaturesToGeoArrowTable
|
|
8
8
|
} from '@loaders.gl/core/arrow-geometry/feature-table';
|
|
9
9
|
import type {
|
|
10
|
-
ArrowTable,
|
|
11
10
|
Feature,
|
|
12
11
|
Geometry,
|
|
13
12
|
GeoArrowEncodingPreference,
|
|
@@ -53,17 +52,14 @@ export function convertTableToGeoArrow(
|
|
|
53
52
|
if (!('shape' in table)) return convertArrowTableToGeoArrow(table, encoding, options);
|
|
54
53
|
|
|
55
54
|
switch (table.shape) {
|
|
56
|
-
case 'arrow-table':
|
|
57
|
-
return convertArrowTableToGeoArrow(table.data, encoding, options);
|
|
58
|
-
|
|
59
55
|
case 'geojson-table':
|
|
60
|
-
return convertFeatureCollectionToGeoArrowTable(table, options)
|
|
56
|
+
return convertFeatureCollectionToGeoArrowTable(table, options);
|
|
61
57
|
|
|
62
58
|
default:
|
|
63
59
|
if (encoding) {
|
|
64
60
|
const featureTable = convertGenericGeometryTable(table, options);
|
|
65
61
|
if (featureTable) {
|
|
66
|
-
return featureTable
|
|
62
|
+
return featureTable;
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
65
|
return convertArrowTableToGeoArrow(convertTableToArrow(table, options), encoding, options);
|
|
@@ -71,46 +67,40 @@ export function convertTableToGeoArrow(
|
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
/**
|
|
74
|
-
* Converts a GeoJSON feature collection table to
|
|
70
|
+
* Converts a GeoJSON feature collection table to an Apache Arrow table with GeoArrow geometry metadata.
|
|
75
71
|
*/
|
|
76
72
|
export function convertFeatureCollectionToGeoArrowTable(
|
|
77
73
|
table: GeoJSONTable,
|
|
78
74
|
options?: GeoArrowConvertFromOptions
|
|
79
|
-
):
|
|
75
|
+
): arrow.Table {
|
|
80
76
|
const encoding = resolveGeoArrowEncoding(options);
|
|
81
77
|
const arrowTable = convertGISFeatureCollectionToGeoArrowTable(table, {
|
|
82
78
|
encoding: getGeoJSONStagingEncoding(encoding),
|
|
83
79
|
geometryColumnName: options?.geoarrow?.geometryColumnName
|
|
84
80
|
});
|
|
85
|
-
return
|
|
86
|
-
shape: 'arrow-table',
|
|
87
|
-
data: convertGeoJSONArrowTableToTarget(arrowTable.data, encoding, options)
|
|
88
|
-
};
|
|
81
|
+
return convertGeoJSONArrowTableToTarget(arrowTable, encoding, options);
|
|
89
82
|
}
|
|
90
83
|
|
|
91
84
|
/**
|
|
92
|
-
* Converts GeoJSON features into
|
|
85
|
+
* Converts GeoJSON features into an Apache Arrow table with GeoArrow geometry metadata.
|
|
93
86
|
*/
|
|
94
87
|
export function convertFeaturesToGeoArrowTable(
|
|
95
88
|
features: Feature[],
|
|
96
89
|
options?: GeoArrowConvertFromOptions
|
|
97
|
-
):
|
|
90
|
+
): arrow.Table {
|
|
98
91
|
const encoding = resolveGeoArrowEncoding(options);
|
|
99
92
|
const arrowTable = convertGISFeaturesToGeoArrowTable(features, {
|
|
100
93
|
encoding: getGeoJSONStagingEncoding(encoding),
|
|
101
94
|
geometryColumnName: options?.geoarrow?.geometryColumnName
|
|
102
95
|
});
|
|
103
|
-
return
|
|
104
|
-
shape: 'arrow-table',
|
|
105
|
-
data: convertGeoJSONArrowTableToTarget(arrowTable.data, encoding, options)
|
|
106
|
-
};
|
|
96
|
+
return convertGeoJSONArrowTableToTarget(arrowTable, encoding, options);
|
|
107
97
|
}
|
|
108
98
|
|
|
109
99
|
/** Converts generic row and column tables when they contain GeoJSON geometry values. */
|
|
110
100
|
function convertGenericGeometryTable(
|
|
111
|
-
table: Exclude<Table,
|
|
101
|
+
table: Exclude<Table, GeoJSONTable>,
|
|
112
102
|
options?: GeoArrowConvertFromOptions
|
|
113
|
-
):
|
|
103
|
+
): arrow.Table | null {
|
|
114
104
|
const geometryColumn = options?.geoarrow?.geometryColumn || 'geometry';
|
|
115
105
|
const rows = getGenericTableRows(table);
|
|
116
106
|
if (!rows.some(row => isGeoJSONGeometry(row[geometryColumn]))) {
|
|
@@ -138,9 +128,7 @@ function convertGenericGeometryTable(
|
|
|
138
128
|
}
|
|
139
129
|
|
|
140
130
|
/** Materializes generic table rows for the opt-in geometry adaptation path. */
|
|
141
|
-
function getGenericTableRows(
|
|
142
|
-
table: Exclude<Table, ArrowTable | GeoJSONTable>
|
|
143
|
-
): Record<string, unknown>[] {
|
|
131
|
+
function getGenericTableRows(table: Exclude<Table, GeoJSONTable>): Record<string, unknown>[] {
|
|
144
132
|
switch (table.shape) {
|
|
145
133
|
case 'object-row-table':
|
|
146
134
|
return table.data as Record<string, unknown>[];
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
import {
|
|
14
14
|
convertArrowToSchema,
|
|
15
15
|
convertArrowToTable,
|
|
16
|
-
|
|
16
|
+
isArrowTable
|
|
17
17
|
} from '@loaders.gl/core/schema-utils';
|
|
18
18
|
import {convertGeoArrowToTable} from '../lib/table-converters/convert-geoarrow-table';
|
|
19
19
|
import {convertTableToGeoArrow} from '../convert-table-to-geoarrow';
|
|
@@ -44,7 +44,7 @@ export function convertGeoArrow(
|
|
|
44
44
|
| 'arrow',
|
|
45
45
|
options?: GeoArrowConvertFromOptions | GeoArrowConvertToOptions
|
|
46
46
|
): Table | arrow.Table {
|
|
47
|
-
if (
|
|
47
|
+
if (isArrowTable(input)) {
|
|
48
48
|
if (shape === 'arrow') return input;
|
|
49
49
|
if (shape === 'geojson-table' && !isGeoArrowApacheTable(input)) {
|
|
50
50
|
return convertArrowToTable(input, 'geojson-table');
|
|
@@ -42,7 +42,6 @@ export const GeoArrowTableConverter: Converter<
|
|
|
42
42
|
| 'array-row-table'
|
|
43
43
|
| 'columnar-table'
|
|
44
44
|
| 'geojson-table'
|
|
45
|
-
| 'arrow-table'
|
|
46
45
|
| 'arrow',
|
|
47
46
|
GeoArrowConvertFromOptions | GeoArrowConvertToOptions
|
|
48
47
|
> = {
|
|
@@ -54,8 +53,7 @@ export const GeoArrowTableConverter: Converter<
|
|
|
54
53
|
'array-row-table',
|
|
55
54
|
'columnar-table',
|
|
56
55
|
'geojson-table',
|
|
57
|
-
'arrow'
|
|
58
|
-
'arrow-table'
|
|
56
|
+
'arrow'
|
|
59
57
|
],
|
|
60
58
|
to: [
|
|
61
59
|
'geoarrow',
|
|
@@ -68,7 +66,7 @@ export const GeoArrowTableConverter: Converter<
|
|
|
68
66
|
canConvert(sourceShape, targetShape) {
|
|
69
67
|
const sourceIsGeoArrow = sourceShape === 'geoarrow';
|
|
70
68
|
const targetIsGeoArrow = targetShape === 'geoarrow';
|
|
71
|
-
return
|
|
69
|
+
return sourceIsGeoArrow !== targetIsGeoArrow;
|
|
72
70
|
},
|
|
73
71
|
detectInputShape(input) {
|
|
74
72
|
return isGeoArrowApacheTable(input as any) ? 'geoarrow' : null;
|
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
6
|
import type {
|
|
7
|
-
ArrowTableBatch,
|
|
8
7
|
GeoArrowDimension,
|
|
9
8
|
GeoArrowMetadata,
|
|
10
9
|
GeoMetadata,
|
|
11
10
|
GeoParquetGeometryType
|
|
12
11
|
} from '@loaders.gl/core/schema';
|
|
13
|
-
import {
|
|
12
|
+
import {makeArrowMetadataBatch} from '@loaders.gl/core/schema-utils';
|
|
14
13
|
import {
|
|
15
14
|
type GeoArrowGeometryConvertOptions,
|
|
16
15
|
type GeoArrowGeometryTarget,
|
|
@@ -41,10 +40,10 @@ export type GeoArrowStreamConvertOptions = GeoArrowGeometryConvertOptions & {
|
|
|
41
40
|
* @returns Async iterator of converted Arrow table batches.
|
|
42
41
|
*/
|
|
43
42
|
export async function* convertGeoArrowBatches(
|
|
44
|
-
batches: Iterable<
|
|
43
|
+
batches: Iterable<arrow.RecordBatch> | AsyncIterable<arrow.RecordBatch>,
|
|
45
44
|
targetEncoding: GeoArrowGeometryTarget,
|
|
46
45
|
options: GeoArrowStreamConvertOptions = {}
|
|
47
|
-
): AsyncIterableIterator<
|
|
46
|
+
): AsyncIterableIterator<arrow.RecordBatch> {
|
|
48
47
|
let stableGeometryTypes: readonly GeoParquetGeometryType[] | undefined;
|
|
49
48
|
let firstBatch = true;
|
|
50
49
|
|
|
@@ -52,28 +51,29 @@ export async function* convertGeoArrowBatches(
|
|
|
52
51
|
if (options.signal?.aborted) {
|
|
53
52
|
throw createAbortError();
|
|
54
53
|
}
|
|
55
|
-
|
|
56
|
-
throw new Error('convertGeoArrowBatches requires ArrowTableBatch inputs.');
|
|
57
|
-
}
|
|
54
|
+
const table = new arrow.Table(batch.schema, [batch]);
|
|
58
55
|
|
|
59
56
|
if (firstBatch) {
|
|
60
|
-
stableGeometryTypes = getStableGeometryTypes(
|
|
57
|
+
stableGeometryTypes = getStableGeometryTypes(table, targetEncoding, options);
|
|
61
58
|
firstBatch = false;
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
const conversionOptions = stableGeometryTypes
|
|
65
62
|
? {...options, geometryTypes: stableGeometryTypes}
|
|
66
63
|
: options;
|
|
67
|
-
const convertedTable = convertGeoArrowGeometry(
|
|
64
|
+
const convertedTable = convertGeoArrowGeometry(table, targetEncoding, conversionOptions);
|
|
68
65
|
const stableTable = stableGeometryTypes
|
|
69
66
|
? stabilizeGeometryUnionTable(convertedTable, stableGeometryTypes)
|
|
70
67
|
: convertedTable;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
for (const convertedBatch of stableTable.batches.length
|
|
69
|
+
? stableTable.batches
|
|
70
|
+
: [makeArrowMetadataBatch(stableTable.schema)]) {
|
|
71
|
+
yield new arrow.RecordBatch(
|
|
72
|
+
convertedBatch.schema,
|
|
73
|
+
convertedBatch.data,
|
|
74
|
+
new Map(batch.metadata)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
package/src/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.ts
CHANGED
|
@@ -73,7 +73,7 @@ export function convertArrowBinaryFeatureCollectionToBinaryFeatureCollection(
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/** Converts binary point features into an Arrow
|
|
76
|
+
/** Converts binary point features into an Arrow-backed geometry family. */
|
|
77
77
|
function convertPointsToArrowTable(binaryPoints: BinaryPointFeature): ArrowBinaryPointFeature {
|
|
78
78
|
const pointOffsets = derivePointOffsets(binaryPoints.featureIds.value as Uint32Array);
|
|
79
79
|
const columns: Record<string, arrow.Data> = {
|
|
@@ -112,7 +112,7 @@ function convertPointsToArrowTable(binaryPoints: BinaryPointFeature): ArrowBinar
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
/** Converts binary line features into an Arrow
|
|
115
|
+
/** Converts binary line features into an Arrow-backed geometry family. */
|
|
116
116
|
function convertLinesToArrowTable(binaryLines: BinaryLineFeature): ArrowBinaryLineFeature {
|
|
117
117
|
const pathOffsets = reinterpretUint32AsInt32(binaryLines.pathIndices.value as Uint32Array);
|
|
118
118
|
const columns: Record<string, arrow.Data> = {
|
|
@@ -147,7 +147,7 @@ function convertLinesToArrowTable(binaryLines: BinaryLineFeature): ArrowBinaryLi
|
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
/** Converts binary polygon features into an Arrow
|
|
150
|
+
/** Converts binary polygon features into an Arrow-backed geometry family. */
|
|
151
151
|
function convertPolygonsToArrowTable(
|
|
152
152
|
binaryPolygons: BinaryPolygonFeature
|
|
153
153
|
): ArrowBinaryPolygonFeature {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
6
|
import type {
|
|
7
|
-
Table,
|
|
8
7
|
ArrayRowTable,
|
|
9
8
|
ColumnarTable,
|
|
10
9
|
ObjectRowTable,
|
|
@@ -16,6 +15,9 @@ import {getGeometryColumnsFromSchema} from '../../metadata/geoarrow-metadata';
|
|
|
16
15
|
import {getGeoMetadata} from '../../metadata/geoparquet-metadata';
|
|
17
16
|
import {convertGeoArrowVectorCellToGeoJSON} from '../../geoarrow-converter/convert-geoarrow-geometry';
|
|
18
17
|
|
|
18
|
+
/** Portable row and column layouts produced from a GeoArrow table. */
|
|
19
|
+
type GeoArrowOutputTable = ArrayRowTable | ColumnarTable | ObjectRowTable | GeoJSONTable;
|
|
20
|
+
|
|
19
21
|
export function convertGeoArrowToTable(
|
|
20
22
|
arrowTable: arrow.Table,
|
|
21
23
|
shape: 'columnar-table'
|
|
@@ -34,16 +36,16 @@ export function convertGeoArrowToTable(
|
|
|
34
36
|
): GeoJSONTable;
|
|
35
37
|
export function convertGeoArrowToTable(
|
|
36
38
|
arrowTable: arrow.Table,
|
|
37
|
-
shape:
|
|
38
|
-
):
|
|
39
|
+
shape: GeoArrowOutputTable['shape']
|
|
40
|
+
): GeoArrowOutputTable;
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Converts an Apache Arrow table with GeoArrow metadata to a loaders.gl table shape.
|
|
42
44
|
*/
|
|
43
45
|
export function convertGeoArrowToTable(
|
|
44
46
|
arrowTable: arrow.Table,
|
|
45
|
-
shape:
|
|
46
|
-
):
|
|
47
|
+
shape: GeoArrowOutputTable['shape']
|
|
48
|
+
): GeoArrowOutputTable {
|
|
47
49
|
switch (shape) {
|
|
48
50
|
case 'array-row-table':
|
|
49
51
|
return convertTable(convertArrowToColumnarTable(arrowTable), 'array-row-table');
|
package/src/index.ts
CHANGED
|
@@ -31,7 +31,7 @@ export {readArrayBuffer} from './lib/fetch/read-array-buffer';
|
|
|
31
31
|
// export {writeFile, writeFileSync} from './lib/fetch/write-file';
|
|
32
32
|
|
|
33
33
|
// CONFIGURATION
|
|
34
|
-
export {setLoaderOptions, getLoaderOptions} from './lib/api/loader-options';
|
|
34
|
+
export {setLoaderOptions, getLoaderOptions, compareLoaderOptions} from './lib/api/loader-options';
|
|
35
35
|
export {registerLoaders} from './lib/api/register-loaders';
|
|
36
36
|
export {selectLoader, selectLoaderSync} from './lib/api/select-loader';
|
|
37
37
|
|
package/src/lib/api/load.ts
CHANGED
|
@@ -11,7 +11,6 @@ import type {
|
|
|
11
11
|
Loader,
|
|
12
12
|
LoaderContext,
|
|
13
13
|
LoaderOptions,
|
|
14
|
-
StrictLoaderOptions,
|
|
15
14
|
LoaderOptionsType,
|
|
16
15
|
LoaderReturnType,
|
|
17
16
|
SourceLoader
|
|
@@ -22,7 +21,6 @@ import {
|
|
|
22
21
|
resolveLoaderAuthenticationOptions
|
|
23
22
|
} from '@loaders.gl/core/loader-utils';
|
|
24
23
|
import {isLoaderObject} from '../loader-utils/normalize-loader';
|
|
25
|
-
import {getNativeArrowOptions, unwrapArrowTable} from '../loader-utils/native-arrow';
|
|
26
24
|
import {getFetchFunction} from '../loader-utils/get-fetch-function';
|
|
27
25
|
import {
|
|
28
26
|
applySearchParamsToUrl,
|
|
@@ -152,16 +150,8 @@ export async function load(
|
|
|
152
150
|
const {parseUrl} = loaderImplementation;
|
|
153
151
|
if (parseUrl) {
|
|
154
152
|
const requestUrl = applySearchParamsToUrl(url, resolvedOptions);
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
normalizeOptions(resolvedOptions, selectedLoader, [selectedLoader], url)
|
|
158
|
-
);
|
|
159
|
-
const result = await parseUrl(
|
|
160
|
-
requestUrl,
|
|
161
|
-
(nativeOptions || resolvedOptions) as StrictLoaderOptions,
|
|
162
|
-
context
|
|
163
|
-
);
|
|
164
|
-
return nativeOptions ? unwrapArrowTable(result) : result;
|
|
153
|
+
const options = normalizeOptions(resolvedOptions, selectedLoader, [selectedLoader], url);
|
|
154
|
+
return parseUrl(requestUrl, options, context);
|
|
165
155
|
}
|
|
166
156
|
}
|
|
167
157
|
}
|