• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

keplergl / kepler.gl / 13499792134

24 Feb 2025 02:01PM UTC coverage: 66.16%. Remained the same
13499792134

Pull #3001

github

web-flow
Merge 8015e2e64 into b98a39def
Pull Request #3001: [chore] fixes to lint warnings in Github's File Changes

6025 of 10616 branches covered (56.75%)

Branch coverage included in aggregate %.

7 of 9 new or added lines in 6 files covered. (77.78%)

63 existing lines in 2 files now uncovered.

12372 of 17191 relevant lines covered (71.97%)

88.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.68
/src/constants/src/default-settings.ts
1
// SPDX-License-Identifier: MIT
2
// Copyright contributors to the kepler.gl project
3

4
import keyMirror from 'keymirror';
5

6
import {
7
  BaseMapStyle,
8
  EffectDescription,
9
  RGBAColor,
10
  SyncTimelineMode,
11
  BaseMapColorModes,
12
  Merge
13
} from '@kepler.gl/types';
14
import {
15
  scaleLinear,
16
  scaleLog,
17
  scaleOrdinal,
18
  scalePoint,
19
  scaleQuantile,
20
  scaleQuantize,
21
  scaleSqrt,
22
  scaleThreshold
23
} from 'd3-scale';
24
import {TOOLTIP_FORMAT_TYPES} from './tooltip';
25

26
export const ACTION_PREFIX = '@@kepler.gl/';
15✔
27
export const KEPLER_UNFOLDED_BUCKET = 'https://studio-public-data.foursquare.com/statics/keplergl';
15✔
28
export const BASEMAP_ICON_PREFIX = `${KEPLER_UNFOLDED_BUCKET}/geodude`;
15✔
29
export const DEFAULT_MAPBOX_API_URL = 'https://api.mapbox.com';
15✔
30
export const TRANSITION_DURATION = 0;
15✔
31

32
// Modal Ids
33
/**
34
 * Modal id: data table
35
 * @constant
36
 * @type {string}
37
 * @public
38
 */
39
export const DATA_TABLE_ID = 'dataTable';
15✔
40
/**
41
 * Modal id: delete dataset confirm dialog
42
 * @constant
43
 * @type {string}
44
 * @public
45
 */
46
export const DELETE_DATA_ID = 'deleteData';
15✔
47
/**
48
 * Modal id: add data modal
49
 * @constant
50
 * @type {string}
51
 * @public
52
 */
53
export const ADD_DATA_ID = 'addData';
15✔
54
/**
55
 * Modal id: export image modal
56
 * @constant
57
 * @type {string}
58
 * @public
59
 */
60
export const EXPORT_IMAGE_ID = 'exportImage';
15✔
61
/**
62
 * Modal id: export data modal
63
 * @constant
64
 * @type {string}
65
 * @public
66
 */
67
export const EXPORT_DATA_ID = 'exportData';
15✔
68
/**
69
 * Modal id: add custom map style modal
70
 * @constant
71
 * @type {string}
72
 * @public
73
 */
74
export const ADD_MAP_STYLE_ID = 'addMapStyle';
15✔
75
/**
76
 * Modal id: export map modal
77
 * @constant
78
 * @type {string}
79
 * @public
80
 */
81
export const EXPORT_MAP_ID = 'exportMap';
15✔
82
/**
83
 * Modal id: save map modal
84
 * @constant
85
 * @type {string}
86
 * @public
87
 */
88
export const SAVE_MAP_ID = 'saveMap';
15✔
89
/**
90
 * Modal id: confirm to overwrite saved map
91
 * @constant
92
 * @type {string}
93
 * @public
94
 */
95
export const OVERWRITE_MAP_ID = 'overwriteMap';
15✔
96
/**
97
 * Modal id: share map url modal
98
 * @constant
99
 * @type {string}
100
 * @public
101
 */
102
export const SHARE_MAP_ID = 'shareMap';
15✔
103

104
export const KEPLER_GL_NAME = 'kepler.gl';
15✔
105

106
// __PACKAGE_VERSION__ is automatically injected by Babel/Esbuild during the build process
107
// Since we are injecting this during the build process with babel
108
// while developing VERSION is not defined, we capture the exception and return
109
// an empty string which will allow us to retrieve the latest umd version
110
export const KEPLER_GL_VERSION = '__PACKAGE_VERSION__';
15✔
111
export const KEPLER_GL_WEBSITE = 'http://kepler.gl/';
15✔
112

113
export const DIMENSIONS = {
15✔
114
  sidePanel: {
115
    width: 300,
116
    margin: {top: 12, left: 12, bottom: 12, right: 20},
117
    headerHeight: 96
118
  },
119
  mapControl: {
120
    width: 184,
121
    padding: 12,
122
    mapLegend: {
123
      pinned: {
124
        bottom: 22,
125
        right: 12
126
      }
127
    }
128
  }
129
};
130

131
/**
132
 * Theme name that can be passed to `KeplerGl` `prop.theme`.
133
 * Available themes are `THEME.light` and `THEME.dark`. Default theme is `THEME.dark`
134
 * @constant
135
 * @type {object}
136
 * @public
137
 * @example
138
 * ```js
139
 * const Map = () => <KeplerGl theme={THEME.light} id="map"/>
140
 * ```
141
 */
142
export const THEME = keyMirror({
15✔
143
  light: null,
144
  dark: null,
145
  base: null
146
});
147

148
export const SIDEBAR_PANELS = [
15✔
149
  {
150
    id: 'layer',
151
    label: 'sidebar.panels.layer',
152
    onClick: null
153
  },
154
  {
155
    id: 'filter',
156
    label: 'sidebar.panels.filter',
157
    onClick: null
158
  },
159
  {
160
    id: 'interaction',
161
    label: 'sidebar.panels.interaction',
162
    onClick: null
163
  },
164
  {
165
    id: 'map',
166
    label: 'sidebar.panels.basemap',
167
    onClick: null
168
  }
169
];
170

171
export const PANEL_VIEW_TOGGLES = keyMirror({
15✔
172
  list: null,
173
  byDataset: null
174
});
175

176
// backward compatibility
177
export const PANELS = SIDEBAR_PANELS;
15✔
178

179
// MAP STYLES
180

181
export const DEFAULT_BLDG_COLOR = '#D1CEC7';
15✔
182

183
export const DEFAULT_BACKGROUND_COLOR = '#000000';
15✔
184

185
// assists in identifying basemap background layers when auto-determining the backgroundColor
186
export const BASE_MAP_BACKGROUND_LAYER_IDS = ['background', 'bg', 'land', 'water'];
15✔
187

188
export const BACKGROUND_LAYER_GROUP_SLUG = 'Background';
15✔
189

190
export const THREE_D_BUILDING_LAYER_GROUP_SLUG = '3d building';
15✔
191

192
export type DEFAULT_LAYER_GROUP = {
193
  slug: string;
194
  filter: (value) => boolean;
195
  defaultVisibility: boolean;
196
  isVisibilityToggleAvailable?: boolean;
197
  isMoveToTopAvailable?: boolean;
198
  isColorPickerAvailable?: boolean;
199
};
200

201
export const BACKGROUND_LAYER_GROUP: DEFAULT_LAYER_GROUP = {
15✔
202
  slug: BACKGROUND_LAYER_GROUP_SLUG,
203
  filter: () => false,
×
204
  defaultVisibility: false,
205
  isVisibilityToggleAvailable: false,
206
  isMoveToTopAvailable: false,
207
  isColorPickerAvailable: true
208
};
209

