@loaders.gl/schema 4.0.0-alpha.22 → 4.0.0-alpha.24
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/dist.min.js +517 -927
- package/dist/es5/index.js +7 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/table/simple-table/convert-table.js +24 -0
- package/dist/es5/lib/table/simple-table/convert-table.js.map +1 -1
- package/dist/es5/types/binary-geometries.js.map +1 -1
- package/dist/es5/types/category-gis.js.map +1 -1
- package/dist/es5/types/category-table.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/table/simple-table/convert-table.js +22 -0
- package/dist/esm/lib/table/simple-table/convert-table.js.map +1 -1
- package/dist/esm/types/binary-geometries.js.map +1 -1
- package/dist/esm/types/category-gis.js.map +1 -1
- package/dist/esm/types/category-table.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/table/simple-table/convert-table.d.ts +34 -1
- package/dist/lib/table/simple-table/convert-table.d.ts.map +1 -1
- package/dist/types/binary-geometries.d.ts +9 -7
- package/dist/types/binary-geometries.d.ts.map +1 -1
- package/dist/types/category-gis.d.ts +1 -1
- package/dist/types/category-gis.d.ts.map +1 -1
- package/dist/types/category-table.d.ts +21 -11
- package/dist/types/category-table.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +8 -4
- package/src/lib/table/simple-table/convert-table.ts +73 -1
- package/src/types/binary-geometries.ts +10 -7
- package/src/types/category-gis.ts +5 -4
- package/src/types/category-table.ts +26 -11
- package/dist/bundle.js +0 -5
- package/dist/index.js +0 -92
- package/dist/lib/mesh/convert-mesh.js +0 -40
- package/dist/lib/mesh/deduce-mesh-schema.js +0 -66
- package/dist/lib/mesh/mesh-to-arrow-table.js +0 -44
- package/dist/lib/mesh/mesh-utils.js +0 -51
- package/dist/lib/table/arrow/arrow-type-utils.js +0 -53
- package/dist/lib/table/arrow/convert-schema-arrow.js +0 -187
- package/dist/lib/table/arrow/convert-table-to-arrow.js +0 -57
- package/dist/lib/table/arrow-api/arrow-like-field.js +0 -34
- package/dist/lib/table/arrow-api/arrow-like-schema.js +0 -81
- package/dist/lib/table/arrow-api/arrow-like-table.js +0 -53
- package/dist/lib/table/arrow-api/arrow-like-type.js +0 -463
- package/dist/lib/table/arrow-api/enum.js +0 -97
- package/dist/lib/table/arrow-api/get-type-info.js +0 -29
- package/dist/lib/table/arrow-api/index.js +0 -25
- package/dist/lib/table/batches/base-table-batch-aggregator.js +0 -60
- package/dist/lib/table/batches/columnar-table-batch-aggregator.js +0 -92
- package/dist/lib/table/batches/row-table-batch-aggregator.js +0 -81
- package/dist/lib/table/batches/table-batch-aggregator.js +0 -3
- package/dist/lib/table/batches/table-batch-builder.js +0 -152
- package/dist/lib/table/simple-table/convert-table.js +0 -65
- package/dist/lib/table/simple-table/data-type.js +0 -93
- package/dist/lib/table/simple-table/make-table.js +0 -95
- package/dist/lib/table/simple-table/row-utils.js +0 -33
- package/dist/lib/table/simple-table/table-accessors.js +0 -319
- package/dist/lib/table/simple-table/table-column.js +0 -41
- package/dist/lib/table/simple-table/table-schema.js +0 -85
- package/dist/lib/utils/assert.js +0 -12
- package/dist/lib/utils/async-queue.js +0 -92
- package/dist/types/binary-geometries.js +0 -2
- package/dist/types/category-gis.js +0 -3
- package/dist/types/category-image.js +0 -2
- package/dist/types/category-mesh.js +0 -3
- package/dist/types/category-table.js +0 -3
- package/dist/types/category-texture.js +0 -3
- package/dist/types/flat-geometries.js +0 -3
- package/dist/types/schema.js +0 -3
- package/dist/types/types.js +0 -2
package/src/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// COMMON CATEGORY
|
|
2
2
|
export type {
|
|
3
3
|
TypedArray,
|
|
4
|
+
BigTypedArray,
|
|
4
5
|
TypedArrayConstructor,
|
|
6
|
+
BigTypedArrayConstructor,
|
|
5
7
|
NumberArray,
|
|
6
8
|
ArrayType,
|
|
7
9
|
AnyArray
|
|
@@ -52,6 +54,7 @@ export {
|
|
|
52
54
|
export {ArrowLikeTable} from './lib/table/arrow-api/arrow-like-table';
|
|
53
55
|
|
|
54
56
|
export {makeTableFromData} from './lib/table/simple-table/make-table';
|
|
57
|
+
export {convertTable} from './lib/table/simple-table/convert-table';
|
|
55
58
|
export {deduceTableSchema} from './lib/table/simple-table/table-schema';
|
|
56
59
|
export {convertToObjectRow, convertToArrayRow} from './lib/table/simple-table/row-utils';
|
|
57
60
|
export {getDataTypeFromArray} from './lib/table/simple-table/data-type';
|
|
@@ -122,10 +125,11 @@ export type {
|
|
|
122
125
|
BinaryAttribute
|
|
123
126
|
} from './types/category-gis';
|
|
124
127
|
export type {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
BinaryFeatureCollection,
|
|
129
|
+
BinaryFeature,
|
|
130
|
+
BinaryPointFeature,
|
|
131
|
+
BinaryLineFeature,
|
|
132
|
+
BinaryPolygonFeature
|
|
129
133
|
} from './types/category-gis';
|
|
130
134
|
|
|
131
135
|
// SCHEMA
|
|
@@ -5,10 +5,57 @@ import {
|
|
|
5
5
|
getTableRowAsArray,
|
|
6
6
|
getTableRowAsObject
|
|
7
7
|
} from './table-accessors';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Table,
|
|
10
|
+
ArrayRowTable,
|
|
11
|
+
ObjectRowTable,
|
|
12
|
+
ColumnarTable,
|
|
13
|
+
ArrowTable
|
|
14
|
+
} from '../../../types/category-table';
|
|
9
15
|
import {deduceTableSchema} from './table-schema';
|
|
10
16
|
import {makeColumnFromField} from './table-column';
|
|
11
17
|
|
|
18
|
+
export function convertTable(table: Table, shape: 'object-row-table'): ObjectRowTable;
|
|
19
|
+
export function convertTable(table: Table, shape: 'array-row-table'): ArrayRowTable;
|
|
20
|
+
export function convertTable(table: Table, shape: 'columnar-table'): ColumnarTable;
|
|
21
|
+
export function convertTable(table: Table, shape: 'arrow-table'): ArrowTable;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Convert a table to a different shape
|
|
25
|
+
* @param table
|
|
26
|
+
* @param shape
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export function convertTable(
|
|
30
|
+
table: Table,
|
|
31
|
+
shape: 'object-row-table' | 'array-row-table' | 'columnar-table' | 'arrow-table'
|
|
32
|
+
) {
|
|
33
|
+
switch (shape) {
|
|
34
|
+
case 'object-row-table':
|
|
35
|
+
return makeObjectRowTable(table);
|
|
36
|
+
case 'array-row-table':
|
|
37
|
+
return makeArrayRowTable(table);
|
|
38
|
+
case 'columnar-table':
|
|
39
|
+
return makeColumnarTable(table);
|
|
40
|
+
case 'arrow-table':
|
|
41
|
+
return makeArrowTable(table);
|
|
42
|
+
default:
|
|
43
|
+
throw new Error(shape);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Convert a table to apache arrow format
|
|
49
|
+
* @note this depends on the `@loaders.gl/arrow module being imported
|
|
50
|
+
*/
|
|
51
|
+
export function makeArrowTable(table: Table): Table {
|
|
52
|
+
const _makeArrowTable = globalThis.__luma?._makeArrowTable;
|
|
53
|
+
if (!_makeArrowTable) {
|
|
54
|
+
throw new Error('');
|
|
55
|
+
}
|
|
56
|
+
return _makeArrowTable(table);
|
|
57
|
+
}
|
|
58
|
+
|
|
12
59
|
/** Convert any simple table into columnar format */
|
|
13
60
|
export function makeColumnarTable(table: Table): ColumnarTable {
|
|
14
61
|
// TODO - should schema really be optional?
|
|
@@ -70,3 +117,28 @@ export function makeObjectRowTable(table: Table): ObjectRowTable {
|
|
|
70
117
|
data
|
|
71
118
|
};
|
|
72
119
|
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* @note - should be part of schema module
|
|
125
|
+
export function convertColumnarToRowFormatTable(columnarTable: ColumnarTable): ObjectRowTable {
|
|
126
|
+
const tableKeys = ;
|
|
127
|
+
const tableRowsCount = columnarTable[tableKeys[0]].length;
|
|
128
|
+
|
|
129
|
+
const objectRows: ObjectRowTable['data'] = [];
|
|
130
|
+
|
|
131
|
+
for (let index = 0; index < tableRowsCount; index++) {
|
|
132
|
+
const objectRow = {};
|
|
133
|
+
for (const fieldName of Object.keys(columnarTable.data)) {
|
|
134
|
+
objectRow[fieldName] = columnarTable[fieldName][index];
|
|
135
|
+
}
|
|
136
|
+
objectRows.push(objectRow);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
shape: 'object-row-table',
|
|
141
|
+
data: objectRows
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
*/
|
|
@@ -45,15 +45,18 @@ export type BinaryProperties = {
|
|
|
45
45
|
fields?: Properties;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
export type
|
|
50
|
-
|
|
48
|
+
/** Binary feature + binary attributes */
|
|
49
|
+
export type BinaryFeature = BinaryPointFeature | BinaryLineFeature | BinaryPolygonFeature;
|
|
50
|
+
|
|
51
|
+
export type BinaryPointFeature = BinaryPointGeometry & BinaryProperties;
|
|
52
|
+
export type BinaryLineFeature = BinaryLineGeometry & BinaryProperties;
|
|
53
|
+
export type BinaryPolygonFeature = BinaryPolygonGeometry & BinaryProperties;
|
|
51
54
|
|
|
52
55
|
/**
|
|
53
56
|
* Represent a collection of Features, similar to a GeoJSON FeatureCollection
|
|
54
57
|
*/
|
|
55
|
-
export type
|
|
56
|
-
points?:
|
|
57
|
-
lines?:
|
|
58
|
-
polygons?:
|
|
58
|
+
export type BinaryFeatureCollection = {
|
|
59
|
+
points?: BinaryPointFeature;
|
|
60
|
+
lines?: BinaryLineFeature;
|
|
61
|
+
polygons?: BinaryPolygonFeature;
|
|
59
62
|
};
|
|
@@ -40,10 +40,11 @@ export type {
|
|
|
40
40
|
BinaryLineGeometry,
|
|
41
41
|
BinaryPolygonGeometry,
|
|
42
42
|
BinaryProperties,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
BinaryFeatureCollection,
|
|
44
|
+
BinaryFeature,
|
|
45
|
+
BinaryPointFeature,
|
|
46
|
+
BinaryLineFeature,
|
|
47
|
+
BinaryPolygonFeature
|
|
47
48
|
} from './binary-geometries';
|
|
48
49
|
|
|
49
50
|
/** Aggregate information for converting GeoJSON into other formats */
|
|
@@ -66,39 +66,54 @@ export type Tables<TableType = Table> = {
|
|
|
66
66
|
// Batches
|
|
67
67
|
|
|
68
68
|
/** Batch for a general table */
|
|
69
|
-
export type TableBatch =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
export type TableBatch =
|
|
70
|
+
| ArrayRowTableBatch
|
|
71
|
+
| ObjectRowTableBatch
|
|
72
|
+
| GeoJSONRowTableBatch
|
|
73
|
+
| ColumnarTableBatch
|
|
74
|
+
| ArrowTableBatch;
|
|
75
75
|
|
|
76
76
|
/** Batch for a table organized as an array of rows, each row is an array of values */
|
|
77
|
-
export type ArrayRowTableBatch =
|
|
77
|
+
export type ArrayRowTableBatch = Batch & {
|
|
78
78
|
shape: 'array-row-table';
|
|
79
|
+
schema?: Schema;
|
|
80
|
+
schemaType?: 'explicit' | 'deduced';
|
|
79
81
|
data: any[][];
|
|
82
|
+
length: number;
|
|
80
83
|
};
|
|
81
84
|
|
|
82
85
|
/** Batch for a table organized as an array of rows, each row is an object mapping columns to values */
|
|
83
|
-
export type ObjectRowTableBatch =
|
|
86
|
+
export type ObjectRowTableBatch = Batch & {
|
|
84
87
|
shape: 'object-row-table';
|
|
88
|
+
schema?: Schema;
|
|
89
|
+
schemaType?: 'explicit' | 'deduced';
|
|
85
90
|
data: {[columnName: string]: any}[];
|
|
91
|
+
length: number;
|
|
86
92
|
};
|
|
87
93
|
|
|
88
94
|
/** Batch for a table organized as an array of rows, each row is an array of values */
|
|
89
|
-
export type GeoJSONRowTableBatch =
|
|
95
|
+
export type GeoJSONRowTableBatch = Batch & {
|
|
90
96
|
shape: 'geojson-row-table';
|
|
97
|
+
schema?: Schema;
|
|
98
|
+
schemaType?: 'explicit' | 'deduced';
|
|
91
99
|
data: Feature[];
|
|
100
|
+
length: number;
|
|
92
101
|
};
|
|
93
102
|
|
|
94
103
|
/** Batch for a table organized as a map of columns, each column is an array of value */
|
|
95
|
-
export type ColumnarTableBatch =
|
|
104
|
+
export type ColumnarTableBatch = Batch & {
|
|
96
105
|
shape: 'columnar-table';
|
|
106
|
+
schemaType?: 'explicit' | 'deduced';
|
|
107
|
+
schema?: Schema;
|
|
97
108
|
data: {[columnName: string]: ArrayLike<unknown>};
|
|
109
|
+
length: number;
|
|
98
110
|
};
|
|
99
111
|
|
|
100
112
|
/** Batch for a table organized as an Apache Arrow table */
|
|
101
|
-
export type ArrowTableBatch =
|
|
113
|
+
export type ArrowTableBatch = Batch & {
|
|
102
114
|
shape: 'arrow-table';
|
|
115
|
+
schemaType?: 'explicit' | 'deduced';
|
|
116
|
+
schema?: Schema;
|
|
103
117
|
data: RecordBatch;
|
|
118
|
+
length: number;
|
|
104
119
|
};
|
package/dist/bundle.js
DELETED
package/dist/index.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TimeMillisecond = exports.Time = exports.DateMillisecond = exports.DateDay = exports.Date = exports.Utf8 = exports.Float64 = exports.Float32 = exports.Float16 = exports.Float = exports.Uint64 = exports.Uint32 = exports.Uint16 = exports.Uint8 = exports.Int64 = exports.Int32 = exports.Int16 = exports.Int8 = exports.Int = exports.Bool = exports.Binary = exports.Null = exports.ArrowLikeDataType = exports.ArrowLikeField = exports.ArrowLikeSchema = exports.makeMeshAttributeMetadata = exports.deduceMeshField = exports.deduceMeshSchema = exports.getMeshBoundingBox = exports.getMeshSize = exports.getDataTypeFromArray = exports.convertToArrayRow = exports.convertToObjectRow = exports.deduceTableSchema = exports.makeTableFromData = exports.ArrowLikeTable = exports.makeObjectRowIterator = exports.makeArrayRowIterator = exports.makeRowIterator = exports.getTableRowAsArray = exports.getTableRowAsObject = exports.getTableColumnName = exports.getTableColumnIndex = exports.getTableRowShape = exports.getTableCell = exports.getTableNumCols = exports.getTableLength = exports.ColumnarTableBatchAggregator = exports.RowTableBatchAggregator = exports.TableBatchBuilder = void 0;
|
|
7
|
-
exports.AsyncQueue = exports.getArrowType = exports.getTypeInfo = exports.Struct = exports.FixedSizeList = exports.IntervalYearMonth = exports.IntervalDayTime = exports.Interval = exports.TimestampNanosecond = exports.TimestampMicrosecond = exports.TimestampMillisecond = exports.TimestampSecond = exports.Timestamp = exports.TimeSecond = void 0;
|
|
8
|
-
// TABLE CATEGORY UTILS
|
|
9
|
-
var table_batch_builder_1 = require("./lib/table/batches/table-batch-builder");
|
|
10
|
-
Object.defineProperty(exports, "TableBatchBuilder", { enumerable: true, get: function () { return table_batch_builder_1.TableBatchBuilder; } });
|
|
11
|
-
var row_table_batch_aggregator_1 = require("./lib/table/batches/row-table-batch-aggregator");
|
|
12
|
-
Object.defineProperty(exports, "RowTableBatchAggregator", { enumerable: true, get: function () { return row_table_batch_aggregator_1.RowTableBatchAggregator; } });
|
|
13
|
-
var columnar_table_batch_aggregator_1 = require("./lib/table/batches/columnar-table-batch-aggregator");
|
|
14
|
-
Object.defineProperty(exports, "ColumnarTableBatchAggregator", { enumerable: true, get: function () { return columnar_table_batch_aggregator_1.ColumnarTableBatchAggregator; } });
|
|
15
|
-
var table_accessors_1 = require("./lib/table/simple-table/table-accessors");
|
|
16
|
-
Object.defineProperty(exports, "getTableLength", { enumerable: true, get: function () { return table_accessors_1.getTableLength; } });
|
|
17
|
-
Object.defineProperty(exports, "getTableNumCols", { enumerable: true, get: function () { return table_accessors_1.getTableNumCols; } });
|
|
18
|
-
Object.defineProperty(exports, "getTableCell", { enumerable: true, get: function () { return table_accessors_1.getTableCell; } });
|
|
19
|
-
Object.defineProperty(exports, "getTableRowShape", { enumerable: true, get: function () { return table_accessors_1.getTableRowShape; } });
|
|
20
|
-
Object.defineProperty(exports, "getTableColumnIndex", { enumerable: true, get: function () { return table_accessors_1.getTableColumnIndex; } });
|
|
21
|
-
Object.defineProperty(exports, "getTableColumnName", { enumerable: true, get: function () { return table_accessors_1.getTableColumnName; } });
|
|
22
|
-
Object.defineProperty(exports, "getTableRowAsObject", { enumerable: true, get: function () { return table_accessors_1.getTableRowAsObject; } });
|
|
23
|
-
Object.defineProperty(exports, "getTableRowAsArray", { enumerable: true, get: function () { return table_accessors_1.getTableRowAsArray; } });
|
|
24
|
-
Object.defineProperty(exports, "makeRowIterator", { enumerable: true, get: function () { return table_accessors_1.makeRowIterator; } });
|
|
25
|
-
Object.defineProperty(exports, "makeArrayRowIterator", { enumerable: true, get: function () { return table_accessors_1.makeArrayRowIterator; } });
|
|
26
|
-
Object.defineProperty(exports, "makeObjectRowIterator", { enumerable: true, get: function () { return table_accessors_1.makeObjectRowIterator; } });
|
|
27
|
-
var arrow_like_table_1 = require("./lib/table/arrow-api/arrow-like-table");
|
|
28
|
-
Object.defineProperty(exports, "ArrowLikeTable", { enumerable: true, get: function () { return arrow_like_table_1.ArrowLikeTable; } });
|
|
29
|
-
var make_table_1 = require("./lib/table/simple-table/make-table");
|
|
30
|
-
Object.defineProperty(exports, "makeTableFromData", { enumerable: true, get: function () { return make_table_1.makeTableFromData; } });
|
|
31
|
-
var table_schema_1 = require("./lib/table/simple-table/table-schema");
|
|
32
|
-
Object.defineProperty(exports, "deduceTableSchema", { enumerable: true, get: function () { return table_schema_1.deduceTableSchema; } });
|
|
33
|
-
var row_utils_1 = require("./lib/table/simple-table/row-utils");
|
|
34
|
-
Object.defineProperty(exports, "convertToObjectRow", { enumerable: true, get: function () { return row_utils_1.convertToObjectRow; } });
|
|
35
|
-
Object.defineProperty(exports, "convertToArrayRow", { enumerable: true, get: function () { return row_utils_1.convertToArrayRow; } });
|
|
36
|
-
var data_type_1 = require("./lib/table/simple-table/data-type");
|
|
37
|
-
Object.defineProperty(exports, "getDataTypeFromArray", { enumerable: true, get: function () { return data_type_1.getDataTypeFromArray; } });
|
|
38
|
-
var mesh_utils_1 = require("./lib/mesh/mesh-utils");
|
|
39
|
-
Object.defineProperty(exports, "getMeshSize", { enumerable: true, get: function () { return mesh_utils_1.getMeshSize; } });
|
|
40
|
-
Object.defineProperty(exports, "getMeshBoundingBox", { enumerable: true, get: function () { return mesh_utils_1.getMeshBoundingBox; } });
|
|
41
|
-
// Commented out due to https://github.com/visgl/deck.gl/issues/6906 and https://github.com/visgl/loaders.gl/issues/2177
|
|
42
|
-
// export {convertMesh} from './category/mesh/convert-mesh';
|
|
43
|
-
var deduce_mesh_schema_1 = require("./lib/mesh/deduce-mesh-schema");
|
|
44
|
-
Object.defineProperty(exports, "deduceMeshSchema", { enumerable: true, get: function () { return deduce_mesh_schema_1.deduceMeshSchema; } });
|
|
45
|
-
Object.defineProperty(exports, "deduceMeshField", { enumerable: true, get: function () { return deduce_mesh_schema_1.deduceMeshField; } });
|
|
46
|
-
Object.defineProperty(exports, "makeMeshAttributeMetadata", { enumerable: true, get: function () { return deduce_mesh_schema_1.makeMeshAttributeMetadata; } });
|
|
47
|
-
// SCHEMA
|
|
48
|
-
var arrow_api_1 = require("./lib/table/arrow-api");
|
|
49
|
-
Object.defineProperty(exports, "ArrowLikeSchema", { enumerable: true, get: function () { return arrow_api_1.Schema; } });
|
|
50
|
-
Object.defineProperty(exports, "ArrowLikeField", { enumerable: true, get: function () { return arrow_api_1.Field; } });
|
|
51
|
-
Object.defineProperty(exports, "ArrowLikeDataType", { enumerable: true, get: function () { return arrow_api_1.DataType; } });
|
|
52
|
-
Object.defineProperty(exports, "Null", { enumerable: true, get: function () { return arrow_api_1.Null; } });
|
|
53
|
-
Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return arrow_api_1.Binary; } });
|
|
54
|
-
Object.defineProperty(exports, "Bool", { enumerable: true, get: function () { return arrow_api_1.Bool; } });
|
|
55
|
-
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return arrow_api_1.Int; } });
|
|
56
|
-
Object.defineProperty(exports, "Int8", { enumerable: true, get: function () { return arrow_api_1.Int8; } });
|
|
57
|
-
Object.defineProperty(exports, "Int16", { enumerable: true, get: function () { return arrow_api_1.Int16; } });
|
|
58
|
-
Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { return arrow_api_1.Int32; } });
|
|
59
|
-
Object.defineProperty(exports, "Int64", { enumerable: true, get: function () { return arrow_api_1.Int64; } });
|
|
60
|
-
Object.defineProperty(exports, "Uint8", { enumerable: true, get: function () { return arrow_api_1.Uint8; } });
|
|
61
|
-
Object.defineProperty(exports, "Uint16", { enumerable: true, get: function () { return arrow_api_1.Uint16; } });
|
|
62
|
-
Object.defineProperty(exports, "Uint32", { enumerable: true, get: function () { return arrow_api_1.Uint32; } });
|
|
63
|
-
Object.defineProperty(exports, "Uint64", { enumerable: true, get: function () { return arrow_api_1.Uint64; } });
|
|
64
|
-
Object.defineProperty(exports, "Float", { enumerable: true, get: function () { return arrow_api_1.Float; } });
|
|
65
|
-
Object.defineProperty(exports, "Float16", { enumerable: true, get: function () { return arrow_api_1.Float16; } });
|
|
66
|
-
Object.defineProperty(exports, "Float32", { enumerable: true, get: function () { return arrow_api_1.Float32; } });
|
|
67
|
-
Object.defineProperty(exports, "Float64", { enumerable: true, get: function () { return arrow_api_1.Float64; } });
|
|
68
|
-
Object.defineProperty(exports, "Utf8", { enumerable: true, get: function () { return arrow_api_1.Utf8; } });
|
|
69
|
-
Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return arrow_api_1.Date; } });
|
|
70
|
-
Object.defineProperty(exports, "DateDay", { enumerable: true, get: function () { return arrow_api_1.DateDay; } });
|
|
71
|
-
Object.defineProperty(exports, "DateMillisecond", { enumerable: true, get: function () { return arrow_api_1.DateMillisecond; } });
|
|
72
|
-
Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return arrow_api_1.Time; } });
|
|
73
|
-
Object.defineProperty(exports, "TimeMillisecond", { enumerable: true, get: function () { return arrow_api_1.TimeMillisecond; } });
|
|
74
|
-
Object.defineProperty(exports, "TimeSecond", { enumerable: true, get: function () { return arrow_api_1.TimeSecond; } });
|
|
75
|
-
Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return arrow_api_1.Timestamp; } });
|
|
76
|
-
Object.defineProperty(exports, "TimestampSecond", { enumerable: true, get: function () { return arrow_api_1.TimestampSecond; } });
|
|
77
|
-
Object.defineProperty(exports, "TimestampMillisecond", { enumerable: true, get: function () { return arrow_api_1.TimestampMillisecond; } });
|
|
78
|
-
Object.defineProperty(exports, "TimestampMicrosecond", { enumerable: true, get: function () { return arrow_api_1.TimestampMicrosecond; } });
|
|
79
|
-
Object.defineProperty(exports, "TimestampNanosecond", { enumerable: true, get: function () { return arrow_api_1.TimestampNanosecond; } });
|
|
80
|
-
Object.defineProperty(exports, "Interval", { enumerable: true, get: function () { return arrow_api_1.Interval; } });
|
|
81
|
-
Object.defineProperty(exports, "IntervalDayTime", { enumerable: true, get: function () { return arrow_api_1.IntervalDayTime; } });
|
|
82
|
-
Object.defineProperty(exports, "IntervalYearMonth", { enumerable: true, get: function () { return arrow_api_1.IntervalYearMonth; } });
|
|
83
|
-
Object.defineProperty(exports, "FixedSizeList", { enumerable: true, get: function () { return arrow_api_1.FixedSizeList; } });
|
|
84
|
-
Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return arrow_api_1.Struct; } });
|
|
85
|
-
// EXPERIMENTAL APIs
|
|
86
|
-
// SCHEMA UTILS
|
|
87
|
-
var get_type_info_1 = require("./lib/table/arrow-api/get-type-info");
|
|
88
|
-
Object.defineProperty(exports, "getTypeInfo", { enumerable: true, get: function () { return get_type_info_1.getTypeInfo; } });
|
|
89
|
-
var arrow_type_utils_1 = require("./lib/table/arrow/arrow-type-utils");
|
|
90
|
-
Object.defineProperty(exports, "getArrowType", { enumerable: true, get: function () { return arrow_type_utils_1.getArrowType; } });
|
|
91
|
-
var async_queue_1 = require("./lib/utils/async-queue");
|
|
92
|
-
Object.defineProperty(exports, "AsyncQueue", { enumerable: true, get: function () { return __importDefault(async_queue_1).default; } });
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.convertMeshToColumnarTable = exports.convertMesh = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Convert a mesh to a specific shape
|
|
7
|
-
*/
|
|
8
|
-
function convertMesh(mesh, shape, options) {
|
|
9
|
-
switch (shape || 'mesh') {
|
|
10
|
-
case 'mesh':
|
|
11
|
-
return mesh;
|
|
12
|
-
case 'columnar-table':
|
|
13
|
-
return convertMeshToColumnarTable(mesh);
|
|
14
|
-
// case 'arrow-table':
|
|
15
|
-
// return {
|
|
16
|
-
// shape: 'arrow-table',
|
|
17
|
-
// data: convertMeshToArrowTable(mesh)
|
|
18
|
-
// };
|
|
19
|
-
default:
|
|
20
|
-
throw new Error(`Unsupported shape ${options?.shape}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.convertMesh = convertMesh;
|
|
24
|
-
/**
|
|
25
|
-
* Convert a loaders.gl Mesh to a Columnar Table
|
|
26
|
-
* @param mesh
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
function convertMeshToColumnarTable(mesh) {
|
|
30
|
-
const columns = {};
|
|
31
|
-
for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
|
|
32
|
-
columns[columnName] = attribute.value;
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
shape: 'columnar-table',
|
|
36
|
-
schema: mesh.schema,
|
|
37
|
-
data: columns
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
exports.convertMeshToColumnarTable = convertMeshToColumnarTable;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.makeMeshAttributeMetadata = exports.deduceMeshField = exports.deduceMeshSchema = void 0;
|
|
5
|
-
const data_type_1 = require("../table/simple-table/data-type");
|
|
6
|
-
/**
|
|
7
|
-
* Create a schema for mesh attributes data
|
|
8
|
-
* @param attributes
|
|
9
|
-
* @param metadata
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
function deduceMeshSchema(attributes, metadata = {}) {
|
|
13
|
-
const fields = deduceMeshFields(attributes);
|
|
14
|
-
return { fields, metadata };
|
|
15
|
-
}
|
|
16
|
-
exports.deduceMeshSchema = deduceMeshSchema;
|
|
17
|
-
/**
|
|
18
|
-
* Create arrow-like schema field for mesh attribute
|
|
19
|
-
* @param attributeName
|
|
20
|
-
* @param attribute
|
|
21
|
-
* @param optionalMetadata
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
function deduceMeshField(name, attribute, optionalMetadata) {
|
|
25
|
-
const type = (0, data_type_1.getDataTypeFromTypedArray)(attribute.value);
|
|
26
|
-
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
27
|
-
return {
|
|
28
|
-
name,
|
|
29
|
-
type: { type: 'fixed-size-list', listSize: attribute.size, children: [{ name: 'value', type }] },
|
|
30
|
-
nullable: false,
|
|
31
|
-
metadata
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
exports.deduceMeshField = deduceMeshField;
|
|
35
|
-
/**
|
|
36
|
-
* Create fields array for mesh attributes
|
|
37
|
-
* @param attributes
|
|
38
|
-
* @returns
|
|
39
|
-
*/
|
|
40
|
-
function deduceMeshFields(attributes) {
|
|
41
|
-
const fields = [];
|
|
42
|
-
for (const attributeName in attributes) {
|
|
43
|
-
const attribute = attributes[attributeName];
|
|
44
|
-
fields.push(deduceMeshField(attributeName, attribute));
|
|
45
|
-
}
|
|
46
|
-
return fields;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Make metadata by mesh attribute properties
|
|
50
|
-
* @param attribute
|
|
51
|
-
* @returns
|
|
52
|
-
*/
|
|
53
|
-
function makeMeshAttributeMetadata(attribute) {
|
|
54
|
-
const result = {};
|
|
55
|
-
if ('byteOffset' in attribute) {
|
|
56
|
-
result.byteOffset = attribute.byteOffset.toString(10);
|
|
57
|
-
}
|
|
58
|
-
if ('byteStride' in attribute) {
|
|
59
|
-
result.byteStride = attribute.byteStride.toString(10);
|
|
60
|
-
}
|
|
61
|
-
if ('normalized' in attribute) {
|
|
62
|
-
result.normalized = attribute.normalized.toString();
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
exports.makeMeshAttributeMetadata = makeMeshAttributeMetadata;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* Problem with arrow dependency...
|
|
3
|
-
import {
|
|
4
|
-
Table,
|
|
5
|
-
Schema,
|
|
6
|
-
RecordBatch,
|
|
7
|
-
FixedSizeList,
|
|
8
|
-
Field,
|
|
9
|
-
Data,
|
|
10
|
-
FixedSizeListVector
|
|
11
|
-
} from 'apache-arrow';
|
|
12
|
-
import {AbstractVector} from 'apache-arrow/vector';
|
|
13
|
-
import {getArrowType, getArrowVector} from '../table/arrow/arrow-type-utils';
|
|
14
|
-
import type {Mesh} from './mesh-types';
|
|
15
|
-
import {makeMeshAttributeMetadata} from './deduce-mesh-schema';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* * Convert a loaders.gl Mesh to an Apache Arrow Table
|
|
19
|
-
* @param mesh
|
|
20
|
-
* @param metadata
|
|
21
|
-
* @param batchSize
|
|
22
|
-
* @returns
|
|
23
|
-
*
|
|
24
|
-
export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {
|
|
25
|
-
const vectors: AbstractVector[] = [];
|
|
26
|
-
const fields: Field[] = [];
|
|
27
|
-
for (const attributeKey in mesh.attributes) {
|
|
28
|
-
const attribute = mesh.attributes[attributeKey];
|
|
29
|
-
const {value, size = 1} = attribute;
|
|
30
|
-
const type = getArrowType(value);
|
|
31
|
-
const vector = getArrowVector(value);
|
|
32
|
-
const listType = new FixedSizeList(size, new Field('value', type));
|
|
33
|
-
const field = new Field(attributeKey, listType, false, makeMeshAttributeMetadata(attribute));
|
|
34
|
-
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
|
|
35
|
-
const listVector = new FixedSizeListVector(data);
|
|
36
|
-
vectors.push(listVector);
|
|
37
|
-
fields.push(field);
|
|
38
|
-
}
|
|
39
|
-
const schema = new Schema(fields, mesh?.schema?.metadata || new Map<string, string>());
|
|
40
|
-
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
|
|
41
|
-
const table = new Table(schema, recordBatch);
|
|
42
|
-
return table;
|
|
43
|
-
}
|
|
44
|
-
*/
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMeshBoundingBox = exports.getMeshSize = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Get number of vertices in mesh
|
|
6
|
-
* @param attributes
|
|
7
|
-
*/
|
|
8
|
-
function getMeshSize(attributes) {
|
|
9
|
-
let size = 0;
|
|
10
|
-
for (const attributeName in attributes) {
|
|
11
|
-
const attribute = attributes[attributeName];
|
|
12
|
-
if (ArrayBuffer.isView(attribute)) {
|
|
13
|
-
// @ts-ignore DataView doesn't have BYTES_PER_ELEMENT
|
|
14
|
-
size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return size;
|
|
18
|
-
}
|
|
19
|
-
exports.getMeshSize = getMeshSize;
|
|
20
|
-
/**
|
|
21
|
-
* Get the (axis aligned) bounding box of a mesh
|
|
22
|
-
* @param attributes
|
|
23
|
-
* @returns array of two vectors representing the axis aligned bounding box
|
|
24
|
-
*/
|
|
25
|
-
// eslint-disable-next-line complexity
|
|
26
|
-
function getMeshBoundingBox(attributes) {
|
|
27
|
-
let minX = Infinity;
|
|
28
|
-
let minY = Infinity;
|
|
29
|
-
let minZ = Infinity;
|
|
30
|
-
let maxX = -Infinity;
|
|
31
|
-
let maxY = -Infinity;
|
|
32
|
-
let maxZ = -Infinity;
|
|
33
|
-
const positions = attributes.POSITION ? attributes.POSITION.value : [];
|
|
34
|
-
const len = positions && positions.length;
|
|
35
|
-
for (let i = 0; i < len; i += 3) {
|
|
36
|
-
const x = positions[i];
|
|
37
|
-
const y = positions[i + 1];
|
|
38
|
-
const z = positions[i + 2];
|
|
39
|
-
minX = x < minX ? x : minX;
|
|
40
|
-
minY = y < minY ? y : minY;
|
|
41
|
-
minZ = z < minZ ? z : minZ;
|
|
42
|
-
maxX = x > maxX ? x : maxX;
|
|
43
|
-
maxY = y > maxY ? y : maxY;
|
|
44
|
-
maxZ = z > maxZ ? z : maxZ;
|
|
45
|
-
}
|
|
46
|
-
return [
|
|
47
|
-
[minX, minY, minZ],
|
|
48
|
-
[maxX, maxY, maxZ]
|
|
49
|
-
];
|
|
50
|
-
}
|
|
51
|
-
exports.getMeshBoundingBox = getMeshBoundingBox;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getArrowType = void 0;
|
|
5
|
-
const apache_arrow_1 = require("apache-arrow");
|
|
6
|
-
// import {AbstractVector} from 'apache-arrow/vector';
|
|
7
|
-
function getArrowType(array) {
|
|
8
|
-
switch (array.constructor) {
|
|
9
|
-
case Int8Array:
|
|
10
|
-
return new apache_arrow_1.Int8();
|
|
11
|
-
case Uint8Array:
|
|
12
|
-
return new apache_arrow_1.Uint8();
|
|
13
|
-
case Int16Array:
|
|
14
|
-
return new apache_arrow_1.Int16();
|
|
15
|
-
case Uint16Array:
|
|
16
|
-
return new apache_arrow_1.Uint16();
|
|
17
|
-
case Int32Array:
|
|
18
|
-
return new apache_arrow_1.Int32();
|
|
19
|
-
case Uint32Array:
|
|
20
|
-
return new apache_arrow_1.Uint32();
|
|
21
|
-
case Float32Array:
|
|
22
|
-
return new apache_arrow_1.Float32();
|
|
23
|
-
case Float64Array:
|
|
24
|
-
return new apache_arrow_1.Float64();
|
|
25
|
-
default:
|
|
26
|
-
throw new Error('array type not supported');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.getArrowType = getArrowType;
|
|
30
|
-
/*
|
|
31
|
-
export function getArrowVector(array: TypedArray): AbstractVector {
|
|
32
|
-
switch (array.constructor) {
|
|
33
|
-
case Int8Array:
|
|
34
|
-
return Int8Vector.from(array);
|
|
35
|
-
case Uint8Array:
|
|
36
|
-
return Uint8Vector.from(array);
|
|
37
|
-
case Int16Array:
|
|
38
|
-
return Int16Vector.from(array);
|
|
39
|
-
case Uint16Array:
|
|
40
|
-
return Uint16Vector.from(array);
|
|
41
|
-
case Int32Array:
|
|
42
|
-
return Int32Vector.from(array);
|
|
43
|
-
case Uint32Array:
|
|
44
|
-
return Uint32Vector.from(array);
|
|
45
|
-
case Float32Array:
|
|
46
|
-
return Float32Vector.from(array);
|
|
47
|
-
case Float64Array:
|
|
48
|
-
return Float64Vector.from(array);
|
|
49
|
-
default:
|
|
50
|
-
throw new Error('array type not supported');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
*/
|