@loaders.gl/schema 3.1.3 → 4.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundle.js.map +1 -0
  3. package/dist/category/common.d.ts +1 -2
  4. package/dist/category/common.d.ts.map +1 -1
  5. package/dist/category/common.js +2 -10
  6. package/dist/{es5/category → category}/common.js.map +0 -0
  7. package/dist/category/gis.js +2 -2
  8. package/dist/{es5/category → category}/gis.js.map +0 -0
  9. package/dist/category/image/image.d.ts +18 -0
  10. package/dist/category/image/image.d.ts.map +1 -0
  11. package/dist/category/image/image.js +2 -0
  12. package/dist/{esm/category/gis.js.map → category/image/image.js.map} +1 -1
  13. package/dist/category/mesh/convert-mesh.js +31 -37
  14. package/dist/category/mesh/convert-mesh.js.map +1 -0
  15. package/dist/category/mesh/deduce-mesh-schema.js +37 -57
  16. package/dist/category/mesh/deduce-mesh-schema.js.map +1 -0
  17. package/dist/category/mesh/mesh-to-arrow-table.d.ts +10 -0
  18. package/dist/category/mesh/mesh-to-arrow-table.d.ts.map +1 -1
  19. package/dist/category/mesh/mesh-to-arrow-table.js +15 -28
  20. package/dist/category/mesh/mesh-to-arrow-table.js.map +1 -0
  21. package/dist/category/mesh/mesh-types.js +2 -2
  22. package/dist/{es5/category → category}/mesh/mesh-types.js.map +0 -0
  23. package/dist/category/mesh/mesh-utils.js +35 -48
  24. package/dist/category/mesh/mesh-utils.js.map +1 -0
  25. package/dist/category/table/deduce-table-schema.js +39 -94
  26. package/dist/category/table/deduce-table-schema.js.map +1 -0
  27. package/dist/category/table/table-types.d.ts +1 -3
  28. package/dist/category/table/table-types.d.ts.map +1 -1
  29. package/dist/category/table/table-types.js +2 -2
  30. package/dist/{es5/category → category}/table/table-types.js.map +0 -0
  31. package/dist/category/texture/texture.d.ts +18 -0
  32. package/dist/category/texture/texture.d.ts.map +1 -0
  33. package/dist/category/texture/texture.js +2 -0
  34. package/dist/{esm/category/common.js.map → category/texture/texture.js.map} +1 -1
  35. package/dist/dist.min.js +15078 -208
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +13 -75
  39. package/dist/index.js.map +1 -0
  40. package/dist/lib/arrow/arrow-like-type-utils.js +31 -26
  41. package/dist/lib/arrow/arrow-like-type-utils.js.map +1 -0
  42. package/dist/lib/arrow/arrow-type-utils.d.ts +5 -0
  43. package/dist/lib/arrow/arrow-type-utils.d.ts.map +1 -1
  44. package/dist/lib/arrow/arrow-type-utils.js +20 -28
  45. package/dist/lib/arrow/arrow-type-utils.js.map +1 -0
  46. package/dist/lib/arrow/get-type-info.js +19 -23
  47. package/dist/lib/arrow/get-type-info.js.map +1 -0
  48. package/dist/lib/batches/base-table-batch-aggregator.js +68 -52
  49. package/dist/lib/batches/base-table-batch-aggregator.js.map +1 -0
  50. package/dist/lib/batches/columnar-table-batch-aggregator.js +92 -82
  51. package/dist/lib/batches/columnar-table-batch-aggregator.js.map +1 -0
  52. package/dist/lib/batches/row-table-batch-aggregator.js +88 -72
  53. package/dist/lib/batches/row-table-batch-aggregator.js.map +1 -0
  54. package/dist/lib/batches/table-batch-aggregator.js +2 -2
  55. package/dist/{es5/lib → lib}/batches/table-batch-aggregator.js.map +0 -0
  56. package/dist/lib/batches/table-batch-builder.js +166 -137
  57. package/dist/lib/batches/table-batch-builder.js.map +1 -0
  58. package/dist/lib/schema/impl/enum.js +48 -96
  59. package/dist/lib/schema/impl/enum.js.map +1 -0
  60. package/dist/lib/schema/impl/field.js +34 -31
  61. package/dist/lib/schema/impl/field.js.map +1 -0
  62. package/dist/lib/schema/impl/schema.js +81 -72
  63. package/dist/lib/schema/impl/schema.js.map +1 -0
  64. package/dist/lib/schema/impl/type.js +490 -454
  65. package/dist/lib/schema/impl/type.js.map +1 -0
  66. package/dist/lib/schema/schema.js +5 -90
  67. package/dist/lib/schema/schema.js.map +1 -0
  68. package/dist/lib/schema-utils/deduce-column-type.js +20 -89
  69. package/dist/lib/schema-utils/deduce-column-type.js.map +1 -0
  70. package/dist/lib/utils/assert.js +5 -11
  71. package/dist/lib/utils/assert.js.map +1 -0
  72. package/dist/lib/utils/async-queue.js +109 -82
  73. package/dist/lib/utils/async-queue.js.map +1 -0
  74. package/dist/lib/utils/row-utils.js +33 -31
  75. package/dist/lib/utils/row-utils.js.map +1 -0
  76. package/dist/types.js +2 -2
  77. package/dist/{es5/types.js.map → types.js.map} +0 -0
  78. package/package.json +6 -5
  79. package/src/category/common.ts +1 -2
  80. package/src/category/image/image.ts +19 -0
  81. package/src/category/mesh/convert-mesh.ts +6 -6
  82. package/src/category/mesh/mesh-to-arrow-table.ts +2 -4
  83. package/src/category/table/table-types.ts +1 -4
  84. package/src/category/texture/texture.ts +28 -0
  85. package/src/index.ts +6 -1
  86. package/src/lib/arrow/arrow-type-utils.ts +0 -2
  87. package/dist/es5/bundle.js +0 -7
  88. package/dist/es5/bundle.js.map +0 -1
  89. package/dist/es5/category/common.js +0 -2
  90. package/dist/es5/category/gis.js +0 -2
  91. package/dist/es5/category/mesh/convert-mesh.js +0 -43
  92. package/dist/es5/category/mesh/convert-mesh.js.map +0 -1
  93. package/dist/es5/category/mesh/deduce-mesh-schema.js +0 -54
  94. package/dist/es5/category/mesh/deduce-mesh-schema.js.map +0 -1
  95. package/dist/es5/category/mesh/mesh-to-arrow-table.js +0 -2
  96. package/dist/es5/category/mesh/mesh-to-arrow-table.js.map +0 -1
  97. package/dist/es5/category/mesh/mesh-types.js +0 -2
  98. package/dist/es5/category/mesh/mesh-utils.js +0 -47
  99. package/dist/es5/category/mesh/mesh-utils.js.map +0 -1
  100. package/dist/es5/category/table/deduce-table-schema.js +0 -58
  101. package/dist/es5/category/table/deduce-table-schema.js.map +0 -1
  102. package/dist/es5/category/table/table-types.js +0 -2
  103. package/dist/es5/index.js +0 -344
  104. package/dist/es5/index.js.map +0 -1
  105. package/dist/es5/lib/arrow/arrow-like-type-utils.js +0 -40
  106. package/dist/es5/lib/arrow/arrow-like-type-utils.js.map +0 -1
  107. package/dist/es5/lib/arrow/arrow-type-utils.js +0 -2
  108. package/dist/es5/lib/arrow/arrow-type-utils.js.map +0 -1
  109. package/dist/es5/lib/arrow/get-type-info.js +0 -33
  110. package/dist/es5/lib/arrow/get-type-info.js.map +0 -1
  111. package/dist/es5/lib/batches/base-table-batch-aggregator.js +0 -92
  112. package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +0 -1
  113. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +0 -128
  114. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
  115. package/dist/es5/lib/batches/row-table-batch-aggregator.js +0 -113
  116. package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +0 -1
  117. package/dist/es5/lib/batches/table-batch-aggregator.js +0 -2
  118. package/dist/es5/lib/batches/table-batch-builder.js +0 -207
  119. package/dist/es5/lib/batches/table-batch-builder.js.map +0 -1
  120. package/dist/es5/lib/schema/impl/enum.js +0 -56
  121. package/dist/es5/lib/schema/impl/enum.js.map +0 -1
  122. package/dist/es5/lib/schema/impl/field.js +0 -56
  123. package/dist/es5/lib/schema/impl/field.js.map +0 -1
  124. package/dist/es5/lib/schema/impl/schema.js +0 -168
  125. package/dist/es5/lib/schema/impl/schema.js.map +0 -1
  126. package/dist/es5/lib/schema/impl/type.js +0 -927
  127. package/dist/es5/lib/schema/impl/type.js.map +0 -1
  128. package/dist/es5/lib/schema/schema.js +0 -236
  129. package/dist/es5/lib/schema/schema.js.map +0 -1
  130. package/dist/es5/lib/schema-utils/deduce-column-type.js +0 -32
  131. package/dist/es5/lib/schema-utils/deduce-column-type.js.map +0 -1
  132. package/dist/es5/lib/utils/assert.js +0 -13
  133. package/dist/es5/lib/utils/assert.js.map +0 -1
  134. package/dist/es5/lib/utils/async-queue.js +0 -213
  135. package/dist/es5/lib/utils/async-queue.js.map +0 -1
  136. package/dist/es5/lib/utils/row-utils.js +0 -44
  137. package/dist/es5/lib/utils/row-utils.js.map +0 -1
  138. package/dist/es5/types.js +0 -2
  139. package/dist/esm/bundle.js +0 -5
  140. package/dist/esm/bundle.js.map +0 -1
  141. package/dist/esm/category/common.js +0 -2
  142. package/dist/esm/category/gis.js +0 -2
  143. package/dist/esm/category/mesh/convert-mesh.js +0 -26
  144. package/dist/esm/category/mesh/convert-mesh.js.map +0 -1
  145. package/dist/esm/category/mesh/deduce-mesh-schema.js +0 -42
  146. package/dist/esm/category/mesh/deduce-mesh-schema.js.map +0 -1
  147. package/dist/esm/category/mesh/mesh-to-arrow-table.js +0 -2
  148. package/dist/esm/category/mesh/mesh-to-arrow-table.js.map +0 -1
  149. package/dist/esm/category/mesh/mesh-types.js +0 -2
  150. package/dist/esm/category/mesh/mesh-types.js.map +0 -1
  151. package/dist/esm/category/mesh/mesh-utils.js +0 -38
  152. package/dist/esm/category/mesh/mesh-utils.js.map +0 -1
  153. package/dist/esm/category/table/deduce-table-schema.js +0 -51
  154. package/dist/esm/category/table/deduce-table-schema.js.map +0 -1
  155. package/dist/esm/category/table/table-types.js +0 -2
  156. package/dist/esm/category/table/table-types.js.map +0 -1
  157. package/dist/esm/index.js +0 -13
  158. package/dist/esm/index.js.map +0 -1
  159. package/dist/esm/lib/arrow/arrow-like-type-utils.js +0 -32
  160. package/dist/esm/lib/arrow/arrow-like-type-utils.js.map +0 -1
  161. package/dist/esm/lib/arrow/arrow-type-utils.js +0 -2
  162. package/dist/esm/lib/arrow/arrow-type-utils.js.map +0 -1
  163. package/dist/esm/lib/arrow/get-type-info.js +0 -24
  164. package/dist/esm/lib/arrow/get-type-info.js.map +0 -1
  165. package/dist/esm/lib/batches/base-table-batch-aggregator.js +0 -74
  166. package/dist/esm/lib/batches/base-table-batch-aggregator.js.map +0 -1
  167. package/dist/esm/lib/batches/columnar-table-batch-aggregator.js +0 -100
  168. package/dist/esm/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
  169. package/dist/esm/lib/batches/row-table-batch-aggregator.js +0 -95
  170. package/dist/esm/lib/batches/row-table-batch-aggregator.js.map +0 -1
  171. package/dist/esm/lib/batches/table-batch-aggregator.js +0 -2
  172. package/dist/esm/lib/batches/table-batch-aggregator.js.map +0 -1
  173. package/dist/esm/lib/batches/table-batch-builder.js +0 -182
  174. package/dist/esm/lib/batches/table-batch-builder.js.map +0 -1
  175. package/dist/esm/lib/schema/impl/enum.js +0 -49
  176. package/dist/esm/lib/schema/impl/enum.js.map +0 -1
  177. package/dist/esm/lib/schema/impl/field.js +0 -35
  178. package/dist/esm/lib/schema/impl/field.js.map +0 -1
  179. package/dist/esm/lib/schema/impl/schema.js +0 -92
  180. package/dist/esm/lib/schema/impl/schema.js.map +0 -1
  181. package/dist/esm/lib/schema/impl/type.js +0 -498
  182. package/dist/esm/lib/schema/impl/type.js.map +0 -1
  183. package/dist/esm/lib/schema/schema.js +0 -5
  184. package/dist/esm/lib/schema/schema.js.map +0 -1
  185. package/dist/esm/lib/schema-utils/deduce-column-type.js +0 -23
  186. package/dist/esm/lib/schema-utils/deduce-column-type.js.map +0 -1
  187. package/dist/esm/lib/utils/assert.js +0 -6
  188. package/dist/esm/lib/utils/assert.js.map +0 -1
  189. package/dist/esm/lib/utils/async-queue.js +0 -119
  190. package/dist/esm/lib/utils/async-queue.js.map +0 -1
  191. package/dist/esm/lib/utils/row-utils.js +0 -35
  192. package/dist/esm/lib/utils/row-utils.js.map +0 -1
  193. package/dist/esm/types.js +0 -2
  194. package/dist/esm/types.js.map +0 -1
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";
2
- // @ts-nocheck
3
1
  const moduleExports = require('./index');