210
export const DEFAULT_LAYER_GROUPS: DEFAULT_LAYER_GROUP[] = [
15✔
211
  {
212
    slug: 'label',
213
    filter: ({id, type}) => id.match(/(?=(label|place-|poi-))/) || type?.match(/(?=(symbol))/),
30✔
214
    defaultVisibility: true,
215
    isVisibilityToggleAvailable: true,
216
    isMoveToTopAvailable: true,
217
    isColorPickerAvailable: false
218
  },
219
  {
220
    slug: 'road',
221
    filter: ({id}) => id.match(/(?=(road|railway|tunnel|street|bridge))(?!.*label)/),
28✔
222
    defaultVisibility: true,
223
    isVisibilityToggleAvailable: true,
224
    isMoveToTopAvailable: true,
225
    isColorPickerAvailable: false
226
  },
227
  {
228
    slug: 'border',
229
    filter: ({id}) => id.match(/border|boundaries|boundary/),
26✔
230
    defaultVisibility: false,
231
    isVisibilityToggleAvailable: true,
232
    isMoveToTopAvailable: true,
233
    isColorPickerAvailable: false
234
  },
235
  {
236
    slug: 'building',
237
    filter: ({id}) => id.match(/building/),
18✔
238
    defaultVisibility: true,
239
    isVisibilityToggleAvailable: true,
240
    isMoveToTopAvailable: true,
241
    isColorPickerAvailable: false
242
  },
243
  {
244
    slug: 'water',
245
    filter: ({id}) => id.match(/(?=(water|stream|ferry))/),
18✔
246
    defaultVisibility: true,
247
    isVisibilityToggleAvailable: true,
248
    isMoveToTopAvailable: true,
249
    isColorPickerAvailable: false
250
  },
251
  {
252
    slug: 'land',
253
    filter: ({id}) => id.match(/(?=(parks|landcover|industrial|sand|hillshade))/),
18✔
254
    defaultVisibility: true,
255
    isVisibilityToggleAvailable: true,
256
    isMoveToTopAvailable: true,
257
    isColorPickerAvailable: false
258
  },
259
  {
260
    slug: THREE_D_BUILDING_LAYER_GROUP_SLUG,
261
    filter: () => false,
26✔
262
    defaultVisibility: false,
263
    isVisibilityToggleAvailable: true,
264
    isMoveToTopAvailable: true,
265
    isColorPickerAvailable: true
266
  }
267
];
268

269
export const BASE_MAP_COLOR_MODES = keyMirror({
15✔
270
  NONE: null,
271
  DARK: null,
272
  LIGHT: null
273
});
274

275
export const NO_MAP_ID = 'no_map';
15✔
276

277
// Fallback style to use when styles are being fetched, or when
278
// a style fails to fetch
279
export const EMPTY_MAPBOX_STYLE = {
15✔
280
  version: 8,
281
  sources: {},
282
  layers: []
283
};
284

285
export const MAP_LIB_OPTIONS = {
15✔
286
  MAPBOX: 'mapbox' as const,
287
  MAPLIBRE: 'maplibre' as const
288
};
289

290
export type BaseMapLibraryType = 'mapbox' | 'maplibre';
291

292
export const NO_BASEMAP_ICON = `${BASEMAP_ICON_PREFIX}/NO_BASEMAP.png`;
15✔
293

294
export const DEFAULT_BASE_MAP_STYLE = 'dark-matter';
15✔
295

296
type DefaultBaseMapStyle = Merge<
297
  BaseMapStyle,
298
  {
299
    colorMode: BaseMapColorModes;
300
  }
301
>;
302

303
export const DEFAULT_NO_BASEMAP_STYLE: DefaultBaseMapStyle = {
15✔
304
  id: NO_MAP_ID,
305
  label: 'No Basemap',
306
  url: '',
307
  icon: NO_BASEMAP_ICON,
308
  layerGroups: [BACKGROUND_LAYER_GROUP],
309
  colorMode: BASE_MAP_COLOR_MODES.NONE,
310
  style: EMPTY_MAPBOX_STYLE
311
};
312

313
export const DEFAULT_MAPBOX_STYLES: DefaultBaseMapStyle[] = [
15✔
314
  {
315
    id: 'dark',
316
    label: 'Dark',
317
    url: 'mapbox://styles/uberdata/cjoqbbf6l9k302sl96tyvka09',
318
    icon: `${BASEMAP_ICON_PREFIX}/UBER_DARK_V2.png`,
319
    layerGroups: DEFAULT_LAYER_GROUPS,
320
    colorMode: BASE_MAP_COLOR_MODES.DARK,
321
    complimentaryStyleId: 'light'
322
  },
323
  {
324
    id: 'light',
325
    label: 'Light',
326
    url: 'mapbox://styles/uberdata/cjoqb9j339k1f2sl9t5ic5bn4',
327
    icon: `${BASEMAP_ICON_PREFIX}/UBER_LIGHT_V2.png`,
328
    layerGroups: DEFAULT_LAYER_GROUPS,
329
    colorMode: BASE_MAP_COLOR_MODES.LIGHT,
330
    complimentaryStyleId: 'dark'
331
  },
332
  {
333
    id: 'muted',
334
    label: 'Muted Light',
335
    url: 'mapbox://styles/uberdata/cjfyl03kp1tul2smf5v2tbdd4',
336
    icon: `${BASEMAP_ICON_PREFIX}/UBER_MUTED_LIGHT.png`,
337
    layerGroups: DEFAULT_LAYER_GROUPS,
338
    colorMode: BASE_MAP_COLOR_MODES.LIGHT,
339
    complimentaryStyleId: 'muted_night'
340
  },
341
  {
342
    id: 'muted_night',
343
    label: 'Muted Night',
344
    url: 'mapbox://styles/uberdata/cjfxhlikmaj1b2soyzevnywgs',
345
    icon: `${BASEMAP_ICON_PREFIX}/UBER_MUTED_NIGHT.png`,
346
    layerGroups: DEFAULT_LAYER_GROUPS,
347
    colorMode: BASE_MAP_COLOR_MODES.DARK,
348
    complimentaryStyleId: 'muted'
349
  }
350
];
351

352
export const DEFAULT_MAPBOX_SATELITE_STYLES: DefaultBaseMapStyle[] = [
15✔
353
  {
354
    id: 'satellite',
355
    label: 'Satellite with streets',
356
    url: `mapbox://styles/mapbox/satellite-streets-v11`,
357
    icon: `${BASEMAP_ICON_PREFIX}/UBER_SATELLITE.png`,
358
    layerGroups: DEFAULT_LAYER_GROUPS,
359
    colorMode: BASE_MAP_COLOR_MODES.NONE
360
  }
361
];
362

363
export const DEFAULT_MAPLIBRE_STYLES: DefaultBaseMapStyle[] = [
15✔
364
  {
365
    id: 'dark-matter',
366
    label: 'DarkMatter',
367
    url: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
368
    icon: `${BASEMAP_ICON_PREFIX}/DARKMATTER.png`,
369
    layerGroups: DEFAULT_LAYER_GROUPS,
370
    colorMode: BASE_MAP_COLOR_MODES.DARK,
371
    complimentaryStyleId: 'positron'
372
  },
373
  {
374
    id: 'positron',
375
    label: 'Positron',
376
    url: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
377
    icon: `${BASEMAP_ICON_PREFIX}/POSITRON.png`,
378
    layerGroups: DEFAULT_LAYER_GROUPS,
379
    colorMode: BASE_MAP_COLOR_MODES.LIGHT,
380
    complimentaryStyleId: 'dark-matter'
381
  },
382
  {
383
    id: 'voyager',
384
    label: 'Voyager',
385
    url: 'https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json',
386
    icon: `${BASEMAP_ICON_PREFIX}/VOYAGER.png`,
387
    layerGroups: DEFAULT_LAYER_GROUPS,
388
    colorMode: BASE_MAP_COLOR_MODES.LIGHT,
389
    complimentaryStyleId: 'dark-matter'
390
  }
391
];
392

