-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtypes.ts
72 lines (63 loc) · 2.45 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// deck.gl-community
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import type { BinaryAttribute, Color, PickingInfo } from "@deck.gl/core";
import { TypedArray } from "@deck.gl/core/dist/types/types";
import * as arrow from "apache-arrow";
/**
* An individual layer's data
*/
export type GeoArrowLayerData<T> = {
data: T;
length: number;
attributes?: Record<string, TypedArray | Buffer | BinaryAttribute>;
};
/**
* Internal type for layer data handling, used in `wrapAccessorFunction`.
*/
export type _GeoArrowInternalLayerData<T> = GeoArrowLayerData<T> & {
/**
* A lookup table from expanded multi-geometry index to original index.
*
* This is omitted from the user-facing type because in `wrapAccessorFunction`
* in `utils.ts` we apply the lookup from "exploded" row to "original" row.
*/
invertedGeomOffsets?: Uint8Array | Uint16Array | Uint32Array;
};
export type AccessorContext<T> = {
/** The current row index of the current iteration */
index: number;
/** The value of the `data` prop */
data: GeoArrowLayerData<T>;
/** A pre-allocated array. The accessor function can optionally fill data into this array and return it,
* instead of creating a new array for every object. In some browsers this improves performance significantly
* by reducing garbage collection. */
target: number[];
};
/**
* Internal type for layer data handling, used in `wrapAccessorFunction`.
*/
export type _InternalAccessorContext<T> = AccessorContext<T> & {
/** The value of the `data` prop */
data: _GeoArrowInternalLayerData<T>;
};
/** Function that returns a value for each object. */
export type AccessorFunction<In, Out> = (
/** Contextual information of the current element. */
objectInfo: AccessorContext<In>,
) => Out;
/** Either a uniform value for all objects, or a function that returns a value for each object. */
export type Accessor<In, Out> = Out | AccessorFunction<In, Out>;
export type GeoArrowPickingInfo = PickingInfo & {
object?: arrow.StructRowProxy;
};
export type FloatAccessor =
| arrow.Vector<arrow.Float>
| Accessor<arrow.RecordBatch, number>;
export type TimestampAccessor = arrow.Vector<arrow.List<arrow.Float>>;
export type ColorAccessor =
| arrow.Vector<arrow.FixedSizeList<arrow.Uint8>>
| Accessor<arrow.RecordBatch, Color | Color[]>;
export type NormalAccessor =
| arrow.Vector<arrow.FixedSizeList<arrow.Float32>>
| Accessor<arrow.Table, arrow.Vector<arrow.FixedSizeList<arrow.Float32>>>;