@loaders.gl/arrow 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/arrow-loader.d.ts.map +1 -1
  2. package/dist/arrow-loader.js.map +1 -1
  3. package/dist/arrow-worker.js +2 -2
  4. package/dist/arrow-writer.d.ts.map +1 -1
  5. package/dist/arrow-writer.js.map +1 -1
  6. package/dist/dist.dev.js +650 -2
  7. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts +24 -0
  8. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -0
  9. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js +190 -0
  10. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js.map +1 -0
  11. package/dist/geoarrow/convert-geoarrow-to-geojson.d.ts +19 -0
  12. package/dist/geoarrow/convert-geoarrow-to-geojson.d.ts.map +1 -0
  13. package/dist/geoarrow/convert-geoarrow-to-geojson.js +138 -0
  14. package/dist/geoarrow/convert-geoarrow-to-geojson.js.map +1 -0
  15. package/dist/geoarrow/get-arrow-bounds.d.ts +11 -0
  16. package/dist/geoarrow/get-arrow-bounds.d.ts.map +1 -0
  17. package/dist/geoarrow/get-arrow-bounds.js +24 -0
  18. package/dist/geoarrow/get-arrow-bounds.js.map +1 -0
  19. package/dist/index.cjs +589 -7
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +4 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/lib/parse-arrow-sync.d.ts.map +1 -1
  25. package/dist/lib/parse-arrow-sync.js +1 -1
  26. package/dist/lib/parse-arrow-sync.js.map +1 -1
  27. package/dist/schema/arrow-type-utils.d.ts +1 -0
  28. package/dist/schema/arrow-type-utils.d.ts.map +1 -1
  29. package/dist/schema/arrow-type-utils.js.map +1 -1
  30. package/dist/schema/{convert-schema-arrow.d.ts → convert-arrow-schema.d.ts} +7 -1
  31. package/dist/schema/convert-arrow-schema.d.ts.map +1 -0
  32. package/dist/schema/{convert-schema-arrow.js → convert-arrow-schema.js} +78 -4
  33. package/dist/schema/convert-arrow-schema.js.map +1 -0
  34. package/dist/{lib/convert-table.d.ts → tables/convert-arrow-to-table.d.ts} +2 -2
  35. package/dist/tables/convert-arrow-to-table.d.ts.map +1 -0
  36. package/dist/{lib/convert-table.js → tables/convert-arrow-to-table.js} +1 -1
  37. package/dist/tables/convert-arrow-to-table.js.map +1 -0
  38. package/dist/{schema → tables}/convert-table-to-arrow.d.ts.map +1 -1
  39. package/dist/{schema → tables}/convert-table-to-arrow.js.map +1 -1
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/types.js.map +1 -1
  42. package/dist/workers/arrow-worker.js.map +1 -1
  43. package/package.json +5 -4
  44. package/src/arrow-loader.ts +1 -0
  45. package/src/arrow-writer.ts +1 -0
  46. package/src/geoarrow/convert-geoarrow-to-binary-geometry.ts +262 -0
  47. package/src/geoarrow/convert-geoarrow-to-geojson.ts +192 -0
  48. package/src/geoarrow/get-arrow-bounds.ts +41 -0
  49. package/src/index.ts +28 -4
  50. package/src/lib/parse-arrow-sync.ts +4 -1
  51. package/src/schema/arrow-type-utils.ts +1 -0
  52. package/src/schema/{convert-schema-arrow.ts → convert-arrow-schema.ts} +97 -21
  53. package/src/{lib/convert-table.ts → tables/convert-arrow-to-table.ts} +2 -1
  54. package/src/types.ts +3 -0
  55. package/src/workers/arrow-worker.ts +3 -0
  56. package/dist/lib/convert-table.d.ts.map +0 -1
  57. package/dist/lib/convert-table.js.map +0 -1
  58. package/dist/schema/convert-schema-arrow.d.ts.map +0 -1
  59. package/dist/schema/convert-schema-arrow.js.map +0 -1
  60. /package/dist/{schema → tables}/convert-table-to-arrow.d.ts +0 -0
  61. /package/dist/{schema → tables}/convert-table-to-arrow.js +0 -0
  62. /package/src/{schema → tables}/convert-table-to-arrow.ts +0 -0