393
export const DEFAULT_MAP_STYLES = [
15✔
394
  DEFAULT_NO_BASEMAP_STYLE,
395
  ...DEFAULT_MAPLIBRE_STYLES,
396
  ...DEFAULT_MAPBOX_SATELITE_STYLES,
397
  ...DEFAULT_MAPBOX_STYLES
398
];
399

400
export const GEOJSON_FIELDS = {
15✔
401
  geojson: ['_geojson', 'all_points', 'geojson']
402
};
403

404
export const ICON_FIELDS = {
15✔
405
  icon: ['icon']
406
};
407

408
export const TRIP_POINT_FIELDS: [string, string][] = [
15✔
409
  ['lat', 'lng'],
410
  ['lat', 'lon'],
411
  ['lat', 'long'],
412
  ['latitude', 'longitude']
413
];
414

415
export const ALTITUDE_FIELDS = ['alt', 'altitude'];
15✔
416
export const TRIP_ARC_FIELDS = {
15✔
417
  lat0: 'begintrip',
418
  lng0: 'begintrip',
419
  lat1: 'dropoff',
420
  lng1: 'dropoff'
421
};
422

423
export const FILTER_TYPES = keyMirror({
15✔
424
  range: null,
425
  select: null,
426
  input: null,
427
  timeRange: null,
428
  multiSelect: null,
429
  polygon: null
430
});
431

432
export const FILTER_VIEW_TYPES = keyMirror({
15✔
433
  side: null,
434
  enlarged: null,
435
  minified: null
436
});
437

438
export const DEFAULT_FILTER_VIEW_TYPE = FILTER_VIEW_TYPES.side;
15✔
439

440
export type SCALE_TYPES_DEF = {
441
  ordinal: 'ordinal';
442
  quantile: 'quantile';
443
  quantize: 'quantize';
444
  linear: 'linear';
445
  sqrt: 'sqrt';
446
  log: 'log';
447
  point: 'point';
448
  threshold: 'threshold';
449
  custom: 'custom';
450
  customOrdinal: 'customOrdinal';
451
};
452

453
export const SCALE_TYPES: SCALE_TYPES_DEF = keyMirror({
15✔
454
  ordinal: null,
455
  quantile: null,
456
  quantize: null,
457
  linear: null,
458
  sqrt: null,
459
  log: null,
460
  threshold: null,
461
  custom: null,
462
  customOrdinal: null,
463
  // ordinal domain to linear range
464
  point: null
465
});
466
export const SCALE_TYPE_NAMES: {[key in keyof SCALE_TYPES_DEF]: string} = {
15✔
467
  ordinal: 'Ordinal',
468
  quantile: 'Quantile',
469
  quantize: 'Quantize',
470
  linear: 'Linear',
471
  sqrt: 'Sqrt',
472
  log: 'Log',
473
  threshold: 'Threshold',
474
  custom: 'Custom Breaks',
475
  customOrdinal: 'Custom Ordinal',
476
  point: 'Point'
477
};
478

479
export type SCALE_FUNC_TYPE = {
480
  [key in keyof SCALE_TYPES_DEF]: () => number;
481
};
482

483
export const SCALE_FUNC = {
15✔
484
  [SCALE_TYPES.linear]: scaleLinear,
485
  [SCALE_TYPES.quantize]: scaleQuantize,
486
  [SCALE_TYPES.quantile]: scaleQuantile,
487
  [SCALE_TYPES.ordinal]: scaleOrdinal,
488
  [SCALE_TYPES.sqrt]: scaleSqrt,
489
  [SCALE_TYPES.log]: scaleLog,
490
  [SCALE_TYPES.point]: scalePoint,
491
  [SCALE_TYPES.threshold]: scaleThreshold,
492
  [SCALE_TYPES.custom]: scaleThreshold,
493
  [SCALE_TYPES.customOrdinal]: scaleOrdinal
494
};
495

496
export const ALL_FIELD_TYPES = keyMirror({
15✔
497
  boolean: null,
498
  date: null,
499
  geojson: null,
500
  integer: null,
501
  real: null,
502
  string: null,
503
  timestamp: null,
504
  point: null,
505
  array: null,
506
  object: null,
507
  geoarrow: null,
508
  h3: null
509
});
510

511
// Data Table
512
export const SORT_ORDER = keyMirror({
15✔
513
  ASCENDING: null,
514
  DESCENDING: null,
515
  UNSORT: null
516
});
517

518
export const TABLE_OPTION = keyMirror({
15✔
519
  SORT_ASC: null,
520
  SORT_DES: null,
521
  UNSORT: null,
522
  PIN: null,
523
  UNPIN: null,
524
  COPY: null,
525
  FORMAT_COLUMN: null
526
});
527

528
export type TableOption = {
529
  value: 'SORT_ASC' | 'SORT_DES' | 'UNSORT' | 'PIN' | 'UNPIN' | 'COPY' | 'FORMAT_COLUMN';
530
  display: string;
531
  icon: string;
532
  condition?: (props: any) => boolean;
533
};
534
export const TABLE_OPTION_LIST: TableOption[] = [
15✔
535
  {
536
    value: TABLE_OPTION.SORT_ASC,
537
    display: 'Sort Ascending',
538
    icon: 'ArrowUp',
539
    condition: props => props.sortTableColumn && props.sortMode !== SORT_ORDER.ASCENDING
86✔
540
  },
541
  {
542
    value: TABLE_OPTION.SORT_DES,
543
    display: 'Sort Descending',
544
    icon: 'ArrowDown',
545
    condition: props => props.sortTableColumn && props.sortMode !== SORT_ORDER.DESCENDING
86✔
546
  },
547
  {
548
    value: TABLE_OPTION.UNSORT,
549
    display: 'Unsort Column',
550
    icon: 'Cancel',
551
    condition: props => props.isSorted
86✔
552
  },
553
  {
554
    value: TABLE_OPTION.PIN,
555
    display: 'Pin Column',
556
    icon: 'Pin',
557
    condition: props => !props.isPinned
86✔
558
  },
559
  {
560
    value: TABLE_OPTION.UNPIN,
561
    display: 'Unpin Column',
562
    icon: 'Cancel',
563
    condition: props => props.isPinned
86✔
564
  },
565
  {value: TABLE_OPTION.COPY, display: 'Copy Column', icon: 'Clipboard'},
566
  {
567
    value: TABLE_OPTION.FORMAT_COLUMN,
568
    display: 'Format Column',
569
    icon: 'Hash',
570
    condition: props => props.setDisplayFormat
86✔
571
  }
572
];
573

574
const YELLOW = '248, 194, 28';
15✔
575
const PINK = '242, 152, 163';
15✔
576
const PURPLE = '160, 106, 206';
15✔
577
const BLUE = '140, 210, 205';
15✔
578
const BLUE2 = '106, 160, 206';
15✔
579
const BLUE3 = '0, 172, 237';
15✔
580
const GREEN = '106, 160, 56';
15✔
581
const GREEN2 = '74, 165, 150';
15✔
582
const RED = '237, 88, 106';
15✔
583
const ORANGE = '231, 110, 58';
15✔
584

