@loaders.gl/schema 4.4.5 → 5.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@
5
5
  import type {Schema} from '../types/schema';
6
6
  import type {TypedArray} from '../types/types';
7
7
  import type {ColumnarTable, ArrowTable} from './category-table';
8
+ import * as arrow from 'apache-arrow';
8
9
 
9
10
  /** Mesh as columnar table */
10
11
  export interface MeshTable extends ColumnarTable {
@@ -16,10 +17,53 @@ export interface MeshTable extends ColumnarTable {
16
17
  /** Mesh as arrow table */
17
18
  export interface MeshArrowTable extends ArrowTable {
18
19
  // shape: 'mesh-arrow-table';
20
+ /** Mesh topology represented by the Arrow table rows and indices. */
19
21
  topology: 'point-list' | 'triangle-list' | 'triangle-strip';
22
+ /** Optional top-level primitive indices accessor for indexed meshes. */
20
23
  indices?: MeshAttribute;
24
+ /** Raw Apache Arrow table data for Mesh or IndexedMesh columns. */
25
+ data: MeshArrowTableData | IndexedMeshArrowTableData;
21
26
  }
22
27
 
28
+ /** Apache Arrow columns for a mesh vertex table. */
29
+ export type MeshArrowColumns = {
30
+ /** XYZ vertex positions as float32 tuples. */
31
+ POSITION: arrow.FixedSizeList<arrow.Float32>;
32
+ /** Loader-specific vertex attribute columns appended after predefined fields. */
33
+ [attributeName: string]: arrow.DataType;
34
+ };
35
+
36
+ /** Apache Arrow columns for an indexed mesh vertex table. */
37
+ export type IndexedMeshArrowColumns = MeshArrowColumns & {
38
+ /** Primitive indices, stored in row 0 and null for remaining vertex rows. */
39
+ indices: arrow.List<arrow.Int32>;
40
+ };
41
+
42
+ /** Raw Apache Arrow table data for a mesh vertex table. */
43
+ export type MeshArrowTableData = arrow.Table<MeshArrowColumns>;
44
+
45
+ /** Raw Apache Arrow table data for an indexed mesh vertex table. */
46
+ export type IndexedMeshArrowTableData = arrow.Table<IndexedMeshArrowColumns>;
47
+
48
+ /** Predefined Apache Arrow schema for common mesh vertex columns. */
49
+ export const meshArrowSchema = new arrow.Schema<MeshArrowColumns>([
50
+ new arrow.Field(
51
+ 'POSITION',
52
+ new arrow.FixedSizeList(3, new arrow.Field('value', new arrow.Float32(), false)),
53
+ false
54
+ )
55
+ ]);
56
+
57
+ /** Predefined Apache Arrow schema for indexed mesh vertex tables. */
58
+ export const indexedMeshArrowSchema = new arrow.Schema<IndexedMeshArrowColumns>([
59
+ ...meshArrowSchema.fields,
60
+ new arrow.Field(
61
+ 'indices',
62
+ new arrow.List(new arrow.Field('item', new arrow.Int32(), false)),
63
+ true
64
+ )
65
+ ]);
66
+
23
67
  /** Geometry part of a Mesh (compatible with a standard luma.gl "mesh") */
24
68
  export type MeshGeometry = {
25
69
  attributes: {[attributeName: string]: MeshAttribute};
@@ -1,3 +1,7 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  // Mesh category utilities
2
6
  // TODO - move to mesh category module, or to math.gl/geometry module
3
7
  import {MeshAttributes} from '../categories/category-mesh';
@@ -0,0 +1,54 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type * as arrow from 'apache-arrow';
6
+ import type {BinaryFeatureCollection, BinaryProperties} from './binary-features';
7
+ import type {BinaryGeometryType} from './binary-geometries';
8
+
9
+ /** One Arrow-backed binary feature family table. */
10
+ export type ArrowBinaryFeatureTable = {
11
+ /** Geometry family stored in this table. */
12
+ type: BinaryGeometryType;
13
+ /** Arrow table wrapper for the family. */
14
+ table: arrow.Table;
15
+ /** Original feature-level properties sidecar from the binary feature collection. */
16
+ properties: BinaryProperties['properties'];
17
+ /** Optional original feature fields sidecar. */
18
+ fields?: BinaryProperties['fields'];
19
+ };
20
+
21
+ /** Arrow-backed wrapper for binary point features. */
22
+ export type ArrowBinaryPointFeature = ArrowBinaryFeatureTable & {
23
+ type: 'Point';
24
+ };
25
+
26
+ /** Arrow-backed wrapper for binary line features. */
27
+ export type ArrowBinaryLineFeature = ArrowBinaryFeatureTable & {
28
+ type: 'LineString';
29
+ };
30
+
31
+ /** Arrow-backed wrapper for binary polygon features. */
32
+ export type ArrowBinaryPolygonFeature = ArrowBinaryFeatureTable & {
33
+ type: 'Polygon';
34
+ };
35
+
36
+ /**
37
+ * Arrow-backed wrapper for a binary feature collection.
38
+ *
39
+ * This mirrors the existing `BinaryFeatureCollection` family split while exposing the
40
+ * renderable arrays through Arrow nested list columns.
41
+ */
42
+ export type ArrowBinaryFeatureCollection = {
43
+ /** Discriminator for Arrow-backed binary feature collections. */
44
+ shape: 'arrow-binary-feature-collection';
45
+ /** Optional Arrow-backed point family table. */
46
+ points?: ArrowBinaryPointFeature;
47
+ /** Optional Arrow-backed line family table. */
48
+ lines?: ArrowBinaryLineFeature;
49
+ /** Optional Arrow-backed polygon family table. */
50
+ polygons?: ArrowBinaryPolygonFeature;
51
+ };
52
+
53
+ /** Supported binary feature collection wrapper shapes. */
54
+ export type BinaryFeatureCollectionLike = BinaryFeatureCollection | ArrowBinaryFeatureCollection;
package/src/index.ts CHANGED
@@ -15,7 +15,7 @@ export type {
15
15
 
16
16
  // SCHEMAS AND DATA TYPES
17
17
 
18
- export type {Schema, Field, DataType, SchemaMetadata, FieldMetadata} from './types/schema';
18
+ export type {Schema, Field, DataType, KeyType, SchemaMetadata, FieldMetadata} from './types/schema';
19
19
  export type {Batch} from './types/batch';
20
20
 
21
21
  // TABLE CATEGORY TYPES
@@ -42,11 +42,16 @@ export type {
42
42
  export type {
43
43
  MeshTable,
44
44
  MeshArrowTable,
45
+ MeshArrowColumns,
46
+ IndexedMeshArrowColumns,
47
+ MeshArrowTableData,
48
+ IndexedMeshArrowTableData,
45
49
  Mesh,
46
50
  MeshGeometry,
47
51
  MeshAttribute,
48
52
  MeshAttributes
49
53
  } from './categories/category-mesh';
54
+ export {meshArrowSchema, indexedMeshArrowSchema} from './categories/category-mesh';
50
55
 
51
56
  // TEXTURES
52
57
  export type {
@@ -113,8 +118,16 @@ export type {
113
118
  BinaryLineFeature,
114
119
  BinaryPolygonFeature
115
120
  } from './categories/category-gis';
121
+ export type {
122
+ ArrowBinaryFeatureTable,
123
+ ArrowBinaryPointFeature,
124
+ ArrowBinaryLineFeature,
125
+ ArrowBinaryPolygonFeature,
126
+ ArrowBinaryFeatureCollection,
127
+ BinaryFeatureCollectionLike
128
+ } from './categories/category-gis';
116
129
 
117
- // DEPRECATED
130
+ // DEPRECATED EXPORTS
118
131
 
119
132
  // MESH CATEGORY
120
133
 
@@ -24,7 +24,9 @@ export type DataType =
24
24
  | 'float32'
25
25
  | 'float64'
26
26
  | 'binary'
27
+ | 'binary-view'
27
28
  | 'utf8'
29
+ | 'utf8-view'
28
30
  | 'date-day'
29
31
  | 'date-millisecond'
30
32
  | 'time-second'