@loaders.gl/schema 3.1.0-alpha.3 → 3.1.0-beta.2
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +1288 -4
- package/dist/category/common.d.ts +20 -0
- package/dist/category/common.d.ts.map +1 -0
- package/dist/category/common.js +10 -2
- package/dist/category/gis.d.ts +50 -0
- package/dist/category/gis.d.ts.map +1 -0
- package/dist/category/gis.js +2 -2
- package/dist/category/mesh/convert-mesh.d.ts +15 -0
- package/dist/category/mesh/convert-mesh.d.ts.map +1 -0
- package/dist/category/mesh/convert-mesh.js +37 -31
- package/dist/category/mesh/deduce-mesh-schema.d.ts +24 -0
- package/dist/category/mesh/deduce-mesh-schema.d.ts.map +1 -0
- package/dist/category/mesh/deduce-mesh-schema.js +57 -37
- package/dist/category/mesh/mesh-to-arrow-table.d.ts +1 -0
- package/dist/category/mesh/mesh-to-arrow-table.d.ts.map +1 -0
- package/dist/category/mesh/mesh-to-arrow-table.js +28 -15
- package/dist/category/mesh/mesh-types.d.ts +50 -0
- package/dist/category/mesh/mesh-types.d.ts.map +1 -0
- package/dist/category/mesh/mesh-types.js +2 -2
- package/dist/category/mesh/mesh-utils.d.ts +23 -0
- package/dist/category/mesh/mesh-utils.d.ts.map +1 -0
- package/dist/category/mesh/mesh-utils.js +48 -35
- package/dist/category/table/deduce-table-schema.d.ts +9 -0
- package/dist/category/table/deduce-table-schema.d.ts.map +1 -0
- package/dist/category/table/deduce-table-schema.js +94 -39
- package/dist/category/table/table-types.d.ts +78 -0
- package/dist/category/table/table-types.d.ts.map +1 -0
- package/dist/category/table/table-types.js +2 -2
- package/dist/es5/bundle.js +7 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/category/common.js +2 -0
- package/dist/{category → es5/category}/common.js.map +0 -0
- package/dist/es5/category/gis.js +2 -0
- package/dist/{category → es5/category}/gis.js.map +0 -0
- package/dist/es5/category/mesh/convert-mesh.js +35 -0
- package/dist/es5/category/mesh/convert-mesh.js.map +1 -0
- package/dist/es5/category/mesh/deduce-mesh-schema.js +54 -0
- package/dist/es5/category/mesh/deduce-mesh-schema.js.map +1 -0
- package/dist/es5/category/mesh/mesh-to-arrow-table.js +2 -0
- package/dist/es5/category/mesh/mesh-to-arrow-table.js.map +1 -0
- package/dist/es5/category/mesh/mesh-types.js +2 -0
- package/dist/{category → es5/category}/mesh/mesh-types.js.map +0 -0
- package/dist/es5/category/mesh/mesh-utils.js +47 -0
- package/dist/es5/category/mesh/mesh-utils.js.map +1 -0
- package/dist/es5/category/table/deduce-table-schema.js +58 -0
- package/dist/es5/category/table/deduce-table-schema.js.map +1 -0
- package/dist/es5/category/table/table-types.js +2 -0
- package/dist/{category → es5/category}/table/table-types.js.map +0 -0
- package/dist/es5/index.js +344 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/arrow/arrow-like-type-utils.js +40 -0
- package/dist/es5/lib/arrow/arrow-like-type-utils.js.map +1 -0
- package/dist/es5/lib/arrow/arrow-type-utils.js +2 -0
- package/dist/es5/lib/arrow/arrow-type-utils.js.map +1 -0
- package/dist/es5/lib/arrow/get-type-info.js +33 -0
- package/dist/es5/lib/arrow/get-type-info.js.map +1 -0
- package/dist/es5/lib/batches/base-table-batch-aggregator.js +81 -0
- package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +1 -0
- package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +109 -0
- package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +1 -0
- package/dist/es5/lib/batches/row-table-batch-aggregator.js +102 -0
- package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +1 -0
- package/dist/es5/lib/batches/table-batch-aggregator.js +2 -0
- package/dist/{lib → es5/lib}/batches/table-batch-aggregator.js.map +0 -0
- package/dist/es5/lib/batches/table-batch-builder.js +187 -0
- package/dist/es5/lib/batches/table-batch-builder.js.map +1 -0
- package/dist/es5/lib/schema/impl/enum.js +56 -0
- package/dist/es5/lib/schema/impl/enum.js.map +1 -0
- package/dist/es5/lib/schema/impl/field.js +43 -0
- package/dist/es5/lib/schema/impl/field.js.map +1 -0
- package/dist/es5/lib/schema/impl/schema.js +103 -0
- package/dist/es5/lib/schema/impl/schema.js.map +1 -0
- package/dist/es5/lib/schema/impl/type.js +594 -0
- package/dist/es5/lib/schema/impl/type.js.map +1 -0
- package/dist/es5/lib/schema/schema.js +236 -0
- package/dist/es5/lib/schema/schema.js.map +1 -0
- package/dist/es5/lib/schema-utils/deduce-column-type.js +32 -0
- package/dist/es5/lib/schema-utils/deduce-column-type.js.map +1 -0
- package/dist/es5/lib/utils/assert.js +13 -0
- package/dist/es5/lib/utils/assert.js.map +1 -0
- package/dist/es5/lib/utils/async-queue.js +130 -0
- package/dist/es5/lib/utils/async-queue.js.map +1 -0
- package/dist/es5/lib/utils/row-utils.js +44 -0
- package/dist/es5/lib/utils/row-utils.js.map +1 -0
- package/dist/es5/types.js +2 -0
- package/dist/{types.js.map → es5/types.js.map} +0 -0
- package/dist/esm/bundle.js +5 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/category/common.js +2 -0
- package/dist/esm/category/common.js.map +1 -0
- package/dist/esm/category/gis.js +2 -0
- package/dist/esm/category/gis.js.map +1 -0
- package/dist/esm/category/mesh/convert-mesh.js +26 -0
- package/dist/esm/category/mesh/convert-mesh.js.map +1 -0
- package/dist/esm/category/mesh/deduce-mesh-schema.js +42 -0
- package/dist/esm/category/mesh/deduce-mesh-schema.js.map +1 -0
- package/dist/esm/category/mesh/mesh-to-arrow-table.js +2 -0
- package/dist/esm/category/mesh/mesh-to-arrow-table.js.map +1 -0
- package/dist/esm/category/mesh/mesh-types.js +2 -0
- package/dist/esm/category/mesh/mesh-types.js.map +1 -0
- package/dist/esm/category/mesh/mesh-utils.js +38 -0
- package/dist/esm/category/mesh/mesh-utils.js.map +1 -0
- package/dist/esm/category/table/deduce-table-schema.js +51 -0
- package/dist/esm/category/table/deduce-table-schema.js.map +1 -0
- package/dist/esm/category/table/table-types.js +2 -0
- package/dist/esm/category/table/table-types.js.map +1 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/arrow/arrow-like-type-utils.js +32 -0
- package/dist/esm/lib/arrow/arrow-like-type-utils.js.map +1 -0
- package/dist/esm/lib/arrow/arrow-type-utils.js +2 -0
- package/dist/esm/lib/arrow/arrow-type-utils.js.map +1 -0
- package/dist/esm/lib/arrow/get-type-info.js +24 -0
- package/dist/esm/lib/arrow/get-type-info.js.map +1 -0
- package/dist/esm/lib/batches/base-table-batch-aggregator.js +74 -0
- package/dist/esm/lib/batches/base-table-batch-aggregator.js.map +1 -0
- package/dist/esm/lib/batches/columnar-table-batch-aggregator.js +100 -0
- package/dist/esm/lib/batches/columnar-table-batch-aggregator.js.map +1 -0
- package/dist/esm/lib/batches/row-table-batch-aggregator.js +95 -0
- package/dist/esm/lib/batches/row-table-batch-aggregator.js.map +1 -0
- package/dist/esm/lib/batches/table-batch-aggregator.js +2 -0
- package/dist/esm/lib/batches/table-batch-aggregator.js.map +1 -0
- package/dist/esm/lib/batches/table-batch-builder.js +182 -0
- package/dist/esm/lib/batches/table-batch-builder.js.map +1 -0
- package/dist/esm/lib/schema/impl/enum.js +49 -0
- package/dist/esm/lib/schema/impl/enum.js.map +1 -0
- package/dist/esm/lib/schema/impl/field.js +35 -0
- package/dist/esm/lib/schema/impl/field.js.map +1 -0
- package/dist/esm/lib/schema/impl/schema.js +92 -0
- package/dist/esm/lib/schema/impl/schema.js.map +1 -0
- package/dist/esm/lib/schema/impl/type.js +498 -0
- package/dist/esm/lib/schema/impl/type.js.map +1 -0
- package/dist/{lib/schema/index.js → esm/lib/schema/schema.js} +1 -1
- package/dist/esm/lib/schema/schema.js.map +1 -0
- package/dist/esm/lib/schema-utils/deduce-column-type.js +23 -0
- package/dist/esm/lib/schema-utils/deduce-column-type.js.map +1 -0
- package/dist/esm/lib/utils/assert.js +6 -0
- package/dist/esm/lib/utils/assert.js.map +1 -0
- package/dist/esm/lib/utils/async-queue.js +119 -0
- package/dist/esm/lib/utils/async-queue.js.map +1 -0
- package/dist/esm/lib/utils/row-utils.js +35 -0
- package/dist/esm/lib/utils/row-utils.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -13
- package/dist/lib/arrow/arrow-like-type-utils.d.ts +4 -0
- package/dist/lib/arrow/arrow-like-type-utils.d.ts.map +1 -0
- package/dist/lib/arrow/arrow-like-type-utils.js +26 -31
- package/dist/lib/arrow/arrow-type-utils.d.ts +1 -0
- package/dist/lib/arrow/arrow-type-utils.d.ts.map +1 -0
- package/dist/lib/arrow/arrow-type-utils.js +28 -20
- package/dist/lib/arrow/get-type-info.d.ts +14 -0
- package/dist/lib/arrow/get-type-info.d.ts.map +1 -0
- package/dist/lib/arrow/get-type-info.js +23 -19
- package/dist/lib/batches/base-table-batch-aggregator.d.ts +19 -0
- package/dist/lib/batches/base-table-batch-aggregator.d.ts.map +1 -0
- package/dist/lib/batches/base-table-batch-aggregator.js +52 -68
- package/dist/lib/batches/columnar-table-batch-aggregator.d.ts +23 -0
- package/dist/lib/batches/columnar-table-batch-aggregator.d.ts.map +1 -0
- package/dist/lib/batches/columnar-table-batch-aggregator.js +82 -92
- package/dist/lib/batches/row-table-batch-aggregator.d.ts +22 -0
- package/dist/lib/batches/row-table-batch-aggregator.d.ts.map +1 -0
- package/dist/lib/batches/row-table-batch-aggregator.js +72 -88
- package/dist/lib/batches/table-batch-aggregator.d.ts +25 -0
- package/dist/lib/batches/table-batch-aggregator.d.ts.map +1 -0
- package/dist/lib/batches/table-batch-aggregator.js +2 -2
- package/dist/lib/batches/table-batch-builder.d.ts +53 -0
- package/dist/lib/batches/table-batch-builder.d.ts.map +1 -0
- package/dist/lib/batches/table-batch-builder.js +137 -166
- package/dist/lib/schema/impl/enum.d.ts +92 -0
- package/dist/lib/schema/impl/enum.d.ts.map +1 -0
- package/dist/lib/schema/impl/enum.js +96 -48
- package/dist/lib/schema/impl/field.d.ts +19 -0
- package/dist/lib/schema/impl/field.d.ts.map +1 -0
- package/dist/lib/schema/impl/field.js +31 -34
- package/dist/lib/schema/impl/schema.d.ts +16 -0
- package/dist/lib/schema/impl/schema.d.ts.map +1 -0
- package/dist/lib/schema/impl/schema.js +72 -81
- package/dist/lib/schema/impl/type.d.ts +176 -0
- package/dist/lib/schema/impl/type.d.ts.map +1 -0
- package/dist/lib/schema/impl/type.js +454 -490
- package/dist/lib/schema/schema.d.ts +5 -0
- package/dist/lib/schema/schema.d.ts.map +1 -0
- package/dist/lib/schema/schema.js +90 -0
- package/dist/lib/schema-utils/deduce-column-type.d.ts +3 -0
- package/dist/lib/schema-utils/deduce-column-type.d.ts.map +1 -0
- package/dist/lib/schema-utils/deduce-column-type.js +89 -20
- package/dist/lib/utils/assert.d.ts +2 -0
- package/dist/lib/utils/assert.d.ts.map +1 -0
- package/dist/lib/utils/assert.js +11 -5
- package/dist/lib/utils/async-queue.d.ts +18 -0
- package/dist/lib/utils/async-queue.d.ts.map +1 -0
- package/dist/lib/utils/async-queue.js +82 -109
- package/dist/lib/utils/row-utils.d.ts +9 -0
- package/dist/lib/utils/row-utils.d.ts.map +1 -0
- package/dist/lib/utils/row-utils.js +31 -33
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -2
- package/package.json +7 -9
- package/src/category/common.ts +2 -1
- package/src/category/mesh/convert-mesh.ts +6 -6
- package/src/category/mesh/deduce-mesh-schema.ts +1 -1
- package/src/category/mesh/mesh-to-arrow-table.ts +4 -2
- package/src/category/mesh/mesh-types.ts +1 -1
- package/src/category/table/deduce-table-schema.ts +1 -1
- package/src/category/table/table-types.ts +5 -2
- package/src/index.ts +1 -1
- package/src/lib/arrow/arrow-like-type-utils.ts +11 -1
- package/src/lib/arrow/arrow-type-utils.ts +3 -1
- package/src/lib/arrow/get-type-info.ts +1 -1
- package/src/lib/batches/base-table-batch-aggregator.ts +1 -1
- package/src/lib/batches/columnar-table-batch-aggregator.ts +1 -1
- package/src/lib/batches/row-table-batch-aggregator.ts +1 -1
- package/src/lib/batches/table-batch-aggregator.ts +1 -1
- package/src/lib/batches/table-batch-builder.ts +2 -2
- package/src/lib/schema/impl/schema.ts +2 -2
- package/src/lib/schema/impl/type.ts +2 -2
- package/src/lib/schema/{index.ts → schema.ts} +0 -0
- package/src/lib/schema-utils/deduce-column-type.ts +6 -2
- package/src/lib/utils/async-queue.ts +7 -4
- package/dist/bundle.js.map +0 -1
- package/dist/category/mesh/convert-mesh.js.map +0 -1
- package/dist/category/mesh/deduce-mesh-schema.js.map +0 -1
- package/dist/category/mesh/mesh-to-arrow-table.js.map +0 -1
- package/dist/category/mesh/mesh-utils.js.map +0 -1
- package/dist/category/table/deduce-table-schema.js.map +0 -1
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/arrow/arrow-like-type-utils.js.map +0 -1
- package/dist/lib/arrow/arrow-type-utils.js.map +0 -1
- package/dist/lib/arrow/get-type-info.js.map +0 -1
- package/dist/lib/batches/base-table-batch-aggregator.js.map +0 -1
- package/dist/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/lib/batches/row-table-batch-aggregator.js.map +0 -1
- package/dist/lib/batches/table-batch-builder.js.map +0 -1
- package/dist/lib/schema/impl/enum.js.map +0 -1
- package/dist/lib/schema/impl/field.js.map +0 -1
- package/dist/lib/schema/impl/schema.js.map +0 -1
- package/dist/lib/schema/impl/type.js.map +0 -1
- package/dist/lib/schema/index.js.map +0 -1
- package/dist/lib/schema-utils/deduce-column-type.js.map +0 -1
- package/dist/lib/utils/assert.js.map +0 -1
- package/dist/lib/utils/async-queue.js.map +0 -1
- package/dist/lib/utils/row-utils.js.map +0 -1
|
@@ -1,51 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deduceTableSchema = void 0;
|
|
4
|
+
// const TYPED_ARRAY_TO_TYPE = {
|
|
5
|
+
// Int8Array: new Int8(),
|
|
6
|
+
// Int16Array: new Int16(),
|
|
7
|
+
// Int32Array: new Int32(),
|
|
8
|
+
// Uint8Array: new Uint8(),
|
|
9
|
+
// Uint8ClampedArray: new Uint8(),
|
|
10
|
+
// Uint16Array: new Uint16(),
|
|
11
|
+
// Uint32Array: new Uint32(),
|
|
12
|
+
// Float32Array: new Float32(),
|
|
13
|
+
// Float64Array: new Float64()
|
|
14
|
+
// };
|
|
15
|
+
// if (typeof BigInt64Array !== 'undefined') {
|
|
16
|
+
// TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();
|
|
17
|
+
// TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();
|
|
18
|
+
// }
|
|
19
|
+
/**
|
|
20
|
+
* SCHEMA SUPPORT - AUTODEDUCTION
|
|
21
|
+
* @param {*} table
|
|
22
|
+
* @param {*} schema
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
function deduceTableSchema(table, schema) {
|
|
26
|
+
const deducedSchema = Array.isArray(table)
|
|
27
|
+
? deduceSchemaForRowTable(table)
|
|
28
|
+
: deduceSchemaForColumnarTable(table);
|
|
29
|
+
// Deduced schema will fill in missing info from partial options.schema, if provided
|
|
30
|
+
return Object.assign(deducedSchema, schema);
|
|
4
31
|
}
|
|
5
|
-
|
|
32
|
+
exports.deduceTableSchema = deduceTableSchema;
|
|
6
33
|
function deduceSchemaForColumnarTable(columnarTable) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
34
|
+
const schema = {};
|
|
35
|
+
for (const field in columnarTable) {
|
|
36
|
+
const column = columnarTable[field];
|
|
37
|
+
// Check if column is typed, if so we are done
|
|
38
|
+
if (ArrayBuffer.isView(column)) {
|
|
39
|
+
schema[field] = column.constructor;
|
|
40
|
+
// else we need data
|
|
41
|
+
}
|
|
42
|
+
else if (column.length) {
|
|
43
|
+
const value = column[0];
|
|
44
|
+
schema[field] = deduceTypeFromValue(value);
|
|
45
|
+
// TODO - support nested schemas?
|
|
46
|
+
}
|
|
47
|
+
// else we mark as present but unknow
|
|
48
|
+
schema[field] = schema[field] || null;
|
|
17
49
|
}
|
|
18
|
-
|
|
19
|
-
schema[field] = schema[field] || null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return schema;
|
|
50
|
+
return schema;
|
|
23
51
|
}
|
|
24
|
-
|
|
25
52
|
function deduceSchemaForRowTable(rowTable) {
|
|
53
|
+
const schema = {};
|
|
54
|
+
if (rowTable.length) {
|
|
55
|
+
const row = rowTable[0];
|
|
56
|
+
// TODO - Could look at additional rows if nulls in first row
|
|
57
|
+
for (const field in row) {
|
|
58
|
+
const value = row[field];
|
|
59
|
+
schema[field] = deduceTypeFromValue(value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return schema;
|
|
63
|
+
}
|
|
64
|
+
function deduceTypeFromValue(value) {
|
|
65
|
+
if (value instanceof Date) {
|
|
66
|
+
return Date;
|
|
67
|
+
}
|
|
68
|
+
else if (value instanceof Number) {
|
|
69
|
+
return Float32Array;
|
|
70
|
+
}
|
|
71
|
+
else if (typeof value === 'string') {
|
|
72
|
+
return String;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/*
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
|
+
function deduceSchema(rows) {
|
|
79
|
+
const row = rows[0];
|
|
80
|
+
|
|
26
81
|
const schema = {};
|
|
82
|
+
let i = 0;
|
|
83
|
+
for (const columnName in row) {
|
|
84
|
+
const value = row[columnName];
|
|
85
|
+
switch (typeof value) {
|
|
86
|
+
case 'number':
|
|
87
|
+
case 'boolean':
|
|
88
|
+
// TODO - booleans could be handled differently...
|
|
89
|
+
schema[columnName] = {name: String(columnName), index: i, type: Float32Array};
|
|
90
|
+
break;
|
|
27
91
|
|
|
28
|
-
|
|
29
|
-
|
|
92
|
+
case 'object':
|
|
93
|
+
schema[columnName] = {name: String(columnName), index: i, type: Array};
|
|
94
|
+
break;
|
|
30
95
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
96
|
+
case 'string':
|
|
97
|
+
default:
|
|
98
|
+
schema[columnName] = {name: String(columnName), index: i, type: Array};
|
|
99
|
+
// We currently only handle numeric rows
|
|
100
|
+
// TODO we could offer a function to map strings to numbers?
|
|
34
101
|
}
|
|
102
|
+
i++;
|
|
35
103
|
}
|
|
36
|
-
|
|
37
104
|
return schema;
|
|
38
105
|
}
|
|
39
|
-
|
|
40
|
-
function deduceTypeFromValue(value) {
|
|
41
|
-
if (value instanceof Date) {
|
|
42
|
-
return Date;
|
|
43
|
-
} else if (value instanceof Number) {
|
|
44
|
-
return Float32Array;
|
|
45
|
-
} else if (typeof value === 'string') {
|
|
46
|
-
return String;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=deduce-table-schema.js.map
|
|
106
|
+
*/
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Schema } from '../../lib/schema/schema';
|
|
2
|
+
import type { AnyArray } from '../../types';
|
|
3
|
+
import type { Batch } from '../common';
|
|
4
|
+
declare type ApacheArrowTable = any;
|
|
5
|
+
declare type RecordBatch = any;
|
|
6
|
+
/** A general table */
|
|
7
|
+
export interface Table {
|
|
8
|
+
shape: 'row-table' | 'array-row-table' | 'object-row-table' | 'columnar-table' | 'arrow-table';
|
|
9
|
+
schema?: Schema;
|
|
10
|
+
schemaType?: 'explicit' | 'deduced';
|
|
11
|
+
}
|
|
12
|
+
/** A table organized as an array of rows */
|
|
13
|
+
export interface RowTable extends Table {
|
|
14
|
+
shape: 'row-table' | 'array-row-table' | 'object-row-table';
|
|
15
|
+
data: any[];
|
|
16
|
+
}
|
|
17
|
+
/** A table organized as an array of rows, each row is an array of values */
|
|
18
|
+
export interface ArrayRowTable extends RowTable {
|
|
19
|
+
shape: 'array-row-table';
|
|
20
|
+
data: any[][];
|
|
21
|
+
}
|
|
22
|
+
/** A table organized as an array of rows, each row is an object mapping columns to values */
|
|
23
|
+
export interface ObjectRowTable extends RowTable {
|
|
24
|
+
shape: 'object-row-table';
|
|
25
|
+
data: {
|
|
26
|
+
[columnName: string]: any;
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
/** A table organized as a map of columns, each column is an array of value */
|
|
30
|
+
export interface ColumnarTable extends Table {
|
|
31
|
+
shape: 'columnar-table';
|
|
32
|
+
data: {
|
|
33
|
+
[columnName: string]: AnyArray;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** A table organized as an Apache Arrow table */
|
|
37
|
+
export interface ArrowTable extends Table {
|
|
38
|
+
shape: 'arrow-table';
|
|
39
|
+
data: ApacheArrowTable;
|
|
40
|
+
}
|
|
41
|
+
/** Batch for a general table */
|
|
42
|
+
export declare type TableBatch = Batch & {
|
|
43
|
+
data: any;
|
|
44
|
+
length: number;
|
|
45
|
+
schema?: Schema;
|
|
46
|
+
schemaType?: 'explicit' | 'deduced';
|
|
47
|
+
};
|
|
48
|
+
/** Batch for a table organized as an array of rows */
|
|
49
|
+
export declare type RowTableBatch = TableBatch & {
|
|
50
|
+
shape: 'row-table';
|
|
51
|
+
data: any[];
|
|
52
|
+
};
|
|
53
|
+
/** Batch for a table organized as an array of rows, each row is an array of values */
|
|
54
|
+
export declare type RowArrayTableBatch = RowTableBatch & {
|
|
55
|
+
shape: 'array-row-table';
|
|
56
|
+
data: any[][];
|
|
57
|
+
};
|
|
58
|
+
/** Batch for a table organized as an array of rows, each row is an object mapping columns to values */
|
|
59
|
+
export declare type RowObjectTableBatch = RowTableBatch & {
|
|
60
|
+
shape: 'object-row-table';
|
|
61
|
+
data: {
|
|
62
|
+
[columnName: string]: any;
|
|
63
|
+
}[];
|
|
64
|
+
};
|
|
65
|
+
/** Batch for a table organized as a map of columns, each column is an array of value */
|
|
66
|
+
export declare type ColumnarTableBatch = TableBatch & {
|
|
67
|
+
shape: 'columnar-table';
|
|
68
|
+
data: {
|
|
69
|
+
[columnName: string]: AnyArray;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/** Batch for a table organized as an Apache Arrow table */
|
|
73
|
+
export declare type ArrowTableBatch = TableBatch & {
|
|
74
|
+
shape: 'arrow-table';
|
|
75
|
+
data: RecordBatch;
|
|
76
|
+
};
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=table-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-types.d.ts","sourceRoot":"","sources":["../../../src/category/table/table-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,WAAW,CAAC;AAGrC,aAAK,gBAAgB,GAAG,GAAG,CAAC;AAC5B,aAAK,WAAW,GAAG,GAAG,CAAC;AAEvB,sBAAsB;AACtB,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,WAAW,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,aAAa,CAAC;IAC/F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACrC;AAED,4CAA4C;AAC5C,MAAM,WAAW,QAAS,SAAQ,KAAK;IACrC,KAAK,EAAE,WAAW,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;IAC5D,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AAED,4EAA4E;AAC5E,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,KAAK,EAAE,iBAAiB,CAAC;IACzB,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;CACf;AAED,6FAA6F;AAC7F,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EAAE,CAAC;CACrC;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAc,SAAQ,KAAK;IAC1C,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAC,CAAC;CACxC;AAED,iDAAiD;AACjD,MAAM,WAAW,UAAW,SAAQ,KAAK;IACvC,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAID,gCAAgC;AAChC,oBAAY,UAAU,GAAG,KAAK,GAAG;IAC/B,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF,sDAAsD;AACtD,oBAAY,aAAa,GAAG,UAAU,GAAG;IACvC,KAAK,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;CACb,CAAC;AAEF,sFAAsF;AACtF,oBAAY,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,EAAE,iBAAiB,CAAC;IACzB,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;CACf,CAAC;AAEF,uGAAuG;AACvG,oBAAY,mBAAmB,GAAG,aAAa,GAAG;IAChD,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EAAE,CAAC;CACrC,CAAC;AAEF,wFAAwF;AACxF,oBAAY,kBAAkB,GAAG,UAAU,GAAG;IAC5C,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE;QAAC,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAC,CAAC;CACxC,CAAC;AAEF,2DAA2D;AAC3D,oBAAY,eAAe,GAAG,UAAU,GAAG;IACzC,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertMesh = convertMesh;
|
|
7
|
+
exports.convertMeshToColumnarTable = convertMeshToColumnarTable;
|
|
8
|
+
|
|
9
|
+
function convertMesh(mesh, shape, options) {
|
|
10
|
+
switch (shape || 'mesh') {
|
|
11
|
+
case 'mesh':
|
|
12
|
+
return mesh;
|
|
13
|
+
|
|
14
|
+
case 'columnar-table':
|
|
15
|
+
return convertMeshToColumnarTable(mesh);
|
|
16
|
+
|
|
17
|
+
default:
|
|
18
|
+
throw new Error("Unsupported shape ".concat(options === null || options === void 0 ? void 0 : options.shape));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function convertMeshToColumnarTable(mesh) {
|
|
23
|
+
const columns = {};
|
|
24
|
+
|
|
25
|
+
for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
|
|
26
|
+
columns[columnName] = attribute.value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
shape: 'columnar-table',
|
|
31
|
+
schema: mesh.schema,
|
|
32
|
+
data: columns
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=convert-mesh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/category/mesh/convert-mesh.ts"],"names":["convertMesh","mesh","shape","options","convertMeshToColumnarTable","Error","columns","columnName","attribute","Object","entries","attributes","value","schema","data"],"mappings":";;;;;;;;AASO,SAASA,WAAT,CACLC,IADK,EAELC,KAFK,EAGLC,OAHK,EAI8B;AACnC,UAAQD,KAAK,IAAI,MAAjB;AACE,SAAK,MAAL;AACE,aAAOD,IAAP;;AACF,SAAK,gBAAL;AACE,aAAOG,0BAA0B,CAACH,IAAD,CAAjC;;AAMF;AACE,YAAM,IAAII,KAAJ,6BAA+BF,OAA/B,aAA+BA,OAA/B,uBAA+BA,OAAO,CAAED,KAAxC,EAAN;AAXJ;AAaD;;AAOM,SAASE,0BAAT,CAAoCH,IAApC,EAA+D;AACpE,QAAMK,OAAO,GAAG,EAAhB;;AAEA,OAAK,MAAM,CAACC,UAAD,EAAaC,SAAb,CAAX,IAAsCC,MAAM,CAACC,OAAP,CAAeT,IAAI,CAACU,UAApB,CAAtC,EAAuE;AACrEL,IAAAA,OAAO,CAACC,UAAD,CAAP,GAAsBC,SAAS,CAACI,KAAhC;AACD;;AAED,SAAO;AACLV,IAAAA,KAAK,EAAE,gBADF;AAELW,IAAAA,MAAM,EAAEZ,IAAI,CAACY,MAFR;AAGLC,IAAAA,IAAI,EAAER;AAHD,GAAP;AAKD","sourcesContent":["import type {Mesh} from './mesh-types';\nimport type {ColumnarTable, ArrowTable} from '../table/table-types';\n// import {convertMeshToArrowTable} from './mesh-to-arrow-table';\n\ntype TargetShape = 'mesh' | 'columnar-table' | 'arrow-table';\n\n/**\n * Convert a mesh to a specific shape\n */\nexport function convertMesh(\n mesh: Mesh,\n shape: TargetShape,\n options?: any\n): Mesh | ColumnarTable | ArrowTable {\n switch (shape || 'mesh') {\n case 'mesh':\n return mesh;\n case 'columnar-table':\n return convertMeshToColumnarTable(mesh);\n // case 'arrow-table':\n // return {\n // shape: 'arrow-table',\n // data: convertMeshToArrowTable(mesh)\n // };\n default:\n throw new Error(`Unsupported shape ${options?.shape}`);\n }\n}\n\n/**\n * Convert a loaders.gl Mesh to a Columnar Table\n * @param mesh\n * @returns\n */\nexport function convertMeshToColumnarTable(mesh: Mesh): ColumnarTable {\n const columns = {};\n\n for (const [columnName, attribute] of Object.entries(mesh.attributes)) {\n columns[columnName] = attribute.value;\n }\n\n return {\n shape: 'columnar-table',\n schema: mesh.schema,\n data: columns\n };\n}\n"],"file":"convert-mesh.js"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deduceMeshSchema = deduceMeshSchema;
|
|
7
|
+
exports.deduceMeshField = deduceMeshField;
|
|
8
|
+
exports.makeMeshAttributeMetadata = makeMeshAttributeMetadata;
|
|
9
|
+
|
|
10
|
+
var _schema = require("../../lib/schema/schema");
|
|
11
|
+
|
|
12
|
+
var _arrowLikeTypeUtils = require("../../lib/arrow/arrow-like-type-utils");
|
|
13
|
+
|
|
14
|
+
function deduceMeshSchema(attributes, metadata) {
|
|
15
|
+
const fields = deduceMeshFields(attributes);
|
|
16
|
+
return new _schema.Schema(fields, metadata);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function deduceMeshField(attributeName, attribute, optionalMetadata) {
|
|
20
|
+
const type = (0, _arrowLikeTypeUtils.getArrowTypeFromTypedArray)(attribute.value);
|
|
21
|
+
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
22
|
+
const field = new _schema.Field(attributeName, new _schema.FixedSizeList(attribute.size, new _schema.Field('value', type)), false, metadata);
|
|
23
|
+
return field;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function deduceMeshFields(attributes) {
|
|
27
|
+
const fields = [];
|
|
28
|
+
|
|
29
|
+
for (const attributeName in attributes) {
|
|
30
|
+
const attribute = attributes[attributeName];
|
|
31
|
+
fields.push(deduceMeshField(attributeName, attribute));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return fields;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function makeMeshAttributeMetadata(attribute) {
|
|
38
|
+
const result = new Map();
|
|
39
|
+
|
|
40
|
+
if ('byteOffset' in attribute) {
|
|
41
|
+
result.set('byteOffset', attribute.byteOffset.toString(10));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if ('byteStride' in attribute) {
|
|
45
|
+
result.set('byteStride', attribute.byteStride.toString(10));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if ('normalized' in attribute) {
|
|
49
|
+
result.set('normalized', attribute.normalized.toString());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=deduce-mesh-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/category/mesh/deduce-mesh-schema.ts"],"names":["deduceMeshSchema","attributes","metadata","fields","deduceMeshFields","Schema","deduceMeshField","attributeName","attribute","optionalMetadata","type","value","makeMeshAttributeMetadata","field","Field","FixedSizeList","size","push","result","Map","set","byteOffset","toString","byteStride","normalized"],"mappings":";;;;;;;;;AACA;;AACA;;AAQO,SAASA,gBAAT,CACLC,UADK,EAELC,QAFK,EAGG;AACR,QAAMC,MAAM,GAAGC,gBAAgB,CAACH,UAAD,CAA/B;AACA,SAAO,IAAII,cAAJ,CAAWF,MAAX,EAAmBD,QAAnB,CAAP;AACD;;AASM,SAASI,eAAT,CACLC,aADK,EAELC,SAFK,EAGLC,gBAHK,EAIE;AACP,QAAMC,IAAI,GAAG,oDAA2BF,SAAS,CAACG,KAArC,CAAb;AACA,QAAMT,QAAQ,GAAGO,gBAAgB,GAAGA,gBAAH,GAAsBG,yBAAyB,CAACJ,SAAD,CAAhF;AACA,QAAMK,KAAK,GAAG,IAAIC,aAAJ,CACZP,aADY,EAEZ,IAAIQ,qBAAJ,CAAkBP,SAAS,CAACQ,IAA5B,EAAkC,IAAIF,aAAJ,CAAU,OAAV,EAAmBJ,IAAnB,CAAlC,CAFY,EAGZ,KAHY,EAIZR,QAJY,CAAd;AAMA,SAAOW,KAAP;AACD;;AAOD,SAAST,gBAAT,CAA0BH,UAA1B,EAA+D;AAC7D,QAAME,MAAe,GAAG,EAAxB;;AACA,OAAK,MAAMI,aAAX,IAA4BN,UAA5B,EAAwC;AACtC,UAAMO,SAAwB,GAAGP,UAAU,CAACM,aAAD,CAA3C;AACAJ,IAAAA,MAAM,CAACc,IAAP,CAAYX,eAAe,CAACC,aAAD,EAAgBC,SAAhB,CAA3B;AACD;;AACD,SAAOL,MAAP;AACD;;AAOM,SAASS,yBAAT,CAAmCJ,SAAnC,EAAkF;AACvF,QAAMU,MAAM,GAAG,IAAIC,GAAJ,EAAf;;AACA,MAAI,gBAAgBX,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACa,UAAV,CAAsBC,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACe,UAAV,CAAsBD,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACgB,UAAV,CAAsBF,QAAtB,EAAzB;AACD;;AACD,SAAOJ,MAAP;AACD","sourcesContent":["import {MeshAttribute, MeshAttributes} from './mesh-types';\nimport {Schema, Field, FixedSizeList} from '../../lib/schema/schema';\nimport {getArrowTypeFromTypedArray} from '../../lib/arrow/arrow-like-type-utils';\n\n/**\n * Create a schema for mesh attributes data\n * @param attributes\n * @param metadata\n * @returns\n */\nexport function deduceMeshSchema(\n attributes: MeshAttributes,\n metadata?: Map<string, string>\n): Schema {\n const fields = deduceMeshFields(attributes);\n return new Schema(fields, metadata);\n}\n\n/**\n * Create arrow-like schema field for mesh attribute\n * @param attributeName\n * @param attribute\n * @param optionalMetadata\n * @returns\n */\nexport function deduceMeshField(\n attributeName: string,\n attribute: MeshAttribute,\n optionalMetadata?: Map<string, string>\n): Field {\n const type = getArrowTypeFromTypedArray(attribute.value);\n const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);\n const field = new Field(\n attributeName,\n new FixedSizeList(attribute.size, new Field('value', type)),\n false,\n metadata\n );\n return field;\n}\n\n/**\n * Create fields array for mesh attributes\n * @param attributes\n * @returns\n */\nfunction deduceMeshFields(attributes: MeshAttributes): Field[] {\n const fields: Field[] = [];\n for (const attributeName in attributes) {\n const attribute: MeshAttribute = attributes[attributeName];\n fields.push(deduceMeshField(attributeName, attribute));\n }\n return fields;\n}\n\n/**\n * Make metadata by mesh attribute properties\n * @param attribute\n * @returns\n */\nexport function makeMeshAttributeMetadata(attribute: MeshAttribute): Map<string, string> {\n const result = new Map();\n if ('byteOffset' in attribute) {\n result.set('byteOffset', attribute.byteOffset!.toString(10));\n }\n if ('byteStride' in attribute) {\n result.set('byteStride', attribute.byteStride!.toString(10));\n }\n if ('normalized' in attribute) {\n result.set('normalized', attribute.normalized!.toString());\n }\n return result;\n}\n"],"file":"deduce-mesh-schema.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"mesh-to-arrow-table.js"}
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getMeshSize = getMeshSize;
|
|
7
|
+
exports.getMeshBoundingBox = getMeshBoundingBox;
|
|
8
|
+
|
|
9
|
+
function getMeshSize(attributes) {
|
|
10
|
+
let size = 0;
|
|
11
|
+
|
|
12
|
+
for (const attributeName in attributes) {
|
|
13
|
+
const attribute = attributes[attributeName];
|
|
14
|
+
|
|
15
|
+
if (ArrayBuffer.isView(attribute)) {
|
|
16
|
+
size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return size;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getMeshBoundingBox(attributes) {
|
|
24
|
+
let minX = Infinity;
|
|
25
|
+
let minY = Infinity;
|
|
26
|
+
let minZ = Infinity;
|
|
27
|
+
let maxX = -Infinity;
|
|
28
|
+
let maxY = -Infinity;
|
|
29
|
+
let maxZ = -Infinity;
|
|
30
|
+
const positions = attributes.POSITION ? attributes.POSITION.value : [];
|
|
31
|
+
const len = positions && positions.length;
|
|
32
|
+
|
|
33
|
+
for (let i = 0; i < len; i += 3) {
|
|
34
|
+
const x = positions[i];
|
|
35
|
+
const y = positions[i + 1];
|
|
36
|
+
const z = positions[i + 2];
|
|
37
|
+
minX = x < minX ? x : minX;
|
|
38
|
+
minY = y < minY ? y : minY;
|
|
39
|
+
minZ = z < minZ ? z : minZ;
|
|
40
|
+
maxX = x > maxX ? x : maxX;
|
|
41
|
+
maxY = y > maxY ? y : maxY;
|
|
42
|
+
maxZ = z > maxZ ? z : maxZ;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return [[minX, minY, minZ], [maxX, maxY, maxZ]];
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=mesh-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/category/mesh/mesh-utils.ts"],"names":["getMeshSize","attributes","size","attributeName","attribute","ArrayBuffer","isView","byteLength","BYTES_PER_ELEMENT","getMeshBoundingBox","minX","Infinity","minY","minZ","maxX","maxY","maxZ","positions","POSITION","value","len","length","i","x","y","z"],"mappings":";;;;;;;;AAiBO,SAASA,WAAT,CAAqBC,UAArB,EAAsD;AAC3D,MAAIC,IAAI,GAAG,CAAX;;AACA,OAAK,MAAMC,aAAX,IAA4BF,UAA5B,EAAwC;AACtC,UAAMG,SAAS,GAAGH,UAAU,CAACE,aAAD,CAA5B;;AACA,QAAIE,WAAW,CAACC,MAAZ,CAAmBF,SAAnB,CAAJ,EAAmC;AAEjCF,MAAAA,IAAI,IAAIE,SAAS,CAACG,UAAV,GAAuBH,SAAS,CAACI,iBAAzC;AACD;AACF;;AACD,SAAON,IAAP;AACD;;AAQM,SAASO,kBAAT,CAA4BR,UAA5B,EAAqE;AAC1E,MAAIS,IAAI,GAAGC,QAAX;AACA,MAAIC,IAAI,GAAGD,QAAX;AACA,MAAIE,IAAI,GAAGF,QAAX;AACA,MAAIG,IAAI,GAAG,CAACH,QAAZ;AACA,MAAII,IAAI,GAAG,CAACJ,QAAZ;AACA,MAAIK,IAAI,GAAG,CAACL,QAAZ;AAEA,QAAMM,SAAS,GAAGhB,UAAU,CAACiB,QAAX,GAAsBjB,UAAU,CAACiB,QAAX,CAAoBC,KAA1C,GAAkD,EAApE;AACA,QAAMC,GAAG,GAAGH,SAAS,IAAIA,SAAS,CAACI,MAAnC;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,GAApB,EAAyBE,CAAC,IAAI,CAA9B,EAAiC;AAC/B,UAAMC,CAAC,GAAGN,SAAS,CAACK,CAAD,CAAnB;AACA,UAAME,CAAC,GAAGP,SAAS,CAACK,CAAC,GAAG,CAAL,CAAnB;AACA,UAAMG,CAAC,GAAGR,SAAS,CAACK,CAAC,GAAG,CAAL,CAAnB;AAEAZ,IAAAA,IAAI,GAAGa,CAAC,GAAGb,IAAJ,GAAWa,CAAX,GAAeb,IAAtB;AACAE,IAAAA,IAAI,GAAGY,CAAC,GAAGZ,IAAJ,GAAWY,CAAX,GAAeZ,IAAtB;AACAC,IAAAA,IAAI,GAAGY,CAAC,GAAGZ,IAAJ,GAAWY,CAAX,GAAeZ,IAAtB;AAEAC,IAAAA,IAAI,GAAGS,CAAC,GAAGT,IAAJ,GAAWS,CAAX,GAAeT,IAAtB;AACAC,IAAAA,IAAI,GAAGS,CAAC,GAAGT,IAAJ,GAAWS,CAAX,GAAeT,IAAtB;AACAC,IAAAA,IAAI,GAAGS,CAAC,GAAGT,IAAJ,GAAWS,CAAX,GAAeT,IAAtB;AACD;;AACD,SAAO,CACL,CAACN,IAAD,EAAOE,IAAP,EAAaC,IAAb,CADK,EAEL,CAACC,IAAD,EAAOC,IAAP,EAAaC,IAAb,CAFK,CAAP;AAID","sourcesContent":["// Mesh category utilities\n// TODO - move to mesh category module, or to math.gl/geometry module\nimport {TypedArray} from '../../types';\nimport {MeshAttributes} from './mesh-types';\n\ntype TypedArrays = {[key: string]: TypedArray};\n\n/**\n * Holds an axis aligned bounding box\n * TODO - make sure AxisAlignedBoundingBox in math.gl/culling understands this format (or change this format)\n */\ntype BoundingBox = [[number, number, number], [number, number, number]];\n\n/**\n * Get number of vertices in mesh\n * @param attributes\n */\nexport function getMeshSize(attributes: TypedArrays): number {\n let size = 0;\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n if (ArrayBuffer.isView(attribute)) {\n // @ts-ignore DataView doesn't have BYTES_PER_ELEMENT\n size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;\n }\n }\n return size;\n}\n\n/**\n * Get the (axis aligned) bounding box of a mesh\n * @param attributes\n * @returns array of two vectors representing the axis aligned bounding box\n */\n// eslint-disable-next-line complexity\nexport function getMeshBoundingBox(attributes: MeshAttributes): BoundingBox {\n let minX = Infinity;\n let minY = Infinity;\n let minZ = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let maxZ = -Infinity;\n\n const positions = attributes.POSITION ? attributes.POSITION.value : [];\n const len = positions && positions.length;\n\n for (let i = 0; i < len; i += 3) {\n const x = positions[i];\n const y = positions[i + 1];\n const z = positions[i + 2];\n\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n minZ = z < minZ ? z : minZ;\n\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n maxZ = z > maxZ ? z : maxZ;\n }\n return [\n [minX, minY, minZ],\n [maxX, maxY, maxZ]\n ];\n}\n"],"file":"mesh-utils.js"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deduceTableSchema = deduceTableSchema;
|
|
7
|
+
|
|
8
|
+
function deduceTableSchema(table, schema) {
|
|
9
|
+
const deducedSchema = Array.isArray(table) ? deduceSchemaForRowTable(table) : deduceSchemaForColumnarTable(table);
|
|
10
|
+
return Object.assign(deducedSchema, schema);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function deduceSchemaForColumnarTable(columnarTable) {
|
|
14
|
+
const schema = {};
|
|
15
|
+
|
|
16
|
+
for (const field in columnarTable) {
|
|
17
|
+
const column = columnarTable[field];
|
|
18
|
+
|
|
19
|
+
if (ArrayBuffer.isView(column)) {
|
|
20
|
+
schema[field] = column.constructor;
|
|
21
|
+
} else if (column.length) {
|
|
22
|
+
const value = column[0];
|
|
23
|
+
schema[field] = deduceTypeFromValue(value);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
schema[field] = schema[field] || null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return schema;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function deduceSchemaForRowTable(rowTable) {
|
|
33
|
+
const schema = {};
|
|
34
|
+
|
|
35
|
+
if (rowTable.length) {
|
|
36
|
+
const row = rowTable[0];
|
|
37
|
+
|
|
38
|
+
for (const field in row) {
|
|
39
|
+
const value = row[field];
|
|
40
|
+
schema[field] = deduceTypeFromValue(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return schema;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function deduceTypeFromValue(value) {
|
|
48
|
+
if (value instanceof Date) {
|
|
49
|
+
return Date;
|
|
50
|
+
} else if (value instanceof Number) {
|
|
51
|
+
return Float32Array;
|
|
52
|
+
} else if (typeof value === 'string') {
|
|
53
|
+
return String;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=deduce-table-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/category/table/deduce-table-schema.ts"],"names":["deduceTableSchema","table","schema","deducedSchema","Array","isArray","deduceSchemaForRowTable","deduceSchemaForColumnarTable","Object","assign","columnarTable","field","column","ArrayBuffer","isView","constructor","length","value","deduceTypeFromValue","rowTable","row","Date","Number","Float32Array","String"],"mappings":";;;;;;;AAyCO,SAASA,iBAAT,CAA2BC,KAA3B,EAAkCC,MAAlC,EAAmD;AACxD,QAAMC,aAAa,GAAGC,KAAK,CAACC,OAAN,CAAcJ,KAAd,IAClBK,uBAAuB,CAACL,KAAD,CADL,GAElBM,4BAA4B,CAACN,KAAD,CAFhC;AAIA,SAAOO,MAAM,CAACC,MAAP,CAAcN,aAAd,EAA6BD,MAA7B,CAAP;AACD;;AAED,SAASK,4BAAT,CAAsCG,aAAtC,EAAqD;AACnD,QAAMR,MAAM,GAAG,EAAf;;AACA,OAAK,MAAMS,KAAX,IAAoBD,aAApB,EAAmC;AACjC,UAAME,MAAM,GAAGF,aAAa,CAACC,KAAD,CAA5B;;AAEA,QAAIE,WAAW,CAACC,MAAZ,CAAmBF,MAAnB,CAAJ,EAAgC;AAC9BV,MAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBC,MAAM,CAACG,WAAvB;AAED,KAHD,MAGO,IAAIH,MAAM,CAACI,MAAX,EAAmB;AACxB,YAAMC,KAAK,GAAGL,MAAM,CAAC,CAAD,CAApB;AACAV,MAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBO,mBAAmB,CAACD,KAAD,CAAnC;AAED;;AAEDf,IAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBT,MAAM,CAACS,KAAD,CAAN,IAAiB,IAAjC;AACD;;AACD,SAAOT,MAAP;AACD;;AAED,SAASI,uBAAT,CAAiCa,QAAjC,EAA2C;AACzC,QAAMjB,MAAM,GAAG,EAAf;;AACA,MAAIiB,QAAQ,CAACH,MAAb,EAAqB;AACnB,UAAMI,GAAG,GAAGD,QAAQ,CAAC,CAAD,CAApB;;AAEA,SAAK,MAAMR,KAAX,IAAoBS,GAApB,EAAyB;AACvB,YAAMH,KAAK,GAAGG,GAAG,CAACT,KAAD,CAAjB;AACAT,MAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBO,mBAAmB,CAACD,KAAD,CAAnC;AACD;AACF;;AACD,SAAOf,MAAP;AACD;;AAED,SAASgB,mBAAT,CAA6BD,KAA7B,EAAoC;AAClC,MAAIA,KAAK,YAAYI,IAArB,EAA2B;AACzB,WAAOA,IAAP;AACD,GAFD,MAEO,IAAIJ,KAAK,YAAYK,MAArB,EAA6B;AAClC,WAAOC,YAAP;AACD,GAFM,MAEA,IAAI,OAAON,KAAP,KAAiB,QAArB,EAA+B;AACpC,WAAOO,MAAP;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["// Type deduction\nimport {\n Schema\n // Int,\n // Int8,\n // Int16,\n // Int32,\n // Uint8,\n // Uint16,\n // Uint32,\n // Float32,\n // Float64\n // Bool,\n // Utf8,\n // TimestampMillisecond,\n // Null\n} from '../../lib/schema/schema';\n\n// const TYPED_ARRAY_TO_TYPE = {\n// Int8Array: new Int8(),\n// Int16Array: new Int16(),\n// Int32Array: new Int32(),\n// Uint8Array: new Uint8(),\n// Uint8ClampedArray: new Uint8(),\n// Uint16Array: new Uint16(),\n// Uint32Array: new Uint32(),\n// Float32Array: new Float32(),\n// Float64Array: new Float64()\n// };\n\n// if (typeof BigInt64Array !== 'undefined') {\n// TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();\n// TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();\n// }\n\n/**\n * SCHEMA SUPPORT - AUTODEDUCTION\n * @param {*} table\n * @param {*} schema\n * @returns\n */\nexport function deduceTableSchema(table, schema?: Schema) {\n const deducedSchema = Array.isArray(table)\n ? deduceSchemaForRowTable(table)\n : deduceSchemaForColumnarTable(table);\n // Deduced schema will fill in missing info from partial options.schema, if provided\n return Object.assign(deducedSchema, schema);\n}\n\nfunction deduceSchemaForColumnarTable(columnarTable) {\n const schema = {};\n for (const field in columnarTable) {\n const column = columnarTable[field];\n // Check if column is typed, if so we are done\n if (ArrayBuffer.isView(column)) {\n schema[field] = column.constructor;\n // else we need data\n } else if (column.length) {\n const value = column[0];\n schema[field] = deduceTypeFromValue(value);\n // TODO - support nested schemas?\n }\n // else we mark as present but unknow\n schema[field] = schema[field] || null;\n }\n return schema;\n}\n\nfunction deduceSchemaForRowTable(rowTable) {\n const schema = {};\n if (rowTable.length) {\n const row = rowTable[0];\n // TODO - Could look at additional rows if nulls in first row\n for (const field in row) {\n const value = row[field];\n schema[field] = deduceTypeFromValue(value);\n }\n }\n return schema;\n}\n\nfunction deduceTypeFromValue(value) {\n if (value instanceof Date) {\n return Date;\n } else if (value instanceof Number) {\n return Float32Array;\n } else if (typeof value === 'string') {\n return String;\n }\n return null;\n}\n\n/*\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction deduceSchema(rows) {\n const row = rows[0];\n\n const schema = {};\n let i = 0;\n for (const columnName in row) {\n const value = row[columnName];\n switch (typeof value) {\n case 'number':\n case 'boolean':\n // TODO - booleans could be handled differently...\n schema[columnName] = {name: String(columnName), index: i, type: Float32Array};\n break;\n\n case 'object':\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n break;\n\n case 'string':\n default:\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n // We currently only handle numeric rows\n // TODO we could offer a function to map strings to numbers?\n }\n i++;\n }\n return schema;\n}\n*/\n"],"file":"deduce-table-schema.js"}
|
|
File without changes
|