585
export const FIELD_TYPE_DISPLAY = {
15✔
586
  [ALL_FIELD_TYPES.boolean]: {
587
    label: 'bool',
588
    color: PINK
589
  },
590
  [ALL_FIELD_TYPES.date]: {
591
    label: 'date',
592
    color: PURPLE
593
  },
594
  [ALL_FIELD_TYPES.geojson]: {
595
    label: 'geo',
596
    color: BLUE2
597
  },
598
  [ALL_FIELD_TYPES.geoarrow]: {
599
    label: 'geo',
600
    color: BLUE2
601
  },
602
  [ALL_FIELD_TYPES.integer]: {
603
    label: 'int',
604
    color: YELLOW
605
  },
606
  [ALL_FIELD_TYPES.real]: {
607
    label: 'float',
608
    color: YELLOW
609
  },
610
  [ALL_FIELD_TYPES.string]: {
611
    label: 'string',
612
    color: BLUE
613
  },
614
  [ALL_FIELD_TYPES.timestamp]: {
615
    label: 'time',
616
    color: GREEN
617
  },
618
  // field pairs
619
  [ALL_FIELD_TYPES.point]: {
620
    label: 'point',
621
    color: BLUE3
622
  },
623
  [ALL_FIELD_TYPES.array]: {
624
    label: 'array',
625
    color: ORANGE
626
  },
627
  [ALL_FIELD_TYPES.object]: {
628
    label: 'object',
629
    color: GREEN2
630
  },
631
  [ALL_FIELD_TYPES.h3]: {
632
    label: 'h3',
633
    color: BLUE
634
  }
635
};
636

637
export const FIELD_COLORS = {
15✔
638
  default: RED
639
};
640
export const HIGHLIGH_COLOR_3D: RGBAColor = [255, 255, 255, 60];
15✔
641
export const CHANNEL_SCALES = keyMirror({
15✔
642
  color: null,
643
  radius: null,
644
  size: null,
645
  colorAggr: null,
646
  sizeAggr: null
647
});
648

649
export const AGGREGATION_TYPES: {
650
  // default
651
  count: 'count';
652
  // linear
653
  average: 'average';
654
  maximum: 'maximum';
655
  minimum: 'minimum';
656
  median: 'median';
657
  stdev: 'stdev';
658
  sum: 'sum';
659
  variance: 'variance';
660
  // ordinal
661
  mode: 'mode';
662
  countUnique: 'countUnique';
663
} = {
15✔
664
  // default
665
  count: 'count',
666
  // linear
667
  average: 'average',
668
  maximum: 'maximum',
669
  minimum: 'minimum',
670
  median: 'median',
671
  stdev: 'stdev',
672
  sum: 'sum',
673
  variance: 'variance',
674
  // ordinal
675
  mode: 'mode',
676
  countUnique: 'countUnique'
677
};
678

679
export const AGGREGATION_TYPE_OPTIONS: {id: string; label: string}[] = Object.entries(
15✔
680
  AGGREGATION_TYPES
681
).map(([key, value]) => ({
150✔
682
  id: key,
683
  label:
684
    key === 'stdev'
150✔
685
      ? 'Std Deviation'
686
      : key === 'countUnique'
135✔
687
      ? 'Count Unique'
688
      : typeof value === 'string'
120!
689
      ? value.charAt(0).toUpperCase() + value.slice(1)
690
      : value
691
}));
692

693
export const linearFieldScaleFunctions = {
15✔
694
  [CHANNEL_SCALES.color]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile, SCALE_TYPES.custom],
695
  [CHANNEL_SCALES.radius]: [SCALE_TYPES.sqrt],
696
  [CHANNEL_SCALES.size]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log]
697
};
698

699
const DEFAULT_AGGREGATION_COLOR_SCALES = [
15✔
700
  SCALE_TYPES.quantize,
701
  SCALE_TYPES.quantile,
702
  SCALE_TYPES.custom
703
];
704

705
export const linearFieldAggrScaleFunctions = {
15✔
706
  [CHANNEL_SCALES.colorAggr]: [
707
    AGGREGATION_TYPES.average,
708
    AGGREGATION_TYPES.maximum,
709
    AGGREGATION_TYPES.minimum,
710
    AGGREGATION_TYPES.median,
711
    AGGREGATION_TYPES.stdev,
712
    AGGREGATION_TYPES.sum,
713
    AGGREGATION_TYPES.variance,
714
    AGGREGATION_TYPES.count
715
  ].reduce((prev, cur) => {
716
    prev[cur] = DEFAULT_AGGREGATION_COLOR_SCALES;
120✔
717
    return prev;
120✔
718
  }, {}),
719

720
  [CHANNEL_SCALES.sizeAggr]: {
721
    [AGGREGATION_TYPES.average]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
722
    [AGGREGATION_TYPES.maximum]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
723
    [AGGREGATION_TYPES.minimum]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
724
    [AGGREGATION_TYPES.median]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
725
    [AGGREGATION_TYPES.stdev]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
726
    [AGGREGATION_TYPES.sum]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
727
    [AGGREGATION_TYPES.variance]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log]
728
  }
729
};
730

731
export const ordinalFieldScaleFunctions = {
15✔
732
  [CHANNEL_SCALES.color]: [SCALE_TYPES.ordinal, SCALE_TYPES.customOrdinal],
733
  [CHANNEL_SCALES.radius]: [SCALE_TYPES.point],
734
  [CHANNEL_SCALES.size]: [SCALE_TYPES.point]
735
};
736

737
export const ordinalFieldAggrScaleFunctions = {
15✔
738
  // [CHANNEL_SCALES.colorAggr]: [SCALE_TYPES.ordinal, SCALE_TYPES.linear],
739
  [CHANNEL_SCALES.colorAggr]: {
740
    [AGGREGATION_TYPES.mode]: [SCALE_TYPES.ordinal],
741
    [AGGREGATION_TYPES.countUnique]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile]
742
  },
743

744
  // Currently doesn't support yet
745
  [CHANNEL_SCALES.sizeAggr]: {}
746
};
747

748
export const notSupportedScaleOpts = {
15✔
749
  [CHANNEL_SCALES.color]: [],
750
  [CHANNEL_SCALES.radius]: [],
751
  [CHANNEL_SCALES.size]: []
752
};
753

754
export const notSupportAggrOpts = {
15✔
755
  [CHANNEL_SCALES.colorAggr]: {},
756
  [CHANNEL_SCALES.sizeAggr]: {}
757
};
758

759
/**
760
 * Default aggregation are based on ocunt
761
 */
762
export const DEFAULT_AGGREGATION = {
15✔
763
  [CHANNEL_SCALES.colorAggr]: {
764
    [AGGREGATION_TYPES.count]: DEFAULT_AGGREGATION_COLOR_SCALES
765
  },
766
  [CHANNEL_SCALES.sizeAggr]: {
767
    [AGGREGATION_TYPES.count]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log]
768
  }
769
};
770

771
/**
772
 * Define what type of scale operation is allowed on each type of fields
773
 */
