-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
default-settings.ts
1437 lines (1331 loc) · 34.4 KB
/
default-settings.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
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
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
import keyMirror from 'keymirror';
import {
scaleLinear,
scaleQuantize,
scaleQuantile,
scaleOrdinal,
scaleSqrt,
scaleLog,
scalePoint
} from 'd3-scale';
import {TOOLTIP_FORMAT_TYPES} from './tooltip';
import {RGBAColor, EffectDescription, BaseMapStyle} from '@kepler.gl/types';
export const ACTION_PREFIX = '@@kepler.gl/';
export const KEPLER_UNFOLDED_BUCKET = 'https://studio-public-data.foursquare.com/statics/keplergl';
export const BASEMAP_ICON_PREFIX = `${KEPLER_UNFOLDED_BUCKET}/geodude`;
export const DEFAULT_MAPBOX_API_URL = 'https://api.mapbox.com';
export const TRANSITION_DURATION = 0;
// Modal Ids
/**
* Modal id: data table
* @constant
* @type {string}
* @public
*/
export const DATA_TABLE_ID = 'dataTable';
/**
* Modal id: delete dataset confirm dialog
* @constant
* @type {string}
* @public
*/
export const DELETE_DATA_ID = 'deleteData';
/**
* Modal id: add data modal
* @constant
* @type {string}
* @public
*/
export const ADD_DATA_ID = 'addData';
/**
* Modal id: export image modal
* @constant
* @type {string}
* @public
*/
export const EXPORT_IMAGE_ID = 'exportImage';
/**
* Modal id: export data modal
* @constant
* @type {string}
* @public
*/
export const EXPORT_DATA_ID = 'exportData';
/**
* Modal id: add custom map style modal
* @constant
* @type {string}
* @public
*/
export const ADD_MAP_STYLE_ID = 'addMapStyle';
/**
* Modal id: export map modal
* @constant
* @type {string}
* @public
*/
export const EXPORT_MAP_ID = 'exportMap';
/**
* Modal id: save map modal
* @constant
* @type {string}
* @public
*/
export const SAVE_MAP_ID = 'saveMap';
/**
* Modal id: confirm to overwrite saved map
* @constant
* @type {string}
* @public
*/
export const OVERWRITE_MAP_ID = 'overwriteMap';
/**
* Modal id: share map url modal
* @constant
* @type {string}
* @public
*/
export const SHARE_MAP_ID = 'shareMap';
export const KEPLER_GL_NAME = 'kepler.gl';
// __PACKAGE_VERSION__ is automatically injected by Babel/Webpack during the building process
// Since we are injecting this during the build process with babel
// while developing VERSION is not defined, we capture the exception and return
// an empty string which will allow us to retrieve the latest umd version
export const KEPLER_GL_VERSION = '__PACKAGE_VERSION__';
export const KEPLER_GL_WEBSITE = 'http://kepler.gl/';
export const DIMENSIONS = {
sidePanel: {
width: 300,
margin: {top: 20, left: 20, bottom: 30, right: 20},
headerHeight: 96
},
mapControl: {
width: 184,
padding: 12,
mapLegend: {
pinned: {
bottom: 22,
right: 12
}
}
}
};
/**
* Theme name that can be passed to `KeplerGl` `prop.theme`.
* Available themes are `THEME.light` and `THEME.dark`. Default theme is `THEME.dark`
* @constant
* @type {object}
* @public
* @example
* ```js
* const Map = () => <KeplerGl theme={THEME.light} id="map"/>
* ```
*/
export const THEME = keyMirror({
light: null,
dark: null,
base: null
});
export const SIDEBAR_PANELS = [
{
id: 'layer',
label: 'sidebar.panels.layer',
onClick: null
},
{
id: 'filter',
label: 'sidebar.panels.filter',
onClick: null
},
{
id: 'interaction',
label: 'sidebar.panels.interaction',
onClick: null
},
{
id: 'map',
label: 'sidebar.panels.basemap',
onClick: null
}
];
export const PANEL_VIEW_TOGGLES = keyMirror({
list: null,
byDataset: null
});
// backward compatibility
export const PANELS = SIDEBAR_PANELS;
// MAP STYLES
export const DEFAULT_BLDG_COLOR = '#D1CEC7';
export const DEFAULT_BACKGROUND_COLOR = '#000000';
// assists in identifying basemap background layers when auto-determining the backgroundColor
export const BASE_MAP_BACKGROUND_LAYER_IDS = ['background', 'bg', 'land', 'water'];
export const BACKGROUND_LAYER_GROUP_SLUG = 'Background';
export const THREE_D_BUILDING_LAYER_GROUP_SLUG = '3d building';
export type DEFAULT_LAYER_GROUP = {
slug: string;
filter: (value) => boolean;
defaultVisibility: boolean;
isVisibilityToggleAvailable?: boolean;
isMoveToTopAvailable?: boolean;
isColorPickerAvailable?: boolean;
};
export const BACKGROUND_LAYER_GROUP: DEFAULT_LAYER_GROUP = {
slug: BACKGROUND_LAYER_GROUP_SLUG,
filter: () => false,
defaultVisibility: false,
isVisibilityToggleAvailable: false,
isMoveToTopAvailable: false,
isColorPickerAvailable: true
};
export const DEFAULT_LAYER_GROUPS: DEFAULT_LAYER_GROUP[] = [
{
slug: 'label',
filter: ({id}) => id.match(/(?=(label|place-|poi-))/),
defaultVisibility: true,
isVisibilityToggleAvailable: true,
isMoveToTopAvailable: true,
isColorPickerAvailable: false
},
{
slug: 'road',
filter: ({id}) => id.match(/(?=(road|railway|tunnel|street|bridge))(?!.*label)/),
defaultVisibility: true,
isVisibilityToggleAvailable: true,
isMoveToTopAvailable: true,
isColorPickerAvailable: false
},
{
slug: 'border',
filter: ({id}) => id.match(/border|boundaries|boundary/),
defaultVisibility: false,
isVisibilityToggleAvailable: true,
isMoveToTopAvailable: true,
isColorPickerAvailable: false
},
{
slug: 'building',
filter: ({id}) => id.match(/building/),
defaultVisibility: true,
isVisibilityToggleAvailable: true,
isMoveToTopAvailable: true,
isColorPickerAvailable: false
},
{
slug: 'water',
filter: ({id}) => id.match(/(?=(water|stream|ferry))/),
defaultVisibility: true,
isVisibilityToggleAvailable: true,
isMoveToTopAvailable: true,
isColorPickerAvailable: false
},
{
slug: 'land',
filter: ({id}) => id.match(/(?=(parks|landcover|industrial|sand|hillshade))/),
defaultVisibility: true,
isVisibilityToggleAvailable: true,
isMoveToTopAvailable: true,
isColorPickerAvailable: false
},
{
slug: THREE_D_BUILDING_LAYER_GROUP_SLUG,
filter: () => false,
defaultVisibility: false,
isVisibilityToggleAvailable: true,
isMoveToTopAvailable: true,
isColorPickerAvailable: true
}
];
export const BASE_MAP_COLOR_MODES = keyMirror({
NONE: null,
DARK: null,
LIGHT: null
});
export const NO_MAP_ID = 'no_map';
// Fallback style to use when styles are being fetched, or when
// a style fails to fetch
export const EMPTY_MAPBOX_STYLE = {
version: 8,
sources: {},
layers: []
};
export const NO_BASEMAP_ICON = `${BASEMAP_ICON_PREFIX}/NO_BASEMAP.png`;
export const DEFAULT_MAP_STYLES: BaseMapStyle[] = [
{
id: NO_MAP_ID,
label: 'No Basemap',
url: '',
icon: NO_BASEMAP_ICON,
layerGroups: [BACKGROUND_LAYER_GROUP],
colorMode: BASE_MAP_COLOR_MODES.NONE,
style: EMPTY_MAPBOX_STYLE
},
{
id: 'dark-matter',
label: 'DarkMatter',
url: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
icon: `${BASEMAP_ICON_PREFIX}/DARKMATTER.png`,
layerGroups: DEFAULT_LAYER_GROUPS,
colorMode: BASE_MAP_COLOR_MODES.DARK,
complimentaryStyleId: 'positron'
},
{
id: 'dark-matter-nolabels',
label: 'DarkMatterNoLabels',
url: 'https://basemaps.cartocdn.com/gl/dark-matter-nolabels-gl-style/style.json',
icon: `${BASEMAP_ICON_PREFIX}/DARKMATTER_NOLABELS.png`,
layerGroups: DEFAULT_LAYER_GROUPS,
colorMode: BASE_MAP_COLOR_MODES.DARK,
complimentaryStyleId: 'positron-nolabels'
},
{
id: 'positron',
label: 'Positron',
url: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
icon: `${BASEMAP_ICON_PREFIX}/POSITRON.png`,
layerGroups: DEFAULT_LAYER_GROUPS,
colorMode: BASE_MAP_COLOR_MODES.LIGHT,
complimentaryStyleId: 'dark-matter'
},
{
id: 'positron-nolabels',
label: 'PositronNoLabels',
url: 'https://basemaps.cartocdn.com/gl/positron-nolabels-gl-style/style.json',
icon: `${BASEMAP_ICON_PREFIX}/POSITRON_NOLABELS.png`,
layerGroups: DEFAULT_LAYER_GROUPS,
colorMode: BASE_MAP_COLOR_MODES.LIGHT,
complimentaryStyleId: 'dark-matter-nolabels'
},
{
id: 'voyager',
label: 'Voyager',
url: 'https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json',
icon: `${BASEMAP_ICON_PREFIX}/VOYAGER.png`,
layerGroups: DEFAULT_LAYER_GROUPS,
colorMode: BASE_MAP_COLOR_MODES.LIGHT,
complimentaryStyleId: 'dark-matter'
},
{
id: 'voyager-nolabels',
label: 'VoyagerNoLabels',
url: 'https://basemaps.cartocdn.com/gl/voyager-nolabels-gl-style/style.json',
icon: `${BASEMAP_ICON_PREFIX}/VOYAGER_NOLABELS.png`,
layerGroups: DEFAULT_LAYER_GROUPS,
colorMode: BASE_MAP_COLOR_MODES.LIGHT,
complimentaryStyleId: 'dark-matter-nolabels'
}
];
export const GEOJSON_FIELDS = {
geojson: ['_geojson', 'all_points', 'geojson']
};
export const ICON_FIELDS = {
icon: ['icon']
};
export const TRIP_POINT_FIELDS: [string, string][] = [
['lat', 'lng'],
['lat', 'lon'],
['lat', 'long'],
['latitude', 'longitude']
];
export const ALTITUDE_FIELDS = ['alt', 'altitude'];
export const TRIP_ARC_FIELDS = {
lat0: 'begintrip',
lng0: 'begintrip',
lat1: 'dropoff',
lng1: 'dropoff'
};
export const FILTER_TYPES = keyMirror({
range: null,
select: null,
input: null,
timeRange: null,
multiSelect: null,
polygon: null
});
export const FILTER_VIEW_TYPES = keyMirror({
side: null,
enlarged: null,
minified: null
});
export const DEFAULT_FILTER_VIEW_TYPE = FILTER_VIEW_TYPES.side;
export const SCALE_TYPES = keyMirror({
ordinal: null,
quantile: null,
quantize: null,
linear: null,
sqrt: null,
log: null,
// ordinal domain to linear range
point: null
});
export const SCALE_FUNC = {
[SCALE_TYPES.linear]: scaleLinear,
[SCALE_TYPES.quantize]: scaleQuantize,
[SCALE_TYPES.quantile]: scaleQuantile,
[SCALE_TYPES.ordinal]: scaleOrdinal,
[SCALE_TYPES.sqrt]: scaleSqrt,
[SCALE_TYPES.log]: scaleLog,
[SCALE_TYPES.point]: scalePoint
};
export const ALL_FIELD_TYPES = keyMirror({
boolean: null,
date: null,
geojson: null,
integer: null,
real: null,
string: null,
timestamp: null,
point: null,
array: null,
object: null,
geoarrow: null
});
// Data Table
export const SORT_ORDER = keyMirror({
ASCENDING: null,
DESCENDING: null,
UNSORT: null
});
export const TABLE_OPTION = keyMirror({
SORT_ASC: null,
SORT_DES: null,
UNSORT: null,
PIN: null,
UNPIN: null,
COPY: null,
FORMAT_COLUMN: null
});
export const TABLE_OPTION_LIST = [
{
value: TABLE_OPTION.SORT_ASC,
display: 'Sort Ascending',
icon: 'ArrowUp',
condition: props => props.sortMode !== SORT_ORDER.ASCENDING
},
{
value: TABLE_OPTION.SORT_DES,
display: 'Sort Descending',
icon: 'ArrowDown',
condition: props => props.sortMode !== SORT_ORDER.DESCENDING
},
{
value: TABLE_OPTION.UNSORT,
display: 'Unsort Column',
icon: 'Cancel',
condition: props => props.isSorted
},
{
value: TABLE_OPTION.PIN,
display: 'Pin Column',
icon: 'Pin',
condition: props => !props.isPinned
},
{
value: TABLE_OPTION.UNPIN,
display: 'Unpin Column',
icon: 'Cancel',
condition: props => props.isPinned
},
{value: TABLE_OPTION.COPY, display: 'Copy Column', icon: 'Clipboard'},
{value: TABLE_OPTION.FORMAT_COLUMN, display: 'Format Column', icon: 'Hash'}
];
const YELLOW = '248, 194, 28';
const PINK = '242, 152, 163';
const PURPLE = '160, 106, 206';
const BLUE = '140, 210, 205';
const BLUE2 = '106, 160, 206';
const BLUE3 = '0, 172, 237';
const GREEN = '106, 160, 56';
const GREEN2 = '74, 165, 150';
const RED = '237, 88, 106';
const ORANGE = '231, 110, 58';
export const FIELD_TYPE_DISPLAY = {
[ALL_FIELD_TYPES.boolean]: {
label: 'bool',
color: PINK
},
[ALL_FIELD_TYPES.date]: {
label: 'date',
color: PURPLE
},
[ALL_FIELD_TYPES.geojson]: {
label: 'geo',
color: BLUE2
},
[ALL_FIELD_TYPES.geoarrow]: {
label: 'geo',
color: BLUE2
},
[ALL_FIELD_TYPES.integer]: {
label: 'int',
color: YELLOW
},
[ALL_FIELD_TYPES.real]: {
label: 'float',
color: YELLOW
},
[ALL_FIELD_TYPES.string]: {
label: 'string',
color: BLUE
},
[ALL_FIELD_TYPES.timestamp]: {
label: 'time',
color: GREEN
},
// field pairs
[ALL_FIELD_TYPES.point]: {
label: 'point',
color: BLUE3
},
[ALL_FIELD_TYPES.array]: {
label: 'array',
color: ORANGE
},
[ALL_FIELD_TYPES.object]: {
label: 'object',
color: GREEN2
}
};
export const FIELD_COLORS = {
default: RED
};
export const HIGHLIGH_COLOR_3D: RGBAColor = [255, 255, 255, 60];
export const CHANNEL_SCALES = keyMirror({
color: null,
radius: null,
size: null,
colorAggr: null,
sizeAggr: null
});
export const AGGREGATION_TYPES: {
// default
count: 'count';
// linear
average: 'average';
maximum: 'maximum';
minimum: 'minimum';
median: 'median';
stdev: 'stdev';
sum: 'sum';
variance: 'variance';
// ordinal
mode: 'mode';
countUnique: 'countUnique';
} = {
// default
count: 'count',
// linear
average: 'average',
maximum: 'maximum',
minimum: 'minimum',
median: 'median',
stdev: 'stdev',
sum: 'sum',
variance: 'variance',
// ordinal
mode: 'mode',
countUnique: 'countUnique'
};
export const AGGREGATION_TYPE_OPTIONS: {id: string; label: string}[] = Object.entries(
AGGREGATION_TYPES
).map(([key, value]) => ({
id: key,
label:
key === 'stdev'
? 'Std Deviation'
: key === 'countUnique'
? 'Count Unique'
: typeof value === 'string'
? value.charAt(0).toUpperCase() + value.slice(1)
: value
}));
export const linearFieldScaleFunctions = {
[CHANNEL_SCALES.color]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile],
[CHANNEL_SCALES.radius]: [SCALE_TYPES.sqrt],
[CHANNEL_SCALES.size]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log]
};
export const linearFieldAggrScaleFunctions = {
[CHANNEL_SCALES.colorAggr]: {
[AGGREGATION_TYPES.average]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile],
[AGGREGATION_TYPES.maximum]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile],
[AGGREGATION_TYPES.minimum]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile],
[AGGREGATION_TYPES.median]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile],
[AGGREGATION_TYPES.stdev]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile],
[AGGREGATION_TYPES.sum]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile],
[AGGREGATION_TYPES.variance]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile]
},
[CHANNEL_SCALES.sizeAggr]: {
[AGGREGATION_TYPES.average]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
[AGGREGATION_TYPES.maximum]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
[AGGREGATION_TYPES.minimum]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
[AGGREGATION_TYPES.median]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
[AGGREGATION_TYPES.stdev]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
[AGGREGATION_TYPES.sum]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
[AGGREGATION_TYPES.variance]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log]
}
};
export const ordinalFieldScaleFunctions = {
[CHANNEL_SCALES.color]: [SCALE_TYPES.ordinal],
[CHANNEL_SCALES.radius]: [SCALE_TYPES.point],
[CHANNEL_SCALES.size]: [SCALE_TYPES.point]
};
export const ordinalFieldAggrScaleFunctions = {
// [CHANNEL_SCALES.colorAggr]: [SCALE_TYPES.ordinal, SCALE_TYPES.linear],
[CHANNEL_SCALES.colorAggr]: {
[AGGREGATION_TYPES.mode]: [SCALE_TYPES.ordinal],
[AGGREGATION_TYPES.countUnique]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile]
},
// Currently doesn't support yet
[CHANNEL_SCALES.sizeAggr]: {}
};
export const notSupportedScaleOpts = {
[CHANNEL_SCALES.color]: [],
[CHANNEL_SCALES.radius]: [],
[CHANNEL_SCALES.size]: []
};
export const notSupportAggrOpts = {
[CHANNEL_SCALES.colorAggr]: {},
[CHANNEL_SCALES.sizeAggr]: {}
};
/**
* Default aggregation are based on ocunt
*/
export const DEFAULT_AGGREGATION = {
[CHANNEL_SCALES.colorAggr]: {
[AGGREGATION_TYPES.count]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile]
},
[CHANNEL_SCALES.sizeAggr]: {
[AGGREGATION_TYPES.count]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log]
}
};
/**
* Define what type of scale operation is allowed on each type of fields
*/
export const FIELD_OPTS = {
[ALL_FIELD_TYPES.string]: {
type: 'categorical',
scale: {
...ordinalFieldScaleFunctions,
...ordinalFieldAggrScaleFunctions
},
format: {
legend: d => d,
tooltip: []
}
},
[ALL_FIELD_TYPES.real]: {
type: 'numerical',
scale: {
...linearFieldScaleFunctions,
...linearFieldAggrScaleFunctions
},
format: {
legend: d => d,
tooltip: [
TOOLTIP_FORMAT_TYPES.NONE,
TOOLTIP_FORMAT_TYPES.DECIMAL,
TOOLTIP_FORMAT_TYPES.PERCENTAGE
]
}
},
[ALL_FIELD_TYPES.timestamp]: {
type: 'time',
scale: {
...linearFieldScaleFunctions,
...notSupportAggrOpts
},
format: {
legend: d => d,
tooltip: [
TOOLTIP_FORMAT_TYPES.NONE,
TOOLTIP_FORMAT_TYPES.DATE,
TOOLTIP_FORMAT_TYPES.DATE_TIME
]
}
},
[ALL_FIELD_TYPES.integer]: {
type: 'numerical',
scale: {
...linearFieldScaleFunctions,
...linearFieldAggrScaleFunctions
},
format: {
legend: d => d,
tooltip: [
TOOLTIP_FORMAT_TYPES.NONE,
TOOLTIP_FORMAT_TYPES.DECIMAL,
TOOLTIP_FORMAT_TYPES.PERCENTAGE
]
}
},
[ALL_FIELD_TYPES.boolean]: {
type: 'boolean',
scale: {
...ordinalFieldScaleFunctions,
...ordinalFieldAggrScaleFunctions
},
format: {
legend: d => d,
tooltip: [TOOLTIP_FORMAT_TYPES.NONE, TOOLTIP_FORMAT_TYPES.BOOLEAN]
}
},
[ALL_FIELD_TYPES.date]: {
type: 'time',
scale: {
...ordinalFieldScaleFunctions,
...ordinalFieldAggrScaleFunctions
},
format: {
legend: d => d,
tooltip: [TOOLTIP_FORMAT_TYPES.NONE, TOOLTIP_FORMAT_TYPES.DATE]
}
},
[ALL_FIELD_TYPES.geojson]: {
type: 'geometry',
scale: {
...notSupportedScaleOpts,
...notSupportAggrOpts
},
format: {
legend: d => '...',
tooltip: []
}
},
[ALL_FIELD_TYPES.geoarrow]: {
type: 'geometry',
scale: {
...notSupportedScaleOpts,
...notSupportAggrOpts
},
format: {
legend: d => '...',
tooltip: []
}
},
[ALL_FIELD_TYPES.object]: {
type: 'numerical',
scale: {},
format: {
legend: d => '...',
tooltip: []
}
},
[ALL_FIELD_TYPES.array]: {
type: 'numerical',
scale: {},
format: {
legend: d => '...',
tooltip: []
}
}
};
export const CHANNEL_SCALE_SUPPORTED_FIELDS = Object.keys(CHANNEL_SCALES).reduce(
(accu, key) => ({
...accu,
[key]: Object.keys(FIELD_OPTS).filter(
ft => FIELD_OPTS[ft].scale[key] && Object.keys(FIELD_OPTS[ft].scale[key]).length
)
}),
{} as {[id: string]: string[]}
);
export const DEFAULT_LAYER_COLOR = {
tripArc: '#9226C6',
begintrip_lat: '#1E96BE',
dropoff_lat: '#FF991F',
request_lat: '#52A353'
};
// let user pass in default tooltip fields
export const DEFAULT_TOOLTIP_FIELDS: any[] = [];
export const NO_VALUE_COLOR: RGBAColor = [0, 0, 0, 0];
export const DEFAULT_PICKING_RADIUS = 3;
export const OVERLAY_BLENDINGS = {
normal: {
label: 'overlayBlending.normal',
value: 'normal'
},
screen: {
label: 'overlayBlending.screen',
value: 'screen'
},
darken: {
label: 'overlayBlending.darken',
value: 'darken'
}
};
export const LAYER_BLENDINGS = {
additive: {
label: 'layerBlending.additive',
blendFunc: ['SRC_ALPHA', 'DST_ALPHA'],
blendEquation: 'FUNC_ADD'
},
normal: {
// reference to
// https://limnu.com/webgl-blending-youre-probably-wrong/
label: 'layerBlending.normal',
blendFunc: ['SRC_ALPHA', 'ONE_MINUS_SRC_ALPHA', 'ONE', 'ONE_MINUS_SRC_ALPHA'],
blendEquation: ['FUNC_ADD', 'FUNC_ADD']
},
subtractive: {
label: 'layerBlending.subtractive',
blendFunc: ['ONE', 'ONE_MINUS_DST_COLOR', 'SRC_ALPHA', 'DST_ALPHA'],
blendEquation: ['FUNC_SUBTRACT', 'FUNC_ADD']
}
};
export const MAX_DEFAULT_TOOLTIPS = 5;
export const RESOLUTIONS = keyMirror({
ONE_X: null,
TWO_X: null
});
export const EXPORT_IMG_RATIOS = keyMirror({
SCREEN: null,
FOUR_BY_THREE: null,
SIXTEEN_BY_NINE: null,
CUSTOM: null
});
export type ExportImage = {
ratio: keyof typeof EXPORT_IMG_RATIOS;
resolution: keyof typeof RESOLUTIONS;
legend: boolean;
mapH: number;
mapW: number;
imageSize: {
zoomOffset: number;
scale: number;
imageW: number;
imageH: number;
};
// exporting state
imageDataUri: string;
exporting: boolean;
processing: boolean;
error: Error | false;
escapeXhtmlForWebpack?: boolean;
// This field was not in the .d.ts file
center: boolean;
};
export type ImageRatioOption = {
id: keyof typeof EXPORT_IMG_RATIOS;
label: string;
hidden?: boolean;
getSize: (screenW: number, screenH: number) => {width: number; height: number};
};
export const ScreenRatioOption: ImageRatioOption = {
id: EXPORT_IMG_RATIOS.SCREEN,
label: 'modal.exportImage.ratioOriginalScreen',
getSize: (screenW, screenH) => ({width: screenW, height: screenH})
};
export const CustomRatioOption: ImageRatioOption = {
id: EXPORT_IMG_RATIOS.CUSTOM,
hidden: true,
label: 'modal.exportImage.ratioCustom',
getSize: (mapW, mapH) => ({width: mapW, height: mapH})
};
export const FourByThreeRatioOption: ImageRatioOption = {
id: EXPORT_IMG_RATIOS.FOUR_BY_THREE,
label: 'modal.exportImage.ratio4_3',
getSize: (screenW, screenH) => ({
width: screenW,
height: Math.round(screenW * 0.75)
})
};
export const SixteenByNineRatioOption: ImageRatioOption = {
id: EXPORT_IMG_RATIOS.SIXTEEN_BY_NINE,
label: 'modal.exportImage.ratio16_9',
getSize: (screenW, screenH) => ({
width: screenW,
height: Math.round(screenW * 0.5625)
})
};
export const EXPORT_IMG_RATIO_OPTIONS: ReadonlyArray<ImageRatioOption> = [
ScreenRatioOption,
CustomRatioOption,
FourByThreeRatioOption,
SixteenByNineRatioOption
];
export type ImageResolutionOption = {
id: keyof typeof RESOLUTIONS;
label: string;
available: boolean;
scale: number;
getSize: (screenW: number, screenH: number) => {width: number; height: number};
};
export const OneXResolutionOption: ImageResolutionOption = {
id: RESOLUTIONS.ONE_X,
label: '1x',
available: true,
scale: 1,
getSize: (screenW, screenH) => ({
width: screenW,
height: screenH
})
};
export const TwoXResolutionOption: ImageResolutionOption = {
id: RESOLUTIONS.TWO_X,
label: '2x',
available: true,
scale: 2,
getSize: (screenW, screenH) => ({
width: screenW * 2,
height: screenH * 2
})
};
export const EXPORT_IMG_RESOLUTION_OPTIONS: ReadonlyArray<ImageResolutionOption> = [
OneXResolutionOption,
TwoXResolutionOption
];
export const EXPORT_DATA_TYPE = keyMirror({
CSV: null
// SHAPEFILE: null,
// JSON: null,
// GEOJSON: null,
// TOPOJSON: null
});
export const EXPORT_DATA_TYPE_OPTIONS = [
{
id: EXPORT_DATA_TYPE.CSV,
label: EXPORT_DATA_TYPE.CSV.toLowerCase(),
available: true
}
// {
// id: EXPORT_DATA_TYPE.SHAPEFILE,
// label: 'shapefile',
// available: false
// },
// {
// id: EXPORT_DATA_TYPE.JSON,
// label: 'json',
// available: false
// },
// {
// id: EXPORT_DATA_TYPE.GEOJSON,
// label: 'geojson',
// available: false
// },
// {
// id: EXPORT_DATA_TYPE.TOPOJSON,
// label: 'topojson',
// available: false
// }
];
// Export map types
export const EXPORT_MAP_FORMATS = keyMirror({
HTML: null,
JSON: null
});
export const EXPORT_HTML_MAP_MODES = keyMirror({
READ: null,
EDIT: null
});
// Export map options
export const EXPORT_MAP_FORMAT_OPTIONS = Object.entries(EXPORT_MAP_FORMATS).map(
(entry: [string, any]) => ({
id: entry[0],