@loaders.gl/schema 4.0.0-alpha.9 → 4.0.0-beta.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 (112) hide show
  1. package/dist/dist.min.js +558 -943
  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 +4 -3
  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 +69 -42
  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 +2 -0
  14. package/dist/es5/types/binary-geometries.js.map +1 -0
  15. package/dist/es5/types/category-gis.js.map +1 -1
  16. package/dist/es5/types/category-image.js.map +1 -1
  17. package/dist/es5/types/category-table.js.map +1 -1
  18. package/dist/es5/types/flat-geometries.js +2 -0
  19. package/dist/es5/types/flat-geometries.js.map +1 -0
  20. package/dist/es5/types/schema.js.map +1 -1
  21. package/dist/esm/index.js +1 -0
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/lib/table/arrow-api/arrow-like-table.js +4 -3
  24. package/dist/esm/lib/table/arrow-api/arrow-like-table.js.map +1 -1
  25. package/dist/esm/lib/table/batches/row-table-batch-aggregator.js.map +1 -1
  26. package/dist/esm/lib/table/simple-table/convert-table.js +22 -0
  27. package/dist/esm/lib/table/simple-table/convert-table.js.map +1 -1
  28. package/dist/esm/lib/table/simple-table/table-accessors.js +49 -22
  29. package/dist/esm/lib/table/simple-table/table-accessors.js.map +1 -1
  30. package/dist/esm/types/batch.js +2 -0
  31. package/dist/esm/types/batch.js.map +1 -0
  32. package/dist/esm/types/binary-geometries.js +2 -0
  33. package/dist/esm/types/binary-geometries.js.map +1 -0
  34. package/dist/esm/types/category-gis.js.map +1 -1
  35. package/dist/esm/types/category-image.js.map +1 -1
  36. package/dist/esm/types/category-table.js.map +1 -1
  37. package/dist/esm/types/flat-geometries.js +2 -0
  38. package/dist/esm/types/flat-geometries.js.map +1 -0
  39. package/dist/esm/types/schema.js.map +1 -1
  40. package/dist/index.d.ts +7 -5
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/lib/table/arrow-api/arrow-like-table.d.ts +1 -5
  43. package/dist/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
  44. package/dist/lib/table/batches/row-table-batch-aggregator.d.ts +3 -3
  45. package/dist/lib/table/batches/row-table-batch-aggregator.d.ts.map +1 -1
  46. package/dist/lib/table/simple-table/convert-table.d.ts +34 -1
  47. package/dist/lib/table/simple-table/convert-table.d.ts.map +1 -1
  48. package/dist/lib/table/simple-table/table-accessors.d.ts.map +1 -1
  49. package/dist/types/batch.d.ts +34 -0
  50. package/dist/types/batch.d.ts.map +1 -0
  51. package/dist/types/binary-geometries.d.ts +56 -0
  52. package/dist/types/binary-geometries.d.ts.map +1 -0
  53. package/dist/types/category-gis.d.ts +3 -84
  54. package/dist/types/category-gis.d.ts.map +1 -1
  55. package/dist/types/category-image.d.ts +1 -1
  56. package/dist/types/category-image.d.ts.map +1 -1
  57. package/dist/types/category-table.d.ts +42 -22
  58. package/dist/types/category-table.d.ts.map +1 -1
  59. package/dist/types/flat-geometries.d.ts +30 -0
  60. package/dist/types/flat-geometries.d.ts.map +1 -0
  61. package/dist/types/schema.d.ts +0 -15
  62. package/dist/types/schema.d.ts.map +1 -1
  63. package/package.json +2 -2
  64. package/src/index.ts +13 -7
  65. package/src/lib/table/arrow-api/arrow-like-table.ts +3 -2
  66. package/src/lib/table/batches/row-table-batch-aggregator.ts +2 -2
  67. package/src/lib/table/simple-table/convert-table.ts +73 -1
  68. package/src/lib/table/simple-table/table-accessors.ts +56 -22
  69. package/src/types/batch.ts +41 -0
  70. package/src/types/binary-geometries.ts +62 -0
  71. package/src/types/category-gis.ts +30 -104
  72. package/src/types/category-image.ts +1 -1
  73. package/src/types/category-table.ts +49 -27
  74. package/src/types/flat-geometries.ts +40 -0
  75. package/src/types/schema.ts +0 -17
  76. package/dist/bundle.js +0 -5
  77. package/dist/index.js +0 -92
  78. package/dist/lib/mesh/convert-mesh.js +0 -40
  79. package/dist/lib/mesh/deduce-mesh-schema.js +0 -66
  80. package/dist/lib/mesh/mesh-to-arrow-table.js +0 -44
  81. package/dist/lib/mesh/mesh-utils.js +0 -51
  82. package/dist/lib/table/arrow/arrow-type-utils.js +0 -53
  83. package/dist/lib/table/arrow/convert-schema-arrow.js +0 -187
  84. package/dist/lib/table/arrow/convert-table-to-arrow.js +0 -57
  85. package/dist/lib/table/arrow-api/arrow-like-field.js +0 -34
  86. package/dist/lib/table/arrow-api/arrow-like-schema.js +0 -81
  87. package/dist/lib/table/arrow-api/arrow-like-table.js +0 -53
  88. package/dist/lib/table/arrow-api/arrow-like-type.js +0 -463
  89. package/dist/lib/table/arrow-api/enum.js +0 -97
  90. package/dist/lib/table/arrow-api/get-type-info.js +0 -29
  91. package/dist/lib/table/arrow-api/index.js +0 -25
  92. package/dist/lib/table/batches/base-table-batch-aggregator.js +0 -60
  93. package/dist/lib/table/batches/columnar-table-batch-aggregator.js +0 -92
  94. package/dist/lib/table/batches/row-table-batch-aggregator.js +0 -81
  95. package/dist/lib/table/batches/table-batch-aggregator.js +0 -3
  96. package/dist/lib/table/batches/table-batch-builder.js +0 -152
  97. package/dist/lib/table/simple-table/convert-table.js +0 -65
  98. package/dist/lib/table/simple-table/data-type.js +0 -93
  99. package/dist/lib/table/simple-table/make-table.js +0 -95
  100. package/dist/lib/table/simple-table/row-utils.js +0 -33
  101. package/dist/lib/table/simple-table/table-accessors.js +0 -319
  102. package/dist/lib/table/simple-table/table-column.js +0 -41
  103. package/dist/lib/table/simple-table/table-schema.js +0 -85
  104. package/dist/lib/utils/assert.js +0 -12
  105. package/dist/lib/utils/async-queue.js +0 -92
  106. package/dist/types/category-gis.js +0 -2
  107. package/dist/types/category-image.js +0 -2
  108. package/dist/types/category-mesh.js +0 -3
  109. package/dist/types/category-table.js +0 -3
  110. package/dist/types/category-texture.js +0 -3
  111. package/dist/types/schema.js +0 -3
  112. package/dist/types/types.js +0 -2