774
export const FIELD_OPTS = {
15✔
775
  [ALL_FIELD_TYPES.string]: {
776
    type: 'categorical',
777
    scale: {
778
      ...ordinalFieldScaleFunctions,
779
      ...ordinalFieldAggrScaleFunctions
780
    },
781
    format: {
782
      legend: d => d,
×
783
      tooltip: []
784
    }
785
  },
786
  [ALL_FIELD_TYPES.real]: {
787
    type: 'numerical',
788
    scale: {
789
      ...linearFieldScaleFunctions,
790
      ...linearFieldAggrScaleFunctions
791
    },
792
    format: {
793
      legend: d => d,
×
794
      tooltip: [
795
        TOOLTIP_FORMAT_TYPES.NONE,
796
        TOOLTIP_FORMAT_TYPES.DECIMAL,
797
        TOOLTIP_FORMAT_TYPES.PERCENTAGE
798
      ]
799
    }
800
  },
801
  [ALL_FIELD_TYPES.timestamp]: {
802
    type: 'time',
803
    scale: {
804
      ...linearFieldScaleFunctions,
805
      ...notSupportAggrOpts
806
    },
807
    format: {
808
      legend: d => d,
×
809
      tooltip: [
810
        TOOLTIP_FORMAT_TYPES.NONE,
811
        TOOLTIP_FORMAT_TYPES.DATE,
812
        TOOLTIP_FORMAT_TYPES.DATE_TIME
813
      ]
814
    }
815
  },
816
  [ALL_FIELD_TYPES.integer]: {
817
    type: 'numerical',
818
    scale: {
819
      ...{
820
        ...linearFieldScaleFunctions,
821
        [CHANNEL_SCALES.color]: [
822
          ...linearFieldScaleFunctions[CHANNEL_SCALES.color],
823
          SCALE_TYPES.customOrdinal
824
        ]
825
      },
826
      ...linearFieldAggrScaleFunctions
827
    },
828
    format: {
829
      legend: d => d,
×
830
      tooltip: [
831
        TOOLTIP_FORMAT_TYPES.NONE,
832
        TOOLTIP_FORMAT_TYPES.DECIMAL,
833
        TOOLTIP_FORMAT_TYPES.PERCENTAGE
834
      ]
835
    }
836
  },
837
  [ALL_FIELD_TYPES.boolean]: {
838
    type: 'boolean',
839
    scale: {
840
      ...ordinalFieldScaleFunctions,
841
      ...ordinalFieldAggrScaleFunctions
842
    },
843
    format: {
844
      legend: d => d,
×
845
      tooltip: [TOOLTIP_FORMAT_TYPES.NONE, TOOLTIP_FORMAT_TYPES.BOOLEAN]
846
    }
847
  },
848
  [ALL_FIELD_TYPES.date]: {
849
    type: 'time',
850
    scale: {
851
      ...ordinalFieldScaleFunctions,
852
      ...ordinalFieldAggrScaleFunctions
853
    },
854
    format: {
855
      legend: d => d,
×
856
      tooltip: [TOOLTIP_FORMAT_TYPES.NONE, TOOLTIP_FORMAT_TYPES.DATE]
857
    }
858
  },
859
  [ALL_FIELD_TYPES.geojson]: {
860
    type: 'geometry',
861
    scale: {
862
      ...notSupportedScaleOpts,
863
      ...notSupportAggrOpts
864
    },
865
    format: {
866
      legend: () => '...',
×
867
      tooltip: []
868
    }
869
  },
870
  [ALL_FIELD_TYPES.geoarrow]: {
871
    type: 'geometry',
872
    scale: {
873
      ...notSupportedScaleOpts,
874
      ...notSupportAggrOpts
875
    },
876
    format: {
877
      legend: () => '...',
×
878
      tooltip: []
879
    }
880
  },
881
  [ALL_FIELD_TYPES.object]: {
882
    type: 'numerical',
883
    scale: {},
884
    format: {
885
      legend: () => '...',
×
886
      tooltip: []
887
    }
888
  },
889
  [ALL_FIELD_TYPES.array]: {
890
    type: 'numerical',
891
    scale: {},
892
    format: {
893
      legend: () => '...',
×
894
      tooltip: []
895
    }
896
  },
897
  [ALL_FIELD_TYPES.h3]: {
898
    type: 'h3',
899
    scale: {
900
      ...notSupportedScaleOpts,
901
      ...notSupportAggrOpts
902
    },
903
    format: {
NEW
904
      legend: () => '...',
×
905
      tooltip: []
906
    }
907
  }
908
};
909

910
export const CHANNEL_SCALE_SUPPORTED_FIELDS = Object.keys(CHANNEL_SCALES).reduce(
15✔
911
  (accu, key) => ({
75✔
912
    ...accu,
913
    [key]: Object.keys(FIELD_OPTS).filter(
914
      ft => FIELD_OPTS[ft].scale[key] && Object.keys(FIELD_OPTS[ft].scale[key]).length
825✔
915
    )
916
  }),
917
  {} as {[id: string]: string[]}
918
);
919

920
export const DEFAULT_LAYER_COLOR = {
15✔
921
  tripArc: '#9226C6',
922
  begintrip_lat: '#1E96BE',
923
  dropoff_lat: '#FF991F',
924
  request_lat: '#52A353'
925
};
926

927
export const DEFAULT_LAYER_COLOR_PALETTE = 'Global Warming';
15✔
928
export const DEFAULT_LAYER_COLOR_PALETTE_STEPS = 6;
15✔
929

930
// let user pass in default tooltip fields
931
export const DEFAULT_TOOLTIP_FIELDS: any[] = [];
15✔
932

933
export const NO_VALUE_COLOR: RGBAColor = [0, 0, 0, 0];
15✔
934

935
export const DEFAULT_PICKING_RADIUS = 3;
15✔
936

937
export const OVERLAY_BLENDINGS = {
15✔
938
  normal: {
939
    label: 'overlayBlending.normal',
940
    value: 'normal'
941
  },
942
  screen: {
943
    label: 'overlayBlending.screen',
944
    value: 'screen'
945
  },
946
  darken: {
947
    label: 'overlayBlending.darken',
948
    value: 'darken'
949
  }
950
};
951

952
export const LAYER_BLENDINGS = {
15✔
953
  additive: {
954
    label: 'layerBlending.additive',
955
    blendFunc: ['SRC_ALPHA', 'DST_ALPHA'],
956
    blendEquation: 'FUNC_ADD'
957
  },
958
  normal: {
959
    // reference to
960
    // https://limnu.com/webgl-blending-youre-probably-wrong/
961
    label: 'layerBlending.normal',
962
    blendFunc: ['SRC_ALPHA', 'ONE_MINUS_SRC_ALPHA', 'ONE', 'ONE_MINUS_SRC_ALPHA'],
963
    blendEquation: ['FUNC_ADD', 'FUNC_ADD']
964
  },
965
  subtractive: {
966
    label: 'layerBlending.subtractive',
967
    blendFunc: ['ONE', 'ONE_MINUS_DST_COLOR', 'SRC_ALPHA', 'DST_ALPHA'],
968
    blendEquation: ['FUNC_SUBTRACT', 'FUNC_ADD']
969
  }
970
};
971

972
export const MAX_DEFAULT_TOOLTIPS = 5;
15✔
973

974
export const RESOLUTIONS = keyMirror({
15✔
975
  ONE_X: null,
976
  TWO_X: null
977
});
978

979
export const EXPORT_IMG_RATIOS = keyMirror({
15✔
980
  SCREEN: null,
981
  FOUR_BY_THREE: null,
982
  SIXTEEN_BY_NINE: null,
983
  CUSTOM: null
984
});
985

986
export type ExportImage = {
987
  ratio: keyof typeof EXPORT_IMG_RATIOS;
988
  resolution: keyof typeof RESOLUTIONS;
989
  legend: boolean;
990
  mapH: number;
991
  mapW: number;
992
  imageSize: {
993
    zoomOffset: number;
994
    scale: number;
995
    imageW: number;
996
    imageH: number;
997
  };
998
  // exporting state
999
  imageDataUri: string;
1000
  exporting: boolean;
1001
  processing: boolean;
1002
  error: Error | false;
1003
  escapeXhtmlForWebpack?: boolean;
1004
  // This field was not in the .d.ts file
1005
  center: boolean;
1006
};
1007

1008
export type ImageRatioOption = {
1009
  id: keyof typeof EXPORT_IMG_RATIOS;
1010
  label: string;
1011
  hidden?: boolean;
1012
  getSize: (screenW: number, screenH: number) => {width: number; height: number};
1013
};
1014