@@ -0,0 +1,262 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
4
+ import {Data, Vector} from 'apache-arrow';
5
+ import {BinaryFeatureCollection as BinaryFeatures} from '@loaders.gl/schema';
6
+ import {GeoArrowEncoding} from '@loaders.gl/gis';
7
+ import {updateBoundsFromGeoArrowSamples} from './get-arrow-bounds';
8
+
9
+ /**
10
+ * Binary data from geoarrow column and can be used by e.g. deck.gl GeojsonLayer
11
+ */
12
+ export type BinaryDataFromGeoArrow = {
13
+ binaryGeometries: BinaryFeatures[];
14
+ bounds: [number, number, number, number];
15
+ featureTypes: {polygon: boolean; point: boolean; line: boolean};
16
+ };
17
+
18
+ type BinaryGeometryContent = {
19
+ featureIds: Uint32Array;
20
+ flatCoordinateArray: Float64Array;
21
+ nDim: number;
22
+ geomOffset: Int32Array;
23
+ geometryIndicies: Uint16Array;
24
+ };
25
+
26
+ // binary geometry template, see deck.gl BinaryGeometry
27
+ const BINARY_GEOMETRY_TEMPLATE = {
28
+ globalFeatureIds: {value: new Uint32Array(0), size: 1},
29
+ positions: {value: new Float32Array(0), size: 2},
30
+ properties: [],
31
+ numericProps: {},
32
+ featureIds: {value: new Uint32Array(0), size: 1}
33
+ };
34
+
35
+ /**
36
+ * get binary geometries from geoarrow column
37
+ *
38
+ * @param geoColumn the geoarrow column, e.g. arrowTable.getChildAt(geoColumnIndex)
39
+ * @param geoEncoding the geo encoding of the geoarrow column, e.g. getGeoArrowEncoding(arrowTable.schema, geoColumnName)
40
+ * @returns BinaryDataFromGeoArrow
41
+ */
42
+ export function getBinaryGeometriesFromArrow(
43
+ geoColumn: Vector,
44
+ geoEncoding: GeoArrowEncoding
45
+ ): BinaryDataFromGeoArrow {
46
+ const featureTypes = {
47
+ polygon: geoEncoding === 'geoarrow.multipolygon' || geoEncoding === 'geoarrow.polygon',
48
+ point: geoEncoding === 'geoarrow.multipoint' || geoEncoding === 'geoarrow.point',
49
+ line: geoEncoding === 'geoarrow.multilinestring' || geoEncoding === 'geoarrow.linestring'
50
+ };
51
+
52
+ const chunks = geoColumn.data;
53
+ const bounds: [number, number, number, number] = [Infinity, Infinity, -Infinity, -Infinity];
54
+ let globalFeatureIdOffset = 0;
55
+ const binaryGeometries: BinaryFeatures[] = [];
56
+
57
+ for (let c = 0; c < chunks.length; c++) {
58
+ const geometries = chunks[c];
59
+ const {featureIds, flatCoordinateArray, nDim, geomOffset} = getBinaryGeometriesFromChunk(
60
+ geometries,
61
+ geoEncoding
62
+ );
63
+
64
+ const numOfVertices = flatCoordinateArray.length / nDim;
65
+ const globalFeatureIds = new Uint32Array(numOfVertices);
66
+ for (let i = 0; i < numOfVertices; i++) {
67
+ globalFeatureIds[i] = featureIds[i] + globalFeatureIdOffset;
68
+ }
69
+
70
+ const binaryContent = {
71
+ globalFeatureIds: {value: globalFeatureIds, size: 1},
72
+ positions: {
73
+ value: flatCoordinateArray,
74
+ size: nDim
75
+ },
76
+ featureIds: {value: featureIds, size: 1},
77
+ // eslint-disable-next-line no-loop-func
78
+ properties: [...Array(geometries.length).keys()].map((i) => ({
79
+ index: i + globalFeatureIdOffset
80
+ }))
81
+ };
82
+
83
+ // TODO: check if chunks are sequentially accessed
84
+ globalFeatureIdOffset += geometries.length;
85
+
86
+ // NOTE: deck.gl defines the BinaryFeatures structure must have points, lines, polygons even if they are empty
87
+ binaryGeometries.push({
88
+ shape: 'binary-feature-collection',
89
+ points: {
90
+ type: 'Point',
91
+ ...BINARY_GEOMETRY_TEMPLATE,
92
+ ...(featureTypes.point ? binaryContent : {})
93
+ },
94
+ lines: {
95
+ type: 'LineString',
96
+ ...BINARY_GEOMETRY_TEMPLATE,
97
+ ...(featureTypes.line ? binaryContent : {}),
98
+ pathIndices: {value: featureTypes.line ? geomOffset : new Uint16Array(0), size: 1}
99
+ },
100
+ polygons: {
101
+ type: 'Polygon',
102
+ ...BINARY_GEOMETRY_TEMPLATE,
103
+ ...(featureTypes.polygon ? binaryContent : {}),
104
+ polygonIndices: {
105
+ // TODO why deck.gl's tessellatePolygon performance is not good when using geometryIndicies
106
+ // even when there is no hole in any polygon
107
+ value: featureTypes.polygon ? geomOffset : new Uint16Array(0),
108
+ size: 1
109
+ },
110
+ primitivePolygonIndices: {
111
+ value: featureTypes.polygon ? geomOffset : new Uint16Array(0),
112
+ size: 1
113
+ }
114
+ }
115
+ });
116
+
117
+ updateBoundsFromGeoArrowSamples(flatCoordinateArray, nDim, bounds);
118
+ }
119
+
120
+ return {binaryGeometries, bounds, featureTypes};
121
+ }
122
+
123
+ /**
124
+ * get binary geometries from geoarrow column
125
+ * @param chunk one chunk/batch of geoarrow column
126
+ * @param geoEncoding geo encoding of the geoarrow column
127
+ * @returns BinaryGeometryContent
128
+ */
129
+ function getBinaryGeometriesFromChunk(
130
+ chunk: Data,
131
+ geoEncoding: GeoArrowEncoding
132
+ ): BinaryGeometryContent {
133
+ switch (geoEncoding) {
134
+ case 'geoarrow.point':
135
+ case 'geoarrow.multipoint':
136
+ return getBinaryPointsFromChunk(chunk, geoEncoding);
137
+ case 'geoarrow.linestring':
138
+ case 'geoarrow.multilinestring':
139
+ return getBinaryLinesFromChunk(chunk, geoEncoding);
140
+ case 'geoarrow.polygon':
141
+ case 'geoarrow.multipolygon':
142
+ return getBinaryPolygonsFromChunk(chunk, geoEncoding);
143
+ default:
144
+ throw Error('invalid geoarrow encoding');
145
+ }
146
+ }
147
+
148
+ /**
149
+ * get binary polygons from geoarrow polygon column
150
+ * @param chunk one chunk of geoarrow polygon column
151
+ * @param geoEncoding the geo encoding of the geoarrow polygon column
152
+ * @returns BinaryGeometryContent
153
+ */
154
+ function getBinaryPolygonsFromChunk(chunk: Data, geoEncoding: string): BinaryGeometryContent {
155
+ const isMultiPolygon = geoEncoding === 'geoarrow.multipolygon';
156
+
157
+ const polygonData = isMultiPolygon ? chunk.children[0] : chunk;
158
+ const ringData = polygonData.children[0];
159
+ const pointData = ringData.children[0];
160
+ const coordData = pointData.children[0];
161
+ const nDim = pointData.stride;
162
+ const geomOffset = ringData.valueOffsets;
163
+ const flatCoordinateArray = coordData.values;
164
+
165
+ const geometryIndicies = new Uint16Array(chunk.length + 1);
166
+ for (let i = 0; i < chunk.length; i++) {
167
+ geometryIndicies[i] = geomOffset[chunk.valueOffsets[i]];
168
+ }
169
+ geometryIndicies[chunk.length] = flatCoordinateArray.length / nDim;
170
+
171
+ const numOfVertices = flatCoordinateArray.length / nDim;
172
+ const featureIds = new Uint32Array(numOfVertices);
173
+ for (let i = 0; i < chunk.length - 1; i++) {
174
+ const startIdx = geomOffset[chunk.valueOffsets[i]];
175
+ const endIdx = geomOffset[chunk.valueOffsets[i + 1]];
176
+ for (let j = startIdx; j < endIdx; j++) {
177
+ featureIds[j] = i;
178
+ }
179
+ }
180
+
181
+ return {
182
+ featureIds,
183
+ flatCoordinateArray,
184
+ nDim,
185
+ geomOffset,
186
+ geometryIndicies
187
+ };
188
+ }
189
+
190
+ /**
191
+ * get binary lines from geoarrow line column
192
+ * @param chunk one chunk/batch of geoarrow column
193
+ * @param geoEncoding the geo encoding of the geoarrow column
194
+ * @returns BinaryGeometryContent
195
+ */
196
+ function getBinaryLinesFromChunk(chunk: Data, geoEncoding: string): BinaryGeometryContent {
197
+ const isMultiLineString = geoEncoding === 'geoarrow.multilinestring';
198
+
199
+ const lineData = isMultiLineString ? chunk.children[0] : chunk;
200
+ const pointData = lineData.children[0];
201
+ const coordData = pointData.children[0];
202
+
203
+ const nDim = pointData.stride;
204
+ const geomOffset = lineData.valueOffsets;
205
+ const flatCoordinateArray = coordData.values;
206
+
207
+ // geometryIndicies is not needed for line string
208
+ const geometryIndicies = new Uint16Array(0);
209
+
210
+ const numOfVertices = flatCoordinateArray.length / nDim;
211
+ const featureIds = new Uint32Array(numOfVertices);
212
+ for (let i = 0; i < chunk.length; i++) {
213
+ const startIdx = geomOffset[i];
214
+ const endIdx = geomOffset[i + 1];
215
+ for (let j = startIdx; j < endIdx; j++) {
216
+ featureIds[j] = i;
217
+ }
218
+ }
219
+
220
+ return {
221
+ featureIds,
222
+ flatCoordinateArray,
223
+ nDim,
224
+ geomOffset,
225
+ geometryIndicies
226
+ };
227
+ }
228
+
229
+ /**
230
+ * get binary points from geoarrow point column
231
+ * @param chunk one chunk/batch of geoarrow column
232
+ * @param geoEncoding geo encoding of the geoarrow column
233
+ * @returns BinaryGeometryContent
234
+ */
235
+ function getBinaryPointsFromChunk(chunk: Data, geoEncoding: string): BinaryGeometryContent {
236
+ const isMultiPoint = geoEncoding === 'geoarrow.multipoint';
237
+
238
+ const pointData = isMultiPoint ? chunk.children[0] : chunk;
239
+ const coordData = pointData.children[0];
240
+
241
+ const nDim = pointData.stride;
242
+ const flatCoordinateArray = coordData.values;
243
+
244
+ // geometryIndices is not needed for point
245
+ const geometryIndicies = new Uint16Array(0);
246
+ // geomOffset is not needed for point
247
+ const geomOffset = new Int32Array(0);
248
+
249
+ const numOfVertices = flatCoordinateArray.length / nDim;
250
+ const featureIds = new Uint32Array(numOfVertices);
251
+ for (let i = 0; i < chunk.length; i++) {
252
+ featureIds[i] = i;
253
+ }
254
+
255
+ return {
256
+ featureIds,
257
+ flatCoordinateArray,
258
+ nDim,
259
+ geomOffset,
260
+ geometryIndicies
261
+ };
262
+ }
@@ -0,0 +1,192 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
4
+ import {Vector} from 'apache-arrow';
5
+ import {
6
+ Feature,
7
+ MultiPolygon,
8
+ Position,
9
+ Polygon,
10
+ MultiPoint,
11
+ Point,
12
+ MultiLineString,
13
+ LineString
14
+ } from '@loaders.gl/schema';
15
+ import type {GeoArrowEncoding} from '@loaders.gl/gis';
16
+
17
+ type RawArrowFeature = {
18
+ encoding?: GeoArrowEncoding;
19
+ data: any;
20
+ };
21
+
22
+ /**
23
+ * parse geometry from arrow data that is returned from processArrowData()
24
+ * NOTE: this function could be duplicated with the binaryToFeature() in deck.gl,
25
+ * it is currently only used for picking because currently deck.gl returns only the index of the feature
26
+ * So the following functions could be deprecated once deck.gl returns the feature directly for binary geojson layer
27
+ *
28
+ * @param rawData the raw geometry data returned from processArrowData, which is an object with two properties: encoding and data
29
+ * @see processArrowData
30
+ * @returns Feature or null
31
+ */
32
+ export function parseGeometryFromArrow(rawData: RawArrowFeature): Feature | null {
33
+ const encoding = rawData.encoding?.toLowerCase();
34
+ const data = rawData.data;
35
+ if (!encoding || !data) {
36
+ return null;
37
+ }
38
+
39
+ let geometry;
40
+
41
+ switch (encoding) {
42
+ case 'geoarrow.multipolygon':
43
+ geometry = arrowMultiPolygonToFeature(data);
44
+ break;
45
+ case 'geoarrow.polygon':
46
+ geometry = arrowPolygonToFeature(data);
47
+ break;
48
+ case 'geoarrow.multipoint':
49
+ geometry = arrowMultiPointToFeature(data);
50
+ break;
51
+ case 'geoarrow.point':
52
+ geometry = arrowPointToFeature(data);
53
+ break;
54
+ case 'geoarrow.multilinestring':
55
+ geometry = arrowMultiLineStringToFeature(data);
56
+ break;
57
+ case 'geoarrow.linestring':
58
+ geometry = arrowLineStringToFeature(data);
59
+ break;
60
+ default: {
61
+ throw Error(`GeoArrow encoding not supported ${encoding}`);
62
+ }
63
+ }
64
+ return {
65
+ type: 'Feature',
66
+ geometry,
67
+ properties: {}
68
+ };
69
+ }
70
+
71
+ /**
72
+ * convert Arrow MultiPolygon to geojson Feature
73
+ */
74
+ function arrowMultiPolygonToFeature(arrowMultiPolygon: Vector): MultiPolygon {
75
+ const multiPolygon: Position[][][] = [];
76
+ for (let m = 0; m < arrowMultiPolygon.length; m++) {
77
+ const arrowPolygon = arrowMultiPolygon.get(m);
78
+ const polygon: Position[][] = [];
79
+ for (let i = 0; arrowPolygon && i < arrowPolygon?.length; i++) {
80
+ const arrowRing = arrowPolygon?.get(i);
81
+ const ring: Position[] = [];
82
+ for (let j = 0; arrowRing && j < arrowRing.length; j++) {
83
+ const arrowCoord = arrowRing.get(j);
84
+ const coord: Position = Array.from(arrowCoord);
85
+ ring.push(coord);
86
+ }
87
+ polygon.push(ring);
88
+ }
89
+ multiPolygon.push(polygon);
90
+ }
91
+ const geometry: MultiPolygon = {
92
+ type: 'MultiPolygon',
93
+ coordinates: multiPolygon
94
+ };
95
+ return geometry;
96
+ }
97
+
98
+ /**
99
+ * convert Arrow Polygon to geojson Feature
100
+ */
101
+ function arrowPolygonToFeature(arrowPolygon: Vector): Polygon {
102
+ const polygon: Position[][] = [];
103
+ for (let i = 0; arrowPolygon && i < arrowPolygon.length; i++) {
104
+ const arrowRing = arrowPolygon.get(i);
105
+ const ring: Position[] = [];
106
+ for (let j = 0; arrowRing && j < arrowRing.length; j++) {
107
+ const arrowCoord = arrowRing.get(j);
108
+ const coords: Position = Array.from(arrowCoord);
109
+ ring.push(coords);
110
+ }
111
+ polygon.push(ring);
112
+ }
113
+ const geometry: Polygon = {
114
+ type: 'Polygon',
115
+ coordinates: polygon
116
+ };
117
+ return geometry;
118
+ }
119
+
120
+ /**
121
+ * convert Arrow MultiPoint to geojson MultiPoint
122
+ */
123
+ function arrowMultiPointToFeature(arrowMultiPoint: Vector): MultiPoint {
124
+ const multiPoint: Position[] = [];
125
+ for (let i = 0; arrowMultiPoint && i < arrowMultiPoint.length; i++) {
126
+ const arrowPoint = arrowMultiPoint.get(i);
127
+ if (arrowPoint) {
128
+ const coord: Position = Array.from(arrowPoint);
129
+ multiPoint.push(coord);
130
+ }
131
+ }
132
+ const geometry: MultiPoint = {
133
+ type: 'MultiPoint',
134
+ coordinates: multiPoint
135
+ };
136
+ return geometry;
137
+ }
138
+
139
+ /**
140
+ * convert Arrow Point to geojson Point
141
+ */
142
+ function arrowPointToFeature(arrowPoint: Vector): Point {
143
+ const point: Position = Array.from(arrowPoint);
144
+ const geometry: Point = {
145
+ type: 'Point',
146
+ coordinates: point
147
+ };
148
+ return geometry;
149
+ }
150
+
151
+ /**
152
+ * convert Arrow MultiLineString to geojson MultiLineString
153
+ */
154
+ function arrowMultiLineStringToFeature(arrowMultiLineString: Vector): MultiLineString {
155
+ const multiLineString: Position[][] = [];
156
+ for (let i = 0; arrowMultiLineString && i < arrowMultiLineString.length; i++) {
157
+ const arrowLineString = arrowMultiLineString.get(i);
158
+ const lineString: Position[] = [];
159
+ for (let j = 0; arrowLineString && j < arrowLineString.length; j++) {
160
+ const arrowCoord = arrowLineString.get(j);
161
+ if (arrowCoord) {
162
+ const coords: Position = Array.from(arrowCoord);
163
+ lineString.push(coords);
164
+ }
165
+ }
166
+ multiLineString.push(lineString);
167
+ }
168
+ const geometry: MultiLineString = {
169
+ type: 'MultiLineString',
170
+ coordinates: multiLineString
171
+ };
172
+ return geometry;
173
+ }
174
+
175
+ /**
176
+ * convert Arrow LineString to geojson LineString
177
+ */
178
+ function arrowLineStringToFeature(arrowLineString: Vector): LineString {
179
+ const lineString: Position[] = [];
180
+ for (let i = 0; arrowLineString && i < arrowLineString.length; i++) {
181
+ const arrowCoord = arrowLineString.get(i);
182
+ if (arrowCoord) {
183
+ const coords: Position = Array.from(arrowCoord);
184
+ lineString.push(coords);
185
+ }
186
+ }
187
+ const geometry: LineString = {
188
+ type: 'LineString',
189
+ coordinates: lineString
190
+ };
191
+ return geometry;
192
+ }
@@ -0,0 +1,41 @@
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
3
+
4
+ /**
5
+ * Update bounds from geoarrow sample data
6
+ *
7
+ * @param flatCoords the flattend coordinates array from one chunk of geoarrow column
8
+ * @param nDim the number of dimensions of the coordinates
9
+ * @param bounds the bounds to be updated
10
+ * @param sampleSize how many samples to be used to update the bounds, default is 1000 per chunk
11
+ * @returns the updated bounds
12
+ */
13
+ export function updateBoundsFromGeoArrowSamples(
14
+ flatCoords: Float64Array,
15
+ nDim: number,
16
+ bounds: [number, number, number, number],
17
+ sampleSize: number = 100
18
+ ): [number, number, number, number] {
19
+ const numberOfFeatures = flatCoords.length / nDim;
20
+ const sampleStep = Math.max(Math.floor(numberOfFeatures / sampleSize), 1);
21
+
22
+ const newBounds: [number, number, number, number] = [...bounds];
23
+ for (let i = 0; i < numberOfFeatures; i += sampleStep) {
24
+ const lng = flatCoords[i * nDim];
25
+ const lat = flatCoords[i * nDim + 1];
26
+ if (lng < bounds[0]) {
27
+ newBounds[0] = lng;
28
+ }
29
+ if (lat < newBounds[1]) {
30
+ newBounds[1] = lat;
31
+ }
32
+ if (lng > newBounds[2]) {
33
+ newBounds[2] = lng;
34
+ }
35
+ if (lat > newBounds[3]) {
36
+ newBounds[3] = lat;
37
+ }
38
+ }
39
+
40
+ return newBounds;
41
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT
1
+ // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
2
3
 
3
4
  import type {LoaderWithParser} from '@loaders.gl/loader-utils';
4
5
  import type {ArrowLoaderOptions} from './arrow-loader';
@@ -12,12 +13,25 @@ import {parseArrowInBatches} from './lib/parse-arrow-in-batches';
12
13
 
13
14
  import {ArrowTableBatchAggregator} from './lib/arrow-table-batch';
14
15
 
15
- // SCHEMA
16
+ // Make the ArrowBatch type available
17
+ TableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;
18
+
19
+ // TYPES
16
20
 
17
21
  export {getArrowType} from './schema/arrow-type-utils';
18
22
 
19
- // Make the ArrowBatch type available
20
- TableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;
23
+ // SCHEMA
24
+
25
+ export {
26
+ serializeArrowSchema,
27
+ deserializeArrowSchema,
28
+ serializeArrowMetadata,
29
+ deserializeArrowMetadata,
30
+ serializeArrowField,
31
+ deserializeArrowField,
32
+ serializeArrowType,
33
+ deserializeArrowType
34
+ } from './schema/convert-arrow-schema';
21
35
 
22
36
  // Types
23
37
  export type {ArrowTable, ArrowTableBatch} from './lib/arrow-table';
@@ -44,3 +58,13 @@ export const ArrowLoader: LoaderWithParser<
44
58
  parseSync,
45
59
  parseInBatches: parseArrowInBatches
46
60
  };