@@ -1,4 +1,3 @@
1
- import type { RecordBatch } from 'apache-arrow';
2
1
  /** For dictionary type */
3
2
  export type KeyType = 'int8' | 'int16' | 'int32' | 'uint8' | 'uint16' | 'uint32';
4
3
  /** ArrowLike DataType class */
@@ -60,18 +59,4 @@ export type Schema = {
60
59
  fields: Field[];
61
60
  metadata: SchemaMetadata;
62
61
  };
63
- export type Batch = {
64
- batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';
65
- batch?: number;
66
- mimeType?: string;
67
- shape: string;
68
- data: any;
69
- recordBatch?: RecordBatch;
70
- length: number;
71
- schema?: Schema;
72
- bytesUsed?: number;
73
- count?: number;
74
- cursor?: number;
75
- [key: string]: any;
76
- };
77
62
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAE9C,0BAA0B;AAC1B,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjF,+BAA+B;AAC/B,MAAM,MAAM,QAAQ,GAChB,MAAM,GAEN,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,SAAS,GACT,SAAS,GACT,SAAS,GACT,QAAQ,GACR,MAAM,GACN,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,EAAE,OAAO,CAAA;CAAC,CAAC;AAGjG;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/schema",
3
- "version": "4.0.0-alpha.9",
3
+ "version": "4.0.0-beta.1",
4
4
  "description": "Table format APIs for JSON, CSV, etc...",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -34,5 +34,5 @@
34
34
  "dependencies": {
35
35
  "@types/geojson": "^7946.0.7"
36
36
  },
37
- "gitHead": "03ff81ab468f20f3bddeec787aa88d477a7e1c72"
37
+ "gitHead": "35c625e67132b0784e597d9ddabae8aefea29ff2"
38
38
  }
