@loaders.gl/arrow 4.0.4 → 4.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow-loader.d.ts +1 -0
- package/dist/arrow-loader.d.ts.map +1 -1
- package/dist/arrow-loader.js +1 -1
- package/dist/arrow-loader.js.map +1 -1
- package/dist/arrow-worker.js +241 -3
- package/dist/arrow-writer.js +1 -1
- package/dist/arrow-writer.js.map +1 -1
- package/dist/dist.dev.js +1496 -641
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts +8 -4
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -1
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js +75 -54
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js.map +1 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts +13 -0
- package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +1 -0
- package/dist/geoarrow/{convert-geoarrow-to-geojson.js → convert-geoarrow-to-geojson-geometry.js} +34 -27
- package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.js.map +1 -0
- package/dist/geoarrow/get-arrow-bounds.d.ts.map +1 -1
- package/dist/geoarrow/get-arrow-bounds.js.map +1 -1
- package/dist/geoarrow-loader.d.ts.map +1 -1
- package/dist/geoarrow-loader.js +0 -1
- package/dist/geoarrow-loader.js.map +1 -1
- package/dist/geoarrow-writer.js +1 -1
- package/dist/geoarrow-writer.js.map +1 -1
- package/dist/index.cjs +436 -347
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/arrow-table-batch.d.ts.map +1 -1
- package/dist/lib/arrow-table-batch.js.map +1 -1
- package/dist/lib/arrow-table.d.ts.map +1 -1
- package/dist/lib/arrow-table.js.map +1 -1
- package/dist/lib/encode-arrow.d.ts.map +1 -1
- package/dist/lib/encode-arrow.js.map +1 -1
- package/dist/lib/encode-geoarrow.d.ts.map +1 -1
- package/dist/lib/encode-geoarrow.js.map +1 -1
- package/dist/parsers/parse-arrow-in-batches.d.ts +2 -1
- package/dist/parsers/parse-arrow-in-batches.d.ts.map +1 -1
- package/dist/parsers/parse-arrow-in-batches.js +8 -1
- package/dist/parsers/parse-arrow-in-batches.js.map +1 -1
- package/dist/parsers/parse-arrow-sync.d.ts.map +1 -1
- package/dist/parsers/parse-arrow-sync.js +2 -0
- package/dist/parsers/parse-arrow-sync.js.map +1 -1
- package/dist/parsers/parse-geoarrow-in-batches.d.ts.map +1 -1
- package/dist/parsers/parse-geoarrow-in-batches.js.map +1 -1
- package/dist/parsers/parse-geoarrow-sync.d.ts.map +1 -1
- package/dist/parsers/parse-geoarrow-sync.js.map +1 -1
- package/dist/schema/arrow-type-utils.d.ts.map +1 -1
- package/dist/schema/arrow-type-utils.js.map +1 -1
- package/dist/schema/convert-arrow-schema.d.ts.map +1 -1
- package/dist/schema/convert-arrow-schema.js.map +1 -1
- package/dist/tables/convert-arrow-to-columnar-table.d.ts.map +1 -1
- package/dist/tables/convert-arrow-to-columnar-table.js +1 -0
- package/dist/tables/convert-arrow-to-columnar-table.js.map +1 -1
- package/dist/tables/convert-arrow-to-geojson-table.d.ts +1 -1
- package/dist/tables/convert-arrow-to-geojson-table.d.ts.map +1 -1
- package/dist/tables/convert-arrow-to-geojson-table.js +14 -8
- package/dist/tables/convert-arrow-to-geojson-table.js.map +1 -1
- package/dist/tables/convert-columnar-to-row-table.d.ts.map +1 -1
- package/dist/tables/convert-columnar-to-row-table.js +1 -0
- package/dist/tables/convert-columnar-to-row-table.js.map +1 -1
- package/dist/tables/convert-table-to-arrow.d.ts.map +1 -1
- package/dist/tables/convert-table-to-arrow.js.map +1 -1
- package/dist/triangulate-on-worker.d.ts +40 -6
- package/dist/triangulate-on-worker.d.ts.map +1 -1
- package/dist/triangulate-on-worker.js +12 -2
- package/dist/triangulate-on-worker.js.map +1 -1
- package/dist/triangulation-worker.js +11703 -34
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/workers/arrow-worker.js.map +1 -1
- package/dist/workers/hard-clone.d.ts +23 -0
- package/dist/workers/hard-clone.d.ts.map +1 -0
- package/dist/workers/hard-clone.js +57 -0
- package/dist/workers/hard-clone.js.map +1 -0
- package/dist/workers/triangulation-worker-node.d.ts.map +1 -1
- package/dist/workers/triangulation-worker-node.js.map +1 -1
- package/dist/workers/triangulation-worker.js +37 -2
- package/dist/workers/triangulation-worker.js.map +1 -1
- package/package.json +18 -12
- package/src/arrow-loader.ts +3 -1
- package/src/geoarrow/convert-geoarrow-to-binary-geometry.ts +105 -62
- package/src/geoarrow/{convert-geoarrow-to-geojson.ts → convert-geoarrow-to-geojson-geometry.ts} +58 -47
- package/src/geoarrow/get-arrow-bounds.ts +2 -1
- package/src/geoarrow-loader.ts +2 -5
- package/src/index.ts +11 -4
- package/src/lib/arrow-table-batch.ts +2 -1
- package/src/lib/arrow-table.ts +2 -1
- package/src/lib/encode-arrow.ts +2 -1
- package/src/lib/encode-geoarrow.ts +2 -1
- package/src/parsers/parse-arrow-in-batches.ts +9 -2
- package/src/parsers/parse-arrow-sync.ts +8 -2
- package/src/parsers/parse-geoarrow-in-batches.ts +2 -1
- package/src/parsers/parse-geoarrow-sync.ts +2 -1
- package/src/schema/arrow-type-utils.ts +2 -1
- package/src/schema/convert-arrow-schema.ts +2 -1
- package/src/tables/convert-arrow-to-columnar-table.ts +3 -1
- package/src/tables/convert-arrow-to-geojson-table.ts +20 -8
- package/src/tables/convert-columnar-to-row-table.ts +3 -1
- package/src/tables/convert-table-to-arrow.ts +2 -1
- package/src/triangulate-on-worker.ts +53 -9
- package/src/types.ts +2 -1
- package/src/workers/arrow-worker.ts +2 -1
- package/src/workers/hard-clone.ts +162 -0
- package/src/workers/triangulation-worker-node.ts +2 -1
- package/src/workers/triangulation-worker.ts +59 -4
- package/dist/geoarrow/convert-geoarrow-to-geojson.d.ts +0 -20
- package/dist/geoarrow/convert-geoarrow-to-geojson.d.ts.map +0 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson.js.map +0 -1
package/src/geoarrow/{convert-geoarrow-to-geojson.ts → convert-geoarrow-to-geojson-geometry.ts}
RENAMED
|
@@ -1,81 +1,96 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
|
-
import * as arrow from 'apache-arrow';
|
|
5
|
+
// import * as arrow from 'apache-arrow';
|
|
5
6
|
import {
|
|
6
|
-
Feature,
|
|
7
7
|
MultiPolygon,
|
|
8
8
|
Position,
|
|
9
9
|
Polygon,
|
|
10
10
|
MultiPoint,
|
|
11
11
|
Point,
|
|
12
12
|
MultiLineString,
|
|
13
|
-
LineString
|
|
13
|
+
LineString,
|
|
14
|
+
Geometry,
|
|
15
|
+
BinaryGeometry
|
|
14
16
|
} from '@loaders.gl/schema';
|
|
15
|
-
import type
|
|
16
|
-
|
|
17
|
-
type RawArrowFeature = {
|
|
18
|
-
data: arrow.Vector;
|
|
19
|
-
encoding?: GeoArrowEncoding;
|
|
20
|
-
};
|
|
17
|
+
import {binaryToGeometry, type GeoArrowEncoding} from '@loaders.gl/gis';
|
|
18
|
+
import {WKBLoader, WKTLoader} from '@loaders.gl/wkt';
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* parse geometry from arrow data that is returned from processArrowData()
|
|
24
|
-
* NOTE: this function could be
|
|
25
|
-
* it is currently
|
|
26
|
-
* So the following functions could be deprecated once deck.gl returns the feature directly for binary geojson layer
|
|
22
|
+
* NOTE: this function could be deduplicated with the binaryToFeature() in deck.gl,
|
|
23
|
+
* it is currently used for deck.gl picking because currently deck.gl returns only the index of the feature
|
|
27
24
|
*
|
|
28
|
-
* @param
|
|
29
|
-
* @
|
|
25
|
+
* @param data data extraced from arrow vector representing a geometry
|
|
26
|
+
* @param encoding the geoarrow encoding of the geometry column
|
|
30
27
|
* @returns Feature or null
|
|
31
28
|
*/
|
|
32
|
-
export function parseGeometryFromArrow(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
export function parseGeometryFromArrow(
|
|
30
|
+
arrowCellValue: any,
|
|
31
|
+
encoding?: GeoArrowEncoding
|
|
32
|
+
): Geometry | null {
|
|
33
|
+
// sanity
|
|
34
|
+
encoding = encoding?.toLowerCase() as GeoArrowEncoding;
|
|
35
|
+
if (!encoding || !arrowCellValue) {
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
let geometry;
|
|
39
|
+
let geometry: Geometry;
|
|
40
40
|
|
|
41
41
|
switch (encoding) {
|
|
42
42
|
case 'geoarrow.multipolygon':
|
|
43
|
-
geometry = arrowMultiPolygonToFeature(
|
|
43
|
+
geometry = arrowMultiPolygonToFeature(arrowCellValue);
|
|
44
44
|
break;
|
|
45
45
|
case 'geoarrow.polygon':
|
|
46
|
-
geometry = arrowPolygonToFeature(
|
|
46
|
+
geometry = arrowPolygonToFeature(arrowCellValue);
|
|
47
47
|
break;
|
|
48
48
|
case 'geoarrow.multipoint':
|
|
49
|
-
geometry = arrowMultiPointToFeature(
|
|
49
|
+
geometry = arrowMultiPointToFeature(arrowCellValue);
|
|
50
50
|
break;
|
|
51
51
|
case 'geoarrow.point':
|
|
52
|
-
geometry = arrowPointToFeature(
|
|
52
|
+
geometry = arrowPointToFeature(arrowCellValue);
|
|
53
53
|
break;
|
|
54
54
|
case 'geoarrow.multilinestring':
|
|
55
|
-
geometry = arrowMultiLineStringToFeature(
|
|
55
|
+
geometry = arrowMultiLineStringToFeature(arrowCellValue);
|
|
56
56
|
break;
|
|
57
57
|
case 'geoarrow.linestring':
|
|
58
|
-
geometry = arrowLineStringToFeature(
|
|
58
|
+
geometry = arrowLineStringToFeature(arrowCellValue);
|
|
59
59
|
break;
|
|
60
60
|
case 'geoarrow.wkb':
|
|
61
|
-
|
|
61
|
+
geometry = arrowWKBToFeature(arrowCellValue);
|
|
62
|
+
break;
|
|
62
63
|
case 'geoarrow.wkt':
|
|
63
|
-
|
|
64
|
+
geometry = arrowWKTToFeature(arrowCellValue);
|
|
65
|
+
break;
|
|
64
66
|
default: {
|
|
65
67
|
throw Error(`GeoArrow encoding not supported ${encoding}`);
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
|
|
71
|
+
return geometry;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function arrowWKBToFeature(arrowCellValue: any) {
|
|
75
|
+
// The actual WKB array buffer starts from byteOffset and ends at byteOffset + byteLength
|
|
76
|
+
const arrayBuffer: ArrayBuffer = arrowCellValue.buffer.slice(
|
|
77
|
+
arrowCellValue.byteOffset,
|
|
78
|
+
arrowCellValue.byteOffset + arrowCellValue.byteLength
|
|
79
|
+
);
|
|
80
|
+
const binaryGeometry = WKBLoader.parseSync?.(arrayBuffer)! as BinaryGeometry;
|
|
81
|
+
const geometry = binaryToGeometry(binaryGeometry);
|
|
82
|
+
return geometry;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function arrowWKTToFeature(arrowCellValue: any) {
|
|
86
|
+
const string: string = arrowCellValue;
|
|
87
|
+
return WKTLoader.parseTextSync?.(string)!;
|
|
73
88
|
}
|
|
74
89
|
|
|
75
90
|
/**
|
|
76
91
|
* convert Arrow MultiPolygon to geojson Feature
|
|
77
92
|
*/
|
|
78
|
-
function arrowMultiPolygonToFeature(arrowMultiPolygon:
|
|
93
|
+
function arrowMultiPolygonToFeature(arrowMultiPolygon: any): MultiPolygon {
|
|
79
94
|
const multiPolygon: Position[][][] = [];
|
|
80
95
|
for (let m = 0; m < arrowMultiPolygon.length; m++) {
|
|
81
96
|
const arrowPolygon = arrowMultiPolygon.get(m);
|
|
@@ -102,7 +117,7 @@ function arrowMultiPolygonToFeature(arrowMultiPolygon: arrow.Vector): MultiPolyg
|
|
|
102
117
|
/**
|
|
103
118
|
* convert Arrow Polygon to geojson Feature
|
|
104
119
|
*/
|
|
105
|
-
function arrowPolygonToFeature(arrowPolygon:
|
|
120
|
+
function arrowPolygonToFeature(arrowPolygon: any): Polygon {
|
|
106
121
|
const polygon: Position[][] = [];
|
|
107
122
|
for (let i = 0; arrowPolygon && i < arrowPolygon.length; i++) {
|
|
108
123
|
const arrowRing = arrowPolygon.get(i);
|
|
@@ -124,7 +139,7 @@ function arrowPolygonToFeature(arrowPolygon: arrow.Vector): Polygon {
|
|
|
124
139
|
/**
|
|
125
140
|
* convert Arrow MultiPoint to geojson MultiPoint
|
|
126
141
|
*/
|
|
127
|
-
function arrowMultiPointToFeature(arrowMultiPoint:
|
|
142
|
+
function arrowMultiPointToFeature(arrowMultiPoint: any): MultiPoint {
|
|
128
143
|
const multiPoint: Position[] = [];
|
|
129
144
|
for (let i = 0; arrowMultiPoint && i < arrowMultiPoint.length; i++) {
|
|
130
145
|
const arrowPoint = arrowMultiPoint.get(i);
|
|
@@ -133,29 +148,27 @@ function arrowMultiPointToFeature(arrowMultiPoint: arrow.Vector): MultiPoint {
|
|
|
133
148
|
multiPoint.push(coord);
|
|
134
149
|
}
|
|
135
150
|
}
|
|
136
|
-
|
|
151
|
+
return {
|
|
137
152
|
type: 'MultiPoint',
|
|
138
153
|
coordinates: multiPoint
|
|
139
154
|
};
|
|
140
|
-
return geometry;
|
|
141
155
|
}
|
|
142
156
|
|
|
143
157
|
/**
|
|
144
158
|
* convert Arrow Point to geojson Point
|
|
145
159
|
*/
|
|
146
|
-
function arrowPointToFeature(arrowPoint:
|
|
160
|
+
function arrowPointToFeature(arrowPoint: any): Point {
|
|
147
161
|
const point: Position = Array.from(arrowPoint);
|
|
148
|
-
|
|
162
|
+
return {
|
|
149
163
|
type: 'Point',
|
|
150
164
|
coordinates: point
|
|
151
165
|
};
|
|
152
|
-
return geometry;
|
|
153
166
|
}
|
|
154
167
|
|
|
155
168
|
/**
|
|
156
169
|
* convert Arrow MultiLineString to geojson MultiLineString
|
|
157
170
|
*/
|
|
158
|
-
function arrowMultiLineStringToFeature(arrowMultiLineString:
|
|
171
|
+
function arrowMultiLineStringToFeature(arrowMultiLineString: any): MultiLineString {
|
|
159
172
|
const multiLineString: Position[][] = [];
|
|
160
173
|
for (let i = 0; arrowMultiLineString && i < arrowMultiLineString.length; i++) {
|
|
161
174
|
const arrowLineString = arrowMultiLineString.get(i);
|
|
@@ -169,17 +182,16 @@ function arrowMultiLineStringToFeature(arrowMultiLineString: arrow.Vector): Mult
|
|
|
169
182
|
}
|
|
170
183
|
multiLineString.push(lineString);
|
|
171
184
|
}
|
|
172
|
-
|
|
185
|
+
return {
|
|
173
186
|
type: 'MultiLineString',
|
|
174
187
|
coordinates: multiLineString
|
|
175
188
|
};
|
|
176
|
-
return geometry;
|
|
177
189
|
}
|
|
178
190
|
|
|
179
191
|
/**
|
|
180
192
|
* convert Arrow LineString to geojson LineString
|
|
181
193
|
*/
|
|
182
|
-
function arrowLineStringToFeature(arrowLineString:
|
|
194
|
+
function arrowLineStringToFeature(arrowLineString: any): LineString {
|
|
183
195
|
const lineString: Position[] = [];
|
|
184
196
|
for (let i = 0; arrowLineString && i < arrowLineString.length; i++) {
|
|
185
197
|
const arrowCoord = arrowLineString.get(i);
|
|
@@ -188,9 +200,8 @@ function arrowLineStringToFeature(arrowLineString: arrow.Vector): LineString {
|
|
|
188
200
|
lineString.push(coords);
|
|
189
201
|
}
|
|
190
202
|
}
|
|
191
|
-
|
|
203
|
+
return {
|
|
192
204
|
type: 'LineString',
|
|
193
205
|
coordinates: lineString
|
|
194
206
|
};
|
|
195
|
-
return geometry;
|
|
196
207
|
}
|
package/src/geoarrow-loader.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
@@ -8,10 +9,6 @@ import type {ArrowTable, ArrowTableBatch} from './lib/arrow-table';
|
|
|
8
9
|
import {parseGeoArrowSync} from './parsers/parse-geoarrow-sync';
|
|
9
10
|
import {parseGeoArrowInBatches} from './parsers/parse-geoarrow-in-batches';
|
|
10
11
|
|
|
11
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
12
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
13
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
14
|
-
|
|
15
12
|
export type GeoArrowLoaderOptions = LoaderOptions & {
|
|
16
13
|
arrow?: {
|
|
17
14
|
shape: 'arrow-table' | 'binary-geometry';
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {ArrowLoaderOptions} from './arrow-loader';
|
|
@@ -52,7 +53,7 @@ export type {
|
|
|
52
53
|
BinaryGeometriesFromArrowOptions
|
|
53
54
|
} from './geoarrow/convert-geoarrow-to-binary-geometry';
|
|
54
55
|
export {
|
|
55
|
-
|
|
56
|
+
getBinaryGeometryTemplate,
|
|
56
57
|
getBinaryGeometriesFromArrow,
|
|
57
58
|
getTriangleIndices,
|
|
58
59
|
getMeanCentersFromBinaryGeometries
|
|
@@ -60,10 +61,16 @@ export {
|
|
|
60
61
|
|
|
61
62
|
export {updateBoundsFromGeoArrowSamples} from './geoarrow/get-arrow-bounds';
|
|
62
63
|
|
|
63
|
-
export {parseGeometryFromArrow} from './geoarrow/convert-geoarrow-to-geojson';
|
|
64
|
+
export {parseGeometryFromArrow} from './geoarrow/convert-geoarrow-to-geojson-geometry';
|
|
64
65
|
|
|
65
66
|
export {convertArrowToGeoJSONTable} from './tables/convert-arrow-to-geojson-table';
|
|
66
67
|
|
|
67
68
|
// EXPERIMENTAL WORKER
|
|
69
|
+
export {hardClone} from './workers/hard-clone';
|
|
68
70
|
|
|
69
|
-
export {
|
|
71
|
+
export type {ParseGeoArrowInput, ParseGeoArrowResult} from './triangulate-on-worker';
|
|
72
|
+
export {
|
|
73
|
+
TriangulationWorker,
|
|
74
|
+
triangulateOnWorker,
|
|
75
|
+
parseGeoArrowOnWorker
|
|
76
|
+
} from './triangulate-on-worker';
|
package/src/lib/arrow-table.ts
CHANGED
package/src/lib/encode-arrow.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {ArrowTableBatch} from '../lib/arrow-table';
|
|
5
6
|
import * as arrow from 'apache-arrow';
|
|
7
|
+
import {ArrowLoaderOptions} from '../arrow-loader';
|
|
6
8
|
// import {isIterable} from '@loaders.gl/core';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
*/
|
|
10
12
|
export function parseArrowInBatches(
|
|
11
|
-
asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer
|
|
13
|
+
asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,
|
|
14
|
+
options?: ArrowLoaderOptions
|
|
12
15
|
): AsyncIterable<ArrowTableBatch> {
|
|
13
16
|
// Creates the appropriate arrow.RecordBatchReader subclasses from the input
|
|
14
17
|
// This will also close the underlying source in case of early termination or errors
|
|
@@ -33,6 +36,10 @@ export function parseArrowInBatches(
|
|
|
33
36
|
const readers = arrow.RecordBatchReader.readAll(asyncIterator);
|
|
34
37
|
for await (const reader of readers) {
|
|
35
38
|
for await (const recordBatch of reader) {
|
|
39
|
+
// use options.batchDebounceMs to add a delay between batches if needed (use case: incremental loading)
|
|
40
|
+
if (options?.arrow?.batchDebounceMs !== undefined && options?.arrow?.batchDebounceMs > 0) {
|
|
41
|
+
await new Promise((resolve) => setTimeout(resolve, options.arrow?.batchDebounceMs || 0));
|
|
42
|
+
}
|
|
36
43
|
const arrowTabledBatch: ArrowTableBatch = {
|
|
37
44
|
shape: 'arrow-table',
|
|
38
45
|
batchType: 'data',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {ArrayRowTable, ColumnarTable, ObjectRowTable} from '@loaders.gl/schema';
|
|
@@ -6,6 +7,7 @@ import type {ArrowTable} from '../lib/arrow-table';
|
|
|
6
7
|
import {convertTable} from '@loaders.gl/schema';
|
|
7
8
|
import * as arrow from 'apache-arrow';
|
|
8
9
|
import {convertArrowToColumnarTable} from '../tables/convert-arrow-to-columnar-table';
|
|
10
|
+
import {serializeArrowSchema} from '../schema/convert-arrow-schema';
|
|
9
11
|
|
|
10
12
|
// Parses arrow to a columnar table
|
|
11
13
|
export function parseArrowSync(
|
|
@@ -13,7 +15,11 @@ export function parseArrowSync(
|
|
|
13
15
|
options?: {shape?: 'arrow-table' | 'columnar-table' | 'object-row-table' | 'array-row-table'}
|
|
14
16
|
): ArrowTable | ColumnarTable | ObjectRowTable | ArrayRowTable {
|
|
15
17
|
const apacheArrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);
|
|
16
|
-
const arrowTable: ArrowTable = {
|
|
18
|
+
const arrowTable: ArrowTable = {
|
|
19
|
+
shape: 'arrow-table',
|
|
20
|
+
schema: serializeArrowSchema(apacheArrowTable.schema),
|
|
21
|
+
data: apacheArrowTable
|
|
22
|
+
};
|
|
17
23
|
|
|
18
24
|
const shape = options?.shape || 'arrow-table';
|
|
19
25
|
switch (shape) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {ColumnarTable} from '@loaders.gl/schema';
|
|
@@ -24,6 +25,7 @@ export function convertArrowToColumnarTable(table: ArrowTable): ColumnarTable {
|
|
|
24
25
|
|
|
25
26
|
return {
|
|
26
27
|
shape: 'columnar-table',
|
|
28
|
+
schema: table.schema,
|
|
27
29
|
data: columnarTable
|
|
28
30
|
};
|
|
29
31
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {Feature, GeoJSONTable} from '@loaders.gl/schema';
|
|
5
|
-
import
|
|
6
|
+
import * as arrow from 'apache-arrow';
|
|
6
7
|
import type {ArrowTable} from '../lib/arrow-table';
|
|
7
8
|
import {serializeArrowSchema, parseGeometryFromArrow} from '@loaders.gl/arrow';
|
|
8
9
|
import {getGeometryColumnsFromSchema} from '@loaders.gl/gis';
|
|
@@ -16,6 +17,7 @@ import {getGeometryColumnsFromSchema} from '@loaders.gl/gis';
|
|
|
16
17
|
export function convertApacheArrowToArrowTable(arrowTable: arrow.Table): ArrowTable {
|
|
17
18
|
return {
|
|
18
19
|
shape: 'arrow-table',
|
|
20
|
+
schema: serializeArrowSchema(arrowTable.schema),
|
|
19
21
|
data: arrowTable
|
|
20
22
|
};
|
|
21
23
|
}
|
|
@@ -34,21 +36,31 @@ export function convertArrowToGeoJSONTable(table: ArrowTable): GeoJSONTable {
|
|
|
34
36
|
|
|
35
37
|
const features: Feature[] = [];
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
// Remove geometry columns
|
|
40
|
+
const propertyColumnNames = arrowTable.schema.fields
|
|
41
|
+
.map((field) => field.name)
|
|
42
|
+
// TODO - this deletes all geometry columns
|
|
43
|
+
.filter((name) => !(name in geometryColumns));
|
|
44
|
+
const propertiesTable = arrowTable.select(propertyColumnNames);
|
|
45
|
+
|
|
46
|
+
const arrowGeometryColumn = arrowTable.getChild('geometry');
|
|
41
47
|
|
|
48
|
+
for (let row = 0; row < arrowTable.numRows; row++) {
|
|
49
|
+
// get the geometry value from arrow geometry column
|
|
50
|
+
// Note that type can vary
|
|
51
|
+
const arrowGeometry = arrowGeometryColumn?.get(row);
|
|
42
52
|
// parse arrow geometry to geojson feature
|
|
43
|
-
const feature = parseGeometryFromArrow(
|
|
53
|
+
const feature = parseGeometryFromArrow(arrowGeometry, encoding);
|
|
44
54
|
if (feature) {
|
|
45
|
-
|
|
55
|
+
const properties = propertiesTable.get(row)?.toJSON() || {};
|
|
56
|
+
features.push({type: 'Feature', geometry: feature, properties});
|
|
46
57
|
}
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
return {
|
|
50
61
|
shape: 'geojson-table',
|
|
51
62
|
type: 'FeatureCollection',
|
|
63
|
+
schema: table.schema,
|
|
52
64
|
features
|
|
53
65
|
};
|
|
54
66
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {ColumnarTable, ObjectRowTable} from '@loaders.gl/schema';
|
|
@@ -24,6 +25,7 @@ export function convertColumnarToRowFormatTable(columnarTable: ColumnarTable): O
|
|
|
24
25
|
|
|
25
26
|
return {
|
|
26
27
|
shape: 'object-row-table',
|
|
28
|
+
schema: columnarTable.schema,
|
|
27
29
|
data: rowFormatTable
|
|
28
30
|
};
|
|
29
31
|
}
|
|
@@ -1,19 +1,53 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
5
|
+
import * as arrow from 'apache-arrow';
|
|
4
6
|
import type {WorkerOptions} from '@loaders.gl/worker-utils';
|
|
5
7
|
import {processOnWorker} from '@loaders.gl/worker-utils';
|
|
8
|
+
import {BinaryDataFromGeoArrow, GeoArrowEncoding} from '@loaders.gl/arrow';
|
|
6
9
|
|
|
7
10
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
11
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
9
12
|
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
10
13
|
|
|
11
|
-
export type TriangulationWorkerInput =
|
|
12
|
-
|
|
14
|
+
export type TriangulationWorkerInput =
|
|
15
|
+
| ({operation: 'triangulate'} & TriangulateInput)
|
|
16
|
+
| ParseGeoArrowInput
|
|
17
|
+
| {operation: 'test'; data: any};
|
|
18
|
+
|
|
19
|
+
export type TriangulationWorkerOutput =
|
|
20
|
+
| ({operation: 'triangulate'} & TriangulateResult)
|
|
21
|
+
| ({operation: 'parse-geoarrow'} & ParseGeoArrowResult)
|
|
22
|
+
| {operation: 'test'; data: any};
|
|
23
|
+
|
|
24
|
+
type GeoArrowChunkData = {
|
|
25
|
+
type: arrow.DataType;
|
|
26
|
+
offset: number;
|
|
27
|
+
length: number;
|
|
28
|
+
nullCount: number;
|
|
29
|
+
buffers: any;
|
|
30
|
+
children: arrow.Data[];
|
|
31
|
+
dictionary?: arrow.Vector;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ParseGeoArrowInput = {
|
|
35
|
+
operation: 'parse-geoarrow';
|
|
36
|
+
chunkData: GeoArrowChunkData;
|
|
37
|
+
chunkIndex: number;
|
|
38
|
+
chunkOffset: number;
|
|
39
|
+
geometryEncoding: GeoArrowEncoding;
|
|
40
|
+
calculateMeanCenters: boolean;
|
|
41
|
+
triangle: boolean;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type ParseGeoArrowResult = {
|
|
45
|
+
chunkIndex: number;
|
|
46
|
+
binaryDataFromGeoArrow: BinaryDataFromGeoArrow | null;
|
|
47
|
+
};
|
|
13
48
|
|
|
14
49
|
/** Input data for operation: 'triangulate' */
|
|
15
50
|
export type TriangulateInput = {
|
|
16
|
-
operation: 'triangulate';
|
|
17
51
|
polygonIndices: Uint16Array;
|
|
18
52
|
primitivePolygonIndices: Int32Array;
|
|
19
53
|
flatCoordinateArray: Float64Array;
|
|
@@ -22,7 +56,7 @@ export type TriangulateInput = {
|
|
|
22
56
|
|
|
23
57
|
/** Result type for operation: 'triangulate' */
|
|
24
58
|
export type TriangulateResult = TriangulateInput & {
|
|
25
|
-
triangleIndices
|
|
59
|
+
triangleIndices?: Uint32Array;
|
|
26
60
|
};
|
|
27
61
|
|
|
28
62
|
/**
|
|
@@ -37,11 +71,21 @@ export const TriangulationWorker = {
|
|
|
37
71
|
};
|
|
38
72
|
|
|
39
73
|
/**
|
|
40
|
-
*
|
|
74
|
+
* Triangulate a set of polygons on worker, type safe API
|
|
41
75
|
*/
|
|
42
76
|
export function triangulateOnWorker(
|
|
43
|
-
data:
|
|
77
|
+
data: TriangulateInput,
|
|
78
|
+
options: WorkerOptions = {}
|
|
79
|
+
): Promise<TriangulateResult> {
|
|
80
|
+
return processOnWorker(TriangulationWorker, {...data, operation: 'triangulate'}, options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Parse GeoArrow geometry colum on worker, type safe API
|
|
85
|
+
*/
|
|
86
|
+
export function parseGeoArrowOnWorker(
|
|
87
|
+
data: ParseGeoArrowInput,
|
|
44
88
|
options: WorkerOptions = {}
|
|
45
|
-
): Promise<
|
|
46
|
-
return processOnWorker(TriangulationWorker, data, options);
|
|
89
|
+
): Promise<ParseGeoArrowResult> {
|
|
90
|
+
return processOnWorker(TriangulationWorker, {...data, operation: 'parse-geoarrow'}, options);
|
|
47
91
|
}
|
package/src/types.ts
CHANGED