@loaders.gl/schema 4.0.0-alpha.9 → 4.0.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/dist.min.js +558 -943
- package/dist/es5/index.js +7 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js +4 -3
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/es5/lib/table/batches/row-table-batch-aggregator.js.map +1 -1
- package/dist/es5/lib/table/simple-table/convert-table.js +24 -0
- package/dist/es5/lib/table/simple-table/convert-table.js.map +1 -1
- package/dist/es5/lib/table/simple-table/table-accessors.js +69 -42
- package/dist/es5/lib/table/simple-table/table-accessors.js.map +1 -1
- package/dist/es5/types/batch.js +2 -0
- package/dist/es5/types/batch.js.map +1 -0
- package/dist/es5/types/binary-geometries.js +2 -0
- package/dist/es5/types/binary-geometries.js.map +1 -0
- package/dist/es5/types/category-gis.js.map +1 -1
- package/dist/es5/types/category-image.js.map +1 -1
- package/dist/es5/types/category-table.js.map +1 -1
- package/dist/es5/types/flat-geometries.js +2 -0
- package/dist/es5/types/flat-geometries.js.map +1 -0
- package/dist/es5/types/schema.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js +4 -3
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/esm/lib/table/batches/row-table-batch-aggregator.js.map +1 -1
- package/dist/esm/lib/table/simple-table/convert-table.js +22 -0
- package/dist/esm/lib/table/simple-table/convert-table.js.map +1 -1
- package/dist/esm/lib/table/simple-table/table-accessors.js +49 -22
- package/dist/esm/lib/table/simple-table/table-accessors.js.map +1 -1
- package/dist/esm/types/batch.js +2 -0
- package/dist/esm/types/batch.js.map +1 -0
- package/dist/esm/types/binary-geometries.js +2 -0
- package/dist/esm/types/binary-geometries.js.map +1 -0
- package/dist/esm/types/category-gis.js.map +1 -1
- package/dist/esm/types/category-image.js.map +1 -1
- package/dist/esm/types/category-table.js.map +1 -1
- package/dist/esm/types/flat-geometries.js +2 -0
- package/dist/esm/types/flat-geometries.js.map +1 -0
- package/dist/esm/types/schema.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/table/arrow-api/arrow-like-table.d.ts +1 -5
- package/dist/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
- package/dist/lib/table/batches/row-table-batch-aggregator.d.ts +3 -3
- package/dist/lib/table/batches/row-table-batch-aggregator.d.ts.map +1 -1
- package/dist/lib/table/simple-table/convert-table.d.ts +34 -1
- package/dist/lib/table/simple-table/convert-table.d.ts.map +1 -1
- package/dist/lib/table/simple-table/table-accessors.d.ts.map +1 -1
- package/dist/types/batch.d.ts +34 -0
- package/dist/types/batch.d.ts.map +1 -0
- package/dist/types/binary-geometries.d.ts +56 -0
- package/dist/types/binary-geometries.d.ts.map +1 -0
- package/dist/types/category-gis.d.ts +3 -84
- package/dist/types/category-gis.d.ts.map +1 -1
- package/dist/types/category-image.d.ts +1 -1
- package/dist/types/category-image.d.ts.map +1 -1
- package/dist/types/category-table.d.ts +42 -22
- package/dist/types/category-table.d.ts.map +1 -1
- package/dist/types/flat-geometries.d.ts +30 -0
- package/dist/types/flat-geometries.d.ts.map +1 -0
- package/dist/types/schema.d.ts +0 -15
- package/dist/types/schema.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +13 -7
- package/src/lib/table/arrow-api/arrow-like-table.ts +3 -2
- package/src/lib/table/batches/row-table-batch-aggregator.ts +2 -2
- package/src/lib/table/simple-table/convert-table.ts +73 -1
- package/src/lib/table/simple-table/table-accessors.ts +56 -22
- package/src/types/batch.ts +41 -0
- package/src/types/binary-geometries.ts +62 -0
- package/src/types/category-gis.ts +30 -104
- package/src/types/category-image.ts +1 -1
- package/src/types/category-table.ts +49 -27
- package/src/types/flat-geometries.ts +40 -0
- package/src/types/schema.ts +0 -17
- package/dist/bundle.js +0 -5
- package/dist/index.js +0 -92
- package/dist/lib/mesh/convert-mesh.js +0 -40
- package/dist/lib/mesh/deduce-mesh-schema.js +0 -66
- package/dist/lib/mesh/mesh-to-arrow-table.js +0 -44
- package/dist/lib/mesh/mesh-utils.js +0 -51
- package/dist/lib/table/arrow/arrow-type-utils.js +0 -53
- package/dist/lib/table/arrow/convert-schema-arrow.js +0 -187
- package/dist/lib/table/arrow/convert-table-to-arrow.js +0 -57
- package/dist/lib/table/arrow-api/arrow-like-field.js +0 -34
- package/dist/lib/table/arrow-api/arrow-like-schema.js +0 -81
- package/dist/lib/table/arrow-api/arrow-like-table.js +0 -53
- package/dist/lib/table/arrow-api/arrow-like-type.js +0 -463
- package/dist/lib/table/arrow-api/enum.js +0 -97
- package/dist/lib/table/arrow-api/get-type-info.js +0 -29
- package/dist/lib/table/arrow-api/index.js +0 -25
- package/dist/lib/table/batches/base-table-batch-aggregator.js +0 -60
- package/dist/lib/table/batches/columnar-table-batch-aggregator.js +0 -92
- package/dist/lib/table/batches/row-table-batch-aggregator.js +0 -81
- package/dist/lib/table/batches/table-batch-aggregator.js +0 -3
- package/dist/lib/table/batches/table-batch-builder.js +0 -152
- package/dist/lib/table/simple-table/convert-table.js +0 -65
- package/dist/lib/table/simple-table/data-type.js +0 -93
- package/dist/lib/table/simple-table/make-table.js +0 -95
- package/dist/lib/table/simple-table/row-utils.js +0 -33
- package/dist/lib/table/simple-table/table-accessors.js +0 -319
- package/dist/lib/table/simple-table/table-column.js +0 -41
- package/dist/lib/table/simple-table/table-schema.js +0 -85
- package/dist/lib/utils/assert.js +0 -12
- package/dist/lib/utils/async-queue.js +0 -92
- package/dist/types/category-gis.js +0 -2
- package/dist/types/category-image.js +0 -2
- package/dist/types/category-mesh.js +0 -3
- package/dist/types/category-table.js +0 -3
- package/dist/types/category-texture.js +0 -3
- package/dist/types/schema.js +0 -3
- package/dist/types/types.js +0 -2
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
// loaders.gl, MIT license
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import type {Batch
|
|
3
|
+
import type {Schema} from './schema';
|
|
4
|
+
import type {Batch} from './batch';
|
|
5
5
|
import type {Feature} from './category-gis';
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
// Avoid a big dependency, apparently even a type import can pull in a lot of code
|
|
8
|
+
// import type {Table as ApacheArrowTable} from 'apache-arrow';
|
|
9
|
+
|
|
10
|
+
type ApacheArrowTable = unknown;
|
|
11
|
+
type ApacheRecordBatch = unknown;
|
|
12
12
|
|
|
13
13
|
/** A general table */
|
|
14
14
|
export type Table =
|
|
15
15
|
| RowTable
|
|
16
16
|
| ArrayRowTable
|
|
17
17
|
| ObjectRowTable
|
|
18
|
-
|
|
|
18
|
+
| GeoJSONTable
|
|
19
19
|
| ColumnarTable
|
|
20
20
|
| ArrowTable;
|
|
21
21
|
|
|
22
22
|
/** A table organized as an array of rows */
|
|
23
|
-
export type RowTable = ArrayRowTable | ObjectRowTable |
|
|
23
|
+
export type RowTable = ArrayRowTable | ObjectRowTable | GeoJSONTable;
|
|
24
24
|
|
|
25
25
|
/** A table organized as an array of rows, each row is an array of values */
|
|
26
26
|
export type ArrayRowTable = {
|
|
@@ -36,11 +36,17 @@ export type ObjectRowTable = {
|
|
|
36
36
|
data: {[columnName: string]: any}[];
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
/**
|
|
40
|
+
* A table organized as an array of rows, each row is a GeoJSON Feature
|
|
41
|
+
* @note For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data`
|
|
42
|
+
*/
|
|
43
|
+
export type GeoJSONTable = {
|
|
44
|
+
shape: 'geojson-table';
|
|
42
45
|
schema?: Schema;
|
|
43
|
-
|
|
46
|
+
/** For compatibility with GeoJSON, the type field must always be set to `FeatureCollection` */
|
|
47
|
+
type: 'FeatureCollection';
|
|
48
|
+
/** For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data` */
|
|
49
|
+
features: Feature[];
|
|
44
50
|
};
|
|
45
51
|
|
|
46
52
|
/** A table organized as a map of columns, each column is an array of value */
|
|
@@ -66,39 +72,55 @@ export type Tables<TableType = Table> = {
|
|
|
66
72
|
// Batches
|
|
67
73
|
|
|
68
74
|
/** Batch for a general table */
|
|
69
|
-
export type TableBatch =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
export type TableBatch =
|
|
76
|
+
| ArrayRowTableBatch
|
|
77
|
+
| ObjectRowTableBatch
|
|
78
|
+
| GeoJSONTableBatch
|
|
79
|
+
| ColumnarTableBatch
|
|
80
|
+
| ArrowTableBatch;
|
|
75
81
|
|
|
76
82
|
/** Batch for a table organized as an array of rows, each row is an array of values */
|
|
77
|
-
export type ArrayRowTableBatch =
|
|
83
|
+
export type ArrayRowTableBatch = Batch & {
|
|
78
84
|
shape: 'array-row-table';
|
|
85
|
+
schema?: Schema;
|
|
86
|
+
schemaType?: 'explicit' | 'deduced';
|
|
79
87
|
data: any[][];
|
|
88
|
+
length: number;
|
|
80
89
|
};
|
|
81
90
|
|
|
82
91
|
/** Batch for a table organized as an array of rows, each row is an object mapping columns to values */
|
|
83
|
-
export type ObjectRowTableBatch =
|
|
92
|
+
export type ObjectRowTableBatch = Batch & {
|
|
84
93
|
shape: 'object-row-table';
|
|
94
|
+
schema?: Schema;
|
|
95
|
+
schemaType?: 'explicit' | 'deduced';
|
|
85
96
|
data: {[columnName: string]: any}[];
|
|
97
|
+
length: number;
|
|
86
98
|
};
|
|
87
99
|
|
|
88
100
|
/** Batch for a table organized as an array of rows, each row is an array of values */
|
|
89
|
-
export type
|
|
90
|
-
shape: 'geojson-
|
|
91
|
-
|
|
101
|
+
export type GeoJSONTableBatch = Batch & {
|
|
102
|
+
shape: 'geojson-table';
|
|
103
|
+
schema?: Schema;
|
|
104
|
+
schemaType?: 'explicit' | 'deduced';
|
|
105
|
+
type: 'FeatureCollection';
|
|
106
|
+
features: Feature[];
|
|
107
|
+
length: number;
|
|
92
108
|
};
|
|
93
109
|
|
|
94
110
|
/** Batch for a table organized as a map of columns, each column is an array of value */
|
|
95
|
-
export type ColumnarTableBatch =
|
|
111
|
+
export type ColumnarTableBatch = Batch & {
|
|
96
112
|
shape: 'columnar-table';
|
|
113
|
+
schemaType?: 'explicit' | 'deduced';
|
|
114
|
+
schema?: Schema;
|
|
97
115
|
data: {[columnName: string]: ArrayLike<unknown>};
|
|
116
|
+
length: number;
|
|
98
117
|
};
|
|
99
118
|
|
|
100
119
|
/** Batch for a table organized as an Apache Arrow table */
|
|
101
|
-
export type ArrowTableBatch =
|
|
120
|
+
export type ArrowTableBatch = Batch & {
|
|
102
121
|
shape: 'arrow-table';
|
|
103
|
-
|
|
122
|
+
schemaType?: 'explicit' | 'deduced';
|
|
123
|
+
schema?: Schema;
|
|
124
|
+
data: ApacheRecordBatch;
|
|
125
|
+
length: number;
|
|
104
126
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
// FLAT GEOJSON FORMAT GEOMETRY
|
|
4
|
+
import type {Feature, Geometry, Point, LineString, Polygon} from 'geojson';
|
|
5
|
+
|
|
6
|
+
/** Flat geometry type */
|
|
7
|
+
export type FlatGeometryType = 'Point' | 'LineString' | 'Polygon';
|
|
8
|
+
|
|
9
|
+
type RemoveCoordinatesField<Type> = {
|
|
10
|
+
[Property in keyof Type as Exclude<Property, 'coordinates'>]: Type[Property];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Generic flat geometry data storage type */
|
|
14
|
+
export type FlatIndexedGeometry = {
|
|
15
|
+
data: number[];
|
|
16
|
+
indices: number[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** GeoJSON (Multi)Point geometry with coordinate data flattened into `data` array and indexed by `indices` */
|
|
20
|
+
export type FlatPoint = RemoveCoordinatesField<Point> & FlatIndexedGeometry;
|
|
21
|
+
|
|
22
|
+
/** GeoJSON (Multi)LineString geometry with coordinate data flattened into `data` array and indexed by `indices` */
|
|
23
|
+
export type FlatLineString = RemoveCoordinatesField<LineString> & FlatIndexedGeometry;
|
|
24
|
+
|
|
25
|
+
/** GeoJSON (Multi)Polygon geometry with coordinate data flattened into `data` array and indexed by 2D `indices` */
|
|
26
|
+
export type FlatPolygon = RemoveCoordinatesField<Polygon> & {
|
|
27
|
+
data: number[];
|
|
28
|
+
indices: number[][];
|
|
29
|
+
areas: number[][];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** GeoJSON geometry with coordinate data flattened into `data` array and indexed by 2D `indices` */
|
|
33
|
+
export type FlatGeometry = FlatPoint | FlatLineString | FlatPolygon;
|
|
34
|
+
|
|
35
|
+
type FlattenGeometry<Type> = {
|
|
36
|
+
[Property in keyof Type]: Type[Property] extends Geometry ? FlatGeometry : Type[Property];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** GeoJSON Feature with Geometry replaced by FlatGeometry */
|
|
40
|
+
export type FlatFeature = FlattenGeometry<Feature>;
|
package/src/types/schema.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// loaders.gl, MIT license
|
|
2
2
|
|
|
3
|
-
import type {RecordBatch} from 'apache-arrow';
|
|
4
|
-
|
|
5
3
|
/** For dictionary type */
|
|
6
4
|
export type KeyType = 'int8' | 'int16' | 'int32' | 'uint8' | 'uint16' | 'uint32';
|
|
7
5
|
|
|
@@ -80,18 +78,3 @@ export type Schema = {
|
|
|
80
78
|
fields: Field[];
|
|
81
79
|
metadata: SchemaMetadata;
|
|
82
80
|
};
|
|
83
|
-
|
|
84
|
-
export type Batch = {
|
|
85
|
-
batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';
|
|
86
|
-
batch?: number;
|
|
87
|
-
mimeType?: string;
|
|
88
|
-
shape: string;
|
|
89
|
-
data: any;
|
|
90
|
-
recordBatch?: RecordBatch;
|
|
91
|
-
length: number;
|
|
92
|
-
schema?: Schema;
|
|
93
|
-
bytesUsed?: number;
|
|
94
|
-
count?: number;
|
|
95
|
-
cursor?: number;
|
|
96
|
-
[key: string]: any;
|
|
97
|
-
};
|
package/dist/bundle.js
DELETED
package/dist/index.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TimeMillisecond = exports.Time = exports.DateMillisecond = exports.DateDay = exports.Date = exports.Utf8 = exports.Float64 = exports.Float32 = exports.Float16 = exports.Float = exports.Uint64 = exports.Uint32 = exports.Uint16 = exports.Uint8 = exports.Int64 = exports.Int32 = exports.Int16 = exports.Int8 = exports.Int = exports.Bool = exports.Binary = exports.Null = exports.ArrowLikeDataType = exports.ArrowLikeField = exports.ArrowLikeSchema = exports.makeMeshAttributeMetadata = exports.deduceMeshField = exports.deduceMeshSchema = exports.getMeshBoundingBox = exports.getMeshSize = exports.getDataTypeFromArray = exports.convertToArrayRow = exports.convertToObjectRow = exports.deduceTableSchema = exports.makeTableFromData = exports.ArrowLikeTable = exports.makeObjectRowIterator = exports.makeArrayRowIterator = exports.makeRowIterator = exports.getTableRowAsArray = exports.getTableRowAsObject = exports.getTableColumnName = exports.getTableColumnIndex = exports.getTableRowShape = exports.getTableCell = exports.getTableNumCols = exports.getTableLength = exports.ColumnarTableBatchAggregator = exports.RowTableBatchAggregator = exports.TableBatchBuilder = void 0;
|
|
7
|
-
exports.AsyncQueue = exports.getArrowType = exports.getTypeInfo = exports.Struct = exports.FixedSizeList = exports.IntervalYearMonth = exports.IntervalDayTime = exports.Interval = exports.TimestampNanosecond = exports.TimestampMicrosecond = exports.TimestampMillisecond = exports.TimestampSecond = exports.Timestamp = exports.TimeSecond = void 0;
|
|
8
|
-
// TABLE CATEGORY UTILS
|
|
9
|
-
var table_batch_builder_1 = require("./lib/table/batches/table-batch-builder");
|
|
10
|
-
Object.defineProperty(exports, "TableBatchBuilder", { enumerable: true, get: function () { return table_batch_builder_1.TableBatchBuilder; } });
|
|
11
|
-
var row_table_batch_aggregator_1 = require("./lib/table/batches/row-table-batch-aggregator");
|
|
12
|
-
Object.defineProperty(exports, "RowTableBatchAggregator", { enumerable: true, get: function () { return row_table_batch_aggregator_1.RowTableBatchAggregator; } });
|
|
13
|
-
var columnar_table_batch_aggregator_1 = require("./lib/table/batches/columnar-table-batch-aggregator");
|
|
14
|
-
Object.defineProperty(exports, "ColumnarTableBatchAggregator", { enumerable: true, get: function () { return columnar_table_batch_aggregator_1.ColumnarTableBatchAggregator; } });
|
|
15
|
-
var table_accessors_1 = require("./lib/table/simple-table/table-accessors");
|
|
16
|
-
Object.defineProperty(exports, "getTableLength", { enumerable: true, get: function () { return table_accessors_1.getTableLength; } });
|
|
17
|
-
Object.defineProperty(exports, "getTableNumCols", { enumerable: true, get: function () { return table_accessors_1.getTableNumCols; } });
|
|
18
|
-
Object.defineProperty(exports, "getTableCell", { enumerable: true, get: function () { return table_accessors_1.getTableCell; } });
|
|
19
|
-
Object.defineProperty(exports, "getTableRowShape", { enumerable: true, get: function () { return table_accessors_1.getTableRowShape; } });
|
|
20
|
-
Object.defineProperty(exports, "getTableColumnIndex", { enumerable: true, get: function () { return table_accessors_1.getTableColumnIndex; } });
|
|
21
|
-
Object.defineProperty(exports, "getTableColumnName", { enumerable: true, get: function () { return table_accessors_1.getTableColumnName; } });
|
|
22
|
-
Object.defineProperty(exports, "getTableRowAsObject", { enumerable: true, get: function () { return table_accessors_1.getTableRowAsObject; } });
|
|
23
|
-
Object.defineProperty(exports, "getTableRowAsArray", { enumerable: true, get: function () { return table_accessors_1.getTableRowAsArray; } });
|
|
24
|
-
Object.defineProperty(exports, "makeRowIterator", { enumerable: true, get: function () { return table_accessors_1.makeRowIterator; } });
|
|
25
|
-
Object.defineProperty(exports, "makeArrayRowIterator", { enumerable: true, get: function () { return table_accessors_1.makeArrayRowIterator; } });
|
|
26
|
-
Object.defineProperty(exports, "makeObjectRowIterator", { enumerable: true, get: function () { return table_accessors_1.makeObjectRowIterator; } });
|
|
27
|
-
var arrow_like_table_1 = require("./lib/table/arrow-api/arrow-like-table");
|
|
28
|
-
Object.defineProperty(exports, "ArrowLikeTable", { enumerable: true, get: function () { return arrow_like_table_1.ArrowLikeTable; } });
|
|
29
|
-
var make_table_1 = require("./lib/table/simple-table/make-table");
|
|
30
|
-
Object.defineProperty(exports, "makeTableFromData", { enumerable: true, get: function () { return make_table_1.makeTableFromData; } });
|
|
31
|
-
var table_schema_1 = require("./lib/table/simple-table/table-schema");
|
|
32
|
-
Object.defineProperty(exports, "deduceTableSchema", { enumerable: true, get: function () { return table_schema_1.deduceTableSchema; } });
|
|
33
|
-
var row_utils_1 = require("./lib/table/simple-table/row-utils");
|
|
34
|
-
Object.defineProperty(exports, "convertToObjectRow", { enumerable: true, get: function () { return row_utils_1.convertToObjectRow; } });
|
|
35
|
-
Object.defineProperty(exports, "convertToArrayRow", { enumerable: true, get: function () { return row_utils_1.convertToArrayRow; } });
|
|
36
|
-
var data_type_1 = require("./lib/table/simple-table/data-type");
|
|
37
|
-
Object.defineProperty(exports, "getDataTypeFromArray", { enumerable: true, get: function () { return data_type_1.getDataTypeFromArray; } });
|
|
38
|
-
var mesh_utils_1 = require("./lib/mesh/mesh-utils");
|
|
39
|
-
Object.defineProperty(exports, "getMeshSize", { enumerable: true, get: function () { return mesh_utils_1.getMeshSize; } });
|
|
40
|
-
Object.defineProperty(exports, "getMeshBoundingBox", { enumerable: true, get: function () { return mesh_utils_1.getMeshBoundingBox; } });
|
|
41
|
-
// Commented out due to https://github.com/visgl/deck.gl/issues/6906 and https://github.com/visgl/loaders.gl/issues/2177
|
|
42
|
-
// export {convertMesh} from './category/mesh/convert-mesh';
|
|
43
|
-
var deduce_mesh_schema_1 = require("./lib/mesh/deduce-mesh-schema");
|
|
44
|
-
Object.defineProperty(exports, "deduceMeshSchema", { enumerable: true, get: function () { return deduce_mesh_schema_1.deduceMeshSchema; } });
|
|
45
|
-
Object.defineProperty(exports, "deduceMeshField", { enumerable: true, get: function () { return deduce_mesh_schema_1.deduceMeshField; } });
|
|
46
|
-
Object.defineProperty(exports, "makeMeshAttributeMetadata", { enumerable: true, get: function () { return deduce_mesh_schema_1.makeMeshAttributeMetadata; } });
|
|
47
|
-
// SCHEMA
|
|
48
|
-
var arrow_api_1 = require("./lib/table/arrow-api");
|
|
49
|
-
Object.defineProperty(exports, "ArrowLikeSchema", { enumerable: true, get: function () { return arrow_api_1.Schema; } });
|
|
50
|
-
Object.defineProperty(exports, "ArrowLikeField", { enumerable: true, get: function () { return arrow_api_1.Field; } });
|
|
51
|
-
Object.defineProperty(exports, "ArrowLikeDataType", { enumerable: true, get: function () { return arrow_api_1.DataType; } });
|
|
52
|
-
Object.defineProperty(exports, "Null", { enumerable: true, get: function () { return arrow_api_1.Null; } });
|
|
53
|
-
Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return arrow_api_1.Binary; } });
|
|
54
|
-
Object.defineProperty(exports, "Bool", { enumerable: true, get: function () { return arrow_api_1.Bool; } });
|
|
55
|
-
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return arrow_api_1.Int; } });
|
|
56
|
-
Object.defineProperty(exports, "Int8", { enumerable: true, get: function () { return arrow_api_1.Int8; } });
|
|
57
|
-
Object.defineProperty(exports, "Int16", { enumerable: true, get: function () { return arrow_api_1.Int16; } });
|
|
58
|
-
Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { return arrow_api_1.Int32; } });
|
|
59
|
-
Object.defineProperty(exports, "Int64", { enumerable: true, get: function () { return arrow_api_1.Int64; } });
|
|
60
|
-
Object.defineProperty(exports, "Uint8", { enumerable: true, get: function () { return arrow_api_1.Uint8; } });
|
|
61
|
-
Object.defineProperty(exports, "Uint16", { enumerable: true, get: function () { return arrow_api_1.Uint16; } });
|
|
62
|
-
Object.defineProperty(exports, "Uint32", { enumerable: true, get: function () { return arrow_api_1.Uint32; } });
|
|
63
|
-
Object.defineProperty(exports, "Uint64", { enumerable: true, get: function () { return arrow_api_1.Uint64; } });
|
|
64
|
-
Object.defineProperty(exports, "Float", { enumerable: true, get: function () { return arrow_api_1.Float; } });
|
|
65
|
-
Object.defineProperty(exports, "Float16", { enumerable: true, get: function () { return arrow_api_1.Float16; } });
|
|
66
|
-
Object.defineProperty(exports, "Float32", { enumerable: true, get: function () { return arrow_api_1.Float32; } });
|
|
67
|
-
Object.defineProperty(exports, "Float64", { enumerable: true, get: function () { return arrow_api_1.Float64; } });
|
|
68
|
-
Object.defineProperty(exports, "Utf8", { enumerable: true, get: function () { return arrow_api_1.Utf8; } });
|
|
69
|
-
Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return arrow_api_1.Date; } });
|
|
70
|
-
Object.defineProperty(exports, "DateDay", { enumerable: true, get: function () { return arrow_api_1.DateDay; } });
|
|
71
|
-
Object.defineProperty(exports, "DateMillisecond", { enumerable: true, get: function () { return arrow_api_1.DateMillisecond; } });
|
|
72
|
-
Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return arrow_api_1.Time; } });
|
|
73
|
-
Object.defineProperty(exports, "TimeMillisecond", { enumerable: true, get: function () { return arrow_api_1.TimeMillisecond; } });
|
|
74
|
-
Object.defineProperty(exports, "TimeSecond", { enumerable: true, get: function () { return arrow_api_1.TimeSecond; } });
|
|
75
|
-
Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return arrow_api_1.Timestamp; } });
|
|
76
|
-
Object.defineProperty(exports, "TimestampSecond", { enumerable: true, get: function () { return arrow_api_1.TimestampSecond; } });
|
|
77
|
-
Object.defineProperty(exports, "TimestampMillisecond", { enumerable: true, get: function () { return arrow_api_1.TimestampMillisecond; } });
|
|
78
|
-
Object.defineProperty(exports, "TimestampMicrosecond", { enumerable: true, get: function () { return arrow_api_1.TimestampMicrosecond; } });
|
|
79
|
-
Object.defineProperty(exports, "TimestampNanosecond", { enumerable: true, get: function () { return arrow_api_1.TimestampNanosecond; } });
|
|
80
|
-
Object.defineProperty(exports, "Interval", { enumerable: true, get: function () { return arrow_api_1.Interval; } });
|
|
81
|
-
Object.defineProperty(exports, "IntervalDayTime", { enumerable: true, get: function () { return arrow_api_1.IntervalDayTime; } });
|
|
82
|
-
Object.defineProperty(exports, "IntervalYearMonth", { enumerable: true, get: function () { return arrow_api_1.IntervalYearMonth; } });
|
|
83
|
-
Object.defineProperty(exports, "FixedSizeList", { enumerable: true, get: function () { return arrow_api_1.FixedSizeList; } });
|
|
84
|
-
Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return arrow_api_1.Struct; } });
|
|
85
|
-
// EXPERIMENTAL APIs
|
|
86
|
-
// SCHEMA UTILS
|
|
87
|
-
var get_type_info_1 = require("./lib/table/arrow-api/get-type-info");
|
|
88
|
-
Object.defineProperty(exports, "getTypeInfo", { enumerable: true, get: function () { return get_type_info_1.getTypeInfo; } });
|
|
89
|
-
var arrow_type_utils_1 = require("./lib/table/arrow/arrow-type-utils");
|
|
90
|
-
Object.defineProperty(exports, "getArrowType", { enumerable: true, get: function () { return arrow_type_utils_1.getArrowType; } });
|
|
91
|
-
var async_queue_1 = require("./lib/utils/async-queue");
|
|
92
|
-
Object.defineProperty(exports, "AsyncQueue", { enumerable: true, get: function () { return __importDefault(async_queue_1).default; } });
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.convertMeshToColumnarTable = exports.convertMesh = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Convert a mesh to a specific shape
|
|
7
|
-
*/
|
|
8
|
-
function convertMesh(mesh, shape, options) {
|
|
9
|
-
switch (shape || 'mesh') {
|
|
10
|
-
case 'mesh':
|
|
11
|
-
return mesh;
|
|
12
|
-
case 'columnar-table':
|
|
13
|
-
return convertMeshToColumnarTable(mesh);
|
|
14
|
-
// case 'arrow-table':
|
|
15
|
-
// return {
|
|
16
|
-
// shape: 'arrow-table',
|
|
17
|
-
// data: convertMeshToArrowTable(mesh)
|
|
18
|
-
// };
|
|
19
|
-
default:
|
|
20
|
-
throw new Error(`Unsupported shape ${options?.shape}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.convertMesh = convertMesh;
|
|
24
|
-
/**
|
|
25
|
-
* Convert a loaders.gl Mesh to a Columnar Table
|
|
26
|
-
* @param mesh
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
function convertMeshToColumnarTable(mesh) {
|
|
30
|
-
const columns = {};
|
|
31
|
-
for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
|
|
32
|
-
columns[columnName] = attribute.value;
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
shape: 'columnar-table',
|
|
36
|
-
schema: mesh.schema,
|
|
37
|
-
data: columns
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
exports.convertMeshToColumnarTable = convertMeshToColumnarTable;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.makeMeshAttributeMetadata = exports.deduceMeshField = exports.deduceMeshSchema = void 0;
|
|
5
|
-
const data_type_1 = require("../table/simple-table/data-type");
|
|
6
|
-
/**
|
|
7
|
-
* Create a schema for mesh attributes data
|
|
8
|
-
* @param attributes
|
|
9
|
-
* @param metadata
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
function deduceMeshSchema(attributes, metadata = {}) {
|
|
13
|
-
const fields = deduceMeshFields(attributes);
|
|
14
|
-
return { fields, metadata };
|
|
15
|
-
}
|
|
16
|
-
exports.deduceMeshSchema = deduceMeshSchema;
|
|
17
|
-
/**
|
|
18
|
-
* Create arrow-like schema field for mesh attribute
|
|
19
|
-
* @param attributeName
|
|
20
|
-
* @param attribute
|
|
21
|
-
* @param optionalMetadata
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
function deduceMeshField(name, attribute, optionalMetadata) {
|
|
25
|
-
const type = (0, data_type_1.getDataTypeFromTypedArray)(attribute.value);
|
|
26
|
-
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
27
|
-
return {
|
|
28
|
-
name,
|
|
29
|
-
type: { type: 'fixed-size-list', listSize: attribute.size, children: [{ name: 'value', type }] },
|
|
30
|
-
nullable: false,
|
|
31
|
-
metadata
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
exports.deduceMeshField = deduceMeshField;
|
|
35
|
-
/**
|
|
36
|
-
* Create fields array for mesh attributes
|
|
37
|
-
* @param attributes
|
|
38
|
-
* @returns
|
|
39
|
-
*/
|
|
40
|
-
function deduceMeshFields(attributes) {
|
|
41
|
-
const fields = [];
|
|
42
|
-
for (const attributeName in attributes) {
|
|
43
|
-
const attribute = attributes[attributeName];
|
|
44
|
-
fields.push(deduceMeshField(attributeName, attribute));
|
|
45
|
-
}
|
|
46
|
-
return fields;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Make metadata by mesh attribute properties
|
|
50
|
-
* @param attribute
|
|
51
|
-
* @returns
|
|
52
|
-
*/
|
|
53
|
-
function makeMeshAttributeMetadata(attribute) {
|
|
54
|
-
const result = {};
|
|
55
|
-
if ('byteOffset' in attribute) {
|
|
56
|
-
result.byteOffset = attribute.byteOffset.toString(10);
|
|
57
|
-
}
|
|
58
|
-
if ('byteStride' in attribute) {
|
|
59
|
-
result.byteStride = attribute.byteStride.toString(10);
|
|
60
|
-
}
|
|
61
|
-
if ('normalized' in attribute) {
|
|
62
|
-
result.normalized = attribute.normalized.toString();
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
exports.makeMeshAttributeMetadata = makeMeshAttributeMetadata;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* Problem with arrow dependency...
|
|
3
|
-
import {
|
|
4
|
-
Table,
|
|
5
|
-
Schema,
|
|
6
|
-
RecordBatch,
|
|
7
|
-
FixedSizeList,
|
|
8
|
-
Field,
|
|
9
|
-
Data,
|
|
10
|
-
FixedSizeListVector
|
|
11
|
-
} from 'apache-arrow';
|
|
12
|
-
import {AbstractVector} from 'apache-arrow/vector';
|
|
13
|
-
import {getArrowType, getArrowVector} from '../table/arrow/arrow-type-utils';
|
|
14
|
-
import type {Mesh} from './mesh-types';
|
|
15
|
-
import {makeMeshAttributeMetadata} from './deduce-mesh-schema';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* * Convert a loaders.gl Mesh to an Apache Arrow Table
|
|
19
|
-
* @param mesh
|
|
20
|
-
* @param metadata
|
|
21
|
-
* @param batchSize
|
|
22
|
-
* @returns
|
|
23
|
-
*
|
|
24
|
-
export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {
|
|
25
|
-
const vectors: AbstractVector[] = [];
|
|
26
|
-
const fields: Field[] = [];
|
|
27
|
-
for (const attributeKey in mesh.attributes) {
|
|
28
|
-
const attribute = mesh.attributes[attributeKey];
|
|
29
|
-
const {value, size = 1} = attribute;
|
|
30
|
-
const type = getArrowType(value);
|
|
31
|
-
const vector = getArrowVector(value);
|
|
32
|
-
const listType = new FixedSizeList(size, new Field('value', type));
|
|
33
|
-
const field = new Field(attributeKey, listType, false, makeMeshAttributeMetadata(attribute));
|
|
34
|
-
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
|
|
35
|
-
const listVector = new FixedSizeListVector(data);
|
|
36
|
-
vectors.push(listVector);
|
|
37
|
-
fields.push(field);
|
|
38
|
-
}
|
|
39
|
-
const schema = new Schema(fields, mesh?.schema?.metadata || new Map<string, string>());
|
|
40
|
-
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
|
|
41
|
-
const table = new Table(schema, recordBatch);
|
|
42
|
-
return table;
|
|
43
|
-
}
|
|
44
|
-
*/
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMeshBoundingBox = exports.getMeshSize = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Get number of vertices in mesh
|
|
6
|
-
* @param attributes
|
|
7
|
-
*/
|
|
8
|
-
function getMeshSize(attributes) {
|
|
9
|
-
let size = 0;
|
|
10
|
-
for (const attributeName in attributes) {
|
|
11
|
-
const attribute = attributes[attributeName];
|
|
12
|
-
if (ArrayBuffer.isView(attribute)) {
|
|
13
|
-
// @ts-ignore DataView doesn't have BYTES_PER_ELEMENT
|
|
14
|
-
size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return size;
|
|
18
|
-
}
|
|
19
|
-
exports.getMeshSize = getMeshSize;
|
|
20
|
-
/**
|
|
21
|
-
* Get the (axis aligned) bounding box of a mesh
|
|
22
|
-
* @param attributes
|
|
23
|
-
* @returns array of two vectors representing the axis aligned bounding box
|
|
24
|
-
*/
|
|
25
|
-
// eslint-disable-next-line complexity
|
|
26
|
-
function getMeshBoundingBox(attributes) {
|
|
27
|
-
let minX = Infinity;
|
|
28
|
-
let minY = Infinity;
|
|
29
|
-
let minZ = Infinity;
|
|
30
|
-
let maxX = -Infinity;
|
|
31
|
-
let maxY = -Infinity;
|
|
32
|
-
let maxZ = -Infinity;
|
|
33
|
-
const positions = attributes.POSITION ? attributes.POSITION.value : [];
|
|
34
|
-
const len = positions && positions.length;
|
|
35
|
-
for (let i = 0; i < len; i += 3) {
|
|
36
|
-
const x = positions[i];
|
|
37
|
-
const y = positions[i + 1];
|
|
38
|
-
const z = positions[i + 2];
|
|
39
|
-
minX = x < minX ? x : minX;
|
|
40
|
-
minY = y < minY ? y : minY;
|
|
41
|
-
minZ = z < minZ ? z : minZ;
|
|
42
|
-
maxX = x > maxX ? x : maxX;
|
|
43
|
-
maxY = y > maxY ? y : maxY;
|
|
44
|
-
maxZ = z > maxZ ? z : maxZ;
|
|
45
|
-
}
|
|
46
|
-
return [
|
|
47
|
-
[minX, minY, minZ],
|
|
48
|
-
[maxX, maxY, maxZ]
|
|
49
|
-
];
|
|
50
|
-
}
|
|
51
|
-
exports.getMeshBoundingBox = getMeshBoundingBox;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getArrowType = void 0;
|
|
5
|
-
const apache_arrow_1 = require("apache-arrow");
|
|
6
|
-
// import {AbstractVector} from 'apache-arrow/vector';
|
|
7
|
-
function getArrowType(array) {
|
|
8
|
-
switch (array.constructor) {
|
|
9
|
-
case Int8Array:
|
|
10
|
-
return new apache_arrow_1.Int8();
|
|
11
|
-
case Uint8Array:
|
|
12
|
-
return new apache_arrow_1.Uint8();
|
|
13
|
-
case Int16Array:
|
|
14
|
-
return new apache_arrow_1.Int16();
|
|
15
|
-
case Uint16Array:
|
|
16
|
-
return new apache_arrow_1.Uint16();
|
|
17
|
-
case Int32Array:
|
|
18
|
-
return new apache_arrow_1.Int32();
|
|
19
|
-
case Uint32Array:
|
|
20
|
-
return new apache_arrow_1.Uint32();
|
|
21
|
-
case Float32Array:
|
|
22
|
-
return new apache_arrow_1.Float32();
|
|
23
|
-
case Float64Array:
|
|
24
|
-
return new apache_arrow_1.Float64();
|
|
25
|
-
default:
|
|
26
|
-
throw new Error('array type not supported');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.getArrowType = getArrowType;
|
|
30
|
-
/*
|
|
31
|
-
export function getArrowVector(array: TypedArray): AbstractVector {
|
|
32
|
-
switch (array.constructor) {
|
|
33
|
-
case Int8Array:
|
|
34
|
-
return Int8Vector.from(array);
|
|
35
|
-
case Uint8Array:
|
|
36
|
-
return Uint8Vector.from(array);
|
|
37
|
-
case Int16Array:
|
|
38
|
-
return Int16Vector.from(array);
|
|
39
|
-
case Uint16Array:
|
|
40
|
-
return Uint16Vector.from(array);
|
|
41
|
-
case Int32Array:
|
|
42
|
-
return Int32Vector.from(array);
|
|
43
|
-
case Uint32Array:
|
|
44
|
-
return Uint32Vector.from(array);
|
|
45
|
-
case Float32Array:
|
|
46
|
-
return Float32Vector.from(array);
|
|
47
|
-
case Float64Array:
|
|
48
|
-
return Float64Vector.from(array);
|
|
49
|
-
default:
|
|
50
|
-
throw new Error('array type not supported');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
*/
|