Skip to content

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

[Chore]: Technical: Translate cluster-layer (#1774)

Maksim Suslov9a0ad62329b2
diff --git a/src/layers/aggregation-layer.ts b/src/layers/aggregation-layer.ts
index 6be7a30c3..f76c3940b 100644
--- a/src/layers/aggregation-layer.ts
+++ b/src/layers/aggregation-layer.ts
@@ -19,7 +19,13 @@
// THE SOFTWARE.
import memoize from 'lodash.memoize';
-import Layer, {LayerBaseConfig, LayerColorConfig, LayerColumn, LayerSizeConfig} from './base-layer';
+import Layer, {
+ LayerBaseConfig,
+ LayerColorConfig,
+ LayerColumn,
+ LayerSizeConfig,
+ VisualChannels
+} from './base-layer';
import {hexToRgb} from '../utils/color-utils';
import {aggregate} from '../utils/aggregate-utils';
import {
@@ -112,7 +118,7 @@ export default class AggregationLayer extends Layer {
];
}
- get visualChannels() {
+ get visualChannels(): VisualChannels {
return {
color: {
aggregation: 'colorAggregation',
diff --git a/src/layers/base-layer.ts b/src/layers/base-layer.ts
index 213a67a0e..6c8177794 100644
--- a/src/layers/base-layer.ts
+++ b/src/layers/base-layer.ts
@@ -147,6 +147,8 @@ export type VisualChannel = {
fixed?: any;
supportedFieldTypes?: boolean;
+
+ aggregation?: 'colorAggregation' | 'sizeAggregation';
};
export type VisualChannelDescription = {
diff --git a/src/layers/cluster-layer/cluster-layer-icon.js b/src/layers/cluster-layer/cluster-layer-icon.tsx
similarity index 100%
rename from src/layers/cluster-layer/cluster-layer-icon.js
rename to src/layers/cluster-layer/cluster-layer-icon.tsx
diff --git a/src/layers/cluster-layer/cluster-layer.js b/src/layers/cluster-layer/cluster-layer.ts
similarity index 77%
rename from src/layers/cluster-layer/cluster-layer.js
rename to src/layers/cluster-layer/cluster-layer.ts
index f85572d03..acf210161 100644
--- a/src/layers/cluster-layer/cluster-layer.js
+++ b/src/layers/cluster-layer/cluster-layer.ts
@@ -18,12 +18,40 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-import AggregationLayer from '../aggregation-layer';
+import AggregationLayer, {AggregationLayerConfig} from '../aggregation-layer';
import {ScatterplotLayer} from '@deck.gl/layers';
import DeckGLClusterLayer from 'deckgl-layers/cluster-layer/cluster-layer';
import {CHANNEL_SCALES} from 'constants/default-settings';
import ClusterLayerIcon from './cluster-layer-icon';
+import {
+ VisConfigColorRange,
+ VisConfigNumber,
+ VisConfigRange,
+ VisConfigSelection
+} from '../layer-factory';
+import {ColorRange} from '../../constants/color-ranges';
+import {AGGREGATION_TYPES} from '../../constants/default-settings';
+import {Merge} from '../../reducers';
+import {VisualChannels} from '../base-layer';
+
+export type ClusterLayerVisConfigSettings = {
+ opacity: VisConfigNumber;
+ clusterRadius: VisConfigNumber;
+ colorRange: VisConfigColorRange;
+ radiusRange: VisConfigRange;
+ colorAggregation: VisConfigSelection;
+};
+
+export type ClusterLayerVisConfig = {
+ opacity: number;
+ clusterRadius: number;
+ colorRange: ColorRange;
+ radiusRange: [number, number];
+ colorAggregation: keyof typeof AGGREGATION_TYPES;
+};
+
+export type ClusterLayerConfig = Merge<AggregationLayerConfig, {visConfig: ClusterLayerVisConfig}>;
export const clusterVisConfigs = {
opacity: 'opacity',
@@ -34,12 +62,15 @@ export const clusterVisConfigs = {
};
export default class ClusterLayer extends AggregationLayer {
+ declare visConfigSettings: ClusterLayerVisConfigSettings;
+ declare config: ClusterLayerConfig;
+
constructor(props) {
super(props);
this.registerVisConfig(clusterVisConfigs);
}
- get type() {
+ get type(): 'cluster' {
return 'cluster';
}
@@ -47,7 +78,7 @@ export default class ClusterLayer extends AggregationLayer {
return ClusterLayerIcon;
}
- get visualChannels() {
+ get visualChannels(): VisualChannels {
return {
color: {
aggregation: 'colorAggregation',