forked from keplergl/kepler.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreducers.d.ts
More file actions
607 lines (544 loc) · 13.3 KB
/
Copy pathreducers.d.ts
File metadata and controls
607 lines (544 loc) · 13.3 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
import {Field, Millisecond} from './types';
import type {MapViewState} from '@deck.gl/core/typed';
export type MapState = {
pitch: number;
bearing: number;
latitude: number;
longitude: number;
zoom: number;
dragRotate: boolean;
width: number;
height: number;
minZoom?: number;
maxZoom?: number;
maxBounds?: Bounds;
initialState?: any;
scale?: number;
// the following 4 properties assist with split viewports that can optionally have (un)synced viewports and zooms
/** Is the application split into 2 maps? */
isSplit: boolean;
/** Are the 2 split maps having synced viewports? */
isViewportSynced: boolean;
/** If split, are the zooms locked to each other or independent? */
isZoomLocked: boolean;
/** An array of either 0 or 2 Viewport objects (index 0 for left map; index 1 for right map) */
splitMapViewports: Viewport[];
};
export type Bounds = [number, number, number, number];
export type RangeFieldDomain = {
domain: number[];
step: number;
bins?: Bins;
};
export type SelectFieldDomain = {
domain: boolean[];
};
export type MultiSelectFieldDomain = {
domain: string[];
};
export type TimeRangeFieldDomain = {
domain: [number, number];
step: number;
timeBins?: TimeBins;
mappedValue: (Millisecond | null)[];
// auto generated based on time domain
defaultTimeFormat?: string | null;
// custom ui input
timeFormat?: string | null;
// custom ui input
timezone?: string | null;
};
export type FieldDomain =
| RangeFieldDomain
| TimeRangeFieldDomain
| SelectFieldDomain
| MultiSelectFieldDomain;
export interface LineDatum {
x: number;
y: number;
delta: string;
pct: number | null;
}
export type LineChart = {
series: {x: number; y: number}[];
yDomain: number[] | undefined[];
xDomain: number[];
// Is this a valid part of LineChart?
aggregation: string;
interval: string;
yAxis: string;
bins?: Bins;
};
type FilterViewType = 'side' | 'enlarged' | 'minified';
export type FilterBase<L extends LineChart> = {
dataId: string[];
id: string;
enabled: boolean;
// time range filter specific
fixedDomain: boolean;
view: FilterViewType;
isAnimating: boolean;
speed: number;
showTimeDisplay?: boolean;
// field specific
name: string[]; // string
type: string | null;
fieldIdx: number[]; // [integer]
domain: any[] | null;
value: any;
mappedValue?: number[];
// plot
yAxis: Field | null;
plotType: {
[key: string]: any;
};
lineChart?: L;
// gpu filter
gpu: boolean;
gpuChannel?: number[];
fieldType?: string;
// polygon
layerId?: string[];
};
export type RangeFilter = FilterBase<LineChart> &
RangeFieldDomain & {
type: 'range';
fieldType: 'real' | 'integer';
value: [number, number];
fixedDomain: true;
typeOptions: ['range'];
plotType: {
[key: string]: any;
};
};
export type SelectFilter = FilterBase<LineChart> &
SelectFieldDomain & {
type: 'select';
fieldType: 'boolean';
value: boolean;
};
export type MultiSelectFilter = FilterBase<LineChart> &
MultiSelectFieldDomain & {
type: 'multiSelect';
fieldType: 'string' | 'date';
value: string[];
};
export type SyncTimelineMode = 0 | 1;
export type TimeRangeFilter = FilterBase<LineChart> &
TimeRangeFieldDomain & {
type: 'timeRange';
fieldType: 'timestamp';
fixedDomain: boolean;
value: [number, number];
plotType: {
[key: string]: any;
};
syncedWithLayerTimeline: boolean;
syncTimelineMode: SyncTimelineMode;
animationWindow: string;
invertTrendColor: boolean;
};
export type PolygonFilter = FilterBase<LineChart> & {
layerId: string[];
type: 'polygon';
fixedDomain: true;
value: Feature;
};
export type Filter =
| FilterBase<LineChart>
| RangeFilter
| TimeRangeFilter
| SelectFilter
| MultiSelectFilter
| PolygonFilter;
export interface Bin {
count: number;
indexes: number[];
x0: number;
x1: number;
}
export interface Bins {
[dataId: string]: Bin[];
}
export interface TimeBins {
[dataId: string]: {
[interval: string]: Bin[];
};
}
export interface PlotType {
interval: ValueOf<Interval>;
type: ValueOf<PlotTypes>;
aggregation: ValueOf<AggregationTypes>;
defaultTimeFormat: string;
colorsByDataId?: {[dataId: string]: string};
}
export type Feature = {
id: string;
properties: any;
geometry: {
type: string;
coordinates: any;
};
type?: string;
};
export type FeatureSelectionContext = {
rightClick: boolean;
position: {x: number; y: number};
mapIndex?: number;
};
export type FeatureValue = {
id: string;
properties: {
filterId: string;
};
geometry: {
type: string;
coordinates: any;
};
};
export type Editor = {
mode: string;
features: Feature[];
selectedFeature: any;
selectionContext?: FeatureSelectionContext;
visible: boolean;
};
export type SplitMapLayers = {[key: string]: boolean};
export type SplitMap = {
id?: string;
layers: SplitMapLayers;
};
/** See "Locale aware formats" at https://momentjs.com/docs/#/parsing/string-format/ */
export type AnimationConfigTimeFormat = 'L' | 'L LT' | 'L LTS';
export type AnimationConfig = {
domain: [number, number] | null;
currentTime: number | null;
speed: number;
duration?: number | null;
isAnimating?: boolean;
timeSteps: number[] | null;
// auto generated based on time domain
defaultTimeFormat: AnimationTimeFormat | null;
// custom ui input
timeFormat?: AnimationTimeFormat | null;
// custom ui input
timezone?: string | null;
// hide or show control
hideControl?: boolean;
};
export type FilterAnimationConfig = Pick<
TimeRangeFilter,
| 'dataId'
| 'value'
| 'animationWindow'
| 'speed'
| 'syncedWithLayerTimeline'
| 'syncTimelineMode'
| 'timezone'
>;
export type Timeline = {
domain: [number, number] | null;
value: number | [number, number];
speed: number;
isAnimating: boolean;
step?: null | number;
timeSteps?: null | number[];
defaultTimeFormat?: null | string;
timeFormat?: null | string;
timezone?: null | string;
timeBins?: null | Record<string, any>;
animationWindow?: null | Filter['animationWindow'];
marks?: null | number[];
} & Record<string, any>;
export type BaseInteraction = {
label: string;
enabled: boolean;
};
export type TooltipField = {
name: string;
format: string | null;
};
export type CompareType = string | null;
export type TooltipInfo = BaseInteraction & {
id: 'tooltip';
config: {
fieldsToShow: {
[key: string]: TooltipField[];
};
compareMode: boolean;
compareType: CompareType;
};
};
export type Geocoder = BaseInteraction & {
id: 'geocoder';
position: number[] | null;
};
export type Brush = BaseInteraction & {
id: 'brush';
config: {
size: number;
};
};
export type Coordinate = BaseInteraction & {
id: 'coordinate';
position: number[] | null;
};
export type InteractionConfig = {
tooltip: TooltipInfo;
geocoder: Geocoder;
brush: Brush;
coordinate: Coordinate;
};
export type MapInfo = {
title: string;
description: string;
};
export type FileLoading = {
filesToLoad: FileList;
onFinish: (payload: any) => any;
fileCache: any[];
};
export type FileLoadingProgress = {
[key: string]: {
percent: number;
message: string;
fileName: string;
error: any;
};
};
export type LayerGroup = {
slug: string;
filter(layer: {id: string}): boolean;
defaultVisibility: boolean;
};
export type CustomStyleType =
| 'LOCAL'
| 'MANAGED'
// boolean for backwards compatability with previous map configs
| boolean;
export type BaseMapColorModes = 'NONE' | 'DARK' | 'LIGHT';
export type BaseMapStyle = {
id: string;
label: string;
url: string;
icon: string;
style?: object;
layerGroups: LayerGroup[];
accessToken?: string;
custom?: CustomStyleType;
colorMode?: BaseMapColorModes;
complimentaryStyleId?: string;
};
export declare type ExportImage = {
legend: boolean;
mapH: number;
mapW: number;
imageSize: {
zoomOffset: number;
scale: number;
imageW: number;
imageH: number;
};
imageDataUri: string;
exporting: boolean;
processing: boolean;
error: Error | false;
center: boolean;
escapeXhtmlForWebpack?: boolean;
};
export type ExportData = {
selectedDataset: string;
dataType: string;
filtered: boolean;
};
export type ExportHtml = {
exportMapboxAccessToken: null | string;
userMapboxToken: string;
mode: string;
};
export type ExportJson = {
hasData: boolean;
};
export type ExportMap = {
HTML: ExportHtml;
JSON: ExportJson;
format: 'HTML' | 'JSON';
};
export type MapControlItem = {
show: boolean;
active: boolean;
disableClose?: boolean;
activeMapIndex?: number;
};
export type MapLegendControlSettings = {
position: {
x: number;
y: number;
anchorX: 'left' | 'right';
anchorY: 'top' | 'bottom';
};
contentHeight: number;
};
export type MapControlMapLegend = MapControlItem & {
disableEdit?: boolean;
settings?: MapLegendControlSettings;
};
export type MapControls = {
visibleLayers?: MapControlItem;
mapLegend?: MapControlMapLegend;
toggle3d?: MapControlItem;
splitMap?: MapControlItem;
mapDraw?: MapControlItem;
mapLocale?: MapControlItem;
effect?: MapControlItem;
aiAssistant?: MapControlItem;
};
export type LoadFiles = {
fileLoading: boolean;
};
export type Notifications = {
message: string;
type: string;
topic: string;
id: string;
count: number;
isExpanded?: boolean;
};
export type Locale = string;
export type PanelListView = string;
export type UiState = {
readOnly: boolean;
activeSidePanel: string | null;
currentModal: string | null;
datasetKeyToRemove: string | null;
visibleDropdown: string | null;
// export image modal ui
exportImage: ExportImage;
// export data modal ui
exportData: ExportData;
// html export
exportMap: ExportMap;
// map control panels
mapControls: MapControls;
// ui notifications
notifications: Notifications[];
// load files
loadFiles: LoadFiles;
// Locale of the UI
locale: Locale;
// view layers by list or dataset
layerPanelListView: PanelListView;
// view filters by list or dataset
filterPanelListView: PanelListView;
// side panel close button visibility
isSidePanelCloseButtonVisible: boolean | null;
// positive value indicates that something is loading
loadingIndicatorValue?: number;
};
/** Width of viewport */
export type Viewport = {
/** Width of viewport */
width?: number;
/** Height of viewport */
height?: number;
/** Zoom of viewport */
zoom?: number;
/** Camera angle in degrees (0 is straight down) */
pitch?: number;
/** Map rotation in degrees (0 means north is up) */
bearing?: number;
/** Latitude center of viewport on map in mercator projection */
latitude?: number;
/** Longitude Center of viewport on map in mercator projection */
longitude?: number;
/** Whether to enable drag and rotate map into perspective viewport */
dragRotate?: boolean;
/** Minimum allowed viewport zoom */
minZoom?: number;
/** Maximum allowed viewport zoom */
maxZoom?: number;
/** Maximum geographical bounds, pan/zoom operations are constrained within those bounds */
maxBounds?: Bounds;
/** viewport transition duration use by geocoder panel **/
transitionDuration?: MapViewState['transitionDuration'];
/** viewport transition duration use by geocoder panel **/
transitionInterpolator?: MapViewState['transitionInterpolator'];
};
export type MapStyles = {
[key: string]: BaseMapStyle;
};
export type VisibleLayerGroups = {
[key: string]: boolean;
};
export type InputStyle = {
id?: string | null;
accessToken: string | null;
error: boolean;
isValid: boolean;
label: string | null;
style: any | null;
url: string | null;
icon: string | null;
custom: CustomStyleType;
uploadedFile: File | null;
};
export type FilterRecord = {
dynamicDomain: Filter[];
fixedDomain: Filter[];
cpu: Filter[];
gpu: Filter[];
};
export type FilterDatasetOpt = {
// only allow cpu filtering
cpuOnly?: boolean;
// ignore filter for domain calculation
ignoreDomain?: boolean;
};
/* DUPLICATES OF FILTER TYPES ABOVE, REMOVE ONCE TYPES ABOVE ARE FIXED */
type FilterBaseOmitRedudant = Omit<FilterBase<LineChart>, 'type' | 'domain'>;
export type TypedRangeFilter = FilterBaseOmitRedudant &
RangeFieldDomain & {
type: 'range';
fieldType: 'real' | 'integer';
value: [number, number];
fixedDomain: true;
typeOptions: ['range'];
};
export type TypedSelectFilter = FilterBaseOmitRedudant &
SelectFieldDomain & {
type: 'select';
fieldType: 'boolean';
value: boolean;
};
export type TypedMultiSelectFilter = FilterBaseOmitRedudant &
MultiSelectFieldDomain & {
type: 'multiSelect';
fieldType: 'string' | 'date';
value: string[];
};
export type TypedTimeRangeFilter = FilterBaseOmitRedudant &
TimeRangeFieldDomain & {
type: 'timeRange';
fieldType: 'timestamp';
fixedDomain: true;
value: [number, number];
plotType: {
[key: string]: any;
};
animationWindow: string;
invertTrendColor: boolean;
};
export type TypedPolygonFilter = FilterBaseOmitRedudant & {
layerId: string[];
type: 'polygon';
fixedDomain: true;
value: Feature;
};
export type TypedFilter =
| TypedRangeFilter
| TypedTimeRangeFilter
| TypedSelectFilter
| TypedMultiSelectFilter
| TypedPolygonFilter;