1015
export const ScreenRatioOption: ImageRatioOption = {
15✔
1016
  id: EXPORT_IMG_RATIOS.SCREEN,
1017
  label: 'modal.exportImage.ratioOriginalScreen',
1018
  getSize: (screenW, screenH) => ({width: screenW, height: screenH})
2✔
1019
};
1020
export const CustomRatioOption: ImageRatioOption = {
15✔
1021
  id: EXPORT_IMG_RATIOS.CUSTOM,
1022
  hidden: true,
1023
  label: 'modal.exportImage.ratioCustom',
1024
  getSize: (mapW, mapH) => ({width: mapW, height: mapH})
1✔
1025
};
1026
export const FourByThreeRatioOption: ImageRatioOption = {
15✔
1027
  id: EXPORT_IMG_RATIOS.FOUR_BY_THREE,
1028
  label: 'modal.exportImage.ratio4_3',
1029
  getSize: screenW => ({
1✔
1030
    width: screenW,
1031
    height: Math.round(screenW * 0.75)
1032
  })
1033
};
1034
export const SixteenByNineRatioOption: ImageRatioOption = {
15✔
1035
  id: EXPORT_IMG_RATIOS.SIXTEEN_BY_NINE,
1036
  label: 'modal.exportImage.ratio16_9',
1037
  getSize: screenW => ({
×
1038
    width: screenW,
1039
    height: Math.round(screenW * 0.5625)
1040
  })
1041
};
1042

1043
export const EXPORT_IMG_RATIO_OPTIONS: ReadonlyArray<ImageRatioOption> = [
15✔
1044
  ScreenRatioOption,
1045
  CustomRatioOption,
1046
  FourByThreeRatioOption,
1047
  SixteenByNineRatioOption
1048
];
1049

1050
export type ImageResolutionOption = {
1051
  id: keyof typeof RESOLUTIONS;
1052
  label: string;
1053
  available: boolean;
1054
  scale: number;
1055
  getSize: (screenW: number, screenH: number) => {width: number; height: number};
1056
};
1057

1058
export const OneXResolutionOption: ImageResolutionOption = {
15✔
1059
  id: RESOLUTIONS.ONE_X,
1060
  label: '1x',
1061
  available: true,
1062
  scale: 1,
1063
  getSize: (screenW, screenH) => ({
4✔
1064
    width: screenW,
1065
    height: screenH
1066
  })
1067
};
1068

1069
export const TwoXResolutionOption: ImageResolutionOption = {
15✔
1070
  id: RESOLUTIONS.TWO_X,
1071
  label: '2x',
1072
  available: true,
1073
  scale: 2,
1074
  getSize: (screenW, screenH) => ({
×
1075
    width: screenW * 2,
1076
    height: screenH * 2
1077
  })
1078
};
1079

1080
export const EXPORT_IMG_RESOLUTION_OPTIONS: ReadonlyArray<ImageResolutionOption> = [
15✔
1081
  OneXResolutionOption,
1082
  TwoXResolutionOption
1083
];
1084

1085
export const EXPORT_DATA_TYPE = keyMirror({
15✔
1086
  CSV: null
1087
  // SHAPEFILE: null,
1088
  // JSON: null,
1089
  // GEOJSON: null,
1090
  // TOPOJSON: null
1091
});
1092

1093
export const EXPORT_DATA_TYPE_OPTIONS = [
15✔
1094
  {
1095
    id: EXPORT_DATA_TYPE.CSV,
1096
    label: EXPORT_DATA_TYPE.CSV.toLowerCase(),
1097
    available: true
1098
  }
1099
  // {
1100
  //   id: EXPORT_DATA_TYPE.SHAPEFILE,
1101
  //   label: 'shapefile',
1102
  //   available: false
1103
  // },
1104
  // {
1105
  //   id: EXPORT_DATA_TYPE.JSON,
1106
  //   label: 'json',
1107
  //   available: false
1108
  // },
1109
  // {
1110
  //   id: EXPORT_DATA_TYPE.GEOJSON,
1111
  //   label: 'geojson',
1112
  //   available: false
1113
  // },
1114
  // {
1115
  //   id: EXPORT_DATA_TYPE.TOPOJSON,
1116
  //   label: 'topojson',
1117
  //   available: false
1118
  // }
1119
];
1120

1121
// Export map types
1122
export const EXPORT_MAP_FORMATS = keyMirror({
15✔
1123
  HTML: null,
1124
  JSON: null
1125
});
1126

1127
export const EXPORT_HTML_MAP_MODES = keyMirror({
15✔
1128
  READ: null,
1129
  EDIT: null
1130
});
1131

1132
// Export map options
1133
export const EXPORT_MAP_FORMAT_OPTIONS = Object.entries(EXPORT_MAP_FORMATS).map(
15✔
1134
  (entry: [string, any]) => ({
30✔
1135
    id: entry[0],
1136
    label: entry[1].toLowerCase(),
1137
    available: true
1138
  })
1139
);
1140

1141
export function getHTMLMapModeTileUrl(mode: string): string {
1142
  return `https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/documentation/map-${mode.toLowerCase()}-mode.png`;
30✔
1143
}
1144

1145
export const EXPORT_HTML_MAP_MODE_OPTIONS = Object.entries(EXPORT_HTML_MAP_MODES).map(
15✔
1146
  (entry: [string, any]) => ({
30✔
1147
    id: entry[0],
1148
    label: `modal.exportMap.html.${entry[1].toLowerCase()}`,
1149
    available: true,
1150
    url: getHTMLMapModeTileUrl(entry[1])
1151
  })
1152
);
1153

1154
export const DEFAULT_UUID_COUNT = 6;
15✔
1155

1156
export const DEFAULT_NOTIFICATION_MESSAGE = 'MESSAGE_NOT_PROVIDED';
15✔
1157

1158
export const DEFAULT_NOTIFICATION_TYPES = keyMirror({
15✔
1159
  info: null,
1160
  error: null,
1161
  warning: null,
1162
  success: null
1163
});
1164

1165
export const DEFAULT_NOTIFICATION_TOPICS = keyMirror({
15✔
1166
  global: null,
1167
  file: null
1168
});
1169

1170
// Minimum time between identical notifications about deck.gl errors
1171
export const THROTTLE_NOTIFICATION_TIME = 330;
15✔
1172

1173
// Animation
1174
export const BASE_SPEED = 600;
15✔
1175
export const FPS = 60;
15✔
1176

1177
/**
1178
 * 4 Animation Window Types
1179
 * 1. free
1180
 *  |->  |->
1181
 * Current time is a fixed range, animation controller calls next animation frames continuously to animation a moving window
1182
 * The increment id based on domain / BASE_SPEED * SPEED
1183
 *
1184
 * 2. incremental
1185
 * |    |->
1186
 * Same as free, current time is a growing range, only the max value of range increment during animation.
1187
 * The increment is also based on domain / BASE_SPEED * SPEED
1188
 *
1189
 * 3. point
1190
 * o -> o
1191
 * Current time is a point, animation controller calls next animation frame continuously to animation a moving point
1192
 * The increment is based on domain / BASE_SPEED * SPEED
1193
 *
1194
 * 4. interval
1195
 * o ~> o
1196
 * Current time is a point. An array of sorted time steps need to be provided.
1197
 * animation controller calls next animation at a interval when the point jumps to the next step
1198
 */
1199
export const ANIMATION_WINDOW = keyMirror({
15✔
1200
  free: null,
1201
  incremental: null,
1202
  point: null,
1203
  interval: null
1204
});
1205
export const DEFAULT_TIME_FORMAT = 'MM/DD/YY HH:mm:ssa';
15✔
1206
export const SPEED_CONTROL_RANGE: [number, number] = [0, 10];
15✔
1207
export const SPEED_CONTROL_STEP = 0.001;
15✔
1208

