Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Chore]: Technical: Setup for different Visual channels per layer (#1751)

Maksim Suslov0057a1e4f94f
diff --git a/src/layers/base-layer.ts b/src/layers/base-layer.ts
index d29c42067..5678c6b24 100644
--- a/src/layers/base-layer.ts
+++ b/src/layers/base-layer.ts
@@ -72,6 +72,7 @@ export type LayerColumns = {
};
export type VisualChannelDomain = number[] | string[];
export type VisualChannelField = Field | null;
+export type VisualChannelScale = keyof typeof SCALE_TYPES;
export type LayerBaseConfig = {
dataId: string | null;
@@ -96,6 +97,27 @@ export type LayerBaseConfig = {
};
};
+export type LayerColorConfig = {
+ colorField: VisualChannelField;
+ colorDomain: VisualChannelDomain;
+ colorScale: VisualChannelScale;
+};
+export type LayerSizeConfig = {
+ // color by size, domain is set by filters, field, scale type
+ sizeDomain: VisualChannelDomain;
+ sizeScale: VisualChannelScale;
+ sizeField: VisualChannelField;
+};
+export type LayerHeightConfig = {
+ heightField: VisualChannelField;
+ heightDomain: VisualChannelDomain;
+ heightScale: VisualChannelScale;
+};
+
+export type LayerWeightConfig = {
+ weightField: VisualChannelField;
+};
+
export type VisualChannel = {
property: string;
field: string;
@@ -156,13 +178,13 @@ function* generateColor(): Generator<RGBColor> {
export const colorMaker = generateColor();
-class Layer {
+class Layer<LayerConfig extends LayerBaseConfig = LayerBaseConfig> {
id: string;
// TODO: define meta
meta: {};
// TODO: define visConfigSettings
visConfigSettings: {};
- config: LayerBaseConfig;
+ config: LayerConfig;
// TODO: define _oldDataUpdateTriggers
_oldDataUpdateTriggers: any;
@@ -179,6 +201,7 @@ class Layer {
// visConfigSettings
this.visConfigSettings = {};
+ // @ts-expect-error
this.config = this.getDefaultLayerConfig({
columns: this.getLayerColumns(),
...props