@loaders.gl/schema 3.1.3 → 4.0.0-alpha.5
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.js +2 -2
- package/dist/bundle.js.map +1 -0
- package/dist/category/common.d.ts +1 -2
- package/dist/category/common.d.ts.map +1 -1
- package/dist/category/common.js +2 -10
- package/dist/{es5/category → category}/common.js.map +0 -0
- package/dist/category/gis.js +2 -2
- package/dist/{es5/category → category}/gis.js.map +0 -0
- package/dist/category/image/image.d.ts +18 -0
- package/dist/category/image/image.d.ts.map +1 -0
- package/dist/category/image/image.js +2 -0
- package/dist/{esm/category/gis.js.map → category/image/image.js.map} +1 -1
- package/dist/category/mesh/convert-mesh.js +31 -37
- package/dist/category/mesh/convert-mesh.js.map +1 -0
- package/dist/category/mesh/deduce-mesh-schema.js +37 -57
- package/dist/category/mesh/deduce-mesh-schema.js.map +1 -0
- package/dist/category/mesh/mesh-to-arrow-table.d.ts +10 -0
- package/dist/category/mesh/mesh-to-arrow-table.d.ts.map +1 -1
- package/dist/category/mesh/mesh-to-arrow-table.js +15 -28
- package/dist/category/mesh/mesh-to-arrow-table.js.map +1 -0
- package/dist/category/mesh/mesh-types.js +2 -2
- package/dist/{es5/category → category}/mesh/mesh-types.js.map +0 -0
- package/dist/category/mesh/mesh-utils.js +35 -48
- package/dist/category/mesh/mesh-utils.js.map +1 -0
- package/dist/category/table/deduce-table-schema.js +39 -94
- package/dist/category/table/deduce-table-schema.js.map +1 -0
- package/dist/category/table/table-types.d.ts +1 -3
- package/dist/category/table/table-types.d.ts.map +1 -1
- package/dist/category/table/table-types.js +2 -2
- package/dist/{es5/category → category}/table/table-types.js.map +0 -0
- package/dist/category/texture/texture.d.ts +18 -0
- package/dist/category/texture/texture.d.ts.map +1 -0
- package/dist/category/texture/texture.js +2 -0
- package/dist/{esm/category/common.js.map → category/texture/texture.js.map} +1 -1
- package/dist/dist.min.js +15078 -208
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -75
- package/dist/index.js.map +1 -0
- package/dist/lib/arrow/arrow-like-type-utils.js +31 -26
- package/dist/lib/arrow/arrow-like-type-utils.js.map +1 -0
- package/dist/lib/arrow/arrow-type-utils.d.ts +5 -0
- package/dist/lib/arrow/arrow-type-utils.d.ts.map +1 -1
- package/dist/lib/arrow/arrow-type-utils.js +20 -28
- package/dist/lib/arrow/arrow-type-utils.js.map +1 -0
- package/dist/lib/arrow/get-type-info.js +19 -23
- package/dist/lib/arrow/get-type-info.js.map +1 -0
- package/dist/lib/batches/base-table-batch-aggregator.js +68 -52
- package/dist/lib/batches/base-table-batch-aggregator.js.map +1 -0
- package/dist/lib/batches/columnar-table-batch-aggregator.js +92 -82
- package/dist/lib/batches/columnar-table-batch-aggregator.js.map +1 -0
- package/dist/lib/batches/row-table-batch-aggregator.js +88 -72
- package/dist/lib/batches/row-table-batch-aggregator.js.map +1 -0
- package/dist/lib/batches/table-batch-aggregator.js +2 -2
- package/dist/{es5/lib → lib}/batches/table-batch-aggregator.js.map +0 -0
- package/dist/lib/batches/table-batch-builder.js +166 -137
- package/dist/lib/batches/table-batch-builder.js.map +1 -0
- package/dist/lib/schema/impl/enum.js +48 -96
- package/dist/lib/schema/impl/enum.js.map +1 -0
- package/dist/lib/schema/impl/field.js +34 -31
- package/dist/lib/schema/impl/field.js.map +1 -0
- package/dist/lib/schema/impl/schema.js +81 -72
- package/dist/lib/schema/impl/schema.js.map +1 -0
- package/dist/lib/schema/impl/type.js +490 -454
- package/dist/lib/schema/impl/type.js.map +1 -0
- package/dist/lib/schema/schema.js +5 -90
- package/dist/lib/schema/schema.js.map +1 -0
- package/dist/lib/schema-utils/deduce-column-type.js +20 -89
- package/dist/lib/schema-utils/deduce-column-type.js.map +1 -0
- package/dist/lib/utils/assert.js +5 -11
- package/dist/lib/utils/assert.js.map +1 -0
- package/dist/lib/utils/async-queue.js +109 -82
- package/dist/lib/utils/async-queue.js.map +1 -0
- package/dist/lib/utils/row-utils.js +33 -31
- package/dist/lib/utils/row-utils.js.map +1 -0
- package/dist/types.js +2 -2
- package/dist/{es5/types.js.map → types.js.map} +0 -0
- package/package.json +6 -5
- package/src/category/common.ts +1 -2
- package/src/category/image/image.ts +19 -0
- package/src/category/mesh/convert-mesh.ts +6 -6
- package/src/category/mesh/mesh-to-arrow-table.ts +2 -4
- package/src/category/table/table-types.ts +1 -4
- package/src/category/texture/texture.ts +28 -0
- package/src/index.ts +6 -1
- package/src/lib/arrow/arrow-type-utils.ts +0 -2
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/category/common.js +0 -2
- package/dist/es5/category/gis.js +0 -2
- package/dist/es5/category/mesh/convert-mesh.js +0 -43
- package/dist/es5/category/mesh/convert-mesh.js.map +0 -1
- package/dist/es5/category/mesh/deduce-mesh-schema.js +0 -54
- package/dist/es5/category/mesh/deduce-mesh-schema.js.map +0 -1
- package/dist/es5/category/mesh/mesh-to-arrow-table.js +0 -2
- package/dist/es5/category/mesh/mesh-to-arrow-table.js.map +0 -1
- package/dist/es5/category/mesh/mesh-types.js +0 -2
- package/dist/es5/category/mesh/mesh-utils.js +0 -47
- package/dist/es5/category/mesh/mesh-utils.js.map +0 -1
- package/dist/es5/category/table/deduce-table-schema.js +0 -58
- package/dist/es5/category/table/deduce-table-schema.js.map +0 -1
- package/dist/es5/category/table/table-types.js +0 -2
- package/dist/es5/index.js +0 -344
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/arrow/arrow-like-type-utils.js +0 -40
- package/dist/es5/lib/arrow/arrow-like-type-utils.js.map +0 -1
- package/dist/es5/lib/arrow/arrow-type-utils.js +0 -2
- package/dist/es5/lib/arrow/arrow-type-utils.js.map +0 -1
- package/dist/es5/lib/arrow/get-type-info.js +0 -33
- package/dist/es5/lib/arrow/get-type-info.js.map +0 -1
- package/dist/es5/lib/batches/base-table-batch-aggregator.js +0 -92
- package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +0 -128
- package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/batches/row-table-batch-aggregator.js +0 -113
- package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/batches/table-batch-aggregator.js +0 -2
- package/dist/es5/lib/batches/table-batch-builder.js +0 -207
- package/dist/es5/lib/batches/table-batch-builder.js.map +0 -1
- package/dist/es5/lib/schema/impl/enum.js +0 -56
- package/dist/es5/lib/schema/impl/enum.js.map +0 -1
- package/dist/es5/lib/schema/impl/field.js +0 -56
- package/dist/es5/lib/schema/impl/field.js.map +0 -1
- package/dist/es5/lib/schema/impl/schema.js +0 -168
- package/dist/es5/lib/schema/impl/schema.js.map +0 -1
- package/dist/es5/lib/schema/impl/type.js +0 -927
- package/dist/es5/lib/schema/impl/type.js.map +0 -1
- package/dist/es5/lib/schema/schema.js +0 -236
- package/dist/es5/lib/schema/schema.js.map +0 -1
- package/dist/es5/lib/schema-utils/deduce-column-type.js +0 -32
- package/dist/es5/lib/schema-utils/deduce-column-type.js.map +0 -1
- package/dist/es5/lib/utils/assert.js +0 -13
- package/dist/es5/lib/utils/assert.js.map +0 -1
- package/dist/es5/lib/utils/async-queue.js +0 -213
- package/dist/es5/lib/utils/async-queue.js.map +0 -1
- package/dist/es5/lib/utils/row-utils.js +0 -44
- package/dist/es5/lib/utils/row-utils.js.map +0 -1
- package/dist/es5/types.js +0 -2
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/category/common.js +0 -2
- package/dist/esm/category/gis.js +0 -2
- package/dist/esm/category/mesh/convert-mesh.js +0 -26
- package/dist/esm/category/mesh/convert-mesh.js.map +0 -1
- package/dist/esm/category/mesh/deduce-mesh-schema.js +0 -42
- package/dist/esm/category/mesh/deduce-mesh-schema.js.map +0 -1
- package/dist/esm/category/mesh/mesh-to-arrow-table.js +0 -2
- package/dist/esm/category/mesh/mesh-to-arrow-table.js.map +0 -1
- package/dist/esm/category/mesh/mesh-types.js +0 -2
- package/dist/esm/category/mesh/mesh-types.js.map +0 -1
- package/dist/esm/category/mesh/mesh-utils.js +0 -38
- package/dist/esm/category/mesh/mesh-utils.js.map +0 -1
- package/dist/esm/category/table/deduce-table-schema.js +0 -51
- package/dist/esm/category/table/deduce-table-schema.js.map +0 -1
- package/dist/esm/category/table/table-types.js +0 -2
- package/dist/esm/category/table/table-types.js.map +0 -1
- package/dist/esm/index.js +0 -13
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/arrow/arrow-like-type-utils.js +0 -32
- package/dist/esm/lib/arrow/arrow-like-type-utils.js.map +0 -1
- package/dist/esm/lib/arrow/arrow-type-utils.js +0 -2
- package/dist/esm/lib/arrow/arrow-type-utils.js.map +0 -1
- package/dist/esm/lib/arrow/get-type-info.js +0 -24
- package/dist/esm/lib/arrow/get-type-info.js.map +0 -1
- package/dist/esm/lib/batches/base-table-batch-aggregator.js +0 -74
- package/dist/esm/lib/batches/base-table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/batches/columnar-table-batch-aggregator.js +0 -100
- package/dist/esm/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/batches/row-table-batch-aggregator.js +0 -95
- package/dist/esm/lib/batches/row-table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/batches/table-batch-aggregator.js +0 -2
- package/dist/esm/lib/batches/table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/batches/table-batch-builder.js +0 -182
- package/dist/esm/lib/batches/table-batch-builder.js.map +0 -1
- package/dist/esm/lib/schema/impl/enum.js +0 -49
- package/dist/esm/lib/schema/impl/enum.js.map +0 -1
- package/dist/esm/lib/schema/impl/field.js +0 -35
- package/dist/esm/lib/schema/impl/field.js.map +0 -1
- package/dist/esm/lib/schema/impl/schema.js +0 -92
- package/dist/esm/lib/schema/impl/schema.js.map +0 -1
- package/dist/esm/lib/schema/impl/type.js +0 -498
- package/dist/esm/lib/schema/impl/type.js.map +0 -1
- package/dist/esm/lib/schema/schema.js +0 -5
- package/dist/esm/lib/schema/schema.js.map +0 -1
- package/dist/esm/lib/schema-utils/deduce-column-type.js +0 -23
- package/dist/esm/lib/schema-utils/deduce-column-type.js.map +0 -1
- package/dist/esm/lib/utils/assert.js +0 -6
- package/dist/esm/lib/utils/assert.js.map +0 -1
- package/dist/esm/lib/utils/async-queue.js +0 -119
- package/dist/esm/lib/utils/async-queue.js.map +0 -1
- package/dist/esm/lib/utils/row-utils.js +0 -35
- package/dist/esm/lib/utils/row-utils.js.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
package/dist/bundle.js
CHANGED
|
@@ -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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { RecordBatch } from 'apache-arrow';
|
|
2
2
|
export declare type Field = any;
|
|
3
3
|
export declare type Schema = {
|
|
4
4
|
[key: string]: Field;
|
|
@@ -16,5 +16,4 @@ export declare type Batch = {
|
|
|
16
16
|
cursor?: number;
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
};
|
|
19
|
-
export {};
|
|
20
19
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/category/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/category/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAE9C,oBAAY,KAAK,GAAG,GAAG,CAAC;AAExB,oBAAY,MAAM,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;CACtB,CAAC;AAEF,oBAAY,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAC;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC"}
|
package/dist/category/common.js
CHANGED
|
File without changes
|
package/dist/category/gis.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=gis.js.map
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data images
|
|
3
|
+
*/
|
|
4
|
+
export declare type ImageDataType = {
|
|
5
|
+
data: Uint8Array;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
compressed?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Supported Image Types
|
|
12
|
+
*/
|
|
13
|
+
export declare type ImageType = ImageBitmap | typeof Image | ImageDataType;
|
|
14
|
+
/**
|
|
15
|
+
* Image type string used to control or determine the type of images returned from ImageLoader
|
|
16
|
+
*/
|
|
17
|
+
export declare type ImageTypeEnum = 'imagebitmap' | 'image' | 'data';
|
|
18
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/category/image/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,aAAa,GAAG;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS,GAAG,WAAW,GAAG,OAAO,KAAK,GAAG,aAAa,CAAC;AAEnE;;GAEG;AACH,oBAAY,aAAa,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"image.js"}
|
|
@@ -1,39 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
throw new Error(`Unsupported shape ${options?.shape}`);
|
|
20
|
-
}
|
|
1
|
+
import { convertMeshToArrowTable } from './mesh-to-arrow-table';
|
|
2
|
+
export function convertMesh(mesh, shape, options) {
|
|
3
|
+
switch (shape || 'mesh') {
|
|
4
|
+
case 'mesh':
|
|
5
|
+
return mesh;
|
|
6
|
+
|
|
7
|
+
case 'columnar-table':
|
|
8
|
+
return convertMeshToColumnarTable(mesh);
|
|
9
|
+
|
|
10
|
+
case 'arrow-table':
|
|
11
|
+
return {
|
|
12
|
+
shape: 'arrow-table',
|
|
13
|
+
data: convertMeshToArrowTable(mesh)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
default:
|
|
17
|
+
throw new Error("Unsupported shape ".concat(options === null || options === void 0 ? void 0 : options.shape));
|
|
18
|
+
}
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
shape: 'columnar-table',
|
|
35
|
-
schema: mesh.schema,
|
|
36
|
-
data: columns
|
|
37
|
-
};
|
|
20
|
+
export function convertMeshToColumnarTable(mesh) {
|
|
21
|
+
const columns = {};
|
|
22
|
+
|
|
23
|
+
for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
|
|
24
|
+
columns[columnName] = attribute.value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
shape: 'columnar-table',
|
|
29
|
+
schema: mesh.schema,
|
|
30
|
+
data: columns
|
|
31
|
+
};
|
|
38
32
|
}
|
|
39
|
-
|
|
33
|
+
//# sourceMappingURL=convert-mesh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/category/mesh/convert-mesh.ts"],"names":["convertMeshToArrowTable","convertMesh","mesh","shape","options","convertMeshToColumnarTable","data","Error","columns","columnName","attribute","Object","entries","attributes","value","schema"],"mappings":"AAEA,SAAQA,uBAAR,QAAsC,uBAAtC;AAOA,OAAO,SAASC,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;;AACF,SAAK,aAAL;AACE,aAAO;AACLC,QAAAA,KAAK,EAAE,aADF;AAELG,QAAAA,IAAI,EAAEN,uBAAuB,CAACE,IAAD;AAFxB,OAAP;;AAIF;AACE,YAAM,IAAIK,KAAJ,6BAA+BH,OAA/B,aAA+BA,OAA/B,uBAA+BA,OAAO,CAAED,KAAxC,EAAN;AAXJ;AAaD;AAOD,OAAO,SAASE,0BAAT,CAAoCH,IAApC,EAA+D;AACpE,QAAMM,OAAO,GAAG,EAAhB;;AAEA,OAAK,MAAM,CAACC,UAAD,EAAaC,SAAb,CAAX,IAAsCC,MAAM,CAACC,OAAP,CAAeV,IAAI,CAACW,UAApB,CAAtC,EAAuE;AACrEL,IAAAA,OAAO,CAACC,UAAD,CAAP,GAAsBC,SAAS,CAACI,KAAhC;AACD;;AAED,SAAO;AACLX,IAAAA,KAAK,EAAE,gBADF;AAELY,IAAAA,MAAM,EAAEb,IAAI,CAACa,MAFR;AAGLT,IAAAA,IAAI,EAAEE;AAHD,GAAP;AAKD","sourcesContent":["import type {Mesh} from './mesh-types';\nimport type {ColumnarTable, ArrowTable} from '../table/table-types';\nimport {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"}
|
|
@@ -1,62 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
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 new schema_1.Schema(fields, metadata);
|
|
1
|
+
import { Schema, Field, FixedSizeList } from '../../lib/schema/schema';
|
|
2
|
+
import { getArrowTypeFromTypedArray } from '../../lib/arrow/arrow-like-type-utils';
|
|
3
|
+
export function deduceMeshSchema(attributes, metadata) {
|
|
4
|
+
const fields = deduceMeshFields(attributes);
|
|
5
|
+
return new Schema(fields, metadata);
|
|
15
6
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* @param optionalMetadata
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
function deduceMeshField(attributeName, attribute, optionalMetadata) {
|
|
25
|
-
const type = (0, arrow_like_type_utils_1.getArrowTypeFromTypedArray)(attribute.value);
|
|
26
|
-
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
27
|
-
const field = new schema_1.Field(attributeName, new schema_1.FixedSizeList(attribute.size, new schema_1.Field('value', type)), false, metadata);
|
|
28
|
-
return field;
|
|
7
|
+
export function deduceMeshField(attributeName, attribute, optionalMetadata) {
|
|
8
|
+
const type = getArrowTypeFromTypedArray(attribute.value);
|
|
9
|
+
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
10
|
+
const field = new Field(attributeName, new FixedSizeList(attribute.size, new Field('value', type)), false, metadata);
|
|
11
|
+
return field;
|
|
29
12
|
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Create fields array for mesh attributes
|
|
33
|
-
* @param attributes
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
13
|
+
|
|
36
14
|
function deduceMeshFields(attributes) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
const fields = [];
|
|
16
|
+
|
|
17
|
+
for (const attributeName in attributes) {
|
|
18
|
+
const attribute = attributes[attributeName];
|
|
19
|
+
fields.push(deduceMeshField(attributeName, attribute));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return fields;
|
|
43
23
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
24
|
+
|
|
25
|
+
export function makeMeshAttributeMetadata(attribute) {
|
|
26
|
+
const result = new Map();
|
|
27
|
+
|
|
28
|
+
if ('byteOffset' in attribute) {
|
|
29
|
+
result.set('byteOffset', attribute.byteOffset.toString(10));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if ('byteStride' in attribute) {
|
|
33
|
+
result.set('byteStride', attribute.byteStride.toString(10));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ('normalized' in attribute) {
|
|
37
|
+
result.set('normalized', attribute.normalized.toString());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return result;
|
|
61
41
|
}
|
|
62
|
-
|
|
42
|
+
//# sourceMappingURL=deduce-mesh-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/category/mesh/deduce-mesh-schema.ts"],"names":["Schema","Field","FixedSizeList","getArrowTypeFromTypedArray","deduceMeshSchema","attributes","metadata","fields","deduceMeshFields","deduceMeshField","attributeName","attribute","optionalMetadata","type","value","makeMeshAttributeMetadata","field","size","push","result","Map","set","byteOffset","toString","byteStride","normalized"],"mappings":"AACA,SAAQA,MAAR,EAAgBC,KAAhB,EAAuBC,aAAvB,QAA2C,yBAA3C;AACA,SAAQC,0BAAR,QAAyC,uCAAzC;AAQA,OAAO,SAASC,gBAAT,CACLC,UADK,EAELC,QAFK,EAGG;AACR,QAAMC,MAAM,GAAGC,gBAAgB,CAACH,UAAD,CAA/B;AACA,SAAO,IAAIL,MAAJ,CAAWO,MAAX,EAAmBD,QAAnB,CAAP;AACD;AASD,OAAO,SAASG,eAAT,CACLC,aADK,EAELC,SAFK,EAGLC,gBAHK,EAIE;AACP,QAAMC,IAAI,GAAGV,0BAA0B,CAACQ,SAAS,CAACG,KAAX,CAAvC;AACA,QAAMR,QAAQ,GAAGM,gBAAgB,GAAGA,gBAAH,GAAsBG,yBAAyB,CAACJ,SAAD,CAAhF;AACA,QAAMK,KAAK,GAAG,IAAIf,KAAJ,CACZS,aADY,EAEZ,IAAIR,aAAJ,CAAkBS,SAAS,CAACM,IAA5B,EAAkC,IAAIhB,KAAJ,CAAU,OAAV,EAAmBY,IAAnB,CAAlC,CAFY,EAGZ,KAHY,EAIZP,QAJY,CAAd;AAMA,SAAOU,KAAP;AACD;;AAOD,SAASR,gBAAT,CAA0BH,UAA1B,EAA+D;AAC7D,QAAME,MAAe,GAAG,EAAxB;;AACA,OAAK,MAAMG,aAAX,IAA4BL,UAA5B,EAAwC;AACtC,UAAMM,SAAwB,GAAGN,UAAU,CAACK,aAAD,CAA3C;AACAH,IAAAA,MAAM,CAACW,IAAP,CAAYT,eAAe,CAACC,aAAD,EAAgBC,SAAhB,CAA3B;AACD;;AACD,SAAOJ,MAAP;AACD;;AAOD,OAAO,SAASQ,yBAAT,CAAmCJ,SAAnC,EAAkF;AACvF,QAAMQ,MAAM,GAAG,IAAIC,GAAJ,EAAf;;AACA,MAAI,gBAAgBT,SAApB,EAA+B;AAC7BQ,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBV,SAAS,CAACW,UAAV,CAAsBC,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBZ,SAApB,EAA+B;AAC7BQ,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBV,SAAS,CAACa,UAAV,CAAsBD,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBZ,SAApB,EAA+B;AAC7BQ,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBV,SAAS,CAACc,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"}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
+
import { Table } from 'apache-arrow/Arrow.dom';
|
|
2
|
+
import type { Mesh } from './mesh-types';
|
|
3
|
+
/**
|
|
4
|
+
* * Convert a loaders.gl Mesh to an Apache Arrow Table
|
|
5
|
+
* @param mesh
|
|
6
|
+
* @param metadata
|
|
7
|
+
* @param batchSize
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table;
|
|
1
11
|
//# sourceMappingURL=mesh-to-arrow-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh-to-arrow-table.d.ts","sourceRoot":"","sources":["../../../src/category/mesh/mesh-to-arrow-table.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"mesh-to-arrow-table.d.ts","sourceRoot":"","sources":["../../../src/category/mesh/mesh-to-arrow-table.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAON,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAGvC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAmB7E"}
|
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Data,
|
|
10
|
-
FixedSizeListVector
|
|
11
|
-
} from 'apache-arrow';
|
|
12
|
-
import {AbstractVector} from 'apache-arrow/vector';
|
|
13
|
-
import {getArrowType, getArrowVector} from '../../lib/arrow/arrow-type-utils.js';
|
|
14
|
-
import type {Mesh} from './mesh-types.js';
|
|
15
|
-
import {makeMeshAttributeMetadata} from './deduce-mesh-schema.js';
|
|
1
|
+
import { Table, Schema, RecordBatch, FixedSizeList, Field, Data, FixedSizeListVector } from 'apache-arrow/Arrow.dom';
|
|
2
|
+
import { getArrowType, getArrowVector } from '../../lib/arrow/arrow-type-utils';
|
|
3
|
+
import { makeMeshAttributeMetadata } from './deduce-mesh-schema';
|
|
4
|
+
export function convertMeshToArrowTable(mesh, batchSize) {
|
|
5
|
+
var _mesh$schema;
|
|
6
|
+
|
|
7
|
+
const vectors = [];
|
|
8
|
+
const fields = [];
|
|
16
9
|
|
|
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
10
|
for (const attributeKey in mesh.attributes) {
|
|
28
11
|
const attribute = mesh.attributes[attributeKey];
|
|
29
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
value,
|
|
14
|
+
size = 1
|
|
15
|
+
} = attribute;
|
|
30
16
|
const type = getArrowType(value);
|
|
31
17
|
const vector = getArrowVector(value);
|
|
32
18
|
const listType = new FixedSizeList(size, new Field('value', type));
|
|
@@ -36,9 +22,10 @@ export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {
|
|
|
36
22
|
vectors.push(listVector);
|
|
37
23
|
fields.push(field);
|
|
38
24
|
}
|
|
39
|
-
|
|
25
|
+
|
|
26
|
+
const schema = new Schema(fields, (mesh === null || mesh === void 0 ? void 0 : (_mesh$schema = mesh.schema) === null || _mesh$schema === void 0 ? void 0 : _mesh$schema.metadata) || new Map());
|
|
40
27
|
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
|
|
41
28
|
const table = new Table(schema, recordBatch);
|
|
42
29
|
return table;
|
|
43
30
|
}
|
|
44
|
-
|
|
31
|
+
//# sourceMappingURL=mesh-to-arrow-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/category/mesh/mesh-to-arrow-table.ts"],"names":["Table","Schema","RecordBatch","FixedSizeList","Field","Data","FixedSizeListVector","getArrowType","getArrowVector","makeMeshAttributeMetadata","convertMeshToArrowTable","mesh","batchSize","vectors","fields","attributeKey","attributes","attribute","value","size","type","vector","listType","field","data","length","undefined","listVector","push","schema","metadata","Map","recordBatch","table"],"mappings":"AAAA,SACEA,KADF,EAEEC,MAFF,EAGEC,WAHF,EAIEC,aAJF,EAKEC,KALF,EAMEC,IANF,EAOEC,mBAPF,QAQO,wBARP;AAUA,SAAQC,YAAR,EAAsBC,cAAtB,QAA2C,kCAA3C;AAEA,SAAQC,yBAAR,QAAwC,sBAAxC;AASA,OAAO,SAASC,uBAAT,CAAiCC,IAAjC,EAA6CC,SAA7C,EAAwE;AAAA;;AAC7E,QAAMC,OAAyB,GAAG,EAAlC;AACA,QAAMC,MAAe,GAAG,EAAxB;;AACA,OAAK,MAAMC,YAAX,IAA2BJ,IAAI,CAACK,UAAhC,EAA4C;AAC1C,UAAMC,SAAS,GAAGN,IAAI,CAACK,UAAL,CAAgBD,YAAhB,CAAlB;AACA,UAAM;AAACG,MAAAA,KAAD;AAAQC,MAAAA,IAAI,GAAG;AAAf,QAAoBF,SAA1B;AACA,UAAMG,IAAI,GAAGb,YAAY,CAACW,KAAD,CAAzB;AACA,UAAMG,MAAM,GAAGb,cAAc,CAACU,KAAD,CAA7B;AACA,UAAMI,QAAQ,GAAG,IAAInB,aAAJ,CAAkBgB,IAAlB,EAAwB,IAAIf,KAAJ,CAAU,OAAV,EAAmBgB,IAAnB,CAAxB,CAAjB;AACA,UAAMG,KAAK,GAAG,IAAInB,KAAJ,CAAUW,YAAV,EAAwBO,QAAxB,EAAkC,KAAlC,EAAyCb,yBAAyB,CAACQ,SAAD,CAAlE,CAAd;AACA,UAAMO,IAAI,GAAG,IAAInB,IAAJ,CAASiB,QAAT,EAAmB,CAAnB,EAAsBJ,KAAK,CAACO,MAAN,GAAeN,IAArC,EAA2C,CAA3C,EAA8CO,SAA9C,EAAyD,CAACL,MAAD,CAAzD,CAAb;AACA,UAAMM,UAAU,GAAG,IAAIrB,mBAAJ,CAAwBkB,IAAxB,CAAnB;AACAX,IAAAA,OAAO,CAACe,IAAR,CAAaD,UAAb;AACAb,IAAAA,MAAM,CAACc,IAAP,CAAYL,KAAZ;AACD;;AACD,QAAMM,MAAM,GAAG,IAAI5B,MAAJ,CAAWa,MAAX,EAAmB,CAAAH,IAAI,SAAJ,IAAAA,IAAI,WAAJ,4BAAAA,IAAI,CAAEkB,MAAN,8DAAcC,QAAd,KAA0B,IAAIC,GAAJ,EAA7C,CAAf;AACA,QAAMC,WAAW,GAAG,IAAI9B,WAAJ,CAAgB2B,MAAhB,EAAwBhB,OAAO,CAAC,CAAD,CAAP,CAAWY,MAAnC,EAA2CZ,OAA3C,CAApB;AACA,QAAMoB,KAAK,GAAG,IAAIjC,KAAJ,CAAU6B,MAAV,EAAkBG,WAAlB,CAAd;AACA,SAAOC,KAAP;AACD","sourcesContent":["import {\n Table,\n Schema,\n RecordBatch,\n FixedSizeList,\n Field,\n Data,\n FixedSizeListVector\n} from 'apache-arrow/Arrow.dom';\nimport {AbstractVector} from 'apache-arrow/vector';\nimport {getArrowType, getArrowVector} from '../../lib/arrow/arrow-type-utils';\nimport type {Mesh} from './mesh-types';\nimport {makeMeshAttributeMetadata} from './deduce-mesh-schema';\n\n/**\n * * Convert a loaders.gl Mesh to an Apache Arrow Table\n * @param mesh\n * @param metadata\n * @param batchSize\n * @returns\n */\nexport function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {\n const vectors: AbstractVector[] = [];\n const fields: Field[] = [];\n for (const attributeKey in mesh.attributes) {\n const attribute = mesh.attributes[attributeKey];\n const {value, size = 1} = attribute;\n const type = getArrowType(value);\n const vector = getArrowVector(value);\n const listType = new FixedSizeList(size, new Field('value', type));\n const field = new Field(attributeKey, listType, false, makeMeshAttributeMetadata(attribute));\n const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);\n const listVector = new FixedSizeListVector(data);\n vectors.push(listVector);\n fields.push(field);\n }\n const schema = new Schema(fields, mesh?.schema?.metadata || new Map<string, string>());\n const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);\n const table = new Table(schema, recordBatch);\n return table;\n}\n"],"file":"mesh-to-arrow-table.js"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=mesh-types.js.map
|
|
File without changes
|
|
@@ -1,51 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
}
|
|
1
|
+
export function getMeshSize(attributes) {
|
|
2
|
+
let size = 0;
|
|
3
|
+
|
|
4
|
+
for (const attributeName in attributes) {
|
|
5
|
+
const attribute = attributes[attributeName];
|
|
6
|
+
|
|
7
|
+
if (ArrayBuffer.isView(attribute)) {
|
|
8
|
+
size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
|
|
16
9
|
}
|
|
17
|
-
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return size;
|
|
18
13
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
];
|
|
14
|
+
export function getMeshBoundingBox(attributes) {
|
|
15
|
+
let minX = Infinity;
|
|
16
|
+
let minY = Infinity;
|
|
17
|
+
let minZ = Infinity;
|
|
18
|
+
let maxX = -Infinity;
|
|
19
|
+
let maxY = -Infinity;
|
|
20
|
+
let maxZ = -Infinity;
|
|
21
|
+
const positions = attributes.POSITION ? attributes.POSITION.value : [];
|
|
22
|
+
const len = positions && positions.length;
|
|
23
|
+
|
|
24
|
+
for (let i = 0; i < len; i += 3) {
|
|
25
|
+
const x = positions[i];
|
|
26
|
+
const y = positions[i + 1];
|
|
27
|
+
const z = positions[i + 2];
|
|
28
|
+
minX = x < minX ? x : minX;
|
|
29
|
+
minY = y < minY ? y : minY;
|
|
30
|
+
minZ = z < minZ ? z : minZ;
|
|
31
|
+
maxX = x > maxX ? x : maxX;
|
|
32
|
+
maxY = y > maxY ? y : maxY;
|
|
33
|
+
maxZ = z > maxZ ? z : maxZ;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return [[minX, minY, minZ], [maxX, maxY, maxZ]];
|
|
50
37
|
}
|
|
51
|
-
|
|
38
|
+
//# 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":"AAiBA,OAAO,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;AAQD,OAAO,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"}
|
|
@@ -1,106 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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);
|
|
1
|
+
export function deduceTableSchema(table, schema) {
|
|
2
|
+
const deducedSchema = Array.isArray(table) ? deduceSchemaForRowTable(table) : deduceSchemaForColumnarTable(table);
|
|
3
|
+
return Object.assign(deducedSchema, schema);
|
|
31
4
|
}
|
|
32
|
-
|
|
5
|
+
|
|
33
6
|
function deduceSchemaForColumnarTable(columnarTable) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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;
|
|
49
|
-
}
|
|
50
|
-
return schema;
|
|
51
|
-
}
|
|
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;
|
|
7
|
+
const schema = {};
|
|
8
|
+
|
|
9
|
+
for (const field in columnarTable) {
|
|
10
|
+
const column = columnarTable[field];
|
|
11
|
+
|
|
12
|
+
if (ArrayBuffer.isView(column)) {
|
|
13
|
+
schema[field] = column.constructor;
|
|
14
|
+
} else if (column.length) {
|
|
15
|
+
const value = column[0];
|
|
16
|
+
schema[field] = deduceTypeFromValue(value);
|
|
73
17
|
}
|
|
74
|
-
|
|
18
|
+
|
|
19
|
+
schema[field] = schema[field] || null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return schema;
|
|
75
23
|
}
|
|
76
|
-
/*
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
|
-
function deduceSchema(rows) {
|
|
79
|
-
const row = rows[0];
|
|
80
24
|
|
|
25
|
+
function deduceSchemaForRowTable(rowTable) {
|
|
81
26
|
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;
|
|
91
27
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
break;
|
|
28
|
+
if (rowTable.length) {
|
|
29
|
+
const row = rowTable[0];
|
|
95
30
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// We currently only handle numeric rows
|
|
100
|
-
// TODO we could offer a function to map strings to numbers?
|
|
31
|
+
for (const field in row) {
|
|
32
|
+
const value = row[field];
|
|
33
|
+
schema[field] = deduceTypeFromValue(value);
|
|
101
34
|
}
|
|
102
|
-
i++;
|
|
103
35
|
}
|
|
36
|
+
|
|
104
37
|
return schema;
|
|
105
38
|
}
|
|
106
|
-
|
|
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
|