1209
// Geocoder
1210
export const GEOCODER_DATASET_NAME = 'geocoder_dataset';
15✔
1211
export const GEOCODER_LAYER_ID = 'geocoder_layer';
15✔
1212
export const GEOCODER_GEO_OFFSET = 0.05;
15✔
1213
export const GEOCODER_ICON_COLOR: [number, number, number] = [255, 0, 0];
15✔
1214
export const GEOCODER_ICON_SIZE = 80;
15✔
1215

1216
// Editor
1217
export const EDITOR_LAYER_ID = 'kepler_editor_layer';
15✔
1218
export const EDITOR_LAYER_PICKING_RADIUS = 6;
15✔
1219
export const EDITOR_MODES = {
15✔
1220
  DRAW_POLYGON: 'DRAW_POLYGON',
1221
  DRAW_RECTANGLE: 'DRAW_RECTANGLE',
1222
  EDIT: 'EDIT_VERTEX'
1223
};
1224

1225
export const PLOT_TYPES = keyMirror({
15✔
1226
  histogram: null,
1227
  lineChart: null
1228
});
1229

1230
// Filter
1231
export const INIT_FILTER_ITEMS_IN_DROPDOWN = 100;
15✔
1232

1233
// GPU Filtering
1234
/**
1235
 * Max number of filter value buffers that deck.gl provides
1236
 */
1237
export const MAX_GPU_FILTERS = 4;
15✔
1238
export const MAP_THUMBNAIL_DIMENSION = {
15✔
1239
  width: 300,
1240
  height: 200
1241
};
1242

1243
export const MAP_INFO_CHARACTER = {
15✔
1244
  title: 100,
1245
  description: 100
1246
};
1247

1248
// Load data
1249
export const LOADING_METHODS = keyMirror({
15✔
1250
  upload: null,
1251
  storage: null,
1252
  tileset: null
1253
});
1254

1255
export const DEFAULT_FEATURE_FLAGS = {};
15✔
1256

1257
export const DATASET_FORMATS = keyMirror({
15✔
1258
  row: null,
1259
  geojson: null,
1260
  csv: null,
1261
  keplergl: null,
1262
  arrow: null,
1263
  duckdb: null
1264
});
1265

1266
export const MAP_CONTROLS = keyMirror({
15✔
1267
  visibleLayers: null,
1268
  mapLegend: null,
1269
  toggle3d: null,
1270
  splitMap: null,
1271
  mapDraw: null,
1272
  mapLocale: null,
1273
  effect: null,
1274
  aiAssistant: null
1275
});
1276

1277
/**
1278
 * A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.
1279
 * Required in order to maintain the same appearance after upgrading to deck.gl v8.5.
1280
 * https://github.com/visgl/deck.gl/blob/master/docs/upgrade-guide.md
1281
 */
1282
export const PROJECTED_PIXEL_SIZE_MULTIPLIER = 2 / 3;
15✔
1283

1284
/**
1285
 * Maximum value for text outline width
1286
 */
1287
export const TEXT_OUTLINE_MULTIPLIER = 5;
15✔
1288

1289
export const dataTestIds: Record<string, string> = {
15✔
1290
  infoIcon: 'info-icon',
1291
  warningIcon: 'warning-icon',
1292
  errorIcon: 'error-icon',
1293
  successIcon: 'success-icon',
1294
  checkmarkIcon: 'checkmark-icon',
1295
  sortableLayerItem: 'sortable-layer-item',
1296
  staticLayerItem: 'static-layer-item',
1297
  layerTitleEditor: 'layer__title__editor',
1298
  removeLayerAction: 'remove-layer-action',
1299
  layerPanel: 'layer-panel',
1300
  sortableEffectItem: 'sortable-effect-item',
1301
  staticEffectItem: 'static-effect-item',
1302
  providerLoading: 'provider-loading',
1303
  providerMapInfoPanel: 'provider-map-info-panel',
1304
  providerSelect: 'provider-select',
1305
  cloudHeader: 'cloud-header',
1306
  providerShareMap: 'provider-share-map'
1307
};
1308

1309
// Effects
1310
export const DEFAULT_TIMEZONE = 'UTC';
15✔
1311
export const DEFAULT_POST_PROCESSING_EFFECT_TYPE = 'ink';
15✔
1312

1313
export const DEFAULT_LIGHT_COLOR: [number, number, number] = [255, 255, 255];
15✔
1314
export const DEFAULT_LIGHT_INTENSITY = 1;
15✔
1315
export const DEFAULT_SHADOW_INTENSITY = 0.5;
15✔
1316
export const DEFAULT_SHADOW_COLOR: [number, number, number] = [0, 0, 0];
15✔
1317

1318
export const LIGHT_AND_SHADOW_EFFECT_TIME_MODES = {
15✔
1319
  pick: 'pick' as const,
1320
  current: 'current' as const,
1321
  animation: 'animation' as const
1322
};
1323
export type LightAndShadowEffectTimeMode = 'pick' | 'current' | 'animation';
1324
export const DEFAULT_LIGHT_AND_SHADOW_PROPS: {
1325
  timestamp: number;
1326
  timeMode: LightAndShadowEffectTimeMode;
1327
  shadowIntensity: number;
1328
  shadowColor: [number, number, number];
1329
  sunLightColor: [number, number, number];
1330
  sunLightIntensity: number;
1331
  ambientLightColor: [number, number, number];
1332
  ambientLightIntensity: number;
1333
} = {
15✔
1334
  timestamp: Date.now(),
1335
  timeMode: LIGHT_AND_SHADOW_EFFECT_TIME_MODES.pick as LightAndShadowEffectTimeMode,
1336
  shadowIntensity: DEFAULT_SHADOW_INTENSITY,
1337
  shadowColor: [...DEFAULT_SHADOW_COLOR] as [number, number, number],
1338
  sunLightColor: [...DEFAULT_LIGHT_COLOR] as [number, number, number],
1339
  sunLightIntensity: DEFAULT_LIGHT_INTENSITY,
1340
  ambientLightColor: [...DEFAULT_LIGHT_COLOR] as [number, number, number],
1341
  ambientLightIntensity: DEFAULT_LIGHT_INTENSITY
1342
};
1343

1344
export const LIGHT_AND_SHADOW_EFFECT: EffectDescription = {
15✔
1345
  type: 'lightAndShadow',
1346
  name: 'Light & Shadow',
1347
  parameters: [
1348
    {name: 'timestamp', min: 0, max: Number.MAX_SAFE_INTEGER},
1349
    {name: 'shadowIntensity', min: 0, max: 1, defaultValue: DEFAULT_SHADOW_INTENSITY},
1350
    {name: 'sunLightIntensity', min: 0, max: 1, defaultValue: DEFAULT_LIGHT_INTENSITY},
1351
    {name: 'ambientLightIntensity', min: 0, max: 1, defaultValue: DEFAULT_LIGHT_INTENSITY},
1352
    {name: 'shadowColor', type: 'color', min: 0, max: 255, defaultValue: DEFAULT_SHADOW_COLOR},
1353
    {name: 'sunLightColor', type: 'color', min: 0, max: 255, defaultValue: DEFAULT_LIGHT_COLOR},
1354
    {name: 'ambientLightColor', type: 'color', min: 0, max: 255, defaultValue: DEFAULT_LIGHT_COLOR}
1355
  ]
1356
};
1357

