Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Chore]: Technical: Translate grid-layer (#1761)
Maksim Suslovb87bba3abce9
diff --git a/src/layers/grid-layer/grid-layer-icon.js b/src/layers/grid-layer/grid-layer-icon.tsxsimilarity index 97%rename from src/layers/grid-layer/grid-layer-icon.jsrename to src/layers/grid-layer/grid-layer-icon.tsxindex ac87871f9..2182bd97c 100644--- a/src/layers/grid-layer/grid-layer-icon.js+++ b/src/layers/grid-layer/grid-layer-icon.tsx@@ -20,7 +20,7 @@import React, {Component} from 'react';import PropTypes from 'prop-types';-import Base from 'components/common/icons/base';+import Base from '../../components/common/icons/base';export default class GridLayerIcon extends Component {static propTypes = {diff --git a/src/layers/grid-layer/grid-layer.js b/src/layers/grid-layer/grid-layer.tssimilarity index 64%rename from src/layers/grid-layer/grid-layer.jsrename to src/layers/grid-layer/grid-layer.tsindex 076766e5c..f3000ba45 100644--- a/src/layers/grid-layer/grid-layer.js+++ b/src/layers/grid-layer/grid-layer.ts@@ -19,10 +19,52 @@// THE SOFTWARE.import {GeoJsonLayer} from '@deck.gl/layers';-import EnhancedGridLayer from 'deckgl-layers/grid-layer/enhanced-cpu-grid-layer';-import AggregationLayer from '../aggregation-layer';+import EnhancedGridLayer from '../../deckgl-layers/grid-layer/enhanced-cpu-grid-layer';+import AggregationLayer, {AggregationLayerConfig} from '../aggregation-layer';import {pointToPolygonGeo} from './grid-utils';import GridLayerIcon from './grid-layer-icon';+import {+ VisConfigBoolean,+ VisConfigColorRange,+ VisConfigNumber,+ VisConfigRange,+ VisConfigSelection+} from '../layer-factory';+import {ColorRange} from '../../constants/color-ranges';+import {AGGREGATION_TYPES} from '../../constants/default-settings';+import {Merge} from '../../reducers';++export type GridLayerVisConfigSettings = {+ opacity: VisConfigNumber;+ worldUnitSize: VisConfigNumber;+ colorRange: VisConfigColorRange;+ coverage: VisConfigNumber;+ sizeRange: VisConfigRange;+ percentile: VisConfigRange;+ elevationPercentile: VisConfigRange;+ elevationScale: VisConfigNumber;+ enableElevationZoomFactor: VisConfigBoolean;+ colorAggregation: VisConfigSelection;+ sizeAggregation: VisConfigSelection;+ enable3d: VisConfigBoolean;+};++export type GridLayerVisConfig = {+ opacity: number;+ worldUnitSize: number;+ colorRange: ColorRange;+ coverage: number;+ sizeRange: [number, number];+ percentile: [number, number];+ elevationPercentile: [number, number];+ elevationScale: number;+ enableElevationZoomFactor: boolean;+ colorAggregation: keyof typeof AGGREGATION_TYPES;+ sizeAggregation: keyof typeof AGGREGATION_TYPES;+ enable3d: boolean;+};++export type GridLayerConfig = Merge<AggregationLayerConfig, {visConfig: GridLayerVisConfig}>;export const gridVisConfigs = {opacity: 'opacity',@@ -40,6 +82,9 @@ export const gridVisConfigs = {};export default class GridLayer extends AggregationLayer {+ declare visConfigSettings: GridLayerVisConfigSettings;+ declare config: GridLayerConfig;+constructor(props) {super(props);@@ -47,7 +92,7 @@ export default class GridLayer extends AggregationLayer {this.visConfigSettings.worldUnitSize.label = 'columns.grid.worldUnitSize';}- get type() {+ get type(): 'grid' {return 'grid';}@@ -64,6 +109,8 @@ export default class GridLayer extends AggregationLayer {const hoveredObject = this.hasHoveredObject(objectHovered);return [+ // @ts-expect-error for some reasons EnhancedGridLayer dont have constructor+ // that expected 1 argumentnew EnhancedGridLayer({...this.getDefaultAggregationLayerProp(opts),...data,diff --git a/src/layers/grid-layer/grid-utils.js b/src/layers/grid-layer/grid-utils.tssimilarity index 85%rename from src/layers/grid-layer/grid-utils.jsrename to src/layers/grid-layer/grid-utils.tsindex 1e0c14041..c1e18d127 100644--- a/src/layers/grid-layer/grid-utils.js+++ b/src/layers/grid-layer/grid-utils.ts@@ -19,20 +19,33 @@// THE SOFTWARE.import {WebMercatorViewport} from '@deck.gl/core';+import {MapState} from '../../reducers';/*** top left of the grid to a square polygon for the hover layer* and current latitude- * @param {object} object- * @param {number} cellSize- * @param {number} coverage- * @param {object} properties- * @param {object} mapState- * @returns {object} - geojson feature+ * @param object+ * @param cellSize+ * @param coverage+ * @param properties+ * @param mapState+ * @returns - geojson feature*/// TODO: TEST-export function pointToPolygonGeo({object, cellSize, coverage, properties, mapState}) {+export function pointToPolygonGeo({+ object,+ cellSize,+ coverage,+ properties,+ mapState+}: {+ object: any;+ cellSize: number;+ coverage: number;+ properties?: any;+ mapState: MapState;+}) {const {position} = object;const viewport = new WebMercatorViewport(mapState);