@loaders.gl/schema 4.0.0-alpha.23 → 4.0.0-alpha.25

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.
Files changed (98) hide show
  1. package/dist/dist.min.js +543 -934
  2. package/dist/es5/index.js +7 -0
  3. package/dist/es5/index.js.map +1 -1
  4. package/dist/es5/lib/table/arrow-api/arrow-like-table.js +1 -1
  5. package/dist/es5/lib/table/arrow-api/arrow-like-table.js.map +1 -1
  6. package/dist/es5/lib/table/batches/row-table-batch-aggregator.js.map +1 -1
  7. package/dist/es5/lib/table/simple-table/convert-table.js +24 -0
  8. package/dist/es5/lib/table/simple-table/convert-table.js.map +1 -1
  9. package/dist/es5/lib/table/simple-table/table-accessors.js +52 -31
  10. package/dist/es5/lib/table/simple-table/table-accessors.js.map +1 -1
  11. package/dist/es5/types/batch.js +2 -0
  12. package/dist/es5/types/batch.js.map +1 -0
  13. package/dist/es5/types/binary-geometries.js.map +1 -1
  14. package/dist/es5/types/category-gis.js.map +1 -1
  15. package/dist/es5/types/category-table.js.map +1 -1
  16. package/dist/es5/types/schema.js.map +1 -1
  17. package/dist/esm/index.js +1 -0
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/lib/table/arrow-api/arrow-like-table.js +1 -1
  20. package/dist/esm/lib/table/arrow-api/arrow-like-table.js.map +1 -1
  21. package/dist/esm/lib/table/batches/row-table-batch-aggregator.js.map +1 -1
  22. package/dist/esm/lib/table/simple-table/convert-table.js +22 -0
  23. package/dist/esm/lib/table/simple-table/convert-table.js.map +1 -1
  24. package/dist/esm/lib/table/simple-table/table-accessors.js +32 -11
  25. package/dist/esm/lib/table/simple-table/table-accessors.js.map +1 -1
  26. package/dist/esm/types/batch.js +2 -0
  27. package/dist/esm/types/batch.js.map +1 -0
  28. package/dist/esm/types/binary-geometries.js.map +1 -1
  29. package/dist/esm/types/category-gis.js.map +1 -1
  30. package/dist/esm/types/category-table.js.map +1 -1
  31. package/dist/esm/types/schema.js.map +1 -1
  32. package/dist/index.d.ts +7 -5
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/lib/table/batches/row-table-batch-aggregator.d.ts +3 -3
  35. package/dist/lib/table/batches/row-table-batch-aggregator.d.ts.map +1 -1
  36. package/dist/lib/table/simple-table/convert-table.d.ts +34 -1
  37. package/dist/lib/table/simple-table/convert-table.d.ts.map +1 -1
  38. package/dist/lib/table/simple-table/table-accessors.d.ts.map +1 -1
  39. package/dist/types/batch.d.ts +34 -0
  40. package/dist/types/batch.d.ts.map +1 -0
  41. package/dist/types/binary-geometries.d.ts +9 -7
  42. package/dist/types/binary-geometries.d.ts.map +1 -1
  43. package/dist/types/category-gis.d.ts +1 -1
  44. package/dist/types/category-gis.d.ts.map +1 -1
  45. package/dist/types/category-table.d.ts +21 -13
  46. package/dist/types/category-table.d.ts.map +1 -1
  47. package/dist/types/schema.d.ts +0 -15
  48. package/dist/types/schema.d.ts.map +1 -1
  49. package/package.json +2 -2
  50. package/src/index.ts +13 -7
  51. package/src/lib/table/arrow-api/arrow-like-table.ts +1 -1
  52. package/src/lib/table/batches/row-table-batch-aggregator.ts +2 -2
  53. package/src/lib/table/simple-table/convert-table.ts +73 -1
  54. package/src/lib/table/simple-table/table-accessors.ts +41 -13
  55. package/src/types/batch.ts +41 -0
  56. package/src/types/binary-geometries.ts +10 -7
  57. package/src/types/category-gis.ts +5 -4
  58. package/src/types/category-table.ts +22 -13
  59. package/src/types/schema.ts +0 -17
  60. package/dist/bundle.js +0 -5
  61. package/dist/index.js +0 -92
  62. package/dist/lib/mesh/convert-mesh.js +0 -40
  63. package/dist/lib/mesh/deduce-mesh-schema.js +0 -66
  64. package/dist/lib/mesh/mesh-to-arrow-table.js +0 -44
  65. package/dist/lib/mesh/mesh-utils.js +0 -51
  66. package/dist/lib/table/arrow/arrow-type-utils.js +0 -53
  67. package/dist/lib/table/arrow/convert-schema-arrow.js +0 -187
  68. package/dist/lib/table/arrow/convert-table-to-arrow.js +0 -57
  69. package/dist/lib/table/arrow-api/arrow-like-field.js +0 -34
  70. package/dist/lib/table/arrow-api/arrow-like-schema.js +0 -81
  71. package/dist/lib/table/arrow-api/arrow-like-table.js +0 -53
  72. package/dist/lib/table/arrow-api/arrow-like-type.js +0 -463
  73. package/dist/lib/table/arrow-api/enum.js +0 -97
  74. package/dist/lib/table/arrow-api/get-type-info.js +0 -29
  75. package/dist/lib/table/arrow-api/index.js +0 -25
  76. package/dist/lib/table/batches/base-table-batch-aggregator.js +0 -60
  77. package/dist/lib/table/batches/columnar-table-batch-aggregator.js +0 -92
  78. package/dist/lib/table/batches/row-table-batch-aggregator.js +0 -81
  79. package/dist/lib/table/batches/table-batch-aggregator.js +0 -3
  80. package/dist/lib/table/batches/table-batch-builder.js +0 -152
  81. package/dist/lib/table/simple-table/convert-table.js +0 -65
  82. package/dist/lib/table/simple-table/data-type.js +0 -93
  83. package/dist/lib/table/simple-table/make-table.js +0 -95
  84. package/dist/lib/table/simple-table/row-utils.js +0 -33
  85. package/dist/lib/table/simple-table/table-accessors.js +0 -319
  86. package/dist/lib/table/simple-table/table-column.js +0 -41
  87. package/dist/lib/table/simple-table/table-schema.js +0 -85
  88. package/dist/lib/utils/assert.js +0 -12
  89. package/dist/lib/utils/async-queue.js +0 -92
  90. package/dist/types/binary-geometries.js +0 -2
  91. package/dist/types/category-gis.js +0 -3
  92. package/dist/types/category-image.js +0 -2
  93. package/dist/types/category-mesh.js +0 -3
  94. package/dist/types/category-table.js +0 -3
  95. package/dist/types/category-texture.js +0 -3
  96. package/dist/types/flat-geometries.js +0 -3
  97. package/dist/types/schema.js +0 -3
  98. package/dist/types/types.js +0 -2