1358
export const POSTPROCESSING_EFFECTS: {[key: string]: EffectDescription} = {
15✔
1359
  ink: {
1360
    type: 'ink',
1361
    name: 'Ink',
1362
    parameters: [{name: 'strength', min: 0, max: 1}]
1363
  },
1364
  brightnessContrast: {
1365
    type: 'brightnessContrast',
1366
    name: 'Brightness & Contrast',
1367
    parameters: [
1368
      {name: 'brightness', min: -1, max: 1},
1369
      {name: 'contrast', min: -1, max: 1}
1370
    ]
1371
  },
1372
  hueSaturation: {
1373
    type: 'hueSaturation',
1374
    name: 'Hue & Saturation',
1375
    parameters: [
1376
      {name: 'hue', min: -1, max: 1},
1377
      {name: 'saturation', defaultValue: 0.25, min: -1, max: 1}
1378
    ]
1379
  },
1380
  vibrance: {
1381
    type: 'vibrance',
1382
    name: 'Vibrance',
1383
    parameters: [{name: 'amount', defaultValue: 0.5, min: -1, max: 1}]
1384
  },
1385
  sepia: {
1386
    type: 'sepia',
1387
    name: 'Sepia',
1388
    parameters: [{name: 'amount', min: 0, max: 1}]
1389
  },
1390
  dotScreen: {
1391
    type: 'dotScreen',
1392
    name: 'Dot Screen',
1393
    parameters: [
1394
      {
1395
        name: 'angle',
1396
        min: 0,
1397
        max: Math.PI / 2
1398
      },
1399
      {
1400
        name: 'size',
1401
        min: 1,
1402
        max: 20
1403
      },
1404
      {
1405
        name: 'center',
1406
        type: 'array',
1407
        label: ['Center X', 'Center Y'],
1408
        defaultValue: [0.5, 0.5],
1409
        min: 0,
1410
        max: 1
1411
      }
1412
    ]
1413
  },
1414
  colorHalftone: {
1415
    type: 'colorHalftone',
1416
    name: 'Color Halftone',
1417
    parameters: [
1418
      {
1419
        name: 'angle',
1420
        min: 0,
1421
        max: Math.PI / 2
1422
      },
1423
      {
1424
        name: 'size',
1425
        min: 1,
1426
        max: 20
1427
      },
1428
      {
1429
        name: 'center',
1430
        type: 'array',
1431
        label: ['Center X', 'Center Y'],
1432
        defaultValue: [0.5, 0.5],
1433
        min: 0,
1434
        max: 1
1435
      }
1436
    ]
1437
  },
1438
  noise: {
1439
    type: 'noise',
1440
    name: 'Noise',
1441
    parameters: [{name: 'amount', min: 0, max: 1}]
1442
  },
1443
  triangleBlur: {
1444
    type: 'triangleBlur',
1445
    name: 'Blur (Triangle)',
1446
    parameters: [{name: 'radius', min: 0, max: 100}]
1447
  },
1448
  zoomBlur: {
1449
    type: 'zoomBlur',
1450
    name: 'Blur (Zoom)',
1451
    parameters: [
1452
      {
1453
        name: 'strength',
1454
        defaultValue: 0.05,
1455
        min: 0,
1456
        max: 1
1457
      },
1458
      {
1459
        name: 'center',
1460
        type: 'array',
1461
        label: ['Center X', 'Center Y'],
1462
        defaultValue: [0.5, 0.5],
1463
        min: 0,
1464
        max: 1
1465
      }
1466
    ]
1467
  },
1468
  tiltShift: {
1469
    type: 'tiltShift',
1470
    name: 'Blur (Tilt Shift)',
1471
    parameters: [
1472
      {
1473
        name: 'blurRadius',
1474
        label: 'Blur',
1475
        min: 0,
1476
        max: 50
1477
      },
1478
      {
1479
        name: 'gradientRadius',
1480
        label: 'Gradient',
1481
        min: 0,
1482
        max: 400
1483
      },
1484
      {
1485
        name: 'start',
1486
        type: 'array',
1487
        label: ['Start', false],
1488
        defaultValue: [0.0, 0.0],
1489
        min: 0,
1490
        max: 1
1491
      },
1492
      {
1493
        name: 'end',
1494
        type: 'array',
1495
        label: ['End', false],
1496
        defaultValue: [1, 1],
1497
        min: 0,
1498
        max: 1
1499
      }
1500
    ]
1501
  },
1502
  edgeWork: {
1503
    type: 'edgeWork',
1504
    name: 'Edge work',
1505
    parameters: [{name: 'radius', min: 1, max: 50}]
1506
  },
1507
  vignette: {
1508
    type: 'vignette',
1509
    name: 'Vignette',
1510
    parameters: [
1511
      {name: 'amount', min: 0, max: 1},
1512
      {name: 'radius', min: 0, max: 1}
1513
    ]
1514
  },
1515
  magnify: {
1516
    type: 'magnify',
1517
    name: 'Magnify',
1518
    parameters: [
1519
      {
1520
        name: 'screenXY',
1521
        type: 'array',
1522
        label: ['Position X', 'Position Y'],
1523
        defaultValue: [0.5, 0.5],
1524
        min: 0,
1525
        max: 1
1526
      },
1527
      {
1528
        name: 'radiusPixels',
1529
        label: 'Size',
1530
        min: 10,
1531
        max: 500
1532
      },
1533
      {
1534
        name: 'zoom',
1535
        min: 0.5,
1536
        max: 50
1537
      },
1538
      {
1539
        name: 'borderWidthPixels',
1540
        label: 'Border Width',
1541
        defaultValue: 3,
1542
        min: 0,
1543
        max: 50
1544
      }
1545
    ]
1546
  },
1547
  hexagonalPixelate: {
1548
    type: 'hexagonalPixelate',
1549
    name: 'Hexagonal Pixelate',
1550
    parameters: [{name: 'scale', defaultValue: 20, min: 1, max: 50}]
1551
  }
1552
};
1553

1554
export const EFFECT_DESCRIPTIONS: EffectDescription[] = [
15✔
1555
  LIGHT_AND_SHADOW_EFFECT,
1556
  ...Object.keys(POSTPROCESSING_EFFECTS).map(keyName => POSTPROCESSING_EFFECTS[keyName])
225✔
1557
];
1558

1559
export type EffectType =
1560
  | 'ink'
1561
  | 'brightnessContrast'
1562
  | 'hueSaturation'
1563
  | 'vibrance'
1564
  | 'sepia'
1565
  | 'dotScreen'
1566
  | 'colorHalftone'
1567
  | 'noise'
1568
  | 'triangleBlur'
1569
  | 'zoomBlur'
1570
  | 'tiltShift'
1571
  | 'edgeWork'
1572
  | 'vignette'
1573
  | 'magnify'
1574
  | 'hexagonalPixelate'
1575
  | 'lightAndShadow';
1576

1577
export const SYNC_TIMELINE_MODES: Record<string, SyncTimelineMode> = {
15✔
1578
  start: 0,
1579
  end: 1
1580
};
1581

1582
export const GEOARROW_METADATA_KEY = 'ARROW:extension:name';
15✔
1583

1584
/**
1585
 * Enum holding GeoArrow extension type names
1586
 */
1587
export enum GEOARROW_EXTENSIONS {
1588
  POINT = 'geoarrow.point',
1589
  LINESTRING = 'geoarrow.linestring',
1590
  POLYGON = 'geoarrow.polygon',
1591
  MULTIPOINT = 'geoarrow.multipoint',
1592
  MULTILINESTRING = 'geoarrow.multilinestring',
1593
  MULTIPOLYGON = 'geoarrow.multipolygon',
1594
  WKB = 'geoarrow.wkb'
1595
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc