@loaders.gl/schema 3.3.0-alpha.4 → 3.3.0-alpha.6
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/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/category/common.js.map +1 -1
- package/dist/es5/category/gis.js.map +1 -1
- package/dist/es5/category/image/image.js.map +1 -1
- package/dist/es5/category/mesh/convert-mesh.js +2 -12
- package/dist/es5/category/mesh/convert-mesh.js.map +1 -1
- package/dist/es5/category/mesh/deduce-mesh-schema.js +1 -10
- package/dist/es5/category/mesh/deduce-mesh-schema.js.map +1 -1
- package/dist/es5/category/mesh/mesh-to-arrow-table.js +2 -9
- package/dist/es5/category/mesh/mesh-to-arrow-table.js.map +1 -1
- package/dist/es5/category/mesh/mesh-types.js.map +1 -1
- package/dist/es5/category/mesh/mesh-utils.js +1 -6
- package/dist/es5/category/mesh/mesh-utils.js.map +1 -1
- package/dist/es5/category/table/deduce-table-schema.js +0 -11
- package/dist/es5/category/table/deduce-table-schema.js.map +1 -1
- package/dist/es5/category/table/table-types.js.map +1 -1
- package/dist/es5/category/texture/texture.js.map +1 -1
- package/dist/es5/index.js +100 -112
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/arrow/arrow-like-type-utils.js +0 -10
- package/dist/es5/lib/arrow/arrow-like-type-utils.js.map +1 -1
- package/dist/es5/lib/arrow/arrow-type-utils.js +0 -19
- package/dist/es5/lib/arrow/arrow-type-utils.js.map +1 -1
- package/dist/es5/lib/arrow/get-type-info.js +0 -6
- package/dist/es5/lib/arrow/get-type-info.js.map +1 -1
- package/dist/es5/lib/batches/base-table-batch-aggregator.js +0 -13
- package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +1 -1
- package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +6 -23
- package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +1 -1
- package/dist/es5/lib/batches/row-table-batch-aggregator.js +0 -13
- package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +1 -1
- package/dist/es5/lib/batches/table-batch-aggregator.js.map +1 -1
- package/dist/es5/lib/batches/table-batch-builder.js +21 -37
- package/dist/es5/lib/batches/table-batch-builder.js.map +1 -1
- package/dist/es5/lib/schema/impl/enum.js +0 -1
- package/dist/es5/lib/schema/impl/enum.js.map +1 -1
- package/dist/es5/lib/schema/impl/field.js +0 -7
- package/dist/es5/lib/schema/impl/field.js.map +1 -1
- package/dist/es5/lib/schema/impl/schema.js +6 -35
- package/dist/es5/lib/schema/impl/schema.js.map +1 -1
- package/dist/es5/lib/schema/impl/type.js +74 -248
- package/dist/es5/lib/schema/impl/type.js.map +1 -1
- package/dist/es5/lib/schema/schema.js +70 -74
- package/dist/es5/lib/schema/schema.js.map +1 -1
- package/dist/es5/lib/schema-utils/deduce-column-type.js +0 -3
- package/dist/es5/lib/schema-utils/deduce-column-type.js.map +1 -1
- package/dist/es5/lib/utils/assert.js +0 -1
- package/dist/es5/lib/utils/assert.js.map +1 -1
- package/dist/es5/lib/utils/async-queue.js +10 -50
- package/dist/es5/lib/utils/async-queue.js.map +1 -1
- package/dist/es5/lib/utils/row-utils.js +1 -10
- package/dist/es5/lib/utils/row-utils.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/category/common.js.map +1 -1
- package/dist/esm/category/gis.js.map +1 -1
- package/dist/esm/category/image/image.js.map +1 -1
- package/dist/esm/category/mesh/convert-mesh.js +1 -5
- package/dist/esm/category/mesh/convert-mesh.js.map +1 -1
- package/dist/esm/category/mesh/deduce-mesh-schema.js +2 -6
- package/dist/esm/category/mesh/deduce-mesh-schema.js.map +1 -1
- package/dist/esm/category/mesh/mesh-to-arrow-table.js +1 -3
- package/dist/esm/category/mesh/mesh-to-arrow-table.js.map +1 -1
- package/dist/esm/category/mesh/mesh-types.js.map +1 -1
- package/dist/esm/category/mesh/mesh-utils.js +3 -5
- package/dist/esm/category/mesh/mesh-utils.js.map +1 -1
- package/dist/esm/category/table/deduce-table-schema.js +2 -11
- package/dist/esm/category/table/deduce-table-schema.js.map +1 -1
- package/dist/esm/category/table/table-types.js.map +1 -1
- package/dist/esm/category/texture/texture.js.map +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/arrow/arrow-like-type-utils.js +0 -8
- package/dist/esm/lib/arrow/arrow-like-type-utils.js.map +1 -1
- package/dist/esm/lib/arrow/arrow-type-utils.js +0 -16
- package/dist/esm/lib/arrow/arrow-type-utils.js.map +1 -1
- package/dist/esm/lib/arrow/get-type-info.js +0 -3
- package/dist/esm/lib/arrow/get-type-info.js.map +1 -1
- package/dist/esm/lib/batches/base-table-batch-aggregator.js +0 -16
- package/dist/esm/lib/batches/base-table-batch-aggregator.js.map +1 -1
- package/dist/esm/lib/batches/columnar-table-batch-aggregator.js +0 -20
- package/dist/esm/lib/batches/columnar-table-batch-aggregator.js.map +1 -1
- package/dist/esm/lib/batches/row-table-batch-aggregator.js +0 -17
- package/dist/esm/lib/batches/row-table-batch-aggregator.js.map +1 -1
- package/dist/esm/lib/batches/table-batch-aggregator.js.map +1 -1
- package/dist/esm/lib/batches/table-batch-builder.js +4 -35
- package/dist/esm/lib/batches/table-batch-builder.js.map +1 -1
- package/dist/esm/lib/schema/impl/enum.js +2 -1
- package/dist/esm/lib/schema/impl/enum.js.map +1 -1
- package/dist/esm/lib/schema/impl/field.js +3 -10
- package/dist/esm/lib/schema/impl/field.js.map +1 -1
- package/dist/esm/lib/schema/impl/schema.js +9 -20
- package/dist/esm/lib/schema/impl/schema.js.map +1 -1
- package/dist/esm/lib/schema/impl/type.js +19 -113
- package/dist/esm/lib/schema/impl/type.js.map +1 -1
- package/dist/esm/lib/schema/schema.js +3 -1
- package/dist/esm/lib/schema/schema.js.map +1 -1
- package/dist/esm/lib/schema-utils/deduce-column-type.js +2 -2
- package/dist/esm/lib/schema-utils/deduce-column-type.js.map +1 -1
- package/dist/esm/lib/utils/assert.js +1 -0
- package/dist/esm/lib/utils/assert.js.map +1 -1
- package/dist/esm/lib/utils/async-queue.js +3 -25
- package/dist/esm/lib/utils/async-queue.js.map +1 -1
- package/dist/esm/lib/utils/row-utils.js +2 -8
- package/dist/esm/lib/utils/row-utils.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/package.json +3 -4
package/dist/es5/bundle.js
CHANGED
package/dist/es5/bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"bundle.js","names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"sources":["../../src/bundle.ts"],"sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAS,CAAC;AACxCC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;AAC7CC,MAAM,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACL,UAAU,CAACC,OAAO,EAAEH,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"common.js","names":[],"sources":["../../../src/category/common.ts"],"sourcesContent":["import type {RecordBatch} from 'apache-arrow';\n\nexport type Field = any;\n\nexport type Schema = {\n [key: string]: Field;\n};\n\nexport type Batch = {\n batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';\n mimeType?: string;\n shape: string;\n data: any;\n recordBatch?: RecordBatch;\n length: number;\n schema?: Schema;\n bytesUsed?: number;\n count?: number;\n cursor?: number;\n [key: string]: any;\n};\n\n/*\nexport type Batch = {\n bytesUsed?: number;\n count?: number;\n cursor?: number;\n [key: string]: any;\n}\n*/\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"gis.js","names":[],"sources":["../../../src/category/gis.ts"],"sourcesContent":["// GIS\nimport type {TypedArray} from '../types';\nimport type {Feature, Geometry, Point, LineString, Polygon} from 'geojson';\n\n// GEOJSON FORMAT GEOMETRY\n\n// eslint-disable-next-line import/no-unresolved\nexport type {\n GeoJSON,\n Feature,\n FeatureCollection,\n Geometry,\n Position,\n GeoJsonProperties\n} from 'geojson';\n// eslint-disable-next-line import/no-unresolved\nexport type {\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon,\n GeometryCollection\n} from 'geojson';\n\n// Aggregate information for converting GeoJSON into other formats\nexport type GeojsonGeometryInfo = {\n coordLength: number;\n pointPositionsCount: number;\n pointFeaturesCount: number;\n linePositionsCount: number;\n linePathsCount: number;\n lineFeaturesCount: number;\n polygonPositionsCount: number;\n polygonObjectsCount: number;\n polygonRingsCount: number;\n polygonFeaturesCount: number;\n};\n\n// FLAT GEOJSON FORMAT GEOMETRY\nexport type FlatGeometryType = 'Point' | 'LineString' | 'Polygon';\ntype RemoveCoordinatesField<Type> = {\n [Property in keyof Type as Exclude<Property, 'coordinates'>]: Type[Property];\n};\n\n/**\n * Generic flat geometry data storage type\n */\nexport type FlatIndexedGeometry = {\n data: number[];\n indices: number[];\n};\n\n/**\n * GeoJSON (Multi)Point geometry with coordinate data flattened into `data` array and indexed by `indices`\n */\nexport type FlatPoint = RemoveCoordinatesField<Point> & FlatIndexedGeometry;\n\n/**\n * GeoJSON (Multi)LineString geometry with coordinate data flattened into `data` array and indexed by `indices`\n */\nexport type FlatLineString = RemoveCoordinatesField<LineString> & FlatIndexedGeometry;\n\n/**\n * GeoJSON (Multi)Polygon geometry with coordinate data flattened into `data` array and indexed by 2D `indices`\n */\nexport type FlatPolygon = RemoveCoordinatesField<Polygon> & {\n data: number[];\n indices: number[][];\n areas: number[][];\n};\n\nexport type FlatGeometry = FlatPoint | FlatLineString | FlatPolygon;\n\ntype FlattenGeometry<Type> = {\n [Property in keyof Type]: Type[Property] extends Geometry ? FlatGeometry : Type[Property];\n};\n\n/**\n * GeoJSON Feature with Geometry replaced by FlatGeometry\n */\nexport type FlatFeature = FlattenGeometry<Feature>;\n\n// BINARY FORMAT GEOMETRY\n\nexport type BinaryAttribute = {value: TypedArray; size: number};\nexport type BinaryGeometryType = 'Point' | 'LineString' | 'Polygon';\n\ntype NumericProps = {[key: string]: BinaryAttribute};\ntype Properties = object[];\n\n/**\n * Represent a single Geometry, similar to a GeoJSON Geometry\n */\nexport type BinaryGeometry = BinaryPointGeometry | BinaryLineGeometry | BinaryPolygonGeometry;\n\nexport type BinaryPointGeometry = {\n type: 'Point';\n positions: BinaryAttribute;\n};\n\nexport type BinaryLineGeometry = {\n type: 'LineString';\n positions: BinaryAttribute;\n pathIndices: BinaryAttribute;\n};\n\nexport type BinaryPolygonGeometry = {\n type: 'Polygon';\n positions: BinaryAttribute;\n polygonIndices: BinaryAttribute;\n primitivePolygonIndices: BinaryAttribute;\n triangles?: BinaryAttribute;\n};\n\nexport type BinaryProperties = {\n featureIds: BinaryAttribute;\n globalFeatureIds: BinaryAttribute;\n numericProps: NumericProps;\n properties: Properties;\n fields?: Properties;\n};\n\nexport type BinaryPointFeatures = BinaryPointGeometry & BinaryProperties;\nexport type BinaryLineFeatures = BinaryLineGeometry & BinaryProperties;\nexport type BinaryPolygonFeatures = BinaryPolygonGeometry & BinaryProperties;\n\n/**\n * Represent a collection of Features, similar to a GeoJSON FeatureCollection\n */\nexport type BinaryFeatures = {\n points?: BinaryPointFeatures;\n lines?: BinaryLineFeatures;\n polygons?: BinaryPolygonFeatures;\n};\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"image.js","names":[],"sources":["../../../../src/category/image/image.ts"],"sourcesContent":["/**\n * data images\n */\nexport type ImageDataType = {\n data: Uint8Array;\n width: number;\n height: number;\n compressed?: boolean;\n};\n\n/**\n * Supported Image Types\n */\nexport type ImageType = ImageBitmap | typeof Image | ImageDataType;\n\n/**\n * Image type string used to control or determine the type of images returned from ImageLoader\n */\nexport type ImageTypeEnum = 'imagebitmap' | 'image' | 'data';\n"],"mappings":""}
|
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.convertMesh = convertMesh;
|
|
9
8
|
exports.convertMeshToColumnarTable = convertMeshToColumnarTable;
|
|
10
|
-
|
|
11
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
|
|
13
10
|
var _meshToArrowTable = require("./mesh-to-arrow-table");
|
|
14
|
-
|
|
15
11
|
function convertMesh(mesh, shape, options) {
|
|
16
12
|
switch (shape || 'mesh') {
|
|
17
13
|
case 'mesh':
|
|
18
14
|
return mesh;
|
|
19
|
-
|
|
20
15
|
case 'columnar-table':
|
|
21
16
|
return convertMeshToColumnarTable(mesh);
|
|
22
|
-
|
|
23
17
|
case 'arrow-table':
|
|
24
18
|
return {
|
|
25
19
|
shape: 'arrow-table',
|
|
26
20
|
data: (0, _meshToArrowTable.convertMeshToArrowTable)(mesh)
|
|
27
21
|
};
|
|
28
|
-
|
|
29
22
|
default:
|
|
30
23
|
throw new Error("Unsupported shape ".concat(options === null || options === void 0 ? void 0 : options.shape));
|
|
31
24
|
}
|
|
@@ -33,15 +26,12 @@ function convertMesh(mesh, shape, options) {
|
|
|
33
26
|
|
|
34
27
|
function convertMeshToColumnarTable(mesh) {
|
|
35
28
|
var columns = {};
|
|
36
|
-
|
|
37
29
|
for (var _i = 0, _Object$entries = Object.entries(mesh.attributes); _i < _Object$entries.length; _i++) {
|
|
38
30
|
var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
columnName = _Object$entries$_i[0],
|
|
32
|
+
attribute = _Object$entries$_i[1];
|
|
42
33
|
columns[columnName] = attribute.value;
|
|
43
34
|
}
|
|
44
|
-
|
|
45
35
|
return {
|
|
46
36
|
shape: 'columnar-table',
|
|
47
37
|
schema: mesh.schema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"convert-mesh.js","names":["convertMesh","mesh","shape","options","convertMeshToColumnarTable","data","convertMeshToArrowTable","Error","columns","Object","entries","attributes","columnName","attribute","value","schema"],"sources":["../../../../src/category/mesh/convert-mesh.ts"],"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"],"mappings":";;;;;;;;;AAEA;AAOO,SAASA,WAAW,CACzBC,IAAU,EACVC,KAAkB,EAClBC,OAAa,EACsB;EACnC,QAAQD,KAAK,IAAI,MAAM;IACrB,KAAK,MAAM;MACT,OAAOD,IAAI;IACb,KAAK,gBAAgB;MACnB,OAAOG,0BAA0B,CAACH,IAAI,CAAC;IACzC,KAAK,aAAa;MAChB,OAAO;QACLC,KAAK,EAAE,aAAa;QACpBG,IAAI,EAAE,IAAAC,yCAAuB,EAACL,IAAI;MACpC,CAAC;IACH;MACE,MAAM,IAAIM,KAAK,6BAAsBJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAED,KAAK,EAAG;EAAC;AAE7D;;AAOO,SAASE,0BAA0B,CAACH,IAAU,EAAiB;EACpE,IAAMO,OAAO,GAAG,CAAC,CAAC;EAElB,mCAAsCC,MAAM,CAACC,OAAO,CAACT,IAAI,CAACU,UAAU,CAAC,qCAAE;IAAlE;MAAOC,UAAU;MAAEC,SAAS;IAC/BL,OAAO,CAACI,UAAU,CAAC,GAAGC,SAAS,CAACC,KAAK;EACvC;EAEA,OAAO;IACLZ,KAAK,EAAE,gBAAgB;IACvBa,MAAM,EAAEd,IAAI,CAACc,MAAM;IACnBV,IAAI,EAAEG;EACR,CAAC;AACH"}
|
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.deduceMeshSchema = deduceMeshSchema;
|
|
7
6
|
exports.deduceMeshField = deduceMeshField;
|
|
7
|
+
exports.deduceMeshSchema = deduceMeshSchema;
|
|
8
8
|
exports.makeMeshAttributeMetadata = makeMeshAttributeMetadata;
|
|
9
|
-
|
|
10
9
|
var _schema = require("../../lib/schema/schema");
|
|
11
|
-
|
|
12
10
|
var _arrowLikeTypeUtils = require("../../lib/arrow/arrow-like-type-utils");
|
|
13
|
-
|
|
14
11
|
function deduceMeshSchema(attributes, metadata) {
|
|
15
12
|
var fields = deduceMeshFields(attributes);
|
|
16
13
|
return new _schema.Schema(fields, metadata);
|
|
@@ -25,30 +22,24 @@ function deduceMeshField(attributeName, attribute, optionalMetadata) {
|
|
|
25
22
|
|
|
26
23
|
function deduceMeshFields(attributes) {
|
|
27
24
|
var fields = [];
|
|
28
|
-
|
|
29
25
|
for (var attributeName in attributes) {
|
|
30
26
|
var attribute = attributes[attributeName];
|
|
31
27
|
fields.push(deduceMeshField(attributeName, attribute));
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
return fields;
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
function makeMeshAttributeMetadata(attribute) {
|
|
38
33
|
var result = new Map();
|
|
39
|
-
|
|
40
34
|
if ('byteOffset' in attribute) {
|
|
41
35
|
result.set('byteOffset', attribute.byteOffset.toString(10));
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
if ('byteStride' in attribute) {
|
|
45
38
|
result.set('byteStride', attribute.byteStride.toString(10));
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
if ('normalized' in attribute) {
|
|
49
41
|
result.set('normalized', attribute.normalized.toString());
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
return result;
|
|
53
44
|
}
|
|
54
45
|
//# sourceMappingURL=deduce-mesh-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"deduce-mesh-schema.js","names":["deduceMeshSchema","attributes","metadata","fields","deduceMeshFields","Schema","deduceMeshField","attributeName","attribute","optionalMetadata","type","getArrowTypeFromTypedArray","value","makeMeshAttributeMetadata","field","Field","FixedSizeList","size","push","result","Map","set","byteOffset","toString","byteStride","normalized"],"sources":["../../../../src/category/mesh/deduce-mesh-schema.ts"],"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"],"mappings":";;;;;;;;AACA;AACA;AAQO,SAASA,gBAAgB,CAC9BC,UAA0B,EAC1BC,QAA8B,EACtB;EACR,IAAMC,MAAM,GAAGC,gBAAgB,CAACH,UAAU,CAAC;EAC3C,OAAO,IAAII,cAAM,CAACF,MAAM,EAAED,QAAQ,CAAC;AACrC;;AASO,SAASI,eAAe,CAC7BC,aAAqB,EACrBC,SAAwB,EACxBC,gBAAsC,EAC/B;EACP,IAAMC,IAAI,GAAG,IAAAC,8CAA0B,EAACH,SAAS,CAACI,KAAK,CAAC;EACxD,IAAMV,QAAQ,GAAGO,gBAAgB,GAAGA,gBAAgB,GAAGI,yBAAyB,CAACL,SAAS,CAAC;EAC3F,IAAMM,KAAK,GAAG,IAAIC,aAAK,CACrBR,aAAa,EACb,IAAIS,qBAAa,CAACR,SAAS,CAACS,IAAI,EAAE,IAAIF,aAAK,CAAC,OAAO,EAAEL,IAAI,CAAC,CAAC,EAC3D,KAAK,EACLR,QAAQ,CACT;EACD,OAAOY,KAAK;AACd;;AAOA,SAASV,gBAAgB,CAACH,UAA0B,EAAW;EAC7D,IAAME,MAAe,GAAG,EAAE;EAC1B,KAAK,IAAMI,aAAa,IAAIN,UAAU,EAAE;IACtC,IAAMO,SAAwB,GAAGP,UAAU,CAACM,aAAa,CAAC;IAC1DJ,MAAM,CAACe,IAAI,CAACZ,eAAe,CAACC,aAAa,EAAEC,SAAS,CAAC,CAAC;EACxD;EACA,OAAOL,MAAM;AACf;;AAOO,SAASU,yBAAyB,CAACL,SAAwB,EAAuB;EACvF,IAAMW,MAAM,GAAG,IAAIC,GAAG,EAAE;EACxB,IAAI,YAAY,IAAIZ,SAAS,EAAE;IAC7BW,MAAM,CAACE,GAAG,CAAC,YAAY,EAAEb,SAAS,CAACc,UAAU,CAAEC,QAAQ,CAAC,EAAE,CAAC,CAAC;EAC9D;EACA,IAAI,YAAY,IAAIf,SAAS,EAAE;IAC7BW,MAAM,CAACE,GAAG,CAAC,YAAY,EAAEb,SAAS,CAACgB,UAAU,CAAED,QAAQ,CAAC,EAAE,CAAC,CAAC;EAC9D;EACA,IAAI,YAAY,IAAIf,SAAS,EAAE;IAC7BW,MAAM,CAACE,GAAG,CAAC,YAAY,EAAEb,SAAS,CAACiB,UAAU,CAAEF,QAAQ,EAAE,CAAC;EAC5D;EACA,OAAOJ,MAAM;AACf"}
|
|
@@ -4,24 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.convertMeshToArrowTable = convertMeshToArrowTable;
|
|
7
|
-
|
|
8
7
|
var _Arrow = require("apache-arrow/Arrow.dom");
|
|
9
|
-
|
|
10
8
|
var _arrowTypeUtils = require("../../lib/arrow/arrow-type-utils");
|
|
11
|
-
|
|
12
9
|
var _deduceMeshSchema = require("./deduce-mesh-schema");
|
|
13
|
-
|
|
14
10
|
function convertMeshToArrowTable(mesh, batchSize) {
|
|
15
11
|
var _mesh$schema;
|
|
16
|
-
|
|
17
12
|
var vectors = [];
|
|
18
13
|
var fields = [];
|
|
19
|
-
|
|
20
14
|
for (var attributeKey in mesh.attributes) {
|
|
21
15
|
var attribute = mesh.attributes[attributeKey];
|
|
22
16
|
var value = attribute.value,
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
_attribute$size = attribute.size,
|
|
18
|
+
size = _attribute$size === void 0 ? 1 : _attribute$size;
|
|
25
19
|
var type = (0, _arrowTypeUtils.getArrowType)(value);
|
|
26
20
|
var vector = (0, _arrowTypeUtils.getArrowVector)(value);
|
|
27
21
|
var listType = new _Arrow.FixedSizeList(size, new _Arrow.Field('value', type));
|
|
@@ -31,7 +25,6 @@ function convertMeshToArrowTable(mesh, batchSize) {
|
|
|
31
25
|
vectors.push(listVector);
|
|
32
26
|
fields.push(field);
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
var schema = new _Arrow.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());
|
|
36
29
|
var recordBatch = new _Arrow.RecordBatch(schema, vectors[0].length, vectors);
|
|
37
30
|
var table = new _Arrow.Table(schema, recordBatch);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"mesh-to-arrow-table.js","names":["convertMeshToArrowTable","mesh","batchSize","vectors","fields","attributeKey","attributes","attribute","value","size","type","getArrowType","vector","getArrowVector","listType","FixedSizeList","Field","field","makeMeshAttributeMetadata","data","Data","length","undefined","listVector","FixedSizeListVector","push","schema","Schema","metadata","Map","recordBatch","RecordBatch","table","Table"],"sources":["../../../../src/category/mesh/mesh-to-arrow-table.ts"],"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"],"mappings":";;;;;;AAAA;AAUA;AAEA;AASO,SAASA,uBAAuB,CAACC,IAAU,EAAEC,SAAkB,EAAS;EAAA;EAC7E,IAAMC,OAAyB,GAAG,EAAE;EACpC,IAAMC,MAAe,GAAG,EAAE;EAC1B,KAAK,IAAMC,YAAY,IAAIJ,IAAI,CAACK,UAAU,EAAE;IAC1C,IAAMC,SAAS,GAAGN,IAAI,CAACK,UAAU,CAACD,YAAY,CAAC;IAC/C,IAAOG,KAAK,GAAcD,SAAS,CAA5BC,KAAK;MAAA,kBAAcD,SAAS,CAArBE,IAAI;MAAJA,IAAI,gCAAG,CAAC;IACtB,IAAMC,IAAI,GAAG,IAAAC,4BAAY,EAACH,KAAK,CAAC;IAChC,IAAMI,MAAM,GAAG,IAAAC,8BAAc,EAACL,KAAK,CAAC;IACpC,IAAMM,QAAQ,GAAG,IAAIC,oBAAa,CAACN,IAAI,EAAE,IAAIO,YAAK,CAAC,OAAO,EAAEN,IAAI,CAAC,CAAC;IAClE,IAAMO,KAAK,GAAG,IAAID,YAAK,CAACX,YAAY,EAAES,QAAQ,EAAE,KAAK,EAAE,IAAAI,2CAAyB,EAACX,SAAS,CAAC,CAAC;IAC5F,IAAMY,IAAI,GAAG,IAAIC,WAAI,CAACN,QAAQ,EAAE,CAAC,EAAEN,KAAK,CAACa,MAAM,GAAGZ,IAAI,EAAE,CAAC,EAAEa,SAAS,EAAE,CAACV,MAAM,CAAC,CAAC;IAC/E,IAAMW,UAAU,GAAG,IAAIC,0BAAmB,CAACL,IAAI,CAAC;IAChDhB,OAAO,CAACsB,IAAI,CAACF,UAAU,CAAC;IACxBnB,MAAM,CAACqB,IAAI,CAACR,KAAK,CAAC;EACpB;EACA,IAAMS,MAAM,GAAG,IAAIC,aAAM,CAACvB,MAAM,EAAE,CAAAH,IAAI,aAAJA,IAAI,uCAAJA,IAAI,CAAEyB,MAAM,iDAAZ,aAAcE,QAAQ,KAAI,IAAIC,GAAG,EAAkB,CAAC;EACtF,IAAMC,WAAW,GAAG,IAAIC,kBAAW,CAACL,MAAM,EAAEvB,OAAO,CAAC,CAAC,CAAC,CAACkB,MAAM,EAAElB,OAAO,CAAC;EACvE,IAAM6B,KAAK,GAAG,IAAIC,YAAK,CAACP,MAAM,EAAEI,WAAW,CAAC;EAC5C,OAAOE,KAAK;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"mesh-types.js","names":[],"sources":["../../../../src/category/mesh/mesh-types.ts"],"sourcesContent":["import type {Schema} from '../../lib/schema/schema';\nimport type {TypedArray} from '../../types';\nimport type {ColumnarTable, ArrowTable} from '../table/table-types';\n\n/** Mesh as columnar table */\nexport interface MeshTable extends ColumnarTable {\n // shape: 'mesh-table';\n topology: 'point-list' | 'triangle-list' | 'triangle-strip';\n indices?: MeshAttribute;\n}\n\n/** Mesh as arrow table */\nexport interface MeshArrowTable extends ArrowTable {\n // shape: 'mesh-arrow-table';\n topology: 'point-list' | 'triangle-list' | 'triangle-strip';\n indices?: MeshAttribute;\n}\n\n/** Geometry part of a Mesh (compatible with a standard luma.gl \"mesh\") */\nexport type MeshGeometry = {\n attributes: {[attributeName: string]: MeshAttribute};\n indices?: MeshAttribute;\n topology: 'point-list' | 'triangle-list' | 'triangle-strip';\n mode: number;\n};\n\n/** Geometry and metadata for a Mesh (compatible with a standard luma.gl \"mesh\") */\nexport type Mesh = MeshGeometry & {\n loader?: string;\n loaderData?: {[key: string]: any};\n header?: {\n vertexCount: number;\n boundingBox?: [number[], number[]];\n };\n schema: Schema;\n};\n\n/**\n * luma.gl compatible attribute descriptors\n * Can be mapped to any WebGL framework\n */\nexport type MeshAttribute = {\n value: TypedArray;\n size: number;\n byteOffset?: number;\n byteStride?: number;\n normalized?: boolean;\n};\n\n/** A map of mesh attributes keyed by attribute names */\nexport type MeshAttributes = {[attributeName: string]: MeshAttribute};\n"],"mappings":""}
|
|
@@ -3,20 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getMeshSize = getMeshSize;
|
|
7
6
|
exports.getMeshBoundingBox = getMeshBoundingBox;
|
|
7
|
+
exports.getMeshSize = getMeshSize;
|
|
8
8
|
|
|
9
9
|
function getMeshSize(attributes) {
|
|
10
10
|
var size = 0;
|
|
11
|
-
|
|
12
11
|
for (var attributeName in attributes) {
|
|
13
12
|
var attribute = attributes[attributeName];
|
|
14
|
-
|
|
15
13
|
if (ArrayBuffer.isView(attribute)) {
|
|
16
14
|
size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
return size;
|
|
21
18
|
}
|
|
22
19
|
|
|
@@ -29,7 +26,6 @@ function getMeshBoundingBox(attributes) {
|
|
|
29
26
|
var maxZ = -Infinity;
|
|
30
27
|
var positions = attributes.POSITION ? attributes.POSITION.value : [];
|
|
31
28
|
var len = positions && positions.length;
|
|
32
|
-
|
|
33
29
|
for (var i = 0; i < len; i += 3) {
|
|
34
30
|
var x = positions[i];
|
|
35
31
|
var y = positions[i + 1];
|
|
@@ -41,7 +37,6 @@ function getMeshBoundingBox(attributes) {
|
|
|
41
37
|
maxY = y > maxY ? y : maxY;
|
|
42
38
|
maxZ = z > maxZ ? z : maxZ;
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
return [[minX, minY, minZ], [maxX, maxY, maxZ]];
|
|
46
41
|
}
|
|
47
42
|
//# sourceMappingURL=mesh-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"mesh-utils.js","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"],"sources":["../../../../src/category/mesh/mesh-utils.ts"],"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"],"mappings":";;;;;;;;AAiBO,SAASA,WAAW,CAACC,UAAuB,EAAU;EAC3D,IAAIC,IAAI,GAAG,CAAC;EACZ,KAAK,IAAMC,aAAa,IAAIF,UAAU,EAAE;IACtC,IAAMG,SAAS,GAAGH,UAAU,CAACE,aAAa,CAAC;IAC3C,IAAIE,WAAW,CAACC,MAAM,CAACF,SAAS,CAAC,EAAE;MAEjCF,IAAI,IAAIE,SAAS,CAACG,UAAU,GAAGH,SAAS,CAACI,iBAAiB;IAC5D;EACF;EACA,OAAON,IAAI;AACb;;AAQO,SAASO,kBAAkB,CAACR,UAA0B,EAAe;EAC1E,IAAIS,IAAI,GAAGC,QAAQ;EACnB,IAAIC,IAAI,GAAGD,QAAQ;EACnB,IAAIE,IAAI,GAAGF,QAAQ;EACnB,IAAIG,IAAI,GAAG,CAACH,QAAQ;EACpB,IAAII,IAAI,GAAG,CAACJ,QAAQ;EACpB,IAAIK,IAAI,GAAG,CAACL,QAAQ;EAEpB,IAAMM,SAAS,GAAGhB,UAAU,CAACiB,QAAQ,GAAGjB,UAAU,CAACiB,QAAQ,CAACC,KAAK,GAAG,EAAE;EACtE,IAAMC,GAAG,GAAGH,SAAS,IAAIA,SAAS,CAACI,MAAM;EAEzC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,GAAG,EAAEE,CAAC,IAAI,CAAC,EAAE;IAC/B,IAAMC,CAAC,GAAGN,SAAS,CAACK,CAAC,CAAC;IACtB,IAAME,CAAC,GAAGP,SAAS,CAACK,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAMG,CAAC,GAAGR,SAAS,CAACK,CAAC,GAAG,CAAC,CAAC;IAE1BZ,IAAI,GAAGa,CAAC,GAAGb,IAAI,GAAGa,CAAC,GAAGb,IAAI;IAC1BE,IAAI,GAAGY,CAAC,GAAGZ,IAAI,GAAGY,CAAC,GAAGZ,IAAI;IAC1BC,IAAI,GAAGY,CAAC,GAAGZ,IAAI,GAAGY,CAAC,GAAGZ,IAAI;IAE1BC,IAAI,GAAGS,CAAC,GAAGT,IAAI,GAAGS,CAAC,GAAGT,IAAI;IAC1BC,IAAI,GAAGS,CAAC,GAAGT,IAAI,GAAGS,CAAC,GAAGT,IAAI;IAC1BC,IAAI,GAAGS,CAAC,GAAGT,IAAI,GAAGS,CAAC,GAAGT,IAAI;EAC5B;EACA,OAAO,CACL,CAACN,IAAI,EAAEE,IAAI,EAAEC,IAAI,CAAC,EAClB,CAACC,IAAI,EAAEC,IAAI,EAAEC,IAAI,CAAC,CACnB;AACH"}
|
|
@@ -9,41 +9,31 @@ function deduceTableSchema(table, schema) {
|
|
|
9
9
|
var deducedSchema = Array.isArray(table) ? deduceSchemaForRowTable(table) : deduceSchemaForColumnarTable(table);
|
|
10
10
|
return Object.assign(deducedSchema, schema);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
12
|
function deduceSchemaForColumnarTable(columnarTable) {
|
|
14
13
|
var schema = {};
|
|
15
|
-
|
|
16
14
|
for (var field in columnarTable) {
|
|
17
15
|
var column = columnarTable[field];
|
|
18
|
-
|
|
19
16
|
if (ArrayBuffer.isView(column)) {
|
|
20
17
|
schema[field] = column.constructor;
|
|
21
18
|
} else if (column.length) {
|
|
22
19
|
var value = column[0];
|
|
23
20
|
schema[field] = deduceTypeFromValue(value);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
schema[field] = schema[field] || null;
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
return schema;
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
function deduceSchemaForRowTable(rowTable) {
|
|
33
27
|
var schema = {};
|
|
34
|
-
|
|
35
28
|
if (rowTable.length) {
|
|
36
29
|
var row = rowTable[0];
|
|
37
|
-
|
|
38
30
|
for (var field in row) {
|
|
39
31
|
var value = row[field];
|
|
40
32
|
schema[field] = deduceTypeFromValue(value);
|
|
41
33
|
}
|
|
42
34
|
}
|
|
43
|
-
|
|
44
35
|
return schema;
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
function deduceTypeFromValue(value) {
|
|
48
38
|
if (value instanceof Date) {
|
|
49
39
|
return Date;
|
|
@@ -52,7 +42,6 @@ function deduceTypeFromValue(value) {
|
|
|
52
42
|
} else if (typeof value === 'string') {
|
|
53
43
|
return String;
|
|
54
44
|
}
|
|
55
|
-
|
|
56
45
|
return null;
|
|
57
46
|
}
|
|
58
47
|
//# sourceMappingURL=deduce-table-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"deduce-table-schema.js","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"],"sources":["../../../../src/category/table/deduce-table-schema.ts"],"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"],"mappings":";;;;;;;AAyCO,SAASA,iBAAiB,CAACC,KAAK,EAAEC,MAAe,EAAE;EACxD,IAAMC,aAAa,GAAGC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,GACtCK,uBAAuB,CAACL,KAAK,CAAC,GAC9BM,4BAA4B,CAACN,KAAK,CAAC;EAEvC,OAAOO,MAAM,CAACC,MAAM,CAACN,aAAa,EAAED,MAAM,CAAC;AAC7C;AAEA,SAASK,4BAA4B,CAACG,aAAa,EAAE;EACnD,IAAMR,MAAM,GAAG,CAAC,CAAC;EACjB,KAAK,IAAMS,KAAK,IAAID,aAAa,EAAE;IACjC,IAAME,MAAM,GAAGF,aAAa,CAACC,KAAK,CAAC;IAEnC,IAAIE,WAAW,CAACC,MAAM,CAACF,MAAM,CAAC,EAAE;MAC9BV,MAAM,CAACS,KAAK,CAAC,GAAGC,MAAM,CAACG,WAAW;IAEpC,CAAC,MAAM,IAAIH,MAAM,CAACI,MAAM,EAAE;MACxB,IAAMC,KAAK,GAAGL,MAAM,CAAC,CAAC,CAAC;MACvBV,MAAM,CAACS,KAAK,CAAC,GAAGO,mBAAmB,CAACD,KAAK,CAAC;IAE5C;IAEAf,MAAM,CAACS,KAAK,CAAC,GAAGT,MAAM,CAACS,KAAK,CAAC,IAAI,IAAI;EACvC;EACA,OAAOT,MAAM;AACf;AAEA,SAASI,uBAAuB,CAACa,QAAQ,EAAE;EACzC,IAAMjB,MAAM,GAAG,CAAC,CAAC;EACjB,IAAIiB,QAAQ,CAACH,MAAM,EAAE;IACnB,IAAMI,GAAG,GAAGD,QAAQ,CAAC,CAAC,CAAC;IAEvB,KAAK,IAAMR,KAAK,IAAIS,GAAG,EAAE;MACvB,IAAMH,KAAK,GAAGG,GAAG,CAACT,KAAK,CAAC;MACxBT,MAAM,CAACS,KAAK,CAAC,GAAGO,mBAAmB,CAACD,KAAK,CAAC;IAC5C;EACF;EACA,OAAOf,MAAM;AACf;AAEA,SAASgB,mBAAmB,CAACD,KAAK,EAAE;EAClC,IAAIA,KAAK,YAAYI,IAAI,EAAE;IACzB,OAAOA,IAAI;EACb,CAAC,MAAM,IAAIJ,KAAK,YAAYK,MAAM,EAAE;IAClC,OAAOC,YAAY;EACrB,CAAC,MAAM,IAAI,OAAON,KAAK,KAAK,QAAQ,EAAE;IACpC,OAAOO,MAAM;EACf;EACA,OAAO,IAAI;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"table-types.js","names":[],"sources":["../../../../src/category/table/table-types.ts"],"sourcesContent":["import type {Schema} from '../../lib/schema/schema';\nimport type {Table as ApacheArrowTable, RecordBatch} from 'apache-arrow/Arrow.dom';\nimport type {AnyArray} from '../../types';\nimport type {Batch} from '../common';\nimport type {Feature} from '../gis';\n\n/** A general table */\nexport interface Table {\n shape:\n | 'row-table'\n | 'array-row-table'\n | 'object-row-table'\n | 'geojson-row-table'\n | 'columnar-table'\n | 'arrow-table';\n schema?: Schema;\n schemaType?: 'explicit' | 'deduced';\n}\n\n/** A table organized as an array of rows */\nexport interface RowTable extends Table {\n shape: 'row-table' | 'array-row-table' | 'object-row-table' | 'geojson-row-table';\n data: any[];\n}\n\n/** A table organized as an array of rows, each row is an array of values */\nexport interface ArrayRowTable extends RowTable {\n shape: 'array-row-table';\n data: any[][];\n}\n\n/** A table organized as an array of rows, each row is an object mapping columns to values */\nexport interface ObjectRowTable extends RowTable {\n shape: 'object-row-table';\n data: {[columnName: string]: any}[];\n}\n\n/** A table organized as an array of rows, each row is a GeoJSON Feature */\nexport interface GeoJSONRowTable extends RowTable {\n shape: 'geojson-row-table';\n data: Feature[];\n}\n\n/** A table organized as a map of columns, each column is an array of value */\nexport interface ColumnarTable extends Table {\n shape: 'columnar-table';\n data: {[columnName: string]: AnyArray};\n}\n\n/** A table organized as an Apache Arrow table */\nexport interface ArrowTable extends Table {\n shape: 'arrow-table';\n data: ApacheArrowTable;\n}\n\n/** A collection of tables */\nexport type Tables<TableType extends Table = Table> = {\n shape: 'tables';\n tables: {name: string; table: TableType}[];\n};\n\n// Batches\n\n/** Batch for a general table */\nexport type TableBatch = Batch & {\n data: any;\n length: number;\n schema?: Schema;\n schemaType?: 'explicit' | 'deduced';\n};\n\n/** Batch for a table organized as an array of rows */\nexport type RowTableBatch = TableBatch & {\n shape: 'row-table';\n data: any[];\n};\n\n/** Batch for a table organized as an array of rows, each row is an array of values */\nexport type RowArrayTableBatch = RowTableBatch & {\n shape: 'array-row-table';\n data: any[][];\n};\n\n/** Batch for a table organized as an array of rows, each row is an object mapping columns to values */\nexport type RowObjectTableBatch = RowTableBatch & {\n shape: 'object-row-table';\n data: {[columnName: string]: any}[];\n};\n\n/** Batch for a table organized as an array of rows, each row is an array of values */\nexport type GeoJSONRowTableBatch = RowTableBatch & {\n shape: 'geojson-row-table';\n data: Feature[];\n};\n\n/** Batch for a table organized as a map of columns, each column is an array of value */\nexport type ColumnarTableBatch = TableBatch & {\n shape: 'columnar-table';\n data: {[columnName: string]: AnyArray};\n};\n\n/** Batch for a table organized as an Apache Arrow table */\nexport type ArrowTableBatch = TableBatch & {\n shape: 'arrow-table';\n data: RecordBatch;\n};\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"texture.js","names":[],"sources":["../../../../src/category/texture/texture.ts"],"sourcesContent":["import type {ImageType} from '../image/image';\n\n/**\n * These represent the main compressed texture formats\n * Each format typically has a number of more specific subformats\n */\nexport type GPUTextureFormat =\n | 'dxt'\n | 'dxt-srgb'\n | 'etc1'\n | 'etc2'\n | 'pvrtc'\n | 'atc'\n | 'astc'\n | 'rgtc';\n\n/** One mip level */\nexport type TextureLevel = {\n compressed: boolean;\n format?: number;\n data: Uint8Array;\n width: number;\n height: number;\n levelSize?: number;\n hasAlpha?: boolean;\n};\n\nexport type TextureOrImage = ImageType | (TextureLevel | ImageType);\n"],"mappings":""}
|