package/src/index.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  // COMMON CATEGORY
2
2
  export type {
3
3
  TypedArray,
4
+ BigTypedArray,
4
5
  TypedArrayConstructor,
6
+ BigTypedArrayConstructor,
5
7
  NumberArray,
6
8
  ArrayType,
7
9
  AnyArray
8
10
  } from './types/types';
9
11
 
10
- export type {Schema, Field, DataType, Batch, SchemaMetadata, FieldMetadata} from './types/schema';
12
+ export type {Schema, Field, DataType, SchemaMetadata, FieldMetadata} from './types/schema';
13
+
14
+ export type {Batch} from './types/batch';
11
15
 
12
16
  // TABLE CATEGORY TYPES
13
17
  export type {
@@ -15,7 +19,7 @@ export type {
15
19
  RowTable,
16
20
  ArrayRowTable,
17
21
  ObjectRowTable,
18
- GeoJSONRowTable,
22
+ GeoJSONTable,
19
23
  ColumnarTable,
20
24
  ArrowTable,
21
25
  Tables
@@ -24,7 +28,7 @@ export type {
24
28
  TableBatch,
25
29
  ArrayRowTableBatch,
26
30
  ObjectRowTableBatch,
27
- GeoJSONRowTableBatch,
31
+ GeoJSONTableBatch,
28
32
  ColumnarTableBatch,
29
33
  ArrowTableBatch
30
34
  } from './types/category-table';
@@ -52,6 +56,7 @@ export {
52
56
  export {ArrowLikeTable} from './lib/table/arrow-api/arrow-like-table';
53
57
 
54
58
  export {makeTableFromData} from './lib/table/simple-table/make-table';
59
+ export {convertTable} from './lib/table/simple-table/convert-table';
55
60
  export {deduceTableSchema} from './lib/table/simple-table/table-schema';
56
61
  export {convertToObjectRow, convertToArrayRow} from './lib/table/simple-table/row-utils';
57
62
  export {getDataTypeFromArray} from './lib/table/simple-table/data-type';
@@ -122,10 +127,11 @@ export type {
122
127
  BinaryAttribute
123
128
  } from './types/category-gis';
124
129
  export type {
125
- BinaryFeatures,
126
- BinaryPointFeatures,
127
- BinaryLineFeatures,
128
- BinaryPolygonFeatures
130
+ BinaryFeatureCollection,
131
+ BinaryFeature,
132
+ BinaryPointFeature,
133
+ BinaryLineFeature,
134
+ BinaryPolygonFeature
129
135
  } from './types/category-gis';
130
136
 
131
137
  // SCHEMA
@@ -34,7 +34,8 @@ class ArrowLikeVector {
34
34
  toArray(): ArrayLike<unknown> {
35
35
  switch (this.table.shape) {
36
36
  case 'arrow-table':
37
- return this.table.data.getChild(this.columnName)?.toArray();
37
+ const arrowTable = this.table.data as any;
38
+ return arrowTable.getChild(this.columnName)?.toArray();
38
39
  case 'columnar-table':
39
40
  return this.table.data[this.columnName];
40
41
  default:
@@ -62,7 +63,7 @@ export class ArrowLikeTable {
62
63
  // }
63
64
 
64
65
  get data() {
65
- return this.table.data;
66
+ return this.table.shape === 'geojson-table' ? this.table.features : this.table.data;
66
67
  }
67
68
 
68
69
  get numCols(): number {
@@ -13,8 +13,8 @@ export class RowTableBatchAggregator implements TableBatchAggregator {
13
13
  options: TableBatchOptions;
14
14
 
15
15
  length: number = 0;
16
- objectRows: {[columnName: string]: any} | null = null;
17
- arrayRows: any[] | null = null;
16
+ objectRows: {[columnName: string]: unknown}[] | null = null;
17
+ arrayRows: unknown[][] | null = null;
18
18
  cursor: number = 0;
19
19
  private _headers: string[] = [];
20
20
 
@@ -5,10 +5,57 @@ import {
5
5
  getTableRowAsArray,
6
6
  getTableRowAsObject
7
7
  } from './table-accessors';
8
- import {Table, ArrayRowTable, ObjectRowTable, ColumnarTable} from '../../../types/category-table';
8
+ import {
9
+ Table,
10
+ ArrayRowTable,
11
+ ObjectRowTable,
12
+ ColumnarTable,
13
+ ArrowTable
14
+ } from '../../../types/category-table';
9
15
  import {deduceTableSchema} from './table-schema';
10
16
  import {makeColumnFromField} from './table-column';
11
17
 
18
+ export function convertTable(table: Table, shape: 'object-row-table'): ObjectRowTable;
19
+ export function convertTable(table: Table, shape: 'array-row-table'): ArrayRowTable;
20
+ export function convertTable(table: Table, shape: 'columnar-table'): ColumnarTable;
21
+ export function convertTable(table: Table, shape: 'arrow-table'): ArrowTable;
22
+
23
+ /**
24
+ * Convert a table to a different shape
25
+ * @param table
26
+ * @param shape
27
+ * @returns
28
+ */
29
+ export function convertTable(
30
+ table: Table,
31
+ shape: 'object-row-table' | 'array-row-table' | 'columnar-table' | 'arrow-table'
32
+ ) {
33
+ switch (shape) {
34
+ case 'object-row-table':
35
+ return makeObjectRowTable(table);
36
+ case 'array-row-table':
37
+ return makeArrayRowTable(table);
38
+ case 'columnar-table':
39
+ return makeColumnarTable(table);
40
+ case 'arrow-table':
41
+ return makeArrowTable(table);
42
+ default:
43
+ throw new Error(shape);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Convert a table to apache arrow format
49
+ * @note this depends on the `@loaders.gl/arrow module being imported
50
+ */
51
+ export function makeArrowTable(table: Table): Table {
52
+ const _makeArrowTable = globalThis.__luma?._makeArrowTable;
53
+ if (!_makeArrowTable) {
54
+ throw new Error('');
55
+ }
56
+ return _makeArrowTable(table);
57
+ }
58
+
12
59
  /** Convert any simple table into columnar format */
13
60
  export function makeColumnarTable(table: Table): ColumnarTable {
14
61
  // TODO - should schema really be optional?
@@ -70,3 +117,28 @@ export function makeObjectRowTable(table: Table): ObjectRowTable {
70
117
  data
71
118
  };
72
119
  }
120
+
121
+ /**
122
+ /**
123
+ *
124
+ * @note - should be part of schema module
125
+ export function convertColumnarToRowFormatTable(columnarTable: ColumnarTable): ObjectRowTable {
126
+ const tableKeys = ;
127
+ const tableRowsCount = columnarTable[tableKeys[0]].length;
128
+
129
+ const objectRows: ObjectRowTable['data'] = [];
130
+
131
+ for (let index = 0; index < tableRowsCount; index++) {
132
+ const objectRow = {};
133
+ for (const fieldName of Object.keys(columnarTable.data)) {
134
+ objectRow[fieldName] = columnarTable[fieldName][index];
135
+ }
136
+ objectRows.push(objectRow);
137
+ }
138
+
139
+ return {
140
+ shape: 'object-row-table',
141
+ data: objectRows
142
+ };
143
+ }
144
+ */
@@ -11,11 +11,14 @@ export function getTableLength(table: Table): number {
11
11
  switch (table.shape) {
12
12
  case 'array-row-table':
13
13
  case 'object-row-table':
14
- case 'geojson-row-table':
15
14
  return table.data.length;
16
15
 
16
+ case 'geojson-table':
17
+ return table.features.length;
18
+
17
19
  case 'arrow-table':
18
- return table.data.numRows;
20
+ const arrowTable = table.data as any;
21
+ return arrowTable.numRows;
19
22
 
20
23
  case 'columnar-table':
21
24
  for (const column of Object.values(table.data)) {
@@ -42,14 +45,14 @@ export function getTableNumCols(table: Table): number {
42
45
  case 'array-row-table':
43
46
  return table.data[0].length;
44
47
  case 'object-row-table':
45
- case 'geojson-row-table':
46
48
  return Object.keys(table.data[0]).length;
47
-
49
+ case 'geojson-table':
50
+ return Object.keys(table.features[0]).length;
48
51
  case 'columnar-table':
49
52
  return Object.keys(table.data).length;
50
-
51
53
  case 'arrow-table':
52
- return table.data.numCols;
54
+ const arrowTable = table.data as any;
55
+ return arrowTable.numCols;
53
56
  default:
54
57
  throw new Error('table');
55
58
  }
@@ -63,18 +66,21 @@ export function getTableCell(table: Table, rowIndex: number, columnName: string)
63
66
  return table.data[rowIndex][columnIndex];
64
67
 
65
68
  case 'object-row-table':
66
- case 'geojson-row-table':
67
69
  return table.data[rowIndex][columnName];
68
70
 
71
+ case 'geojson-table':
72
+ return table.features[rowIndex][columnName];
73
+
69
74
  case 'columnar-table':
70
75
  const column = table.data[columnName];
71
76
  return column[rowIndex];
72
77
 
73
78
  case 'arrow-table':
74
- const arrowColumnIndex = table.data.schema.fields.findIndex(
79
+ const arrowTable = table.data as any;
80
+ const arrowColumnIndex = arrowTable.schema.fields.findIndex(
75
81
  (field) => field.name === columnName
76
82
  );
77
- return table.data.getChildAt(arrowColumnIndex)?.get(rowIndex);
83
+ return arrowTable.getChildAt(arrowColumnIndex)?.get(rowIndex);
78
84
 
79
85
  default:
80
86
  throw new Error('todo');
@@ -88,17 +94,21 @@ export function getTableCellAt(table: Table, rowIndex: number, columnIndex: numb
88
94
  return table.data[rowIndex][columnIndex];
89
95
 
90
96
  case 'object-row-table':
91
- case 'geojson-row-table':
92
- let columnName = getTableColumnName(table, columnIndex);
93
- return table.data[rowIndex][columnName];
97
+ const columnName1 = getTableColumnName(table, columnIndex);
98
+ return table.data[rowIndex][columnName1];
99
+
100
+ case 'geojson-table':
101
+ const columnName2 = getTableColumnName(table, columnIndex);
102
+ return table.features[rowIndex][columnName2];
94
103
 
95
104
  case 'columnar-table':
96
- columnName = getTableColumnName(table, columnIndex);
97
- const column = table.data[columnName];
105
+ const columnName3 = getTableColumnName(table, columnIndex);
106
+ const column = table.data[columnName3];
98
107
  return column[rowIndex];
99
108
 
100
109
  case 'arrow-table':
101
- return table.data.getChildAt(columnIndex)?.get(rowIndex);
110
+ const arrowTable = table.data as any;
111
+ return arrowTable.getChildAt(columnIndex)?.get(rowIndex);
102
112
 
103
113
  default:
104
114
  throw new Error('todo');
@@ -112,7 +122,8 @@ export function getTableRowShape(table: Table): 'array-row-table' | 'object-row-
112
122
  case 'object-row-table':
113
123
  return table.shape;
114
124
 
115
- case 'geojson-row-table':
125
+ case 'geojson-table':
126
+ // TODO - this is not correct, geojson-table is not a row table
116
127
  return 'object-row-table';
117
128
 
118
129
  case 'columnar-table':
@@ -156,7 +167,6 @@ export function getTableRowAsObject(
156
167
  return copy ? Object.fromEntries(Object.entries(table.data[rowIndex])) : table.data[rowIndex];
157
168
 
158
169
  case 'array-row-table':
159
- case 'geojson-row-table':
160
170
  if (table.schema) {
161
171
  const objectRow: {[columnName: string]: unknown} = target || {};
162
172
  for (let i = 0; i < table.schema.fields.length; i++) {
@@ -166,6 +176,17 @@ export function getTableRowAsObject(
166
176
  }
167
177
  throw new Error('no schema');
168
178
 
179
+ case 'geojson-table':
180
+ if (table.schema) {
181
+ const objectRow: {[columnName: string]: unknown} = target || {};
182
+ // TODO - should lift properties to top level
183
+ for (let i = 0; i < table.schema.fields.length; i++) {
184
+ objectRow[table.schema.fields[i].name] = table.features[rowIndex][i];
185
+ }
186
+ return objectRow;
187
+ }
188
+ throw new Error('no schema');
189
+
169
190
  case 'columnar-table':
170
191
  if (table.schema) {
171
192
  const objectRow: {[columnName: string]: unknown} = target || {};
@@ -184,9 +205,10 @@ export function getTableRowAsObject(
184
205
  }
185
206
 
186
207
  case 'arrow-table':
208
+ const arrowTable = table.data as any;
187
209
  const objectRow: {[columnName: string]: unknown} = target || {};
188
- const row = table.data.get(rowIndex);
189
- const schema = table.data.schema;
210
+ const row = arrowTable.get(rowIndex);
211
+ const schema = arrowTable.schema;
190
212
  for (let i = 0; i < schema.fields.length; i++) {
191
213
  objectRow[schema.fields[i].name] = row?.[schema.fields[i].name];
192
214
  }
@@ -214,7 +236,6 @@ export function getTableRowAsArray(
214
236
  return copy ? Array.from(table.data[rowIndex]) : table.data[rowIndex];
215
237
 
216
238
  case 'object-row-table':
217
- case 'geojson-row-table':
218
239
  if (table.schema) {
219
240
  const arrayRow: unknown[] = target || [];
220
241
  for (let i = 0; i < table.schema.fields.length; i++) {
@@ -225,6 +246,18 @@ export function getTableRowAsArray(
225
246
  // Warning: just slap on the values, this risks mismatches between rows
226
247
  return Object.values(table.data[rowIndex]);
227
248
 
249
+ case 'geojson-table':
250
+ if (table.schema) {
251
+ const arrayRow: unknown[] = target || [];
252
+ // TODO - should lift properties to top level
253
+ for (let i = 0; i < table.schema.fields.length; i++) {
254
+ arrayRow[i] = table.features[rowIndex][table.schema.fields[i].name];
255
+ }
256
+ return arrayRow;
257
+ }
258
+ // Warning: just slap on the values, this risks mismatches between rows
259
+ return Object.values(table.features[rowIndex]);
260
+
228
261
  case 'columnar-table':
229
262
  if (table.schema) {
230
263
  const arrayRow: unknown[] = target || [];
@@ -244,9 +277,10 @@ export function getTableRowAsArray(
244
277
  }
245
278
 
246
279
  case 'arrow-table':
280
+ const arrowTable = table.data as any;
247
281
  const arrayRow: unknown[] = target || [];
248
- const row = table.data.get(rowIndex);
249
- const schema = table.data.schema;
282
+ const row = arrowTable.get(rowIndex);
283
+ const schema = arrowTable.schema;
250
284
  for (let i = 0; i < schema.fields.length; i++) {
251
285
  arrayRow[i] = row?.[schema.fields[i].name];
252
286
  }
@@ -0,0 +1,41 @@
1
+ // loaders.gl, MIT license
2
+
3
+ import {Schema} from './schema';
4
+ import type {RecordBatch} from 'apache-arrow';
5
+
6
+ /**
7
+ * A batch of data (or metadata/schema), from a streaming loader
8
+ * @see parseInBatches()
9
+ * @see loadInBatches()
10
+ */
11
+ export type Batch = {
12
+ /** A batch can contain metadata, data, or in case of unstructured data (JSON) */
13
+ batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';
14
+ /** A string identifying the shape of data in this batch (table, etc) */
15
+ shape: string;
16
+ /** Schema of the data in this batch */
17
+ schema?: Schema;
18
+ /** Data in this batch */
19
+ data: unknown;
20
+ /** If this is an arrow table. @deprecated Use `data` */
21
+ recordBatch?: RecordBatch;
22
+ /** Length of data in this batch */
23
+ length: number;
24
+
25
+ /** A count of batches received */
26
+ batch?: number;
27
+
28
+ /** A count of batches received */
29
+ count?: number;
30
+
31
+ /** Bytes used so far */
32
+ bytesUsed?: number;
33
+ /** cursor is the */
34
+ cursor?: number;
35
+
36
+ /** MIME type of the data generating this batch */
37
+ mimeType?: string;
38
+
39
+ /** Any other data */
40
+ [key: string]: unknown;
41
+ };
@@ -0,0 +1,62 @@
1
+ // GIS
2
+ import type {TypedArray} from './types';
3
+
4
+ // BINARY FORMAT GEOMETRY
5
+
6
+ export type BinaryAttribute = {value: TypedArray; size: number};
7
+ export type BinaryGeometryType = 'Point' | 'LineString' | 'Polygon';
8
+
9
+ type NumericProps = {[key: string]: BinaryAttribute};
10
+ type Properties = object[];
11
+
12
+ /**
13
+ * Represent a single Geometry, similar to a GeoJSON Geometry
14
+ */
15
+ export type BinaryGeometry = BinaryPointGeometry | BinaryLineGeometry | BinaryPolygonGeometry;
16
+
17
+ /** Binary point geometry: an array of positions */
18
+ export type BinaryPointGeometry = {
19
+ type: 'Point';
20
+ positions: BinaryAttribute;
21
+ };
22
+
23
+ /** Binary line geometry, array of positions and indices to the start of each line */
24
+ export type BinaryLineGeometry = {
25
+ type: 'LineString';
26
+ positions: BinaryAttribute;
27
+ pathIndices: BinaryAttribute;
28
+ };
29
+
30
+ /** Binary polygon geometry, an array of positions to each primitite polygon and polygon */
31
+ export type BinaryPolygonGeometry = {
32
+ type: 'Polygon';
33
+ positions: BinaryAttribute;
34
+ polygonIndices: BinaryAttribute;
35
+ primitivePolygonIndices: BinaryAttribute;
36
+ triangles?: BinaryAttribute;
37
+ };
38
+
39
+ /** Common properties for binary geometries */
40
+ export type BinaryProperties = {
41
+ featureIds: BinaryAttribute;
42
+ globalFeatureIds: BinaryAttribute;
43
+ numericProps: NumericProps;
44
+ properties: Properties;
45
+ fields?: Properties;
46
+ };
47
+
48
+ /** Binary feature + binary attributes */
49
+ export type BinaryFeature = BinaryPointFeature | BinaryLineFeature | BinaryPolygonFeature;
50
+
51
+ export type BinaryPointFeature = BinaryPointGeometry & BinaryProperties;
52
+ export type BinaryLineFeature = BinaryLineGeometry & BinaryProperties;
53
+ export type BinaryPolygonFeature = BinaryPolygonGeometry & BinaryProperties;
54
+
55
+ /**
56
+ * Represent a collection of Features, similar to a GeoJSON FeatureCollection
57
+ */
58
+ export type BinaryFeatureCollection = {
59
+ points?: BinaryPointFeature;
60
+ lines?: BinaryLineFeature;
61
+ polygons?: BinaryPolygonFeature;
62
+ };
@@ -1,10 +1,6 @@
1
1
  // GIS
2
- import type {TypedArray} from './types';
3
- import type {Feature, Geometry, Point, LineString, Polygon} from 'geojson';
4
2
 
5
- // GEOJSON FORMAT GEOMETRY
6
-
7
- // eslint-disable-next-line import/no-unresolved
3
+ // NORMAL GEOJSON FORMAT GEOMETRY
8
4
  export type {
9
5
  GeoJSON,
10
6
  Feature,
@@ -13,7 +9,7 @@ export type {
13
9
  Position,
14
10
  GeoJsonProperties
15
11
  } from 'geojson';
16
- // eslint-disable-next-line import/no-unresolved
12
+
17
13
  export type {
18
14
  Point,
19
15
  MultiPoint,
@@ -24,7 +20,34 @@ export type {
24
20
  GeometryCollection
25
21
  } from 'geojson';
26
22
 
27
- // Aggregate information for converting GeoJSON into other formats
23
+ // FLAT GEOJSON FORMAT GEOMETRY
24
+ export type {
25
+ FlatGeometryType,
26
+ FlatIndexedGeometry,
27
+ FlatPoint,
28
+ FlatLineString,
29
+ FlatPolygon,
30
+ FlatGeometry,
31
+ FlatFeature
32
+ } from './flat-geometries';
33
+
34
+ // BINARY FORMAT GEOMETRY
35
+ export type {
36
+ BinaryAttribute,
37
+ BinaryGeometryType,
38
+ BinaryGeometry,
39
+ BinaryPointGeometry,
40
+ BinaryLineGeometry,
41
+ BinaryPolygonGeometry,
42
+ BinaryProperties,
43
+ BinaryFeatureCollection,
44
+ BinaryFeature,
45
+ BinaryPointFeature,
46
+ BinaryLineFeature,
47
+ BinaryPolygonFeature
48
+ } from './binary-geometries';
49
+
50
+ /** Aggregate information for converting GeoJSON into other formats */
28
51
  export type GeojsonGeometryInfo = {
29
52
  coordLength: number;
30
53
  pointPositionsCount: number;
@@ -37,100 +60,3 @@ export type GeojsonGeometryInfo = {
37
60
  polygonRingsCount: number;
38
61
  polygonFeaturesCount: number;
39
62
  };
40
-
41
- // FLAT GEOJSON FORMAT GEOMETRY
42
- export type FlatGeometryType = 'Point' | 'LineString' | 'Polygon';
43
- type RemoveCoordinatesField<Type> = {
44
- [Property in keyof Type as Exclude<Property, 'coordinates'>]: Type[Property];
45
- };
46
-
47
- /**
48
- * Generic flat geometry data storage type
49
- */
50
- export type FlatIndexedGeometry = {
51
- data: number[];
52
- indices: number[];
53
- };
54
-
55
- /**
56
- * GeoJSON (Multi)Point geometry with coordinate data flattened into `data` array and indexed by `indices`
57
- */
58
- export type FlatPoint = RemoveCoordinatesField<Point> & FlatIndexedGeometry;
59
-
60
- /**
61
- * GeoJSON (Multi)LineString geometry with coordinate data flattened into `data` array and indexed by `indices`
62
- */
63
- export type FlatLineString = RemoveCoordinatesField<LineString> & FlatIndexedGeometry;
64
-
65
- /**
66
- * GeoJSON (Multi)Polygon geometry with coordinate data flattened into `data` array and indexed by 2D `indices`
67
- */
68
- export type FlatPolygon = RemoveCoordinatesField<Polygon> & {
69
- data: number[];
70
- indices: number[][];
71
- areas: number[][];
72
- };
73
-
74
- export type FlatGeometry = FlatPoint | FlatLineString | FlatPolygon;
75
-
76
- type FlattenGeometry<Type> = {
77
- [Property in keyof Type]: Type[Property] extends Geometry ? FlatGeometry : Type[Property];
78
- };
79
-
80
- /**
81
- * GeoJSON Feature with Geometry replaced by FlatGeometry
82
- */
83
- export type FlatFeature = FlattenGeometry<Feature>;
84
-
85
- // BINARY FORMAT GEOMETRY
86
-
87
- export type BinaryAttribute = {value: TypedArray; size: number};
88
- export type BinaryGeometryType = 'Point' | 'LineString' | 'Polygon';
89
-
90
- type NumericProps = {[key: string]: BinaryAttribute};
91
- type Properties = object[];
92
-
93
- /**
94
- * Represent a single Geometry, similar to a GeoJSON Geometry
95
- */
96
- export type BinaryGeometry = BinaryPointGeometry | BinaryLineGeometry | BinaryPolygonGeometry;
97
-
98
- export type BinaryPointGeometry = {
99
- type: 'Point';
100
- positions: BinaryAttribute;
101
- };
102
-
103
- export type BinaryLineGeometry = {
104
- type: 'LineString';
105
- positions: BinaryAttribute;
106
- pathIndices: BinaryAttribute;
107
- };
108
-
109
- export type BinaryPolygonGeometry = {
110
- type: 'Polygon';
111
- positions: BinaryAttribute;
112
- polygonIndices: BinaryAttribute;
113
- primitivePolygonIndices: BinaryAttribute;
114
- triangles?: BinaryAttribute;
115
- };
116
-
117
- export type BinaryProperties = {
118
- featureIds: BinaryAttribute;
119
- globalFeatureIds: BinaryAttribute;
120
- numericProps: NumericProps;
121
- properties: Properties;
122
- fields?: Properties;
123
- };
124
-
125
- export type BinaryPointFeatures = BinaryPointGeometry & BinaryProperties;
126
- export type BinaryLineFeatures = BinaryLineGeometry & BinaryProperties;
127
- export type BinaryPolygonFeatures = BinaryPolygonGeometry & BinaryProperties;
128
-
129
- /**
130
- * Represent a collection of Features, similar to a GeoJSON FeatureCollection
131
- */
132
- export type BinaryFeatures = {
133
- points?: BinaryPointFeatures;
134
- lines?: BinaryLineFeatures;
135
- polygons?: BinaryPolygonFeatures;
136
- };
@@ -11,7 +11,7 @@ export type ImageDataType = {
11
11
  /**
12
12
  * Supported Image Types
13
13
  */
14
- export type ImageType = ImageBitmap | typeof Image | ImageDataType;
14
+ export type ImageType = ImageBitmap | ImageDataType | HTMLImageElement;
15
15
 
16
16
  /**
17
17
  * Image type string used to control or determine the type of images returned from ImageLoader