@@ -1,7 +1,8 @@
1
1
  // loaders.gl, MIT license
2
2
 
3
- import type {Table as ApacheArrowTable, RecordBatch} from 'apache-arrow';
4
- import type {Batch, Schema} from './schema';
3
+ import type {Table as ApacheArrowTable} from 'apache-arrow';
4
+ import type {Schema} from './schema';
5
+ import type {Batch} from './batch';
5
6
  import type {Feature} from './category-gis';
6
7
 
7
8
  // Idea was to just import types, but it seems
@@ -15,12 +16,12 @@ export type Table =
15
16
  | RowTable
16
17
  | ArrayRowTable
17
18
  | ObjectRowTable
18
- | GeoJSONRowTable
19
+ | GeoJSONTable
19
20
  | ColumnarTable
20
21
  | ArrowTable;
21
22
 
22
23
  /** A table organized as an array of rows */
23
- export type RowTable = ArrayRowTable | ObjectRowTable | GeoJSONRowTable;
24
+ export type RowTable = ArrayRowTable | ObjectRowTable | GeoJSONTable;
24
25
 
25
26
  /** A table organized as an array of rows, each row is an array of values */
26
27
  export type ArrayRowTable = {
@@ -36,11 +37,17 @@ export type ObjectRowTable = {
36
37
  data: {[columnName: string]: any}[];
37
38
  };
38
39
 
39
- /** A table organized as an array of rows, each row is a GeoJSON Feature */
40
- export type GeoJSONRowTable = {
41
- shape: 'geojson-row-table';
40
+ /**
41
+ * A table organized as an array of rows, each row is a GeoJSON Feature
42
+ * @note For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data`
43
+ */
44
+ export type GeoJSONTable = {
45
+ shape: 'geojson-table';
42
46
  schema?: Schema;
43
- data: Feature[];
47
+ /** For compatibility with GeoJSON, the type field must always be set to `FeatureCollection` */
48
+ type: 'FeatureCollection';
49
+ /** For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data` */
50
+ features: Feature[];
44
51
  };
45
52
 
46
53
  /** A table organized as a map of columns, each column is an array of value */
@@ -69,7 +76,7 @@ export type Tables<TableType = Table> = {
69
76
  export type TableBatch =
70
77
  | ArrayRowTableBatch
71
78
  | ObjectRowTableBatch
72
- | GeoJSONRowTableBatch
79
+ | GeoJSONTableBatch
73
80
  | ColumnarTableBatch
74
81
  | ArrowTableBatch;
75
82
 
@@ -92,11 +99,12 @@ export type ObjectRowTableBatch = Batch & {
92
99
  };
93
100
 
94
101
  /** Batch for a table organized as an array of rows, each row is an array of values */
95
- export type GeoJSONRowTableBatch = Batch & {
96
- shape: 'geojson-row-table';
102
+ export type GeoJSONTableBatch = Batch & {
103
+ shape: 'geojson-table';
97
104
  schema?: Schema;
98
105
  schemaType?: 'explicit' | 'deduced';
99
- data: Feature[];
106
+ type: 'FeatureCollection';
107
+ features: Feature[];
100
108
  length: number;
101
109
  };
102
110
 
@@ -114,6 +122,7 @@ export type ArrowTableBatch = Batch & {
114
122
  shape: 'arrow-table';
115
123
  schemaType?: 'explicit' | 'deduced';
116
124
  schema?: Schema;
117
- data: RecordBatch;
125
+ data: ApacheArrowTable;
126
+ // recordBatch: RecordBatch;
118
127
  length: number;
119
128
  };
@@ -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
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- const moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);
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
- */
@@ -1,187 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.deserializeArrowType = exports.serializeArrowType = exports.deserializeArrowField = exports.serializeArrowField = exports.deserializeArrowMetadata = exports.serializeArrowMetadata = exports.deserializeArrowSchema = exports.serializeArrowSchema = void 0;
5
- const Arrow_dom_1 = require("apache-arrow/Arrow.dom");
6
- function serializeArrowSchema(arrowSchema) {
7
- return {
8
- fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
9
- metadata: serializeArrowMetadata(arrowSchema.metadata)
10
- };
11
- }
12
- exports.serializeArrowSchema = serializeArrowSchema;
13
- function deserializeArrowSchema(schema) {
14
- return new Arrow_dom_1.Schema(schema.fields.map((field) => deserializeArrowField(field)), deserializeArrowMetadata(schema.metadata));
15
- }
16
- exports.deserializeArrowSchema = deserializeArrowSchema;
17
- function serializeArrowMetadata(arrowMetadata) {
18
- return Object.fromEntries(arrowMetadata);
19
- }
20
- exports.serializeArrowMetadata = serializeArrowMetadata;
21
- function deserializeArrowMetadata(metadata) {
22
- return metadata ? new Map(Object.entries(metadata)) : new Map();
23
- }
24
- exports.deserializeArrowMetadata = deserializeArrowMetadata;
25
- function serializeArrowField(field) {
26
- return {
27
- name: field.name,
28
- type: serializeArrowType(field.type),
29
- nullable: field.nullable,
30
- metadata: serializeArrowMetadata(field.metadata)
31
- };
32
- }
33
- exports.serializeArrowField = serializeArrowField;
34
- function deserializeArrowField(field) {
35
- return new Arrow_dom_1.Field(field.name, deserializeArrowType(field.type), field.nullable, deserializeArrowMetadata(field.metadata));
36
- }
37
- exports.deserializeArrowField = deserializeArrowField;
38
- /** Converts a serializable loaders.gl data type to hydrated arrow data type */
39
- // eslint-disable-next-line complexity
40
- function serializeArrowType(arrowType) {
41
- switch (arrowType.constructor) {
42
- case Arrow_dom_1.Null:
43
- return 'null';
44
- case Arrow_dom_1.Binary:
45
- return 'binary';
46
- case Arrow_dom_1.Bool:
47
- return 'bool';
48
- // case Int: return 'int';
49
- case Arrow_dom_1.Int8:
50
- return 'int8';
51
- case Arrow_dom_1.Int16:
52
- return 'int16';
53
- case Arrow_dom_1.Int32:
54
- return 'int32';
55
- case Arrow_dom_1.Int64:
56
- return 'int64';
57
- case Arrow_dom_1.Uint8:
58
- return 'uint8';
59
- case Arrow_dom_1.Uint16:
60
- return 'uint16';
61
- case Arrow_dom_1.Uint32:
62
- return 'uint32';
63
- case Arrow_dom_1.Uint64:
64
- return 'uint64';
65
- // case Float: return 'float';
66
- case Arrow_dom_1.Float16:
67
- return 'float16';
68
- case Arrow_dom_1.Float32:
69
- return 'float32';
70
- case Arrow_dom_1.Float64:
71
- return 'float64';
72
- case Arrow_dom_1.Utf8:
73
- return 'utf8';
74
- // case Date: return 'date';
75
- case Arrow_dom_1.DateDay:
76
- return 'date-day';
77
- case Arrow_dom_1.DateMillisecond:
78
- return 'date-millisecond';
79
- // case Time: return 'time';
80
- case Arrow_dom_1.TimeMillisecond:
81
- return 'time-millisecond';
82
- case Arrow_dom_1.TimeSecond:
83
- return 'time-second';
84
- // case Timestamp: return 'timestamp';
85
- case Arrow_dom_1.TimestampSecond:
86
- return 'timestamp-second';
87
- case Arrow_dom_1.TimestampMillisecond:
88
- return 'timestamp-millisecond';
89
- case Arrow_dom_1.TimestampMicrosecond:
90
- return 'timestamp-microsecond';
91
- case Arrow_dom_1.TimestampNanosecond:
92
- return 'timestamp-nanosecond';
93
- // case Interval: return 'interval';
94
- case Arrow_dom_1.IntervalDayTime:
95
- return 'interval-daytime';
96
- case Arrow_dom_1.IntervalYearMonth:
97
- return 'interval-yearmonth';
98
- case Arrow_dom_1.FixedSizeList:
99
- return {
100
- type: 'fixed-size-list',
101
- listSize: arrowType.listSize,
102
- children: [serializeArrowField(arrowType.children[0])]
103
- };
104
- // case Struct:
105
- // return {type: 'struct', children: (arrowType as Struct).children};
106
- default:
107
- throw new Error('array type not supported');
108
- }
109
- }
110
- exports.serializeArrowType = serializeArrowType;
111
- /** Converts a serializable loaders.gl data type to hydrated arrow data type */
112
- // eslint-disable-next-line complexity
113
- function deserializeArrowType(dataType) {
114
- if (typeof dataType === 'object') {
115
- switch (dataType.type) {
116
- case 'fixed-size-list':
117
- const child = deserializeArrowField(dataType.children[0]);
118
- return new Arrow_dom_1.FixedSizeList(dataType.listSize, child);
119
- case 'struct':
120
- const children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));
121
- return new Arrow_dom_1.Struct(children);
122
- default:
123
- throw new Error('array type not supported');
124
- }
125
- }
126
- switch (dataType) {
127
- case 'null':
128
- return new Arrow_dom_1.Null();
129
- case 'binary':
130
- return new Arrow_dom_1.Binary();
131
- case 'bool':
132
- return new Arrow_dom_1.Bool();
133
- // case 'int': return new Int();
134
- case 'int8':
135
- return new Arrow_dom_1.Int8();
136
- case 'int16':
137
- return new Arrow_dom_1.Int16();
138
- case 'int32':
139
- return new Arrow_dom_1.Int32();
140
- case 'int64':
141
- return new Arrow_dom_1.Int64();
142
- case 'uint8':
143
- return new Arrow_dom_1.Uint8();
144
- case 'uint16':
145
- return new Arrow_dom_1.Uint16();
146
- case 'uint32':
147
- return new Arrow_dom_1.Uint32();
148
- case 'uint64':
149
- return new Arrow_dom_1.Uint64();
150
- // case 'float': return new Float();
151
- case 'float16':
152
- return new Arrow_dom_1.Float16();
153
- case 'float32':
154
- return new Arrow_dom_1.Float32();
155
- case 'float64':
156
- return new Arrow_dom_1.Float64();
157
- case 'utf8':
158
- return new Arrow_dom_1.Utf8();
159
- // case 'date': return new Date();
160
- case 'date-day':
161
- return new Arrow_dom_1.DateDay();
162
- case 'date-millisecond':
163
- return new Arrow_dom_1.DateMillisecond();
164
- // case 'time': return new Time();
165
- case 'time-millisecond':
166
- return new Arrow_dom_1.TimeMillisecond();
167
- case 'time-second':
168
- return new Arrow_dom_1.TimeSecond();
169
- // case 'timestamp': return new Timestamp();
170
- case 'timestamp-second':
171
- return new Arrow_dom_1.TimestampSecond();
172
- case 'timestamp-millisecond':
173
- return new Arrow_dom_1.TimestampMillisecond();
174
- case 'timestamp-microsecond':
175
- return new Arrow_dom_1.TimestampMicrosecond();
176
- case 'timestamp-nanosecond':
177
- return new Arrow_dom_1.TimestampNanosecond();
178
- // case 'interval': return new Interval();
179
- case 'interval-daytime':
180
- return new Arrow_dom_1.IntervalDayTime();
181
- case 'interval-yearmonth':
182
- return new Arrow_dom_1.IntervalYearMonth();
183
- default:
184
- throw new Error('array type not supported');
185
- }
186
- }
187
- exports.deserializeArrowType = deserializeArrowType;