@loaders.gl/schema 3.1.0-beta.5 → 3.1.1

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 (42) hide show
  1. package/dist/category/gis.d.ts +49 -0
  2. package/dist/category/gis.d.ts.map +1 -1
  3. package/dist/es5/bundle.js +1 -1
  4. package/dist/es5/bundle.js.map +1 -1
  5. package/dist/es5/category/mesh/convert-mesh.js +10 -2
  6. package/dist/es5/category/mesh/convert-mesh.js.map +1 -1
  7. package/dist/es5/category/mesh/deduce-mesh-schema.js +8 -8
  8. package/dist/es5/category/mesh/deduce-mesh-schema.js.map +1 -1
  9. package/dist/es5/category/mesh/mesh-utils.js +16 -16
  10. package/dist/es5/category/mesh/mesh-utils.js.map +1 -1
  11. package/dist/es5/category/table/deduce-table-schema.js +9 -9
  12. package/dist/es5/category/table/deduce-table-schema.js.map +1 -1
  13. package/dist/es5/index.js +52 -52
  14. package/dist/es5/index.js.map +1 -1
  15. package/dist/es5/lib/arrow/get-type-info.js +3 -3
  16. package/dist/es5/lib/arrow/get-type-info.js.map +1 -1
  17. package/dist/es5/lib/batches/base-table-batch-aggregator.js +53 -42
  18. package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +1 -1
  19. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +90 -71
  20. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +1 -1
  21. package/dist/es5/lib/batches/row-table-batch-aggregator.js +70 -59
  22. package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +1 -1
  23. package/dist/es5/lib/batches/table-batch-builder.js +133 -113
  24. package/dist/es5/lib/batches/table-batch-builder.js.map +1 -1
  25. package/dist/es5/lib/schema/impl/enum.js +1 -1
  26. package/dist/es5/lib/schema/impl/field.js +32 -19
  27. package/dist/es5/lib/schema/impl/field.js.map +1 -1
  28. package/dist/es5/lib/schema/impl/schema.js +119 -54
  29. package/dist/es5/lib/schema/impl/schema.js.map +1 -1
  30. package/dist/es5/lib/schema/impl/type.js +728 -395
  31. package/dist/es5/lib/schema/impl/type.js.map +1 -1
  32. package/dist/es5/lib/schema/schema.js +37 -37
  33. package/dist/es5/lib/utils/async-queue.js +164 -81
  34. package/dist/es5/lib/utils/async-queue.js.map +1 -1
  35. package/dist/es5/lib/utils/row-utils.js +4 -4
  36. package/dist/es5/lib/utils/row-utils.js.map +1 -1
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/package.json +2 -2
  41. package/src/category/gis.ts +60 -0
  42. package/src/index.ts +13 -0
@@ -1,6 +1,54 @@
1
1
  import type { TypedArray } from '../types';
2
+ import type { Feature, Geometry, Point, LineString, Polygon } from 'geojson';
2
3
  export type { GeoJSON, Feature, Geometry, Position, GeoJsonProperties } from 'geojson';
3
4
  export type { Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon } from 'geojson';
5
+ export declare type GeojsonGeometryInfo = {
6
+ coordLength: number;
7
+ pointPositionsCount: number;
8
+ pointFeaturesCount: number;
9
+ linePositionsCount: number;
10
+ linePathsCount: number;
11
+ lineFeaturesCount: number;
12
+ polygonPositionsCount: number;
13
+ polygonObjectsCount: number;
14
+ polygonRingsCount: number;
15
+ polygonFeaturesCount: number;
16
+ };
17
+ export declare type FlatGeometryType = 'Point' | 'LineString' | 'Polygon';
18
+ declare type RemoveCoordinatesField<Type> = {
19
+ [Property in keyof Type as Exclude<Property, 'coordinates'>]: Type[Property];
20
+ };
21
+ /**
22
+ * Generic flat geometry data storage type
23
+ */
24
+ export declare type FlatIndexedGeometry = {
25
+ data: number[];
26
+ indices: number[];
27
+ };
28
+ /**
29
+ * GeoJSON (Multi)Point geometry with coordinate data flattened into `data` array and indexed by `indices`
30
+ */
31
+ export declare type FlatPoint = RemoveCoordinatesField<Point> & FlatIndexedGeometry;
32
+ /**
33
+ * GeoJSON (Multi)LineString geometry with coordinate data flattened into `data` array and indexed by `indices`
34
+ */
35
+ export declare type FlatLineString = RemoveCoordinatesField<LineString> & FlatIndexedGeometry;
36
+ /**
37
+ * GeoJSON (Multi)Polygon geometry with coordinate data flattened into `data` array and indexed by 2D `indices`
38
+ */
39
+ export declare type FlatPolygon = RemoveCoordinatesField<Polygon> & {
40
+ data: number[];
41
+ indices: number[][];
42
+ areas: number[][];
43
+ };
44
+ export declare type FlatGeometry = FlatPoint | FlatLineString | FlatPolygon;
45
+ declare type FlattenGeometry<Type> = {
46
+ [Property in keyof Type]: Type[Property] extends Geometry ? FlatGeometry : Type[Property];
47
+ };
48
+ /**
49
+ * GeoJSON Feature with Geometry replaced by FlatGeometry
50
+ */
51
+ export declare type FlatFeature = FlattenGeometry<Feature>;
4
52
  export declare type BinaryAttribute = {
5
53
  value: TypedArray;
6
54
  size: number;
@@ -28,6 +76,7 @@ export declare type BinaryPolygonGeometry = {
28
76
  positions: BinaryAttribute;
29
77
  polygonIndices: BinaryAttribute;
30
78
  primitivePolygonIndices: BinaryAttribute;
79
+ triangles?: BinaryAttribute;
31
80
  };
32
81
  export declare type BinaryProperties = {
33
82
  featureIds: BinaryAttribute;
@@ -1 +1 @@
1
- {"version":3,"file":"gis.d.ts","sourceRoot":"","sources":["../../src/category/gis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAKzC,YAAY,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAErF,YAAY,EAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AAInG,oBAAY,eAAe,GAAG;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC;AAChE,oBAAY,kBAAkB,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;AAEpE,aAAK,YAAY,GAAG;IAAC,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e,CAAC;IACzC,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,UAAU,EAAE,eAAe,CAAC;IAC5B,gBAAgB,EAAE,eAAe,CAAC;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,oBAAY,mBAAmB,GAAG,mBAAmB,GAAG,gBAAgB,CAAC;AACzE,oBAAY,kBAAkB,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AACvE,oBAAY,qBAAqB,GAAG,qBAAqB,GAAG,gBAAgB,CAAC;AAE7E;;GAEG;AACH,oBAAY,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const moduleExports = require('./index');
3
+ var moduleExports = require('./index');
4
4
 
5
5
  globalThis.loaders = globalThis.loaders || {};
6
6
  module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1 +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
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,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,11 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.convertMesh = convertMesh;
7
9
  exports.convertMeshToColumnarTable = convertMeshToColumnarTable;
8
10
 
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+
9
13
  function convertMesh(mesh, shape, options) {
10
14
  switch (shape || 'mesh') {
11
15
  case 'mesh':
@@ -20,9 +24,13 @@ function convertMesh(mesh, shape, options) {
20
24
  }
21
25
 
22
26
  function convertMeshToColumnarTable(mesh) {
23
- const columns = {};
27
+ var columns = {};
28
+
29
+ for (var _i = 0, _Object$entries = Object.entries(mesh.attributes); _i < _Object$entries.length; _i++) {
30
+ var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
31
+ columnName = _Object$entries$_i[0],
32
+ attribute = _Object$entries$_i[1];
24
33
 
25
- for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
26
34
  columns[columnName] = attribute.value;
27
35
  }
28
36
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/category/mesh/convert-mesh.ts"],"names":["convertMesh","mesh","shape","options","convertMeshToColumnarTable","Error","columns","columnName","attribute","Object","entries","attributes","value","schema","data"],"mappings":";;;;;;;;AASO,SAASA,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;;AAMF;AACE,YAAM,IAAII,KAAJ,6BAA+BF,OAA/B,aAA+BA,OAA/B,uBAA+BA,OAAO,CAAED,KAAxC,EAAN;AAXJ;AAaD;;AAOM,SAASE,0BAAT,CAAoCH,IAApC,EAA+D;AACpE,QAAMK,OAAO,GAAG,EAAhB;;AAEA,OAAK,MAAM,CAACC,UAAD,EAAaC,SAAb,CAAX,IAAsCC,MAAM,CAACC,OAAP,CAAeT,IAAI,CAACU,UAApB,CAAtC,EAAuE;AACrEL,IAAAA,OAAO,CAACC,UAAD,CAAP,GAAsBC,SAAS,CAACI,KAAhC;AACD;;AAED,SAAO;AACLV,IAAAA,KAAK,EAAE,gBADF;AAELW,IAAAA,MAAM,EAAEZ,IAAI,CAACY,MAFR;AAGLC,IAAAA,IAAI,EAAER;AAHD,GAAP;AAKD","sourcesContent":["import type {Mesh} from './mesh-types';\nimport type {ColumnarTable, ArrowTable} from '../table/table-types';\n// import {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
+ {"version":3,"sources":["../../../../src/category/mesh/convert-mesh.ts"],"names":["convertMesh","mesh","shape","options","convertMeshToColumnarTable","Error","columns","Object","entries","attributes","columnName","attribute","value","schema","data"],"mappings":";;;;;;;;;;;;AASO,SAASA,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;;AAMF;AACE,YAAM,IAAII,KAAJ,6BAA+BF,OAA/B,aAA+BA,OAA/B,uBAA+BA,OAAO,CAAED,KAAxC,EAAN;AAXJ;AAaD;;AAOM,SAASE,0BAAT,CAAoCH,IAApC,EAA+D;AACpE,MAAMK,OAAO,GAAG,EAAhB;;AAEA,qCAAsCC,MAAM,CAACC,OAAP,CAAeP,IAAI,CAACQ,UAApB,CAAtC,qCAAuE;AAAlE;AAAA,QAAOC,UAAP;AAAA,QAAmBC,SAAnB;;AACHL,IAAAA,OAAO,CAACI,UAAD,CAAP,GAAsBC,SAAS,CAACC,KAAhC;AACD;;AAED,SAAO;AACLV,IAAAA,KAAK,EAAE,gBADF;AAELW,IAAAA,MAAM,EAAEZ,IAAI,CAACY,MAFR;AAGLC,IAAAA,IAAI,EAAER;AAHD,GAAP;AAKD","sourcesContent":["import type {Mesh} from './mesh-types';\nimport type {ColumnarTable, ArrowTable} from '../table/table-types';\n// import {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"}
@@ -12,22 +12,22 @@ var _schema = require("../../lib/schema/schema");
12
12
  var _arrowLikeTypeUtils = require("../../lib/arrow/arrow-like-type-utils");
13
13
 
14
14
  function deduceMeshSchema(attributes, metadata) {
15
- const fields = deduceMeshFields(attributes);
15
+ var fields = deduceMeshFields(attributes);
16
16
  return new _schema.Schema(fields, metadata);
17
17
  }
18
18
 
19
19
  function deduceMeshField(attributeName, attribute, optionalMetadata) {
20
- const type = (0, _arrowLikeTypeUtils.getArrowTypeFromTypedArray)(attribute.value);
21
- const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
22
- const field = new _schema.Field(attributeName, new _schema.FixedSizeList(attribute.size, new _schema.Field('value', type)), false, metadata);
20
+ var type = (0, _arrowLikeTypeUtils.getArrowTypeFromTypedArray)(attribute.value);
21
+ var metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
22
+ var field = new _schema.Field(attributeName, new _schema.FixedSizeList(attribute.size, new _schema.Field('value', type)), false, metadata);
23
23
  return field;
24
24
  }
25
25
 
26
26
  function deduceMeshFields(attributes) {
27
- const fields = [];
27
+ var fields = [];
28
28
 
29
- for (const attributeName in attributes) {
30
- const attribute = attributes[attributeName];
29
+ for (var attributeName in attributes) {
30
+ var attribute = attributes[attributeName];
31
31
  fields.push(deduceMeshField(attributeName, attribute));
32
32
  }
33
33
 
@@ -35,7 +35,7 @@ function deduceMeshFields(attributes) {
35
35
  }
36
36
 
37
37
  function makeMeshAttributeMetadata(attribute) {
38
- const result = new Map();
38
+ var result = new Map();
39
39
 
40
40
  if ('byteOffset' in attribute) {
41
41
  result.set('byteOffset', attribute.byteOffset.toString(10));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/category/mesh/deduce-mesh-schema.ts"],"names":["deduceMeshSchema","attributes","metadata","fields","deduceMeshFields","Schema","deduceMeshField","attributeName","attribute","optionalMetadata","type","value","makeMeshAttributeMetadata","field","Field","FixedSizeList","size","push","result","Map","set","byteOffset","toString","byteStride","normalized"],"mappings":";;;;;;;;;AACA;;AACA;;AAQO,SAASA,gBAAT,CACLC,UADK,EAELC,QAFK,EAGG;AACR,QAAMC,MAAM,GAAGC,gBAAgB,CAACH,UAAD,CAA/B;AACA,SAAO,IAAII,cAAJ,CAAWF,MAAX,EAAmBD,QAAnB,CAAP;AACD;;AASM,SAASI,eAAT,CACLC,aADK,EAELC,SAFK,EAGLC,gBAHK,EAIE;AACP,QAAMC,IAAI,GAAG,oDAA2BF,SAAS,CAACG,KAArC,CAAb;AACA,QAAMT,QAAQ,GAAGO,gBAAgB,GAAGA,gBAAH,GAAsBG,yBAAyB,CAACJ,SAAD,CAAhF;AACA,QAAMK,KAAK,GAAG,IAAIC,aAAJ,CACZP,aADY,EAEZ,IAAIQ,qBAAJ,CAAkBP,SAAS,CAACQ,IAA5B,EAAkC,IAAIF,aAAJ,CAAU,OAAV,EAAmBJ,IAAnB,CAAlC,CAFY,EAGZ,KAHY,EAIZR,QAJY,CAAd;AAMA,SAAOW,KAAP;AACD;;AAOD,SAAST,gBAAT,CAA0BH,UAA1B,EAA+D;AAC7D,QAAME,MAAe,GAAG,EAAxB;;AACA,OAAK,MAAMI,aAAX,IAA4BN,UAA5B,EAAwC;AACtC,UAAMO,SAAwB,GAAGP,UAAU,CAACM,aAAD,CAA3C;AACAJ,IAAAA,MAAM,CAACc,IAAP,CAAYX,eAAe,CAACC,aAAD,EAAgBC,SAAhB,CAA3B;AACD;;AACD,SAAOL,MAAP;AACD;;AAOM,SAASS,yBAAT,CAAmCJ,SAAnC,EAAkF;AACvF,QAAMU,MAAM,GAAG,IAAIC,GAAJ,EAAf;;AACA,MAAI,gBAAgBX,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACa,UAAV,CAAsBC,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACe,UAAV,CAAsBD,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACgB,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
+ {"version":3,"sources":["../../../../src/category/mesh/deduce-mesh-schema.ts"],"names":["deduceMeshSchema","attributes","metadata","fields","deduceMeshFields","Schema","deduceMeshField","attributeName","attribute","optionalMetadata","type","value","makeMeshAttributeMetadata","field","Field","FixedSizeList","size","push","result","Map","set","byteOffset","toString","byteStride","normalized"],"mappings":";;;;;;;;;AACA;;AACA;;AAQO,SAASA,gBAAT,CACLC,UADK,EAELC,QAFK,EAGG;AACR,MAAMC,MAAM,GAAGC,gBAAgB,CAACH,UAAD,CAA/B;AACA,SAAO,IAAII,cAAJ,CAAWF,MAAX,EAAmBD,QAAnB,CAAP;AACD;;AASM,SAASI,eAAT,CACLC,aADK,EAELC,SAFK,EAGLC,gBAHK,EAIE;AACP,MAAMC,IAAI,GAAG,oDAA2BF,SAAS,CAACG,KAArC,CAAb;AACA,MAAMT,QAAQ,GAAGO,gBAAgB,GAAGA,gBAAH,GAAsBG,yBAAyB,CAACJ,SAAD,CAAhF;AACA,MAAMK,KAAK,GAAG,IAAIC,aAAJ,CACZP,aADY,EAEZ,IAAIQ,qBAAJ,CAAkBP,SAAS,CAACQ,IAA5B,EAAkC,IAAIF,aAAJ,CAAU,OAAV,EAAmBJ,IAAnB,CAAlC,CAFY,EAGZ,KAHY,EAIZR,QAJY,CAAd;AAMA,SAAOW,KAAP;AACD;;AAOD,SAAST,gBAAT,CAA0BH,UAA1B,EAA+D;AAC7D,MAAME,MAAe,GAAG,EAAxB;;AACA,OAAK,IAAMI,aAAX,IAA4BN,UAA5B,EAAwC;AACtC,QAAMO,SAAwB,GAAGP,UAAU,CAACM,aAAD,CAA3C;AACAJ,IAAAA,MAAM,CAACc,IAAP,CAAYX,eAAe,CAACC,aAAD,EAAgBC,SAAhB,CAA3B;AACD;;AACD,SAAOL,MAAP;AACD;;AAOM,SAASS,yBAAT,CAAmCJ,SAAnC,EAAkF;AACvF,MAAMU,MAAM,GAAG,IAAIC,GAAJ,EAAf;;AACA,MAAI,gBAAgBX,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACa,UAAV,CAAsBC,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACe,UAAV,CAAsBD,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACgB,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"}
@@ -7,10 +7,10 @@ exports.getMeshSize = getMeshSize;
7
7
  exports.getMeshBoundingBox = getMeshBoundingBox;
8
8
 
9
9
  function getMeshSize(attributes) {
10
- let size = 0;
10
+ var size = 0;
11
11
 
12
- for (const attributeName in attributes) {
13
- const attribute = attributes[attributeName];
12
+ for (var attributeName in attributes) {
13
+ var attribute = attributes[attributeName];
14
14
 
15
15
  if (ArrayBuffer.isView(attribute)) {
16
16
  size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
@@ -21,19 +21,19 @@ function getMeshSize(attributes) {
21
21
  }
22
22
 
23
23
  function getMeshBoundingBox(attributes) {
24
- let minX = Infinity;
25
- let minY = Infinity;
26
- let minZ = Infinity;
27
- let maxX = -Infinity;
28
- let maxY = -Infinity;
29
- let maxZ = -Infinity;
30
- const positions = attributes.POSITION ? attributes.POSITION.value : [];
31
- const len = positions && positions.length;
32
-
33
- for (let i = 0; i < len; i += 3) {
34
- const x = positions[i];
35
- const y = positions[i + 1];
36
- const z = positions[i + 2];
24
+ var minX = Infinity;
25
+ var minY = Infinity;
26
+ var minZ = Infinity;
27
+ var maxX = -Infinity;
28
+ var maxY = -Infinity;
29
+ var maxZ = -Infinity;
30
+ var positions = attributes.POSITION ? attributes.POSITION.value : [];
31
+ var len = positions && positions.length;
32
+
33
+ for (var i = 0; i < len; i += 3) {
34
+ var x = positions[i];
35
+ var y = positions[i + 1];
36
+ var z = positions[i + 2];
37
37
  minX = x < minX ? x : minX;
38
38
  minY = y < minY ? y : minY;
39
39
  minZ = z < minZ ? z : minZ;
@@ -1 +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":";;;;;;;;AAiBO,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;;AAQM,SAASO,kBAAT,CAA4BR,UAA5B,EAAqE;AAC1E,MAAIS,IAAI,GAAGC,QAAX;AACA,MAAIC,IAAI,GAAGD,Q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Array} 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
+ {"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":";;;;;;;;AAiBO,SAASA,WAAT,CAAqBC,UAArB,EAAsD;AAC3D,MA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AAI,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"}
@@ -6,20 +6,20 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.deduceTableSchema = deduceTableSchema;
7
7
 
8
8
  function deduceTableSchema(table, schema) {
9
- const deducedSchema = Array.isArray(table) ? deduceSchemaForRowTable(table) : deduceSchemaForColumnarTable(table);
9
+ var deducedSchema = Array.isArray(table) ? deduceSchemaForRowTable(table) : deduceSchemaForColumnarTable(table);
10
10
  return Object.assign(deducedSchema, schema);
11
11
  }
12
12
 
13
13
  function deduceSchemaForColumnarTable(columnarTable) {
14
- const schema = {};
14
+ var schema = {};
15
15
 
16
- for (const field in columnarTable) {
17
- const column = columnarTable[field];
16
+ for (var field in columnarTable) {
17
+ var column = columnarTable[field];
18
18
 
19
19
  if (ArrayBuffer.isView(column)) {
20
20
  schema[field] = column.constructor;
21
21
  } else if (column.length) {
22
- const value = column[0];
22
+ var value = column[0];
23
23
  schema[field] = deduceTypeFromValue(value);
24
24
  }
25
25
 
@@ -30,13 +30,13 @@ function deduceSchemaForColumnarTable(columnarTable) {
30
30
  }
31
31
 
32
32
  function deduceSchemaForRowTable(rowTable) {
33
- const schema = {};
33
+ var schema = {};
34
34
 
35
35
  if (rowTable.length) {
36
- const row = rowTable[0];
36
+ var row = rowTable[0];
37
37
 
38
- for (const field in row) {
39
- const value = row[field];
38
+ for (var field in row) {
39
+ var value = row[field];
40
40
  schema[field] = deduceTypeFromValue(value);
41
41
  }
42
42
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/category/table/deduce-table-schema.ts"],"names":["deduceTableSchema","table","schema","deducedSchema","Array","isArray","deduceSchemaForRowTable","deduceSchemaForColumnarTable","Object","assign","columnarTable","field","column","ArrayBuffer","isView","constructor","length","value","deduceTypeFromValue","rowTable","row","Date","Number","Float32Array","String"],"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P;AACD;;AAED,SAASgB,mBAAT,CAA6BD,KAA7B,EAAoC;AAClC,MAAIA,KAAK,YAAYI,IAArB,EAA2B;AACzB,WAAOA,IAAP;AACD,GAFD,MAEO,IAAIJ,KAAK,YAAYK,MAArB,EAA6B;AAClC,WAAOC,YAAP;AACD,GAFM,MAEA,IAAI,OAAON,KAAP,KAAiB,QAArB,EAA+B;AACpC,WAAOO,MAAP;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["// Type deduction\nimport {\n Schema\n // Int,\n // Int8,\n // Int16,\n // Int32,\n // Uint8,\n // Uint16,\n // Uint32,\n // Float32,\n // Float64\n // Bool,\n // Utf8,\n // TimestampMillisecond,\n // Null\n} from '../../lib/schema/schema';\n\n// const TYPED_ARRAY_TO_TYPE = {\n// Int8Array: new Int8(),\n// Int16Array: new Int16(),\n// Int32Array: new Int32(),\n// Uint8Array: new Uint8(),\n// Uint8ClampedArray: new Uint8(),\n// Uint16Array: new Uint16(),\n// Uint32Array: new Uint32(),\n// Float32Array: new Float32(),\n// Float64Array: new Float64()\n// };\n\n// if (typeof BigInt64Array !== 'undefined') {\n// TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();\n// TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();\n// }\n\n/**\n * SCHEMA SUPPORT - AUTODEDUCTION\n * @param {*} table\n * @param {*} schema\n * @returns\n */\nexport function deduceTableSchema(table, schema?: Schema) {\n const deducedSchema = Array.isArray(table)\n ? deduceSchemaForRowTable(table)\n : deduceSchemaForColumnarTable(table);\n // Deduced schema will fill in missing info from partial options.schema, if provided\n return Object.assign(deducedSchema, schema);\n}\n\nfunction deduceSchemaForColumnarTable(columnarTable) {\n const schema = {};\n for (const field in columnarTable) {\n const column = columnarTable[field];\n // Check if column is typed, if so we are done\n if (ArrayBuffer.isView(column)) {\n schema[field] = column.constructor;\n // else we need data\n } else if (column.length) {\n const value = column[0];\n schema[field] = deduceTypeFromValue(value);\n // TODO - support nested schemas?\n }\n // else we mark as present but unknow\n schema[field] = schema[field] || null;\n }\n return schema;\n}\n\nfunction deduceSchemaForRowTable(rowTable) {\n const schema = {};\n if (rowTable.length) {\n const row = rowTable[0];\n // TODO - Could look at additional rows if nulls in first row\n for (const field in row) {\n const value = row[field];\n schema[field] = deduceTypeFromValue(value);\n }\n }\n return schema;\n}\n\nfunction deduceTypeFromValue(value) {\n if (value instanceof Date) {\n return Date;\n } else if (value instanceof Number) {\n return Float32Array;\n } else if (typeof value === 'string') {\n return String;\n }\n return null;\n}\n\n/*\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction deduceSchema(rows) {\n const row = rows[0];\n\n const schema = {};\n let i = 0;\n for (const columnName in row) {\n const value = row[columnName];\n switch (typeof value) {\n case 'number':\n case 'boolean':\n // TODO - booleans could be handled differently...\n schema[columnName] = {name: String(columnName), index: i, type: Float32Array};\n break;\n\n case 'object':\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n break;\n\n case 'string':\n default:\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n // We currently only handle numeric rows\n // TODO we could offer a function to map strings to numbers?\n }\n i++;\n }\n return schema;\n}\n*/\n"],"file":"deduce-table-schema.js"}
1
+ {"version":3,"sources":["../../../../src/category/table/deduce-table-schema.ts"],"names":["deduceTableSchema","table","schema","deducedSchema","Array","isArray","deduceSchemaForRowTable","deduceSchemaForColumnarTable","Object","assign","columnarTable","field","column","ArrayBuffer","isView","constructor","length","value","deduceTypeFromValue","rowTable","row","Date","Number","Float32Array","String"],"mappings":";;;;;;;AAyCO,SAASA,iBAAT,CAA2BC,KAA3B,EAAkCC,MAAlC,EAAmD;AACxD,MAAMC,aAAa,GAAGC,KAAK,CAACC,OAAN,CAAcJ,KAAd,IAClBK,uBAAuB,CAACL,KAAD,CADL,GAElBM,4BAA4B,CAACN,KAAD,CAFhC;AAIA,SAAOO,MAAM,CAACC,MAAP,CAAcN,aAAd,EAA6BD,MAA7B,CAAP;AACD;;AAED,SAASK,4BAAT,CAAsC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type deduction\nimport {\n Schema\n // Int,\n // Int8,\n // Int16,\n // Int32,\n // Uint8,\n // Uint16,\n // Uint32,\n // Float32,\n // Float64\n // Bool,\n // Utf8,\n // TimestampMillisecond,\n // Null\n} from '../../lib/schema/schema';\n\n// const TYPED_ARRAY_TO_TYPE = {\n// Int8Array: new Int8(),\n// Int16Array: new Int16(),\n// Int32Array: new Int32(),\n// Uint8Array: new Uint8(),\n// Uint8ClampedArray: new Uint8(),\n// Uint16Array: new Uint16(),\n// Uint32Array: new Uint32(),\n// Float32Array: new Float32(),\n// Float64Array: new Float64()\n// };\n\n// if (typeof BigInt64Array !== 'undefined') {\n// TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();\n// TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();\n// }\n\n/**\n * SCHEMA SUPPORT - AUTODEDUCTION\n * @param {*} table\n * @param {*} schema\n * @returns\n */\nexport function deduceTableSchema(table, schema?: Schema) {\n const deducedSchema = Array.isArray(table)\n ? deduceSchemaForRowTable(table)\n : deduceSchemaForColumnarTable(table);\n // Deduced schema will fill in missing info from partial options.schema, if provided\n return Object.assign(deducedSchema, schema);\n}\n\nfunction deduceSchemaForColumnarTable(columnarTable) {\n const schema = {};\n for (const field in columnarTable) {\n const column = columnarTable[field];\n // Check if column is typed, if so we are done\n if (ArrayBuffer.isView(column)) {\n schema[field] = column.constructor;\n // else we need data\n } else if (column.length) {\n const value = column[0];\n schema[field] = deduceTypeFromValue(value);\n // TODO - support nested schemas?\n }\n // else we mark as present but unknow\n schema[field] = schema[field] || null;\n }\n return schema;\n}\n\nfunction deduceSchemaForRowTable(rowTable) {\n const schema = {};\n if (rowTable.length) {\n const row = rowTable[0];\n // TODO - Could look at additional rows if nulls in first row\n for (const field in row) {\n const value = row[field];\n schema[field] = deduceTypeFromValue(value);\n }\n }\n return schema;\n}\n\nfunction deduceTypeFromValue(value) {\n if (value instanceof Date) {\n return Date;\n } else if (value instanceof Number) {\n return Float32Array;\n } else if (typeof value === 'string') {\n return String;\n }\n return null;\n}\n\n/*\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction deduceSchema(rows) {\n const row = rows[0];\n\n const schema = {};\n let i = 0;\n for (const columnName in row) {\n const value = row[columnName];\n switch (typeof value) {\n case 'number':\n case 'boolean':\n // TODO - booleans could be handled differently...\n schema[columnName] = {name: String(columnName), index: i, type: Float32Array};\n break;\n\n case 'object':\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n break;\n\n case 'string':\n default:\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n // We currently only handle numeric rows\n // TODO we could offer a function to map strings to numbers?\n }\n i++;\n }\n return schema;\n}\n*/\n"],"file":"deduce-table-schema.js"}