2
+
4
3
  globalThis.loaders = globalThis.loaders || {};
5
4
  module.exports = Object.assign(globalThis.loaders, moduleExports);
5
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
@@ -1,4 +1,4 @@
1
- declare type RecordBatch = any;
1
+ import type { RecordBatch } from 'apache-arrow';
2
2
  export declare type Field = any;
3
3
  export declare type Schema = {
4
4
  [key: string]: Field;
@@ -16,5 +16,4 @@ export declare type Batch = {
16
16
  cursor?: number;
17
17
  [key: string]: any;
18
18
  };
19
- export {};
20
19
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/category/common.ts"],"names":[],"mappings":"AACA,aAAK,WAAW,GAAG,GAAG,CAAC;AAEvB,oBAAY,KAAK,GAAG,GAAG,CAAC;AAExB,oBAAY,MAAM,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;CACtB,CAAC;AAEF,oBAAY,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAC;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/category/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAE9C,oBAAY,KAAK,GAAG,GAAG,CAAC;AAExB,oBAAY,MAAM,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;CACtB,CAAC;AAEF,oBAAY,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAC;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC"}
@@ -1,10 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /*
4
- export type Batch = {
5
- bytesUsed?: number;
6
- count?: number;
7
- cursor?: number;
8
- [key: string]: any;
9
- }
10
- */
1
+ export {};
2
+ //# sourceMappingURL=common.js.map
File without changes
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=gis.js.map
File without changes
@@ -0,0 +1,18 @@
1
+ /**
2
+ * data images
3
+ */
4
+ export declare type ImageDataType = {
5
+ data: Uint8Array;
6
+ width: number;
7
+ height: number;
8
+ compressed?: boolean;
9
+ };
10
+ /**
11
+ * Supported Image Types
12
+ */
13
+ export declare type ImageType = ImageBitmap | typeof Image | ImageDataType;
14
+ /**
15
+ * Image type string used to control or determine the type of images returned from ImageLoader
16
+ */
17
+ export declare type ImageTypeEnum = 'imagebitmap' | 'image' | 'data';
18
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/category/image/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,aAAa,GAAG;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS,GAAG,WAAW,GAAG,OAAO,KAAK,GAAG,aAAa,CAAC;AAEnE;;GAEG;AACH,oBAAY,aAAa,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=image.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"gis.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"image.js"}
@@ -1,39 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertMeshToColumnarTable = exports.convertMesh = void 0;
4
- /**
5
- * Convert a mesh to a specific shape
6
- */
7
- function convertMesh(mesh, shape, options) {
8
- switch (shape || 'mesh') {
9
- case 'mesh':
10
- return mesh;
11
- case 'columnar-table':
12
- return convertMeshToColumnarTable(mesh);
13
- // case 'arrow-table':
14
- // return {
15
- // shape: 'arrow-table',
16
- // data: convertMeshToArrowTable(mesh)
17
- // };
18
- default:
19
- throw new Error(`Unsupported shape ${options?.shape}`);
20
- }
1
+ import { convertMeshToArrowTable } from './mesh-to-arrow-table';
2
+ export function convertMesh(mesh, shape, options) {
3
+ switch (shape || 'mesh') {
4
+ case 'mesh':
5
+ return mesh;
6
+
7
+ case 'columnar-table':
8
+ return convertMeshToColumnarTable(mesh);
9
+
10
+ case 'arrow-table':
11
+ return {
12
+ shape: 'arrow-table',
13
+ data: convertMeshToArrowTable(mesh)
14
+ };
15
+
16
+ default:
17
+ throw new Error("Unsupported shape ".concat(options === null || options === void 0 ? void 0 : options.shape));
18
+ }
21
19
  }
22
- exports.convertMesh = convertMesh;
23
- /**
24
- * Convert a loaders.gl Mesh to a Columnar Table
25
- * @param mesh
26
- * @returns
27
- */
28
- function convertMeshToColumnarTable(mesh) {
29
- const columns = {};
30
- for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
31
- columns[columnName] = attribute.value;
32
- }
33
- return {
34
- shape: 'columnar-table',
35
- schema: mesh.schema,
36
- data: columns
37
- };
20
+ export function convertMeshToColumnarTable(mesh) {
21
+ const columns = {};
22
+
23
+ for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
24
+ columns[columnName] = attribute.value;
25
+ }
26
+
27
+ return {
28
+ shape: 'columnar-table',
29
+ schema: mesh.schema,
30
+ data: columns
31
+ };
38
32
  }
39
- exports.convertMeshToColumnarTable = convertMeshToColumnarTable;
33
+ //# sourceMappingURL=convert-mesh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/category/mesh/convert-mesh.ts"],"names":["convertMeshToArrowTable","convertMesh","mesh","shape","options","convertMeshToColumnarTable","data","Error","columns","columnName","attribute","Object","entries","attributes","value","schema"],"mappings":"AAEA,SAAQA,uBAAR,QAAsC,uBAAtC;AAOA,OAAO,SAASC,WAAT,CACLC,IADK,EAELC,KAFK,EAGLC,OAHK,EAI8B;AACnC,UAAQD,KAAK,IAAI,MAAjB;AACE,SAAK,MAAL;AACE,aAAOD,IAAP;;AACF,SAAK,gBAAL;AACE,aAAOG,0BAA0B,CAACH,IAAD,CAAjC;;AACF,SAAK,aAAL;AACE,aAAO;AACLC,QAAAA,KAAK,EAAE,aADF;AAELG,QAAAA,IAAI,EAAEN,uBAAuB,CAACE,IAAD;AAFxB,OAAP;;AAIF;AACE,YAAM,IAAIK,KAAJ,6BAA+BH,OAA/B,aAA+BA,OAA/B,uBAA+BA,OAAO,CAAED,KAAxC,EAAN;AAXJ;AAaD;AAOD,OAAO,SAASE,0BAAT,CAAoCH,IAApC,EAA+D;AACpE,QAAMM,OAAO,GAAG,EAAhB;;AAEA,OAAK,MAAM,CAACC,UAAD,EAAaC,SAAb,CAAX,IAAsCC,MAAM,CAACC,OAAP,CAAeV,IAAI,CAACW,UAApB,CAAtC,EAAuE;AACrEL,IAAAA,OAAO,CAACC,UAAD,CAAP,GAAsBC,SAAS,CAACI,KAAhC;AACD;;AAED,SAAO;AACLX,IAAAA,KAAK,EAAE,gBADF;AAELY,IAAAA,MAAM,EAAEb,IAAI,CAACa,MAFR;AAGLT,IAAAA,IAAI,EAAEE;AAHD,GAAP;AAKD","sourcesContent":["import type {Mesh} from './mesh-types';\nimport type {ColumnarTable, ArrowTable} from '../table/table-types';\nimport {convertMeshToArrowTable} from './mesh-to-arrow-table';\n\ntype TargetShape = 'mesh' | 'columnar-table' | 'arrow-table';\n\n/**\n * Convert a mesh to a specific shape\n */\nexport function convertMesh(\n mesh: Mesh,\n shape: TargetShape,\n options?: any\n): Mesh | ColumnarTable | ArrowTable {\n switch (shape || 'mesh') {\n case 'mesh':\n return mesh;\n case 'columnar-table':\n return convertMeshToColumnarTable(mesh);\n case 'arrow-table':\n return {\n shape: 'arrow-table',\n data: convertMeshToArrowTable(mesh)\n };\n default:\n throw new Error(`Unsupported shape ${options?.shape}`);\n }\n}\n\n/**\n * Convert a loaders.gl Mesh to a Columnar Table\n * @param mesh\n * @returns\n */\nexport function convertMeshToColumnarTable(mesh: Mesh): ColumnarTable {\n const columns = {};\n\n for (const [columnName, attribute] of Object.entries(mesh.attributes)) {\n columns[columnName] = attribute.value;\n }\n\n return {\n shape: 'columnar-table',\n schema: mesh.schema,\n data: columns\n };\n}\n"],"file":"convert-mesh.js"}
@@ -1,62 +1,42 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeMeshAttributeMetadata = exports.deduceMeshField = exports.deduceMeshSchema = void 0;
4
- const schema_1 = require("../../lib/schema/schema");
5
- const arrow_like_type_utils_1 = require("../../lib/arrow/arrow-like-type-utils");
6
- /**
7
- * Create a schema for mesh attributes data
8
- * @param attributes
9
- * @param metadata
10
- * @returns
11
- */
12
- function deduceMeshSchema(attributes, metadata) {
13
- const fields = deduceMeshFields(attributes);
14
- return new schema_1.Schema(fields, metadata);
1
+ import { Schema, Field, FixedSizeList } from '../../lib/schema/schema';
2
+ import { getArrowTypeFromTypedArray } from '../../lib/arrow/arrow-like-type-utils';
3
+ export function deduceMeshSchema(attributes, metadata) {
4
+ const fields = deduceMeshFields(attributes);
5
+ return new Schema(fields, metadata);
15
6
  }
16
- 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(attributeName, attribute, optionalMetadata) {
25
- const type = (0, arrow_like_type_utils_1.getArrowTypeFromTypedArray)(attribute.value);
26
- const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
27
- const field = new schema_1.Field(attributeName, new schema_1.FixedSizeList(attribute.size, new schema_1.Field('value', type)), false, metadata);
28
- return field;
7
+ export function deduceMeshField(attributeName, attribute, optionalMetadata) {
8
+ const type = getArrowTypeFromTypedArray(attribute.value);
9
+ const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
10
+ const field = new Field(attributeName, new FixedSizeList(attribute.size, new Field('value', type)), false, metadata);
11
+ return field;
29
12
  }
30
- exports.deduceMeshField = deduceMeshField;
31
- /**
32
- * Create fields array for mesh attributes
33
- * @param attributes
34
- * @returns
35
- */
13
+
36
14
  function deduceMeshFields(attributes) {
37
- const fields = [];
38
- for (const attributeName in attributes) {
39
- const attribute = attributes[attributeName];
40
- fields.push(deduceMeshField(attributeName, attribute));
41
- }
42
- return fields;
15
+ const fields = [];
16
+
17
+ for (const attributeName in attributes) {
18
+ const attribute = attributes[attributeName];
19
+ fields.push(deduceMeshField(attributeName, attribute));
20
+ }
21
+
22
+ return fields;
43
23
  }
44
- /**
45
- * Make metadata by mesh attribute properties
46
- * @param attribute
47
- * @returns
48
- */
49
- function makeMeshAttributeMetadata(attribute) {
50
- const result = new Map();
51
- if ('byteOffset' in attribute) {
52
- result.set('byteOffset', attribute.byteOffset.toString(10));
53
- }
54
- if ('byteStride' in attribute) {
55
- result.set('byteStride', attribute.byteStride.toString(10));
56
- }
57
- if ('normalized' in attribute) {
58
- result.set('normalized', attribute.normalized.toString());
59
- }
60
- return result;
24
+
25
+ export function makeMeshAttributeMetadata(attribute) {
26
+ const result = new Map();
27
+
28
+ if ('byteOffset' in attribute) {
29
+ result.set('byteOffset', attribute.byteOffset.toString(10));
30
+ }
31
+
32
+ if ('byteStride' in attribute) {
33
+ result.set('byteStride', attribute.byteStride.toString(10));
34
+ }
35
+
36
+ if ('normalized' in attribute) {
37
+ result.set('normalized', attribute.normalized.toString());
38
+ }
39
+
40
+ return result;
61
41
  }
62
- exports.makeMeshAttributeMetadata = makeMeshAttributeMetadata;
42
+ //# sourceMappingURL=deduce-mesh-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/category/mesh/deduce-mesh-schema.ts"],"names":["Schema","Field","FixedSizeList","getArrowTypeFromTypedArray","deduceMeshSchema","attributes","metadata","fields","deduceMeshFields","deduceMeshField","attributeName","attribute","optionalMetadata","type","value","makeMeshAttributeMetadata","field","size","push","result","Map","set","byteOffset","toString","byteStride","normalized"],"mappings":"AACA,SAAQA,MAAR,EAAgBC,KAAhB,EAAuBC,aAAvB,QAA2C,yBAA3C;AACA,SAAQC,0BAAR,QAAyC,uCAAzC;AAQA,OAAO,SAASC,gBAAT,CACLC,UADK,EAELC,QAFK,EAGG;AACR,QAAMC,MAAM,GAAGC,gBAAgB,CAACH,UAAD,CAA/B;AACA,SAAO,IAAIL,MAAJ,CAAWO,MAAX,EAAmBD,QAAnB,CAAP;AACD;AASD,OAAO,SAASG,eAAT,CACLC,aADK,EAELC,SAFK,EAGLC,gBAHK,EAIE;AACP,QAAMC,IAAI,GAAGV,0BAA0B,CAACQ,SAAS,CAACG,KAAX,CAAvC;AACA,QAAMR,QAAQ,GAAGM,gBAAgB,GAAGA,gBAAH,GAAsBG,yBAAyB,CAACJ,SAAD,CAAhF;AACA,QAAMK,KAAK,GAAG,IAAIf,KAAJ,CACZS,aADY,EAEZ,IAAIR,aAAJ,CAAkBS,SAAS,CAACM,IAA5B,EAAkC,IAAIhB,KAAJ,CAAU,OAAV,EAAmBY,IAAnB,CAAlC,CAFY,EAGZ,KAHY,EAIZP,QAJY,CAAd;AAMA,SAAOU,KAAP;AACD;;AAOD,SAASR,gBAAT,CAA0BH,UAA1B,EAA+D;AAC7D,QAAME,MAAe,GAAG,EAAxB;;AACA,OAAK,MAAMG,aAAX,IAA4BL,UAA5B,EAAwC;AACtC,UAAMM,SAAwB,GAAGN,UAAU,CAACK,aAAD,CAA3C;AACAH,IAAAA,MAAM,CAACW,IAAP,CAAYT,eAAe,CAACC,aAAD,EAAgBC,SAAhB,CAA3B;AACD;;AACD,SAAOJ,MAAP;AACD;;AAOD,OAAO,SAASQ,yBAAT,CAAmCJ,SAAnC,EAAkF;AACvF,QAAMQ,MAAM,GAAG,IAAIC,GAAJ,EAAf;;AACA,MAAI,gBAAgBT,SAApB,EAA+B;AAC7BQ,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBV,SAAS,CAACW,UAAV,CAAsBC,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBZ,SAApB,EAA+B;AAC7BQ,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBV,SAAS,CAACa,UAAV,CAAsBD,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBZ,SAApB,EAA+B;AAC7BQ,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBV,SAAS,CAACc,UAAV,CAAsBF,QAAtB,EAAzB;AACD;;AACD,SAAOJ,MAAP;AACD","sourcesContent":["import {MeshAttribute, MeshAttributes} from './mesh-types';\nimport {Schema, Field, FixedSizeList} from '../../lib/schema/schema';\nimport {getArrowTypeFromTypedArray} from '../../lib/arrow/arrow-like-type-utils';\n\n/**\n * Create a schema for mesh attributes data\n * @param attributes\n * @param metadata\n * @returns\n */\nexport function deduceMeshSchema(\n attributes: MeshAttributes,\n metadata?: Map<string, string>\n): Schema {\n const fields = deduceMeshFields(attributes);\n return new Schema(fields, metadata);\n}\n\n/**\n * Create arrow-like schema field for mesh attribute\n * @param attributeName\n * @param attribute\n * @param optionalMetadata\n * @returns\n */\nexport function deduceMeshField(\n attributeName: string,\n attribute: MeshAttribute,\n optionalMetadata?: Map<string, string>\n): Field {\n const type = getArrowTypeFromTypedArray(attribute.value);\n const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);\n const field = new Field(\n attributeName,\n new FixedSizeList(attribute.size, new Field('value', type)),\n false,\n metadata\n );\n return field;\n}\n\n/**\n * Create fields array for mesh attributes\n * @param attributes\n * @returns\n */\nfunction deduceMeshFields(attributes: MeshAttributes): Field[] {\n const fields: Field[] = [];\n for (const attributeName in attributes) {\n const attribute: MeshAttribute = attributes[attributeName];\n fields.push(deduceMeshField(attributeName, attribute));\n }\n return fields;\n}\n\n/**\n * Make metadata by mesh attribute properties\n * @param attribute\n * @returns\n */\nexport function makeMeshAttributeMetadata(attribute: MeshAttribute): Map<string, string> {\n const result = new Map();\n if ('byteOffset' in attribute) {\n result.set('byteOffset', attribute.byteOffset!.toString(10));\n }\n if ('byteStride' in attribute) {\n result.set('byteStride', attribute.byteStride!.toString(10));\n }\n if ('normalized' in attribute) {\n result.set('normalized', attribute.normalized!.toString());\n }\n return result;\n}\n"],"file":"deduce-mesh-schema.js"}
@@ -1 +1,11 @@
1
+ import { Table } from 'apache-arrow/Arrow.dom';
2
+ import type { Mesh } from './mesh-types';
3
+ /**
4
+ * * Convert a loaders.gl Mesh to an Apache Arrow Table
5
+ * @param mesh
6
+ * @param metadata
7
+ * @param batchSize
8
+ * @returns
9
+ */
10
+ export declare function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table;
1
11
  //# sourceMappingURL=mesh-to-arrow-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mesh-to-arrow-table.d.ts","sourceRoot":"","sources":["../../../src/category/mesh/mesh-to-arrow-table.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"mesh-to-arrow-table.d.ts","sourceRoot":"","sources":["../../../src/category/mesh/mesh-to-arrow-table.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAON,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAGvC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAmB7E"}
@@ -1,32 +1,18 @@
1
- "use strict";
2
- /*
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 '../../lib/arrow/arrow-type-utils.js';
14
- import type {Mesh} from './mesh-types.js';
15
- import {makeMeshAttributeMetadata} from './deduce-mesh-schema.js';
1
+ import { Table, Schema, RecordBatch, FixedSizeList, Field, Data, FixedSizeListVector } from 'apache-arrow/Arrow.dom';
2
+ import { getArrowType, getArrowVector } from '../../lib/arrow/arrow-type-utils';
3
+ import { makeMeshAttributeMetadata } from './deduce-mesh-schema';
4
+ export function convertMeshToArrowTable(mesh, batchSize) {
5
+ var _mesh$schema;
6
+
7
+ const vectors = [];
8
+ const fields = [];
16
9
 
17
- /**
18
- * * Convert a loaders.gl Mesh to an Apache Arrow Table
19
- * @param mesh
20
- * @param metadata
21
- * @param batchSize
22
- * @returns
23
- *
24
- export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {
25
- const vectors: AbstractVector[] = [];
26
- const fields: Field[] = [];
27
10
  for (const attributeKey in mesh.attributes) {
28
11
  const attribute = mesh.attributes[attributeKey];
29
- const {value, size = 1} = attribute;
12
+ const {
13
+ value,
14
+ size = 1
15
+ } = attribute;
30
16
  const type = getArrowType(value);
31
17
  const vector = getArrowVector(value);
32
18
  const listType = new FixedSizeList(size, new Field('value', type));
@@ -36,9 +22,10 @@ export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {
36
22
  vectors.push(listVector);
37
23
  fields.push(field);
38
24
  }
39
- const schema = new Schema(fields, mesh?.schema?.metadata || new Map<string, string>());
25
+
26
+ const schema = new Schema(fields, (mesh === null || mesh === void 0 ? void 0 : (_mesh$schema = mesh.schema) === null || _mesh$schema === void 0 ? void 0 : _mesh$schema.metadata) || new Map());
40
27
  const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
41
28
  const table = new Table(schema, recordBatch);
42
29
  return table;
43
30
  }
44
- */
31
+ //# sourceMappingURL=mesh-to-arrow-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/category/mesh/mesh-to-arrow-table.ts"],"names":["Table","Schema","RecordBatch","FixedSizeList","Field","Data","FixedSizeListVector","getArrowType","getArrowVector","makeMeshAttributeMetadata","convertMeshToArrowTable","mesh","batchSize","vectors","fields","attributeKey","attributes","attribute","value","size","type","vector","listType","field","data","length","undefined","listVector","push","schema","metadata","Map","recordBatch","table"],"mappings":"AAAA,SACEA,KADF,EAEEC,MAFF,EAGEC,WAHF,EAIEC,aAJF,EAKEC,KALF,EAMEC,IANF,EAOEC,mBAPF,QAQO,wBARP;AAUA,SAAQC,YAAR,EAAsBC,cAAtB,QAA2C,kCAA3C;AAEA,SAAQC,yBAAR,QAAwC,sBAAxC;AASA,OAAO,SAASC,uBAAT,CAAiCC,IAAjC,EAA6CC,SAA7C,EAAwE;AAAA;;AAC7E,QAAMC,OAAyB,GAAG,EAAlC;AACA,QAAMC,MAAe,GAAG,EAAxB;;AACA,OAAK,MAAMC,YAAX,IAA2BJ,IAAI,CAACK,UAAhC,EAA4C;AAC1C,UAAMC,SAAS,GAAGN,IAAI,CAACK,UAAL,CAAgBD,YAAhB,CAAlB;AACA,UAAM;AAACG,MAAAA,KAAD;AAAQC,MAAAA,IAAI,GAAG;AAAf,QAAoBF,SAA1B;AACA,UAAMG,IAAI,GAAGb,YAAY,CAACW,KAAD,CAAzB;AACA,UAAMG,MAAM,GAAGb,cAAc,CAACU,KAAD,CAA7B;AACA,UAAMI,QAAQ,GAAG,IAAInB,aAAJ,CAAkBgB,IAAlB,EAAwB,IAAIf,KAAJ,CAAU,OAAV,EAAmBgB,IAAnB,CAAxB,CAAjB;AACA,UAAMG,KAAK,GAAG,IAAInB,KAAJ,CAAUW,YAAV,EAAwBO,QAAxB,EAAkC,KAAlC,EAAyCb,yBAAyB,CAACQ,SAAD,CAAlE,CAAd;AACA,UAAMO,IAAI,GAAG,IAAInB,IAAJ,CAASiB,QAAT,EAAmB,CAAnB,EAAsBJ,KAAK,CAACO,MAAN,GAAeN,IAArC,EAA2C,CAA3C,EAA8CO,SAA9C,EAAyD,CAACL,MAAD,CAAzD,CAAb;AACA,UAAMM,UAAU,GAAG,IAAIrB,mBAAJ,CAAwBkB,IAAxB,CAAnB;AACAX,IAAAA,OAAO,CAACe,IAAR,CAAaD,UAAb;AACAb,IAAAA,MAAM,CAACc,IAAP,CAAYL,KAAZ;AACD;;AACD,QAAMM,MAAM,GAAG,IAAI5B,MAAJ,CAAWa,MAAX,EAAmB,CAAAH,IAAI,SAAJ,IAAAA,IAAI,WAAJ,4BAAAA,IAAI,CAAEkB,MAAN,8DAAcC,QAAd,KAA0B,IAAIC,GAAJ,EAA7C,CAAf;AACA,QAAMC,WAAW,GAAG,IAAI9B,WAAJ,CAAgB2B,MAAhB,EAAwBhB,OAAO,CAAC,CAAD,CAAP,CAAWY,MAAnC,EAA2CZ,OAA3C,CAApB;AACA,QAAMoB,KAAK,GAAG,IAAIjC,KAAJ,CAAU6B,MAAV,EAAkBG,WAAlB,CAAd;AACA,SAAOC,KAAP;AACD","sourcesContent":["import {\n Table,\n Schema,\n RecordBatch,\n FixedSizeList,\n Field,\n Data,\n FixedSizeListVector\n} from 'apache-arrow/Arrow.dom';\nimport {AbstractVector} from 'apache-arrow/vector';\nimport {getArrowType, getArrowVector} from '../../lib/arrow/arrow-type-utils';\nimport type {Mesh} from './mesh-types';\nimport {makeMeshAttributeMetadata} from './deduce-mesh-schema';\n\n/**\n * * Convert a loaders.gl Mesh to an Apache Arrow Table\n * @param mesh\n * @param metadata\n * @param batchSize\n * @returns\n */\nexport function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {\n const vectors: AbstractVector[] = [];\n const fields: Field[] = [];\n for (const attributeKey in mesh.attributes) {\n const attribute = mesh.attributes[attributeKey];\n const {value, size = 1} = attribute;\n const type = getArrowType(value);\n const vector = getArrowVector(value);\n const listType = new FixedSizeList(size, new Field('value', type));\n const field = new Field(attributeKey, listType, false, makeMeshAttributeMetadata(attribute));\n const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);\n const listVector = new FixedSizeListVector(data);\n vectors.push(listVector);\n fields.push(field);\n }\n const schema = new Schema(fields, mesh?.schema?.metadata || new Map<string, string>());\n const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);\n const table = new Table(schema, recordBatch);\n return table;\n}\n"],"file":"mesh-to-arrow-table.js"}
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=mesh-types.js.map
@@ -1,51 +1,38 @@
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
- }
1
+ export function getMeshSize(attributes) {
2
+ let size = 0;
3
+
4
+ for (const attributeName in attributes) {
5
+ const attribute = attributes[attributeName];
6
+
7
+ if (ArrayBuffer.isView(attribute)) {
8
+ size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
16
9
  }
17
- return size;
10
+ }
11
+
12
+ return size;
18
13
  }
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
- ];
14
+ export function getMeshBoundingBox(attributes) {
15
+ let minX = Infinity;
16
+ let minY = Infinity;
17
+ let minZ = Infinity;
18
+ let maxX = -Infinity;
19
+ let maxY = -Infinity;
20
+ let maxZ = -Infinity;
21
+ const positions = attributes.POSITION ? attributes.POSITION.value : [];
22
+ const len = positions && positions.length;
23
+
24
+ for (let i = 0; i < len; i += 3) {
25
+ const x = positions[i];
26
+ const y = positions[i + 1];
27
+ const z = positions[i + 2];
28
+ minX = x < minX ? x : minX;
29
+ minY = y < minY ? y : minY;
30
+ minZ = z < minZ ? z : minZ;
31
+ maxX = x > maxX ? x : maxX;
32
+ maxY = y > maxY ? y : maxY;
33
+ maxZ = z > maxZ ? z : maxZ;
34
+ }
35
+
36
+ return [[minX, minY, minZ], [maxX, maxY, maxZ]];
50
37
  }
51
- exports.getMeshBoundingBox = getMeshBoundingBox;
38
+ //# sourceMappingURL=mesh-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/category/mesh/mesh-utils.ts"],"names":["getMeshSize","attributes","size","attributeName","attribute","ArrayBuffer","isView","byteLength","BYTES_PER_ELEMENT","getMeshBoundingBox","minX","Infinity","minY","minZ","maxX","maxY","maxZ","positions","POSITION","value","len","length","i","x","y","z"],"mappings":"AAiBA,OAAO,SAASA,WAAT,CAAqBC,UAArB,EAAsD;AAC3D,MAAIC,IAAI,GAAG,CAAX;;AACA,OAAK,MAAMC,aAAX,IAA4BF,UAA5B,EAAwC;AACtC,UAAMG,SAAS,GAAGH,UAAU,CAACE,aAAD,CAA5B;;AACA,QAAIE,WAAW,CAACC,MAAZ,CAAmBF,SAAnB,CAAJ,EAAmC;AAEjCF,MAAAA,IAAI,IAAIE,SAAS,CAACG,UAAV,GAAuBH,SAAS,CAACI,iBAAzC;AACD;AACF;;AACD,SAAON,IAAP;AACD;AAQD,OAAO,SAASO,kBAAT,CAA4BR,UAA5B,EAAqE;AAC1E,MAAIS,IAAI,GAAGC,QAAX;AACA,MAAIC,IAAI,GAAGD,QAAX;AACA,MAAIE,IAAI,GAAGF,QAAX;AACA,MAAIG,IAAI,GAAG,CAACH,QAAZ;AACA,MAAII,IAAI,GAAG,CAACJ,QAAZ;AACA,MAAIK,IAAI,GAAG,CAACL,QAAZ;AAEA,QAAMM,SAAS,GAAGhB,UAAU,CAACiB,QAAX,GAAsBjB,UAAU,CAACiB,QAAX,CAAoBC,KAA1C,GAAkD,EAApE;AACA,QAAMC,GAAG,GAAGH,SAAS,IAAIA,SAAS,CAACI,MAAnC;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,GAApB,EAAyBE,CAAC,IAAI,CAA9B,EAAiC;AAC/B,UAAMC,CAAC,GAAGN,SAAS,CAACK,CAAD,CAAnB;AACA,UAAME,CAAC,GAAGP,SAAS,CAACK,CAAC,GAAG,CAAL,CAAnB;AACA,UAAMG,CAAC,GAAGR,SAAS,CAACK,CAAC,GAAG,CAAL,CAAnB;AAEAZ,IAAAA,IAAI,GAAGa,CAAC,GAAGb,IAAJ,GAAWa,CAAX,GAAeb,IAAtB;AACAE,IAAAA,IAAI,GAAGY,CAAC,GAAGZ,IAAJ,GAAWY,CAAX,GAAeZ,IAAtB;AACAC,IAAAA,IAAI,GAAGY,CAAC,GAAGZ,IAAJ,GAAWY,CAAX,GAAeZ,IAAtB;AAEAC,IAAAA,IAAI,GAAGS,CAAC,GAAGT,IAAJ,GAAWS,CAAX,GAAeT,IAAtB;AACAC,IAAAA,IAAI,GAAGS,CAAC,GAAGT,IAAJ,GAAWS,CAAX,GAAeT,IAAtB;AACAC,IAAAA,IAAI,GAAGS,CAAC,GAAGT,IAAJ,GAAWS,CAAX,GAAeT,IAAtB;AACD;;AACD,SAAO,CACL,CAACN,IAAD,EAAOE,IAAP,EAAaC,IAAb,CADK,EAEL,CAACC,IAAD,EAAOC,IAAP,EAAaC,IAAb,CAFK,CAAP;AAID","sourcesContent":["// Mesh category utilities\n// TODO - move to mesh category module, or to math.gl/geometry module\nimport {TypedArray} from '../../types';\nimport {MeshAttributes} from './mesh-types';\n\ntype TypedArrays = {[key: string]: TypedArray};\n\n/**\n * Holds an axis aligned bounding box\n * TODO - make sure AxisAlignedBoundingBox in math.gl/culling understands this format (or change this format)\n */\ntype BoundingBox = [[number, number, number], [number, number, number]];\n\n/**\n * Get number of vertices in mesh\n * @param attributes\n */\nexport function getMeshSize(attributes: TypedArrays): number {\n let size = 0;\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n if (ArrayBuffer.isView(attribute)) {\n // @ts-ignore DataView doesn't have BYTES_PER_ELEMENT\n size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;\n }\n }\n return size;\n}\n\n/**\n * Get the (axis aligned) bounding box of a mesh\n * @param attributes\n * @returns array of two vectors representing the axis aligned bounding box\n */\n// eslint-disable-next-line complexity\nexport function getMeshBoundingBox(attributes: MeshAttributes): BoundingBox {\n let minX = Infinity;\n let minY = Infinity;\n let minZ = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let maxZ = -Infinity;\n\n const positions = attributes.POSITION ? attributes.POSITION.value : [];\n const len = positions && positions.length;\n\n for (let i = 0; i < len; i += 3) {\n const x = positions[i];\n const y = positions[i + 1];\n const z = positions[i + 2];\n\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n minZ = z < minZ ? z : minZ;\n\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n maxZ = z > maxZ ? z : maxZ;\n }\n return [\n [minX, minY, minZ],\n [maxX, maxY, maxZ]\n ];\n}\n"],"file":"mesh-utils.js"}
@@ -1,106 +1,51 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deduceTableSchema = void 0;
4
- // const TYPED_ARRAY_TO_TYPE = {
5
- // Int8Array: new Int8(),
6
- // Int16Array: new Int16(),
7
- // Int32Array: new Int32(),
8
- // Uint8Array: new Uint8(),
9
- // Uint8ClampedArray: new Uint8(),
10
- // Uint16Array: new Uint16(),
11
- // Uint32Array: new Uint32(),
12
- // Float32Array: new Float32(),
13
- // Float64Array: new Float64()
14
- // };
15
- // if (typeof BigInt64Array !== 'undefined') {
16
- // TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();
17
- // TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();
18
- // }
19
- /**
20
- * SCHEMA SUPPORT - AUTODEDUCTION
21
- * @param {*} table
22
- * @param {*} schema
23
- * @returns
24
- */
25
- function deduceTableSchema(table, schema) {
26
- const deducedSchema = Array.isArray(table)
27
- ? deduceSchemaForRowTable(table)
28
- : deduceSchemaForColumnarTable(table);
29
- // Deduced schema will fill in missing info from partial options.schema, if provided
30
- return Object.assign(deducedSchema, schema);
1
+ export function deduceTableSchema(table, schema) {
2
+ const deducedSchema = Array.isArray(table) ? deduceSchemaForRowTable(table) : deduceSchemaForColumnarTable(table);
3
+ return Object.assign(deducedSchema, schema);
31
4
  }
32
- exports.deduceTableSchema = deduceTableSchema;
5
+
33
6
  function deduceSchemaForColumnarTable(columnarTable) {
34
- const schema = {};
35
- for (const field in columnarTable) {
36
- const column = columnarTable[field];
37
- // Check if column is typed, if so we are done
38
- if (ArrayBuffer.isView(column)) {
39
- schema[field] = column.constructor;
40
- // else we need data
41
- }
42
- else if (column.length) {
43
- const value = column[0];
44
- schema[field] = deduceTypeFromValue(value);
45
- // TODO - support nested schemas?
46
- }
47
- // else we mark as present but unknow
48
- schema[field] = schema[field] || null;
49
- }
50
- return schema;
51
- }
52
- function deduceSchemaForRowTable(rowTable) {
53
- const schema = {};
54
- if (rowTable.length) {
55
- const row = rowTable[0];
56
- // TODO - Could look at additional rows if nulls in first row
57
- for (const field in row) {
58
- const value = row[field];
59
- schema[field] = deduceTypeFromValue(value);
60
- }
61
- }
62
- return schema;
63
- }
64
- function deduceTypeFromValue(value) {
65
- if (value instanceof Date) {
66
- return Date;
67
- }
68
- else if (value instanceof Number) {
69
- return Float32Array;
70
- }
71
- else if (typeof value === 'string') {
72
- return String;
7
+ const schema = {};
8
+
9
+ for (const field in columnarTable) {
10
+ const column = columnarTable[field];
11
+
12
+ if (ArrayBuffer.isView(column)) {
13
+ schema[field] = column.constructor;
14
+ } else if (column.length) {
15
+ const value = column[0];
16
+ schema[field] = deduceTypeFromValue(value);
73
17
  }
74
- return null;
18
+
19
+ schema[field] = schema[field] || null;
20
+ }
21
+
22
+ return schema;
75
23
  }
76
- /*
77
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
78
- function deduceSchema(rows) {
79
- const row = rows[0];
80
24
 
25
+ function deduceSchemaForRowTable(rowTable) {
81
26
  const schema = {};
82
- let i = 0;
83
- for (const columnName in row) {
84
- const value = row[columnName];
85
- switch (typeof value) {
86
- case 'number':
87
- case 'boolean':
88
- // TODO - booleans could be handled differently...
89
- schema[columnName] = {name: String(columnName), index: i, type: Float32Array};
90
- break;
91
27
 
92
- case 'object':
93
- schema[columnName] = {name: String(columnName), index: i, type: Array};
94
- break;
28
+ if (rowTable.length) {
29
+ const row = rowTable[0];
95
30
 
96
- case 'string':
97
- default:
98
- schema[columnName] = {name: String(columnName), index: i, type: Array};
99
- // We currently only handle numeric rows
100
- // TODO we could offer a function to map strings to numbers?
31
+ for (const field in row) {
32
+ const value = row[field];
33
+ schema[field] = deduceTypeFromValue(value);
101
34
  }
102
- i++;
103
35
  }
36
+
104
37
  return schema;
105
38
  }
106
- */
39
+
40
+ function deduceTypeFromValue(value) {
41
+ if (value instanceof Date) {
42
+ return Date;
43
+ } else if (value instanceof Number) {
44
+ return Float32Array;
45
+ } else if (typeof value === 'string') {
46
+ return String;
47
+ }
48
+
49
+ return null;
50
+ }
51
+ //# sourceMappingURL=deduce-table-schema.js.map