@loaders.gl/geospatial 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/dist/dbf-loader-types.cjs +1 -1
- package/dist/dbf-loader.cjs +2 -4
- package/dist/dbf-loader.cjs.map +2 -2
- package/dist/dbf-worker.js +22 -79
- package/dist/flatgeobuf/flatgeobuf-loader-types.cjs +1 -1
- package/dist/flatgeobuf/flatgeobuf-loader-types.js +1 -1
- package/dist/flatgeobuf/lib/parse-flatgeobuf.cjs +6 -20
- package/dist/flatgeobuf/lib/parse-flatgeobuf.cjs.map +2 -2
- package/dist/flatgeobuf/lib/parse-flatgeobuf.d.ts +4 -4
- package/dist/flatgeobuf/lib/parse-flatgeobuf.d.ts.map +1 -1
- package/dist/flatgeobuf/lib/parse-flatgeobuf.js +9 -22
- package/dist/flatgeobuf/lib/parse-flatgeobuf.js.map +1 -1
- package/dist/flatgeobuf-loader-types.cjs +1 -1
- package/dist/flatgeobuf-worker.js +655 -77
- package/dist/geopackage/geopackage-source-loader.cjs +1 -1
- package/dist/geopackage/geopackage-source-loader.cjs.map +2 -2
- package/dist/geopackage/geopackage-source-loader.js +1 -1
- package/dist/geopackage/geopackage-source-loader.js.map +1 -1
- package/dist/geopackage/lib/parse-geopackage.cjs +2 -6
- package/dist/geopackage/lib/parse-geopackage.cjs.map +2 -2
- package/dist/geopackage/lib/parse-geopackage.d.ts +3 -3
- package/dist/geopackage/lib/parse-geopackage.d.ts.map +1 -1
- package/dist/geopackage/lib/parse-geopackage.js +2 -6
- package/dist/geopackage/lib/parse-geopackage.js.map +1 -1
- package/dist/geopackage-source-loader.cjs +1 -1
- package/dist/geopackage-source-loader.cjs.map +2 -2
- package/dist/gpx-loader-types.cjs +1 -1
- package/dist/kml/gpx-loader-types.cjs +1 -1
- package/dist/kml/gpx-loader-types.js +1 -1
- package/dist/kml/kml-loader-types.cjs +1 -1
- package/dist/kml/kml-loader-types.js +1 -1
- package/dist/kml/kml-writer.cjs +1 -1
- package/dist/kml/kml-writer.js +1 -1
- package/dist/kml/kmz-loader-types.cjs +1 -1
- package/dist/kml/kmz-loader-types.js +1 -1
- package/dist/kml/lib/feature-collection-to-arrow.cjs +1 -1
- package/dist/kml/lib/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/kml/lib/feature-collection-to-arrow.js +1 -1
- package/dist/kml/lib/feature-collection-to-arrow.js.map +1 -1
- package/dist/kml/tcx-loader-types.cjs +1 -1
- package/dist/kml/tcx-loader-types.js +1 -1
- package/dist/kml-loader-types.cjs +1 -1
- package/dist/kml-writer.cjs +1 -1
- package/dist/kmz-loader-types.cjs +1 -1
- package/dist/shapefile/dbf-loader-types.cjs +1 -1
- package/dist/shapefile/dbf-loader-types.js +1 -1
- package/dist/shapefile/dbf-loader.cjs +2 -4
- package/dist/shapefile/dbf-loader.cjs.map +2 -2
- package/dist/shapefile/dbf-loader.d.ts.map +1 -1
- package/dist/shapefile/dbf-loader.js +3 -5
- package/dist/shapefile/dbf-loader.js.map +1 -1
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.cjs +1 -5
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.cjs.map +2 -2
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.d.ts +5 -4
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.d.ts.map +1 -1
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.js +2 -6
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.js.map +1 -1
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.cjs.map +2 -2
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.d.ts +4 -3
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.d.ts.map +1 -1
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.js.map +1 -1
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.cjs +7 -10
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.cjs.map +2 -2
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.d.ts +3 -3
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.d.ts.map +1 -1
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.js +11 -9
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.js.map +1 -1
- package/dist/shapefile/lib/shapefile-worker-transport.cjs +0 -3
- package/dist/shapefile/lib/shapefile-worker-transport.cjs.map +2 -2
- package/dist/shapefile/lib/shapefile-worker-transport.d.ts.map +1 -1
- package/dist/shapefile/lib/shapefile-worker-transport.js +1 -5
- package/dist/shapefile/lib/shapefile-worker-transport.js.map +1 -1
- package/dist/shapefile/shapefile-arrow-loader.cjs +53 -48
- package/dist/shapefile/shapefile-arrow-loader.cjs.map +2 -2
- package/dist/shapefile/shapefile-arrow-loader.d.ts +5 -3
- package/dist/shapefile/shapefile-arrow-loader.d.ts.map +1 -1
- package/dist/shapefile/shapefile-arrow-loader.js +54 -52
- package/dist/shapefile/shapefile-arrow-loader.js.map +1 -1
- package/dist/shapefile/shapefile-loader-types.cjs +1 -1
- package/dist/shapefile/shapefile-loader-types.d.ts +4 -4
- package/dist/shapefile/shapefile-loader-types.js +1 -1
- package/dist/shapefile/shapefile-loader.cjs +19 -55
- package/dist/shapefile/shapefile-loader.cjs.map +2 -2
- package/dist/shapefile/shapefile-loader.d.ts +5 -42
- package/dist/shapefile/shapefile-loader.d.ts.map +1 -1
- package/dist/shapefile/shapefile-loader.js +22 -64
- package/dist/shapefile/shapefile-loader.js.map +1 -1
- package/dist/shapefile/shp-loader-types.cjs +1 -1
- package/dist/shapefile/shp-loader-types.js +1 -1
- package/dist/shapefile/shp-loader.cjs +1 -44
- package/dist/shapefile/shp-loader.cjs.map +2 -2
- package/dist/shapefile/shp-loader.d.ts +1 -115
- package/dist/shapefile/shp-loader.d.ts.map +1 -1
- package/dist/shapefile/shp-loader.js +1 -48
- package/dist/shapefile/shp-loader.js.map +1 -1
- package/dist/shapefile-arrow-loader.cjs +53 -48
- package/dist/shapefile-arrow-loader.cjs.map +2 -2
- package/dist/shapefile-loader-types.cjs +1 -1
- package/dist/shapefile-loader.cjs +19 -55
- package/dist/shapefile-loader.cjs.map +2 -2
- package/dist/shapefile-worker.js +117 -272
- package/dist/shp-loader-types.cjs +1 -1
- package/dist/shp-loader.cjs +1 -44
- package/dist/shp-loader.cjs.map +2 -2
- package/dist/shp-worker.js +16964 -17085
- package/dist/tcx-loader-types.cjs +1 -1
- package/dist/wkt/lib/version.cjs +1 -1
- package/dist/wkt/lib/version.js +1 -1
- package/dist/wkt-worker.js +1 -1
- package/dist/workers/shapefile-worker.cjs +3 -3
- package/dist/workers/shapefile-worker.cjs.map +2 -2
- package/dist/workers/shapefile-worker.js +4 -4
- package/dist/workers/shapefile-worker.js.map +1 -1
- package/dist/workers/shp-worker.cjs +1 -1
- package/dist/workers/shp-worker.cjs.map +2 -2
- package/dist/workers/shp-worker.js +2 -2
- package/dist/workers/shp-worker.js.map +1 -1
- package/package.json +6 -6
- package/src/flatgeobuf/lib/parse-flatgeobuf.ts +15 -33
- package/src/geopackage/geopackage-source-loader.ts +1 -1
- package/src/geopackage/lib/parse-geopackage.ts +4 -9
- package/src/kml/lib/feature-collection-to-arrow.ts +1 -1
- package/src/shapefile/dbf-loader.ts +4 -7
- package/src/shapefile/lib/parsers/build-geoarrow-geometry-arrow.ts +5 -9
- package/src/shapefile/lib/parsers/build-wkb-geometry-arrow.ts +4 -3
- package/src/shapefile/lib/parsers/parse-shp-to-arrow.ts +14 -20
- package/src/shapefile/lib/shapefile-worker-transport.ts +1 -6
- package/src/shapefile/shapefile-arrow-loader.ts +76 -70
- package/src/shapefile/shapefile-loader.ts +40 -90
- package/src/shapefile/shp-loader.ts +7 -61
- package/src/workers/shapefile-worker.ts +4 -4
- package/src/workers/shp-worker.ts +2 -2
|
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(tcx_loader_types_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/kml/tcx-loader-types.ts
|
|
38
38
|
var import_kml_format = require("./kml-format.cjs");
|
|
39
|
-
var VERSION = true ? "5.0.0-beta.
|
|
39
|
+
var VERSION = true ? "5.0.0-beta.11" : "latest";
|
|
40
40
|
async function preloadTCXLoader() {
|
|
41
41
|
const { TCXLoaderWithParser } = await import("@loaders.gl/geospatial/tcx");
|
|
42
42
|
return TCXLoaderWithParser;
|
package/dist/wkt/lib/version.cjs
CHANGED
|
@@ -23,7 +23,7 @@ __export(version_exports, {
|
|
|
23
23
|
VERSION: () => VERSION
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(version_exports);
|
|
26
|
-
var VERSION = true ? "5.0.0-beta.
|
|
26
|
+
var VERSION = true ? "5.0.0-beta.11" : "latest";
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|
|
29
29
|
VERSION
|
package/dist/wkt/lib/version.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
// Version constant cannot be imported, it needs to correspond to the build version of **this** module.
|
|
5
5
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
6
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
-
export const VERSION = typeof "5.0.0-beta.
|
|
7
|
+
export const VERSION = typeof "5.0.0-beta.11" !== 'undefined' ? "5.0.0-beta.11" : 'latest';
|
|
8
8
|
//# sourceMappingURL=version.js.map
|
package/dist/wkt-worker.js
CHANGED
|
@@ -50,10 +50,10 @@ function getArrowOptions(options) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
(0, import_loader_utils.createLoaderWorker)({
|
|
53
|
-
...import_shapefile_loader.
|
|
53
|
+
...import_shapefile_loader.ShapefileLoaderWithParser,
|
|
54
54
|
/** Parses geometries and sidecar attributes into owned transferable columns. */
|
|
55
55
|
parse(input, options, context) {
|
|
56
|
-
return import_shapefile_loader.
|
|
56
|
+
return import_shapefile_loader.ShapefileLoaderWithParser.parse(
|
|
57
57
|
input,
|
|
58
58
|
getArrowOptions(options),
|
|
59
59
|
createShapefileContext(context, options)
|
|
@@ -61,7 +61,7 @@ function getArrowOptions(options) {
|
|
|
61
61
|
},
|
|
62
62
|
/** Joins streamed geometry and attribute batches without delegating their rows to the caller. */
|
|
63
63
|
parseInBatches(input, options, context) {
|
|
64
|
-
return import_shapefile_loader.
|
|
64
|
+
return import_shapefile_loader.ShapefileLoaderWithParser.parseInBatches(
|
|
65
65
|
input,
|
|
66
66
|
getArrowOptions(options),
|
|
67
67
|
createShapefileContext(context, options)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/workers/shapefile-worker.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n createLoaderWorker,\n createAuthenticatedFetch,\n type LoaderContext,\n type LoaderWithParser\n} from '@loaders.gl/core/loader-utils';\nimport {
|
|
5
|
-
"mappings": ";;;AAIA,0BAKO;AACP,
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n createLoaderWorker,\n createAuthenticatedFetch,\n type LoaderContext,\n type LoaderWithParser\n} from '@loaders.gl/core/loader-utils';\nimport {ShapefileLoaderWithParser} from '../shapefile/shapefile-loader';\n\n/** Installs local subloader parsing so streamed sidecars and geometry stay in this worker. */\nfunction createShapefileContext(context?: LoaderContext, options?: any): LoaderContext {\n return {\n ...context,\n fetch: createAuthenticatedFetch({\n fetch: (url, init) => fetch(url as RequestInfo, init),\n credentials: options?.core?.credentials || [],\n fetchOptions: typeof options?.core?.fetch === 'object' ? options?.core?.fetch : undefined\n }),\n _parse: async (input: any, loader: LoaderWithParser, options: any) =>\n loader.parse!(\n input instanceof Response ? await input.arrayBuffer() : input,\n options,\n createShapefileContext(context, options)\n ),\n _parseInBatches: async (input: any, loader: LoaderWithParser, options: any) =>\n loader.parseInBatches!(\n input instanceof Response ? readResponse(input) : input,\n options,\n createShapefileContext(context, options)\n )\n } as LoaderContext;\n}\n\n/** Releases the streamed sidecar reader on completion, failure, or iterator cancellation. */\nasync function* readResponse(response: Response): AsyncIterable<Uint8Array> {\n const reader = response.body!.getReader();\n try {\n while (true) {\n const {done, value} = await reader.read();\n if (done) return;\n yield value;\n }\n } finally {\n await reader.cancel();\n reader.releaseLock();\n }\n}\n\n/** Uses WKB columns for legacy output so feature construction runs only on the caller. */\nfunction getArrowOptions(options: any): any {\n if ((options?.shapefile?.shape || 'arrow') === 'arrow') return options;\n return {\n ...options,\n geoarrow: {encodingPreference: 'geoarrow.wkb'},\n shapefile: {\n ...options?.shapefile,\n shape: 'arrow',\n geoarrowEncoding: 'geoarrow.wkb',\n geoarrow: {encodingPreference: 'geoarrow.wkb'}\n }\n };\n}\n\ncreateLoaderWorker({\n ...ShapefileLoaderWithParser,\n /** Parses geometries and sidecar attributes into owned transferable columns. */\n parse(input, options, context) {\n return ShapefileLoaderWithParser.parse(\n input,\n getArrowOptions(options),\n createShapefileContext(context, options)\n );\n },\n /** Joins streamed geometry and attribute batches without delegating their rows to the caller. */\n parseInBatches(input, options, context) {\n return ShapefileLoaderWithParser.parseInBatches(\n input,\n getArrowOptions(options),\n createShapefileContext(context, options)\n );\n }\n});\n"],
|
|
5
|
+
"mappings": ";;;AAIA,0BAKO;AACP,8BAAwC;AAGxC,SAAS,uBAAuB,SAAyB,SAA8B;AACrF,SAAO;AAAA,IACL,GAAG;AAAA,IACH,WAAO,8CAAyB;AAAA,MAC9B,OAAO,CAAC,KAAK,SAAS,MAAM,KAAoB,IAAI;AAAA,MACpD,aAAa,SAAS,MAAM,eAAe,CAAC;AAAA,MAC5C,cAAc,OAAO,SAAS,MAAM,UAAU,WAAW,SAAS,MAAM,QAAQ;AAAA,IAClF,CAAC;AAAA,IACD,QAAQ,OAAO,OAA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["options"]
|
|
7
7
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { createLoaderWorker, createAuthenticatedFetch } from '@loaders.gl/core/loader-utils';
|
|
5
|
-
import {
|
|
5
|
+
import { ShapefileLoaderWithParser } from "../shapefile/shapefile-loader.js";
|
|
6
6
|
/** Installs local subloader parsing so streamed sidecars and geometry stay in this worker. */
|
|
7
7
|
function createShapefileContext(context, options) {
|
|
8
8
|
return {
|
|
@@ -48,14 +48,14 @@ function getArrowOptions(options) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
createLoaderWorker({
|
|
51
|
-
...
|
|
51
|
+
...ShapefileLoaderWithParser,
|
|
52
52
|
/** Parses geometries and sidecar attributes into owned transferable columns. */
|
|
53
53
|
parse(input, options, context) {
|
|
54
|
-
return
|
|
54
|
+
return ShapefileLoaderWithParser.parse(input, getArrowOptions(options), createShapefileContext(context, options));
|
|
55
55
|
},
|
|
56
56
|
/** Joins streamed geometry and attribute batches without delegating their rows to the caller. */
|
|
57
57
|
parseInBatches(input, options, context) {
|
|
58
|
-
return
|
|
58
|
+
return ShapefileLoaderWithParser.parseInBatches(input, getArrowOptions(options), createShapefileContext(context, options));
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
//# sourceMappingURL=shapefile-worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapefile-worker.js","sourceRoot":"","sources":["../../src/workers/shapefile-worker.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EAGzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"shapefile-worker.js","sourceRoot":"","sources":["../../src/workers/shapefile-worker.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC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worker.ts
|
|
4
4
|
var import_shp_loader = require("../shapefile/shp-loader.cjs");
|
|
5
5
|
var import_loader_utils = require("@loaders.gl/core/loader-utils");
|
|
6
|
-
(0, import_loader_utils.createLoaderWorker)(import_shp_loader.
|
|
6
|
+
(0, import_loader_utils.createLoaderWorker)(import_shp_loader.SHPLoaderWithParser);
|
|
7
7
|
//# sourceMappingURL=shp-worker.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/workers/shp-worker.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {
|
|
5
|
-
"mappings": ";;;AAIA,
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {SHPLoaderWithParser} from '../shapefile/shp-loader';\nimport {createLoaderWorker} from '@loaders.gl/core/loader-utils';\n\ncreateLoaderWorker(SHPLoaderWithParser);\n"],
|
|
5
|
+
"mappings": ";;;AAIA,wBAAkC;AAClC,0BAAiC;AAAA,IAEjC,wCAAmB,qCAAmB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import {
|
|
4
|
+
import { SHPLoaderWithParser } from "../shapefile/shp-loader.js";
|
|
5
5
|
import { createLoaderWorker } from '@loaders.gl/core/loader-utils';
|
|
6
|
-
createLoaderWorker(
|
|
6
|
+
createLoaderWorker(SHPLoaderWithParser);
|
|
7
7
|
//# sourceMappingURL=shp-worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shp-worker.js","sourceRoot":"","sources":["../../src/workers/shp-worker.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"shp-worker.js","sourceRoot":"","sources":["../../src/workers/shp-worker.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,mBAAmB,EAAC,mCAAgC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AAEjE,kBAAkB,CAAC,mBAAmB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/geospatial",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.11",
|
|
4
4
|
"description": "Geospatial loaders and writers for vector files and geometry encodings",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -375,10 +375,10 @@
|
|
|
375
375
|
"build-worker-shapefile": "node ../../scripts/build-codec-worker.mjs src/workers/shapefile-worker.ts --bundle --outfile=dist/shapefile-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
376
376
|
},
|
|
377
377
|
"dependencies": {
|
|
378
|
-
"@loaders.gl/archives": "5.0.0-beta.
|
|
379
|
-
"@loaders.gl/documents": "5.0.0-beta.
|
|
380
|
-
"@math.gl/arrow": "5.0.0-beta.
|
|
381
|
-
"@math.gl/geospatial": "5.0.0-beta.
|
|
378
|
+
"@loaders.gl/archives": "5.0.0-beta.11",
|
|
379
|
+
"@loaders.gl/documents": "5.0.0-beta.11",
|
|
380
|
+
"@math.gl/arrow": "5.0.0-beta.11",
|
|
381
|
+
"@math.gl/geospatial": "5.0.0-beta.11",
|
|
382
382
|
"@types/sql.js": "^1.4.5",
|
|
383
383
|
"apache-arrow": ">= 17.0.0"
|
|
384
384
|
},
|
|
@@ -419,5 +419,5 @@
|
|
|
419
419
|
"fgb",
|
|
420
420
|
"gpkg"
|
|
421
421
|
],
|
|
422
|
-
"gitHead": "
|
|
422
|
+
"gitHead": "d23c857c2a9c0a028e63d58bf9e1a94a1b27a0fd"
|
|
423
423
|
}
|
|
@@ -6,17 +6,9 @@ import * as arrow from 'apache-arrow';
|
|
|
6
6
|
import {projectionEngine} from '@math.gl/geospatial/projection';
|
|
7
7
|
import type {Projection} from '@math.gl/geospatial/projection';
|
|
8
8
|
import type {ReadonlyCRSDefinition} from '@math.gl/geospatial/crs';
|
|
9
|
-
import type {
|
|
10
|
-
ArrowTable,
|
|
11
|
-
ArrowTableBatch,
|
|
12
|
-
Feature,
|
|
13
|
-
Field,
|
|
14
|
-
Schema,
|
|
15
|
-
Table
|
|
16
|
-
} from '@loaders.gl/core/schema';
|
|
9
|
+
import type {Feature, Field, Schema, Table} from '@loaders.gl/core/schema';
|
|
17
10
|
import {
|
|
18
11
|
filterColumnarRowIndices,
|
|
19
|
-
makeTableScanBatch,
|
|
20
12
|
planTableQuery,
|
|
21
13
|
CRSReprojectionError,
|
|
22
14
|
type CRSReprojectionOptions,
|
|
@@ -34,7 +26,11 @@ import {makeWKBGeometryDataFromArray} from '@loaders.gl/core/arrow-geometry/wkb-
|
|
|
34
26
|
import {convertFeaturesToGeoArrowTable} from '@loaders.gl/core/arrow-geometry/feature-table';
|
|
35
27
|
import {type GeoParquetGeometryType} from '@loaders.gl/core/schema';
|
|
36
28
|
import {WKBBuilder} from '@loaders.gl/core/arrow-geometry';
|
|
37
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
convertArrowToTable,
|
|
31
|
+
convertSchemaToArrow,
|
|
32
|
+
queryArrowTable
|
|
33
|
+
} from '@loaders.gl/core/schema-utils';
|
|
38
34
|
import {
|
|
39
35
|
decodeFlatGeobufGeometry,
|
|
40
36
|
FlatGeobufColumnType,
|
|
@@ -74,7 +70,7 @@ export function parseFlatGeobuf(
|
|
|
74
70
|
const arrowTable = parseFlatGeobufToArrowTable(arrayBuffer, options);
|
|
75
71
|
switch (options.shape) {
|
|
76
72
|
case 'arrow':
|
|
77
|
-
return arrowTable
|
|
73
|
+
return arrowTable;
|
|
78
74
|
case 'geojson-table':
|
|
79
75
|
return makeGeoJsonTable(arrayBuffer, options);
|
|
80
76
|
case 'binary-geometry':
|
|
@@ -82,16 +78,7 @@ export function parseFlatGeobuf(
|
|
|
82
78
|
makeGeoJsonTable(arrayBuffer, options).features
|
|
83
79
|
);
|
|
84
80
|
case 'columnar-table':
|
|
85
|
-
return
|
|
86
|
-
shape: 'columnar-table',
|
|
87
|
-
schema: arrowTable.schema,
|
|
88
|
-
data: Object.fromEntries(
|
|
89
|
-
(arrowTable.schema?.fields || []).map(field => [
|
|
90
|
-
field.name,
|
|
91
|
-
arrowTable.data.getChild(field.name)?.toArray()
|
|
92
|
-
])
|
|
93
|
-
)
|
|
94
|
-
} as Table;
|
|
81
|
+
return convertArrowToTable(arrowTable, 'columnar-table');
|
|
95
82
|
default:
|
|
96
83
|
throw new Error(`Unsupported FlatGeobuf output shape ${options.shape}`);
|
|
97
84
|
}
|
|
@@ -101,7 +88,7 @@ export function parseFlatGeobuf(
|
|
|
101
88
|
export function parseFlatGeobufToArrowTable(
|
|
102
89
|
arrayBuffer: ArrayBuffer,
|
|
103
90
|
options: ParseFlatGeobufOptions = {}
|
|
104
|
-
):
|
|
91
|
+
): arrow.Table {
|
|
105
92
|
const preference = options.geoarrow?.encodingPreference;
|
|
106
93
|
if (preference && preference !== 'geoarrow.wkb') {
|
|
107
94
|
return convertFeaturesToGeoArrowTable(makeGeoJsonTable(arrayBuffer, options).features, {
|
|
@@ -149,11 +136,7 @@ export function parseFlatGeobufToArrowTable(
|
|
|
149
136
|
undefined,
|
|
150
137
|
[...propertyData, geometryData]
|
|
151
138
|
);
|
|
152
|
-
return
|
|
153
|
-
shape: 'arrow-table',
|
|
154
|
-
schema,
|
|
155
|
-
data: new arrow.Table(arrowSchema, [new arrow.RecordBatch(arrowSchema, structData)])
|
|
156
|
-
};
|
|
139
|
+
return new arrow.Table(arrowSchema, [new arrow.RecordBatch(arrowSchema, structData)]);
|
|
157
140
|
}
|
|
158
141
|
|
|
159
142
|
/** Executes a portable projection, residual predicate, and limit over FlatGeobuf features. */
|
|
@@ -165,18 +148,17 @@ export function queryFlatGeobufArrowTable(
|
|
|
165
148
|
const sourceTable = parseFlatGeobufToArrowTable(arrayBuffer, {
|
|
166
149
|
boundingBox: options.boundingBox
|
|
167
150
|
});
|
|
168
|
-
const sourceColumnNames = sourceTable.
|
|
151
|
+
const sourceColumnNames = sourceTable.schema.fields.map(field => field.name);
|
|
169
152
|
const plan = planTableQuery(sourceColumnNames, options);
|
|
170
153
|
const scanStep = plan.find(step => step.kind === 'scan');
|
|
171
154
|
const projectStep = plan.find(step => step.kind === 'project');
|
|
172
155
|
if (!scanStep || scanStep.kind !== 'scan' || !projectStep || projectStep.kind !== 'project') {
|
|
173
156
|
throw new Error('FlatGeobuf query planner produced an invalid plan.');
|
|
174
157
|
}
|
|
175
|
-
if (!sourceTable.schema) throw new Error('FlatGeobuf query source is missing a schema.');
|
|
176
158
|
const predicateStep = plan.find(step => step.kind === 'filter');
|
|
177
159
|
const limitStep = plan.find(step => step.kind === 'limit');
|
|
178
160
|
return queryArrowTable(
|
|
179
|
-
sourceTable
|
|
161
|
+
sourceTable,
|
|
180
162
|
{
|
|
181
163
|
predicate: predicateStep?.kind === 'filter' ? predicateStep.predicate : undefined,
|
|
182
164
|
columns: projectStep.columns,
|
|
@@ -186,14 +168,14 @@ export function queryFlatGeobufArrowTable(
|
|
|
186
168
|
);
|
|
187
169
|
}
|
|
188
170
|
|
|
189
|
-
/** Loads FlatGeobuf as
|
|
171
|
+
/** Loads FlatGeobuf as native Arrow record batches. */
|
|
190
172
|
export async function* parseFlatGeobufInBatches(
|
|
191
173
|
stream: ReadableStream,
|
|
192
174
|
options: ParseFlatGeobufOptions
|
|
193
|
-
): AsyncGenerator<
|
|
175
|
+
): AsyncGenerator<arrow.RecordBatch> {
|
|
194
176
|
const arrayBuffer = await new Response(stream).arrayBuffer();
|
|
195
177
|
const table = parseFlatGeobufToArrowTable(arrayBuffer, options);
|
|
196
|
-
yield
|
|
178
|
+
yield* table.batches;
|
|
197
179
|
}
|
|
198
180
|
|
|
199
181
|
/** Creates the public Arrow schema from FlatGeobuf header metadata. */
|
|
@@ -246,7 +246,7 @@ export class GeoPackageDataSource
|
|
|
246
246
|
/** Loads one GeoPackage vector table as an Arrow table. */
|
|
247
247
|
async getTable(tableName?: string): Promise<Table> {
|
|
248
248
|
const arrayBuffer = await this.getArrayBuffer();
|
|
249
|
-
return
|
|
249
|
+
return parseGeoPackageToArrow(arrayBuffer, this.getLoaderOptions(tableName));
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
/** Executes projection, residual predicates, and a global limit on the selected feature table. */
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import type {Table} from 'apache-arrow';
|
|
7
7
|
import {CRSReprojectionError} from '@loaders.gl/core/loader-utils';
|
|
8
8
|
import type {
|
|
9
|
-
ArrowTable,
|
|
10
9
|
DataType,
|
|
11
10
|
Feature,
|
|
12
11
|
Field,
|
|
@@ -97,7 +96,7 @@ export async function parseGeoPackage(
|
|
|
97
96
|
): Promise<GeoJSONTable | Table> {
|
|
98
97
|
const shape = options?.geopackage?.shape || 'arrow';
|
|
99
98
|
if (shape === 'arrow') {
|
|
100
|
-
return
|
|
99
|
+
return parseGeoPackageToArrow(arrayBuffer, options);
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
const database = await loadGeoPackageDatabase(
|
|
@@ -125,7 +124,7 @@ export async function parseGeoPackage(
|
|
|
125
124
|
export async function parseGeoPackageToArrow(
|
|
126
125
|
arrayBuffer: ArrayBuffer,
|
|
127
126
|
options?: GeoPackageLoaderOptions
|
|
128
|
-
): Promise<
|
|
127
|
+
): Promise<Table> {
|
|
129
128
|
const database = await loadGeoPackageDatabase(
|
|
130
129
|
arrayBuffer,
|
|
131
130
|
options?.geopackage?.sqlJsCDN ?? DEFAULT_SQLJS_CDN
|
|
@@ -283,7 +282,7 @@ export function getGeoPackageArrowTable(
|
|
|
283
282
|
vectorTable: GeoPackageVectorTableInfo,
|
|
284
283
|
projections: ProjectionMapping,
|
|
285
284
|
options: {reproject: boolean; targetCrs: ReadonlyCRSDefinition}
|
|
286
|
-
):
|
|
285
|
+
): Table {
|
|
287
286
|
const queryResult = database.exec(`SELECT * FROM \`${vectorTable.name}\`;`)[0];
|
|
288
287
|
const columns = queryResult?.columns || [];
|
|
289
288
|
const values = queryResult?.values || [];
|
|
@@ -302,11 +301,7 @@ export function getGeoPackageArrowTable(
|
|
|
302
301
|
);
|
|
303
302
|
}
|
|
304
303
|
|
|
305
|
-
return
|
|
306
|
-
shape: 'arrow-table',
|
|
307
|
-
schema: structuredClone(tableBuilder.schema),
|
|
308
|
-
data: tableBuilder.finishTable()
|
|
309
|
-
};
|
|
304
|
+
return tableBuilder.finishTable();
|
|
310
305
|
}
|
|
311
306
|
|
|
312
307
|
/** Find all projections defined in GeoPackage. */
|
|
@@ -30,7 +30,7 @@ export function convertFeatureCollectionToArrowTable(
|
|
|
30
30
|
options: {encodingPreference?: GeoArrowEncodingPreference} = {}
|
|
31
31
|
): Table {
|
|
32
32
|
if (options.encodingPreference && options.encodingPreference !== 'geoarrow.wkb') {
|
|
33
|
-
return convertFeaturesToGeoArrowTable(features, options)
|
|
33
|
+
return convertFeaturesToGeoArrowTable(features, options);
|
|
34
34
|
}
|
|
35
35
|
const propertyRows = features.map(feature => normalizeProperties(feature.properties));
|
|
36
36
|
const propertySchema = getPropertySchema(propertyRows);
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {Table, RecordBatch} from 'apache-arrow';
|
|
6
|
-
import {convertArrowToSchema
|
|
6
|
+
import {convertArrowToSchema} from '@loaders.gl/core/schema-utils';
|
|
7
7
|
import type {Loader, LoaderWithParser, StrictLoaderOptions} from '@loaders.gl/core/loader-utils';
|
|
8
|
-
import type {
|
|
8
|
+
import type {ObjectRowTable} from '@loaders.gl/core/schema';
|
|
9
9
|
import {
|
|
10
10
|
parseDBF as parseDBFToObjectRows,
|
|
11
11
|
parseDBFInBatches as parseDBFToObjectRowsInBatches
|
|
@@ -87,8 +87,7 @@ function getDBFShape(options?: DBFLoaderOptions): NonNullable<DBFLoaderOptions['
|
|
|
87
87
|
|
|
88
88
|
/** Converts hydrated Arrow scalars to the requested legacy row output on the caller. */
|
|
89
89
|
function deserializeDBFWorkerResult(result: unknown, options?: DBFLoaderOptions) {
|
|
90
|
-
const
|
|
91
|
-
const table = 'shape' in value ? value.data : value;
|
|
90
|
+
const table = deserializeShapefileWorkerResult<Table>(result);
|
|
92
91
|
const shape = getDBFShape(options);
|
|
93
92
|
if (shape === 'arrow') return table;
|
|
94
93
|
const rows = table.toArray().map(row => row.toJSON());
|
|
@@ -100,9 +99,7 @@ function deserializeDBFWorkerResult(result: unknown, options?: DBFLoaderOptions)
|
|
|
100
99
|
|
|
101
100
|
/** Keeps legacy header events and materializes row arrays only on the caller. */
|
|
102
101
|
function deserializeDBFWorkerBatch(result: unknown, options?: DBFLoaderOptions) {
|
|
103
|
-
const
|
|
104
|
-
const batch =
|
|
105
|
-
'shape' in value ? (value.data.batches[0] ?? makeArrowMetadataBatch(value.data.schema)) : value;
|
|
102
|
+
const batch = deserializeShapefileWorkerResult<DBFHeader | RecordBatch>(result);
|
|
106
103
|
return batch instanceof RecordBatch && getDBFShape(options) !== 'arrow'
|
|
107
104
|
? batch.toArray().map(row => row.toJSON())
|
|
108
105
|
: batch;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
|
-
import type {
|
|
6
|
+
import type {Schema as TableSchema} from '@loaders.gl/core/schema';
|
|
7
7
|
import {convertSchemaToArrow} from '@loaders.gl/core/schema-utils';
|
|
8
8
|
import {GeoArrowBuilder, type GeoArrowBuilderEncoding} from '@loaders.gl/core/arrow-geometry';
|
|
9
9
|
import {type GeoParquetGeometryType} from '@loaders.gl/core/schema';
|
|
@@ -31,7 +31,7 @@ export function makeSHPGeoArrowGeometryTable(
|
|
|
31
31
|
arrayBuffer: ArrayBuffer,
|
|
32
32
|
options?: SHPLoaderOptions,
|
|
33
33
|
geoArrowOptions?: SHPGeoArrowGeometryOptions
|
|
34
|
-
):
|
|
34
|
+
): arrow.Table {
|
|
35
35
|
const header = parseSHPHeader(new DataView(arrayBuffer, 0, SHP_HEADER_SIZE), options);
|
|
36
36
|
const encoding = getDefaultGeoArrowEncoding(header);
|
|
37
37
|
const builderOptions = {
|
|
@@ -78,11 +78,11 @@ export function makeSHPGeoArrowGeometrySchema(
|
|
|
78
78
|
return schema;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
/** Wraps typed GeoArrow geometry buffers in
|
|
81
|
+
/** Wraps typed GeoArrow geometry buffers in an Apache Arrow table. */
|
|
82
82
|
export function makeGeoArrowGeometryTable(
|
|
83
83
|
geometryArray: ReturnType<GeoArrowBuilder['getGeometryArray']>,
|
|
84
84
|
schema: TableSchema
|
|
85
|
-
):
|
|
85
|
+
): arrow.Table {
|
|
86
86
|
const arrowSchema = convertSchemaToArrow(schema);
|
|
87
87
|
const geometryData = GeoArrowBuilder.makeGeometryData(geometryArray);
|
|
88
88
|
const structField = new arrow.Struct(arrowSchema.fields);
|
|
@@ -91,11 +91,7 @@ export function makeGeoArrowGeometryTable(
|
|
|
91
91
|
]);
|
|
92
92
|
const recordBatch = new arrow.RecordBatch(arrowSchema, structData);
|
|
93
93
|
|
|
94
|
-
return
|
|
95
|
-
shape: 'arrow-table',
|
|
96
|
-
schema,
|
|
97
|
-
data: new arrow.Table(arrowSchema, [recordBatch])
|
|
98
|
-
};
|
|
94
|
+
return new arrow.Table(arrowSchema, [recordBatch]);
|
|
99
95
|
}
|
|
100
96
|
|
|
101
97
|
/** Returns the default typed GeoArrow encoding for an SHP header. */
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
|
-
import type {
|
|
6
|
+
import type {Table} from 'apache-arrow';
|
|
7
|
+
import type {Schema as TableSchema} from '@loaders.gl/core/schema';
|
|
7
8
|
import {WKBBuilder} from '@loaders.gl/core/arrow-geometry';
|
|
8
9
|
import {type CoordinateTransform} from '@loaders.gl/core/arrow-geometry/binary-geometry-to-wkb';
|
|
9
10
|
import {
|
|
@@ -32,7 +33,7 @@ export function makeWKBGeometryArrowTable(
|
|
|
32
33
|
geometries: (SHPWKBGeometry | null | undefined)[],
|
|
33
34
|
schema: TableSchema,
|
|
34
35
|
transform?: CoordinateTransform
|
|
35
|
-
):
|
|
36
|
+
): Table {
|
|
36
37
|
return makeSharedWKBGeometryArrowTable(geometries, schema, {transform});
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -42,7 +43,7 @@ export function makeSHPWKBGeometryArrowTable(
|
|
|
42
43
|
schema: TableSchema,
|
|
43
44
|
options?: SHPLoaderOptions,
|
|
44
45
|
transform?: CoordinateTransform
|
|
45
|
-
):
|
|
46
|
+
): Table {
|
|
46
47
|
const geometryData = makeSHPWKBGeometryData(arrayBuffer, options, transform);
|
|
47
48
|
return makeWKBGeometryArrowTableFromData(schema, geometryData);
|
|
48
49
|
}
|
|
@@ -2,13 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
ArrowTableBatch,
|
|
8
|
-
Field,
|
|
9
|
-
GeoArrowEncodingPreference
|
|
10
|
-
} from '@loaders.gl/core/schema';
|
|
11
|
-
import {makeTableScanBatch} from '@loaders.gl/core/loader-utils';
|
|
5
|
+
import type {Schema, Field, GeoArrowEncodingPreference} from '@loaders.gl/core/schema';
|
|
6
|
+
import type {Table, RecordBatch} from 'apache-arrow';
|
|
12
7
|
import {type GeoParquetGeometryType} from '@loaders.gl/core/schema';
|
|
13
8
|
import {convertFeaturesToGeoArrowTable} from '@loaders.gl/core/arrow-geometry/feature-table';
|
|
14
9
|
import {convertWKBToGeometry} from '@loaders.gl/core/arrow-geometry/geometry-codecs';
|
|
@@ -16,7 +11,7 @@ import {
|
|
|
16
11
|
makeWKBGeometryField,
|
|
17
12
|
setWKBGeometryColumnMetadata
|
|
18
13
|
} from '@loaders.gl/core/arrow-geometry/geometry-field';
|
|
19
|
-
import {
|
|
14
|
+
import {convertSchemaToArrow, makeArrowMetadataBatch} from '@loaders.gl/core/schema-utils';
|
|
20
15
|
import {parseSHP, parseSHPInBatches} from './parse-shp';
|
|
21
16
|
import {parseSHPHeader, type SHPHeader} from './parse-shp-header';
|
|
22
17
|
import type {SHPLoaderOptions} from './types';
|
|
@@ -30,7 +25,7 @@ import {makeSHPGeoArrowGeometryTable} from './build-geoarrow-geometry-arrow';
|
|
|
30
25
|
const GEOMETRY_COLUMN_NAME = 'geometry';
|
|
31
26
|
const SHP_HEADER_SIZE = 100;
|
|
32
27
|
|
|
33
|
-
export function parseSHPToArrow(arrayBuffer: ArrayBuffer, options?: SHPLoaderOptions):
|
|
28
|
+
export function parseSHPToArrow(arrayBuffer: ArrayBuffer, options?: SHPLoaderOptions): Table {
|
|
34
29
|
if (
|
|
35
30
|
options?.geoarrow?.encodingPreference === 'geoarrow.geometry' ||
|
|
36
31
|
options?.shp?.geoarrow?.encodingPreference === 'geoarrow.geometry'
|
|
@@ -64,7 +59,7 @@ export async function* parseSHPToArrowInBatches(
|
|
|
64
59
|
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
65
60
|
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
66
61
|
options?: SHPLoaderOptions
|
|
67
|
-
): AsyncIterable<
|
|
62
|
+
): AsyncIterable<RecordBatch> {
|
|
68
63
|
const preference =
|
|
69
64
|
options?.geoarrow?.encodingPreference || options?.shp?.geoarrow?.encodingPreference;
|
|
70
65
|
if (preference && preference !== 'geoarrow.wkb') {
|
|
@@ -79,9 +74,11 @@ export async function* parseSHPToArrowInBatches(
|
|
|
79
74
|
geometry: geometry ? convertWKBToGeometry(geometry.buffer) : null,
|
|
80
75
|
properties: {}
|
|
81
76
|
}));
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
77
|
+
const table = convertFeaturesToGeoArrowTable(geometryFeatures as any, {
|
|
78
|
+
encodingPreference: preference
|
|
79
|
+
});
|
|
80
|
+
if (table.batches.length) yield* table.batches;
|
|
81
|
+
else yield makeArrowMetadataBatch(table.schema);
|
|
85
82
|
return;
|
|
86
83
|
}
|
|
87
84
|
|
|
@@ -103,7 +100,7 @@ export async function* parseSHPToArrowInBatches(
|
|
|
103
100
|
const schema = buildOutputSchema(header);
|
|
104
101
|
const arrowTable = makeWKBGeometryArrowTable(geometries, schema);
|
|
105
102
|
yieldedDataBatch = true;
|
|
106
|
-
yield
|
|
103
|
+
yield* arrowTable.batches;
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
if (!yieldedDataBatch) {
|
|
@@ -175,10 +172,7 @@ function getWKBOptions(options?: SHPLoaderOptions): SHPLoaderOptions {
|
|
|
175
172
|
};
|
|
176
173
|
}
|
|
177
174
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
const table = new ArrowTableBuilder(schema).finishTable();
|
|
183
|
-
return makeTableScanBatch({shape: 'arrow-table', data: table, schema});
|
|
175
|
+
/** Preserves the declared SHP geometry schema for streams without rows. */
|
|
176
|
+
function makeEmptyArrowBatch(schema: Schema): RecordBatch {
|
|
177
|
+
return makeArrowMetadataBatch(convertSchemaToArrow(schema));
|
|
184
178
|
}
|
|
@@ -4,17 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import {Table, RecordBatch} from 'apache-arrow';
|
|
6
6
|
import {
|
|
7
|
-
serializeArrowWorkerTable,
|
|
8
7
|
serializeNativeArrowWorkerResult,
|
|
9
|
-
deserializeNativeArrowWorkerResult
|
|
10
|
-
deserializeArrowWorkerTable
|
|
8
|
+
deserializeNativeArrowWorkerResult
|
|
11
9
|
} from '@loaders.gl/core/arrow-worker-transport';
|
|
12
10
|
|
|
13
11
|
/** Transfers owned Arrow columns or WKB buffers, with small SHP/DBF header envelopes. */
|
|
14
12
|
export function serializeShapefileWorkerResult(result: any): unknown {
|
|
15
13
|
if (result instanceof Table || result instanceof RecordBatch)
|
|
16
14
|
return serializeNativeArrowWorkerResult(result);
|
|
17
|
-
if (result?.shape === 'arrow-table') return serializeArrowWorkerTable(result);
|
|
18
15
|
if (
|
|
19
16
|
Array.isArray(result) &&
|
|
20
17
|
result.every(value => value === null || value instanceof Uint8Array)
|
|
@@ -39,8 +36,6 @@ export function serializeShapefileWorkerResult(result: any): unknown {
|
|
|
39
36
|
export function deserializeShapefileWorkerResult<T>(result: any): T {
|
|
40
37
|
if (result?.transport === 'arrow-table-columns' || result?.transport === 'arrow-record-batch')
|
|
41
38
|
return deserializeNativeArrowWorkerResult(result) as T;
|
|
42
|
-
if (result?.transport === 'arrow-column-envelope' || result?.shape === 'arrow-table')
|
|
43
|
-
return deserializeArrowWorkerTable(result);
|
|
44
39
|
if (result?.transport === 'shapefile-header') return result.header as T;
|
|
45
40
|
if (result?.transport === 'shp-wkb') {
|
|
46
41
|
return (
|