61
+
62
+ // Arrow Utils
63
+ export type {GeoArrowEncoding} from '@loaders.gl/gis';
64
+ // getGeometryColumnsFromArrowTable,
65
+ // getGeoArrowEncoding
66
+
67
+ export type {BinaryDataFromGeoArrow} from './geoarrow/convert-geoarrow-to-binary-geometry';
68
+ export {getBinaryGeometriesFromArrow} from './geoarrow/convert-geoarrow-to-binary-geometry';
69
+
70
+ export {parseGeometryFromArrow} from './geoarrow/convert-geoarrow-to-geojson';
@@ -3,7 +3,10 @@ import type {ArrowTable} from './arrow-table';
3
3
  import {convertTable} from '@loaders.gl/schema';
4
4
  import {tableFromIPC} from 'apache-arrow';
5
5
  import type {ArrowLoaderOptions} from '../arrow-loader';
6
- import {convertApacheArrowToArrowTable, convertArrowToColumnarTable} from './convert-table';
6
+ import {
7
+ convertApacheArrowToArrowTable,
8
+ convertArrowToColumnarTable
9
+ } from '../tables/convert-arrow-to-table';
7
10
 
8
11
  // Parses arrow to a columnar table
9
12
  export default function parseArrowSync(
@@ -23,6 +23,7 @@ import {
23
23
  } from 'apache-arrow';
24
24
  // import {AbstractVector} from 'apache-arrow/vector';
25
25
 
26
+ /** Return an Apache Arrow Type instance that corresponds to the type of the elements in the supplied Typed Array */
26
27
  export function getArrowType(array: TypedArray): DataType {
27
28
  switch (array.constructor) {
28
29
  case Int8Array: