Skip to content

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

[Chore]: Technical: Translate layers final changes (#1783)

Maksim Suslov8c5e50756144
diff --git a/src/constants/default-settings.ts b/src/constants/default-settings.ts
index 186983c19..eaa5f66b3 100644
--- a/src/constants/default-settings.ts
+++ b/src/constants/default-settings.ts
@@ -44,6 +44,7 @@ import {
import {getHTMLMapModeTileUrl} from 'utils/utils';
import {TOOLTIP_FORMAT_TYPES} from './tooltip';
import {LAYER_TYPES} from 'layers/types';
+import {RGBAColor} from 'reducers';
export const ACTION_PREFIX = '@@kepler.gl/';
export const CLOUDFRONT = 'https://d1a3f4spazzrp4.cloudfront.net/kepler.gl';
@@ -435,7 +436,7 @@ export const FILED_TYPE_DISPLAY = {
export const FIELD_COLORS = {
default: RED
};
-export const HIGHLIGH_COLOR_3D = [255, 255, 255, 60];
+export const HIGHLIGH_COLOR_3D: RGBAColor = [255, 255, 255, 60];
export const CHANNEL_SCALES = keyMirror({
color: null,
radius: null,
@@ -654,7 +655,7 @@ export const DEFAULT_LAYER_COLOR = {
// let user pass in default tooltip fields
export const DEFAULT_TOOLTIP_FIELDS: any[] = [];
-export const NO_VALUE_COLOR: [number, number, number, number] = [0, 0, 0, 0];
+export const NO_VALUE_COLOR: RGBAColor = [0, 0, 0, 0];
export const LAYER_BLENDINGS = {
additive: {
diff --git a/src/deckgl-layers/line-layer/line-layer.ts b/src/deckgl-layers/line-layer/line-layer.ts
index 7a52f4d26..0f3701846 100644
--- a/src/deckgl-layers/line-layer/line-layer.ts
+++ b/src/deckgl-layers/line-layer/line-layer.ts
@@ -110,7 +110,7 @@ export default class EnhancedLineLayer extends LineLayer<
const {attributeManager} = this.state;
attributeManager.addInstanced({
instanceTargetColors: {
- size: this.props.colorFormat.length,
+ size: this.props.colorFormat?.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
transition: true,
diff --git a/src/layers/aggregation-layer.ts b/src/layers/aggregation-layer.ts
index f76c3940b..e57c47917 100644
--- a/src/layers/aggregation-layer.ts
+++ b/src/layers/aggregation-layer.ts
@@ -24,6 +24,7 @@ import Layer, {
LayerColorConfig,
LayerColumn,
LayerSizeConfig,
+ VisualChannelDescription,
VisualChannels
} from './base-layer';
import {hexToRgb} from '../utils/color-utils';
@@ -36,12 +37,17 @@ import {
} from '../constants/default-settings';
import {Datasets, Merge} from '../reducers';
import {ColorRange} from '../constants/color-ranges';
+import {KeplerTable} from '../utils';
type AggregationLayerColumns = {
lat: LayerColumn;
lng: LayerColumn;
};
+export type AggregationLayerData = {
+ index: number;
+};
+
export const pointPosAccessor = ({lat, lng}: AggregationLayerColumns) => dc => d => [
dc.valueAt(d.index, lng.fieldIdx),
dc.valueAt(d.index, lat.fieldIdx)
@@ -149,17 +155,22 @@ export default class AggregationLayer extends Layer {
/**
* Get the description of a visualChannel config
* @param key
- * @returns {{label: string, measure: (string|string)}}
+ * @returns
*/
- getVisualChannelDescription(key) {
+ getVisualChannelDescription(key: string): VisualChannelDescription {
+ const channel = this.visualChannels[key];
+ if (!channel) return {label: '', measure: ''};
// e.g. label: Color, measure: Average of ETA
- const {range, field, defaultMeasure, aggregation} = this.visualChannels[key];
+ const {range, field, defaultMeasure, aggregation} = channel;
const fieldConfig = this.config[field];
+ const label = this.visConfigSettings[range].label;
return {
- label: this.visConfigSettings[range].label,
- measure: fieldConfig
- ? `${this.config.visConfig[aggregation]} of ${fieldConfig.displayName || fieldConfig.name}`
- : defaultMeasure
+ label: typeof label === 'function' ? label(this.config) : label,
+ measure:
+ fieldConfig && aggregation
+ ? `${this.config.visConfig[aggregation]} of ${fieldConfig.displayName ||
+ fieldConfig.name}`
+ : defaultMeasure
};
}
@@ -171,7 +182,7 @@ export default class AggregationLayer extends Layer {
/**
* Aggregation layer handles visual channel aggregation inside deck.gl layer
*/
- updateLayerVisualChannel({data, dataContainer}, channel) {
+ updateLayerVisualChannel({dataContainer}, channel) {
this.validateVisualChannel(channel);
}
@@ -227,6 +238,7 @@ export default class AggregationLayer extends Layer {
getScaleOptions(channel: string): string[] {
const visualChannel = this.visualChannels[channel];
const {field, aggregation, channelScaleType} = visualChannel;
+ // @ts-expect-error
const aggregationType = this.config.visConfig[aggregation];
return this.config[field]
? // scale options based on aggregation
@@ -238,7 +250,7 @@ export default class AggregationLayer extends Layer {
/**
* Aggregation layer handles visual channel aggregation inside deck.gl layer
*/
- updateLayerDomain(datasets, newFilter) {
+ updateLayerDomain(datasets, newFilter): AggregationLayer {
return this;
}
@@ -249,8 +261,8 @@ export default class AggregationLayer extends Layer {
this.updateMeta({bounds});
}
- calculateDataAttribute({dataContainer, filteredIndex}, getPosition) {
- const data = [];
+ calculateDataAttribute({dataContainer, filteredIndex}: KeplerTable, getPosition) {
+ const data: AggregationLayerData[] = [];
for (let i = 0; i < filteredIndex.length; i++) {
const index = filteredIndex[i];
@@ -294,7 +306,9 @@ export default class AggregationLayer extends Layer {
data,
getPosition,
_filterData: filterData,
+ // @ts-expect-error
...(getColorValue ? {getColorValue} : {}),
+ // @ts-expect-error
...(getElevationValue ? {getElevationValue} : {})
};
}
diff --git a/src/layers/arc-layer/arc-layer.ts b/src/layers/arc-layer/arc-layer.ts
index 0efbe6282..50a336602 100644
--- a/src/layers/arc-layer/arc-layer.ts
+++ b/src/layers/arc-layer/arc-layer.ts
@@ -41,6 +41,7 @@ import {
VisConfigRange
} from '../layer-factory';
import {ColorRange} from '../../constants/color-ranges';
+import KeplerTable from '../../utils/table-utils/kepler-table';
export type ArcLayerVisConfigSettings = {
opacity: VisConfigNumber;
@@ -100,7 +101,13 @@ export const arcColumnLabels = {
lng1: 'arc.lng1'
};
-export const arcVisConfigs = {
+export const arcVisConfigs: {
+ opacity: 'opacity';
+ thickness: 'thickness';
+ colorRange: 'colorRange';
+ sizeRange: 'strokeWidthRange';
+ targetColor: 'targetColor';
+} = {
opacity: 'opacity',
thickness: 'thickness',
colorRange: 'colorRange',
@@ -117,7 +124,8 @@ export default class ArcLayer extends Layer {
super(props);
this.registerVisConfig(arcVisConfigs);
- this.getPositionAccessor = dataContainer => arcPosAccessor(this.config.columns)(dataContainer);
+ this.getPositionAccessor = (dataContainer: DataContainerInterface) =>
+ arcPosAccessor(this.config.columns)(dataContainer);
}
get type() {
@@ -169,7 +177,7 @@ export default class ArcLayer extends Layer {
static findDefaultLayerProps({
fieldPairs = []
- }): {props: {color?: RGBColor; columns: ArcLayerColumnsConfig; label: string}[]} {
+ }: KeplerTable): {props: {color?: RGBColor; columns: ArcLayerColumnsConfig; label: string}[]} {
if (fieldPairs.length < 2) {
return {props: []};
}
diff --git a/src/layers/base-layer.ts b/src/layers/base-layer.ts
index 234412530..d166e65c4 100644
--- a/src/layers/base-layer.ts
+++ b/src/layers/base-layer.ts
@@ -62,6 +62,7 @@ import {LayerTextLabel, ColorUI} from './layer-factory';
import {KeplerTable} from '../utils';
import {DataContainerInterface} from 'utils/table-utils/data-container-interface';
import {Field, GpuFilter} from 'utils/table-utils/kepler-table';
+import React from 'react';
export type LayerColumn = {value: string | null; fieldIdx: number; optional?: boolean};
@@ -73,7 +74,8 @@ export type VisualChannelField = Field | null;
export type VisualChannelScale = keyof typeof SCALE_TYPES;
export type LayerBaseConfig = {
- dataId: string | null;
+ // TODO: allow to become null
+ dataId: string;
label: string;
color: RGBColor;
@@ -235,7 +237,7 @@ class Layer {
});
}
- get layerIcon() {
+ get layerIcon(): React.ElementType {
return DefaultLayerIcon;
}
@@ -243,8 +245,7 @@ class Layer {
return OVERLAY_TYPE.deckgl;
}
- get type(): string {
- // @ts-expect-error
+ get type(): string | null {
return null;
}
@@ -256,11 +257,11 @@ class Layer {
return false;
}
- get requiredLayerColumns() {
+ get requiredLayerColumns(): string[] {
return [];
}
- get optionalColumns() {
+ get optionalColumns(): string[] {
return [];
}
@@ -340,7 +341,7 @@ class Layer {
* };
* }
*/
- get layerInfoModal() {
+ get layerInfoModal(): any {
return null;
}
/*
@@ -435,6 +436,7 @@ class Layer {
props: Partial<LayerBaseConfig> = {}
): LayerBaseConfig & Partial<LayerColorConfig & LayerSizeConfig> {
return {
+ // @ts-expect-error
dataId: props.dataId || null,
label: props.label || DEFAULT_LAYER_LABEL,
color: props.color || colorMaker.next().value,
@@ -1067,13 +1069,13 @@ class Layer {
const dataUpdateTriggers = this.getDataUpdateTriggers(layerDataset);
const triggerChanged = this.getChangedTriggers(dataUpdateTriggers);
- if (triggerChanged.getMeta) {
+ if (triggerChanged && triggerChanged.getMeta) {
this.updateLayerMeta(dataContainer, getPosition);
}
let data = [];
- if (!triggerChanged.getData && oldLayerData && oldLayerData.data) {
+ if (!(triggerChanged && triggerChanged.getData) && oldLayerData && oldLayerData.data) {
// same data
data = oldLayerData.data;
} else {
diff --git a/src/layers/cluster-layer/cluster-layer.ts b/src/layers/cluster-layer/cluster-layer.ts
index 759658279..8178d9b51 100644
--- a/src/layers/cluster-layer/cluster-layer.ts
+++ b/src/layers/cluster-layer/cluster-layer.ts
@@ -32,7 +32,6 @@ import {
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';
@@ -54,7 +53,13 @@ export type ClusterLayerVisConfig = {
export type ClusterLayerConfig = Merge<AggregationLayerConfig, {visConfig: ClusterLayerVisConfig}>;
-export const clusterVisConfigs = {
+export const clusterVisConfigs: {
+ opacity: 'opacity';
+ clusterRadius: 'clusterRadius';
+ colorRange: 'colorRange';
+ radiusRange: 'clusterRadiusRange';
+ colorAggregation: 'colorAggregation';
+} = {
opacity: 'opacity',
clusterRadius: 'clusterRadius',
colorRange: 'colorRange',
@@ -141,7 +146,7 @@ export default class ClusterLayer extends AggregationLayer {
// hover layer
...(hoveredObject
? [
- new ScatterplotLayer({
+ new ScatterplotLayer<{radius: number}>({
id: `${this.id}-hovered`,
data: [hoveredObject],
getFillColor: this.config.highlightColor,
diff --git a/src/layers/default-layer-icon.js b/src/layers/default-layer-icon.tsx
similarity index 100%
rename from src/layers/default-layer-icon.js
rename to src/layers/default-layer-icon.tsx
diff --git a/src/layers/geojson-layer/geojson-layer.ts b/src/layers/geojson-layer/geojson-layer.ts
index 38fcfa4fd..7c3915d2b 100644
--- a/src/layers/geojson-layer/geojson-layer.ts
+++ b/src/layers/geojson-layer/geojson-layer.ts
@@ -51,7 +51,7 @@ import {
import {DataContainerInterface} from '../../utils/table-utils/data-container-interface';
import {Merge, RGBColor} from '../../reducers';
import {ColorRange} from '../../constants/color-ranges';
-import {Feature} from 'geojson';
+import {KeplerTable} from '../../utils';
const SUPPORTED_ANALYZER_TYPES = {
[DATA_TYPES.GEOMETRY]: true,
@@ -59,7 +59,25 @@ const SUPPORTED_ANALYZER_TYPES = {
[DATA_TYPES.PAIR_GEOMETRY_FROM_STRING]: true
};
-export const geojsonVisConfigs = {
+export const geojsonVisConfigs: {
+ opacity: 'opacity';
+ strokeOpacity: VisConfigNumber;
+ thickness: VisConfigNumber;
+ strokeColor: 'strokeColor';
+ colorRange: 'colorRange';
+ strokeColorRange: 'strokeColorRange';
+ radius: 'radius';
+
+ sizeRange: 'strokeWidthRange';
+ radiusRange: 'radiusRange';
+ heightRange: 'elevationRange';
+ elevationScale: 'elevationScale';
+ enableElevationZoomFactor: 'enableElevationZoomFactor';
+ stroked: 'stroked';
+ filled: 'filled';
+ enable3d: 'enable3d';
+ wireframe: 'wireframe';
+} = {
opacity: 'opacity',
strokeOpacity: {
...LAYER_VIS_CONFIGS.opacity,
@@ -166,7 +184,8 @@ export default class GeoJsonLayer extends Layer {
this.dataToFeature = [];
this.registerVisConfig(geojsonVisConfigs);
- this.getPositionAccessor = dataContainer => featureAccessor(this.config.columns)(dataContainer);
+ this.getPositionAccessor = (dataContainer: DataContainerInterface) =>
+ featureAccessor(this.config.columns)(dataContainer);
}
get type() {
@@ -252,7 +271,7 @@ export default class GeoJsonLayer extends Layer {
};
}
- static findDefaultLayerProps({label, fields = []}) {
+ static findDefaultLayerProps({label, fields = []}: KeplerTable) {
const geojsonColumns = fields
.filter(f => f.type === 'geojson' && SUPPORTED_ANALYZER_TYPES[f.analyzerType])
.map(f => f.name);
@@ -411,9 +430,9 @@ export default class GeoJsonLayer extends Layer {
rounded: true,
updateTriggers,
_subLayerProps: {
- ...(featureTypes.polygon ? {'polygons-stroke': opaOverwrite} : {}),
- ...(featureTypes.line ? {'line-strings': opaOverwrite} : {}),
- ...(featureTypes.point
+ ...(featureTypes?.polygon ? {'polygons-stroke': opaOverwrite} : {}),
+ ...(featureTypes?.line ? {'line-strings': opaOverwrite} : {}),
+ ...(featureTypes?.point
? {
points: {
lineOpacity: visConfig.strokeOpacity
diff --git a/src/layers/geojson-layer/geojson-utils.ts b/src/layers/geojson-layer/geojson-utils.ts
index 989d0f5e3..3a64e6432 100644
--- a/src/layers/geojson-layer/geojson-utils.ts
+++ b/src/layers/geojson-layer/geojson-utils.ts
@@ -86,7 +86,7 @@ export function getGeojsonDataMaps(dataContainer: any, getFeature: GetFeature):
'GeometryCollection'
];
- const dataToFeature: (Feature | null)[] = [];
+ const dataToFeature: GeojsonDataMaps = [];
for (let index = 0; index < dataContainer.numRows(); index++) {
const feature = parseGeoJsonRawFeature(getFeature({index}));
@@ -149,7 +149,7 @@ export function parseGeometryFromString(geoString: string): Feature | null {
return normalized.features[0];
}
-export function getGeojsonBounds(features: Feature[] = []): BBox | null {
+export function getGeojsonBounds(features: GeojsonDataMaps = []): BBox | null {
// 70 ms for 10,000 polygons
// here we only pick couple
const maxCount = 10000;
@@ -183,14 +183,16 @@ export const featureToDeckGlGeoType = {
* @param {Array<Object>} allFeatures
* @returns {Object} mapping of feature type existence
*/
-export function getGeojsonFeatureTypes(allFeatures: Feature[]): FeatureTypeMap {
+export function getGeojsonFeatureTypes(allFeatures: GeojsonDataMaps): FeatureTypeMap {
// @ts-expect-error
const featureTypes: FeatureTypeMap = {};
for (let f = 0; f < allFeatures.length; f++) {
const feature = allFeatures[f];
- const geoType = featureToDeckGlGeoType[feature && feature.geometry && feature.geometry.type];
- if (geoType) {
- featureTypes[geoType] = true;
+ if (feature) {
+ const geoType = featureToDeckGlGeoType[feature.geometry && feature.geometry.type];
+ if (geoType) {
+ featureTypes[geoType] = true;
+ }
}
}
diff --git a/src/layers/grid-layer/grid-layer.ts b/src/layers/grid-layer/grid-layer.ts
index 7c3ff0b55..bd415fd58 100644
--- a/src/layers/grid-layer/grid-layer.ts
+++ b/src/layers/grid-layer/grid-layer.ts
@@ -32,7 +32,6 @@ import {
VisConfigSelection
} from '../layer-factory';
import {ColorRange} from '../../constants/color-ranges';
-import {AGGREGATION_TYPES} from '../../constants/default-settings';
import {Merge} from '../../reducers';
export type GridLayerVisConfigSettings = {
@@ -67,7 +66,20 @@ export type GridLayerVisConfig = {
export type GridLayerConfig = Merge<AggregationLayerConfig, {visConfig: GridLayerVisConfig}>;
-export const gridVisConfigs = {
+export const gridVisConfigs: {
+ opacity: 'opacity';
+ worldUnitSize: 'worldUnitSize';
+ colorRange: 'colorRange';
+ coverage: 'coverage';
+ sizeRange: 'elevationRange';
+ percentile: 'percentile';
+ elevationPercentile: 'elevationPercentile';
+ elevationScale: 'elevationScale';
+ enableElevationZoomFactor: 'enableElevationZoomFactor';
+ colorAggregation: 'colorAggregation';
+ sizeAggregation: 'sizeAggregation';
+ enable3d: 'enable3d';
+} = {
opacity: 'opacity',
worldUnitSize: 'worldUnitSize',
colorRange: 'colorRange',
@@ -110,8 +122,6 @@ 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 argument
new EnhancedGridLayer({
...this.getDefaultAggregationLayerProp(opts),
...data,
diff --git a/src/layers/h3-hexagon-layer/h3-hexagon-layer.ts b/src/layers/h3-hexagon-layer/h3-hexagon-layer.ts
index b6818a360..041f9aaca 100644
--- a/src/layers/h3-hexagon-layer/h3-hexagon-layer.ts
+++ b/src/layers/h3-hexagon-layer/h3-hexagon-layer.ts
@@ -22,7 +22,6 @@ import Layer, {
LayerBaseConfig,
LayerColorConfig,
LayerColumn,
- LayerColumns,
LayerCoverageConfig,
LayerSizeConfig
} from '../base-layer';
@@ -36,7 +35,6 @@ import {CHANNEL_SCALES, HIGHLIGH_COLOR_3D} from 'constants/default-settings';
import {createDataContainer} from 'utils/table-utils';
import {
- LayerVisConfigSettings,
VisConfigBoolean,
VisConfigColorRange,
VisConfigNumber,
@@ -45,6 +43,7 @@ import {
import {Merge} from '../../reducers';
import {DataContainerInterface} from '../../utils/table-utils/data-container-interface';
import {ColorRange} from '../../constants/color-ranges';
+import {KeplerTable} from '../../utils';
export type HexagonIdLayerColumnsConfig = {
hex_id: LayerColumn;
@@ -81,6 +80,8 @@ export type HexagonIdLayerConfig = Merge<
> &
HexagonIdLayerVisualChannelConfig;
+export type HexagonIdLayerData = {index: number; id; centroid: Centroid};
+
const DEFAULT_LINE_SCALE_VALUE = 8;
export const hexIdRequiredColumns: ['hex_id'] = ['hex_id'];
@@ -91,7 +92,16 @@ export const hexIdAccessor = ({hex_id}: HexagonIdLayerColumnsConfig) => (
export const defaultElevation = 500;
export const defaultCoverage = 1;
-export const HexagonIdVisConfigs = {
+export const HexagonIdVisConfigs: {
+ opacity: 'opacity';
+ colorRange: 'colorRange';
+ coverage: 'coverage';
+ enable3d: 'enable3d';
+ sizeRange: 'elevationRange';
+ coverageRange: 'coverageRange';
+ elevationScale: 'elevationScale';
+ enableElevationZoomFactor: 'enableElevationZoomFactor';
+} = {
opacity: 'opacity',
colorRange: 'colorRange',
coverage: 'coverage',
@@ -109,8 +119,10 @@ export default class HexagonIdLayer extends Layer {
declare visConfigSettings: HexagonIdLayerVisConfigSettings;
constructor(props) {
super(props);
+ this.dataToFeature = {centroids: []};
this.registerVisConfig(HexagonIdVisConfigs);
- this.getPositionAccessor = dataContainer => hexIdAccessor(this.config.columns)(dataContainer);
+ this.getPositionAccessor = (dataContainer: DataContainerInterface) =>
+ hexIdAccessor(this.config.columns)(dataContainer);
}
get type(): 'hexagonId' {
@@ -173,7 +185,7 @@ export default class HexagonIdLayer extends Layer {
return this;
}
- static findDefaultLayerProps({fields = [], dataContainer}) {
+ static findDefaultLayerProps({fields = [], dataContainer}: KeplerTable) {
const hexFields = getHexFields(fields, dataContainer);
if (!hexFields.length) {
return {props: []};
@@ -204,8 +216,8 @@ export default class HexagonIdLayer extends Layer {
};
}
- calculateDataAttribute({dataContainer, filteredIndex}, getHexId) {
- const data = [];
+ calculateDataAttribute({dataContainer, filteredIndex}: KeplerTable, getHexId) {
+ const data: HexagonIdLayerData[] = [];
for (let i = 0; i < filteredIndex.length; i++) {
const index = filteredIndex[i];
@@ -289,7 +301,7 @@ export default class HexagonIdLayer extends Layer {
...data,
wrapLongitude: false,
- getHexagon: x => x.id,
+ getHexagon: (x: any) => x.id,
// coverage
coverage: config.coverageField ? 1 : visConfig.coverage,
diff --git a/src/layers/heatmap-layer/heatmap-layer.ts b/src/layers/heatmap-layer/heatmap-layer.ts
index c5e26f3bf..6c5c650e9 100644
--- a/src/layers/heatmap-layer/heatmap-layer.ts
+++ b/src/layers/heatmap-layer/heatmap-layer.ts
@@ -60,7 +60,11 @@ export const pointPosAccessor = ({lat, lng}: HeatmapLayerColumnsConfig) => (
export const pointColResolver = ({lat, lng}: HeatmapLayerColumnsConfig) =>
`${lat.fieldIdx}-${lng.fieldIdx}`;
-export const heatmapVisConfigs = {
+export const heatmapVisConfigs: {
+ opacity: 'opacity';
+ colorRange: 'colorRange';
+ radius: 'heatmapRadius';
+} = {
opacity: 'opacity',
colorRange: 'colorRange',
radius: 'heatmapRadius'
@@ -78,7 +82,7 @@ export const heatmapVisConfigs = {
* 1, "rgb(178,24,43)"
* ]
*/
-const heatmapDensity = (colorRange: ColorRange): string[] => {
+const heatmapDensity = (colorRange: ColorRange): (string | number)[] => {
const scaleFunction = SCALE_FUNC.quantize;
const colors: HexColor[] = ['#000000', ...colorRange.colors];
@@ -87,7 +91,7 @@ const heatmapDensity = (colorRange: ColorRange): string[] => {
.domain([0, 1])
.range(colors);
- const colorDensity = scale.range().reduce((bands, level) => {
+ const colorDensity = scale.range().reduce((bands: (string | number)[], level) => {
const invert = scale.invertExtent(level);
return [
...bands,
@@ -160,6 +164,7 @@ class HeatmapLayer extends MapboxGLLayer {
weightScale: 'linear'
};
+ // @ts-expect-error
return layerConfig;
}
diff --git a/src/layers/hexagon-layer/hexagon-layer.ts b/src/layers/hexagon-layer/hexagon-layer.ts
index db889bab5..fee174057 100644
--- a/src/layers/hexagon-layer/hexagon-layer.ts
+++ b/src/layers/hexagon-layer/hexagon-layer.ts
@@ -34,7 +34,6 @@ import {
VisConfigSelection
} from '../layer-factory';
import {ColorRange} from '../../constants/color-ranges';
-import {AGGREGATION_TYPES} from '../../constants/default-settings';
export type HexagonLayerVisConfigSettings = {
opacity: VisConfigNumber;
@@ -70,7 +69,21 @@ export type HexagonLayerVisConfig = {
export type HexagonLayerConfig = Merge<AggregationLayerConfig, {visConfig: HexagonLayerVisConfig}>;
-export const hexagonVisConfigs = {
+export const hexagonVisConfigs: {
+ opacity: 'opacity';
+ worldUnitSize: 'worldUnitSize';
+ resolution: 'resolution';
+ colorRange: 'colorRange';
+ coverage: 'coverage';
+ sizeRange: 'elevationRange';
+ percentile: 'percentile';
+ elevationPercentile: 'elevationPercentile';
+ elevationScale: 'elevationScale';
+ enableElevationZoomFactor: 'enableElevationZoomFactor';
+ colorAggregation: 'colorAggregation';
+ sizeAggregation: 'sizeAggregation';
+ enable3d: 'enable3d';
+} = {
opacity: 'opacity',
worldUnitSize: 'worldUnitSize',
resolution: 'resolution',
diff --git a/src/layers/hexagon-layer/hexagon-utils.ts b/src/layers/hexagon-layer/hexagon-utils.ts
index 2f28c2d8d..09ba3a75d 100644
--- a/src/layers/hexagon-layer/hexagon-utils.ts
+++ b/src/layers/hexagon-layer/hexagon-utils.ts
@@ -38,7 +38,7 @@ export function hexagonToPolygonGeo(object, properties, radius, mapState) {
const pixRadius = radius * unitsPerMeter[0];
- const coordinates = [];
+ const coordinates: any[] = [];
for (let i = 0; i < 6; i++) {
const vertex = hex_corner(screenCenter, pixRadius, i);
diff --git a/src/layers/icon-layer/icon-info-modal.tsx b/src/layers/icon-layer/icon-info-modal.tsx
index 9b7b84b04..011b29a85 100644
--- a/src/layers/icon-layer/icon-info-modal.tsx
+++ b/src/layers/icon-layer/icon-info-modal.tsx
@@ -28,7 +28,7 @@ const lineFunction = line()
.x(d => d[0] * 10)
.y(d => d[1] * 10);
-const IconShape = ({mesh}) => (
+const IconShape = ({mesh, className}) => (
<svg width="20px" height="20px">
<g transform="translate(10, 10)">
{mesh.cells.map((cell, i) => (
@@ -120,7 +120,7 @@ const IconTable = styled.div`
flex-wrap: wrap;
`;
-const IconInfoModalFactory = (svgIcons = []) => {
+const IconInfoModalFactory = (svgIcons: any[] = []) => {
const IconInfoModal = () => (
<div className="icon-info-modal">
<div className="icon-info-modal__description">
diff --git a/src/layers/icon-layer/icon-layer.ts b/src/layers/icon-layer/icon-layer.ts
index 16a60ab9c..836900140 100644
--- a/src/layers/icon-layer/icon-layer.ts
+++ b/src/layers/icon-layer/icon-layer.ts
@@ -29,7 +29,6 @@ import Layer, {LayerBaseConfig, LayerColumn} from '../base-layer';
import {getTextOffsetByRadius, formatTextLabelData} from '../layer-text-label';
import {DataContainerInterface} from '../../utils/table-utils/data-container-interface';
import {
- LayerVisConfigSettings,
VisConfigBoolean,
VisConfigColorRange,
VisConfigNumber,
@@ -37,6 +36,7 @@ import {
} from '../layer-factory';
import {ColorRange} from '../../constants/color-ranges';
import {Merge} from '../../reducers';
+import {KeplerTable} from '../../utils';
export type IconLayerColumnsConfig = {
lat: LayerColumn;
@@ -45,7 +45,7 @@ export type IconLayerColumnsConfig = {
icon: LayerColumn;
};
-type IconGeometry = {};
+type IconGeometry = {} | null;
export type IconLayerVisConfigSettings = {
radius: VisConfigNumber;
@@ -68,6 +68,8 @@ export type IconLayerConfig = Merge<
{columns: IconLayerColumnsConfig; visConfig: IconLayerVisConfig}
>;
+export type IconLayerData = {index: number; icon: string};
+
const brushingExtension = new BrushingExtension();
export const SVG_ICON_URL = `${CLOUDFRONT}/icons/svg-icons.json`;
@@ -86,7 +88,13 @@ export const iconAccessor = ({icon}: IconLayerColumnsConfig) => (dc: DataContain
export const iconRequiredColumns: ['lat', 'lng', 'icon'] = ['lat', 'lng', 'icon'];
export const iconOptionalColumns: ['altitude'] = ['altitude'];
-export const pointVisConfigs = {
+export const pointVisConfigs: {
+ radius: 'radius';
+ fixedRadius: 'fixedRadius';
+ opacity: 'opacity';
+ colorRange: 'colorRange';
+ radiusRange: 'radiusRange';
+} = {
radius: 'radius',
fixedRadius: 'fixedRadius',
opacity: 'opacity',
@@ -123,7 +131,8 @@ export default class IconLayer extends Layer {
super(props);
this.registerVisConfig(pointVisConfigs);
- this.getPositionAccessor = dataContainer => iconPosAccessor(this.config.columns)(dataContainer);
+ this.getPositionAccessor = (dataContainer: DataContainerInterface) =>
+ iconPosAccessor(this.config.columns)(dataContainer);
this.getIconAccessor = dataContainer => iconAccessor(this.config.columns)(dataContainer);
// prepare layer info modal
@@ -206,7 +215,7 @@ export default class IconLayer extends Layer {
}
}
- static findDefaultLayerProps({fieldPairs = [], fields = []}) {
+ static findDefaultLayerProps({fieldPairs = [], fields = []}: KeplerTable) {
const notFound = {props: []};
if (!fieldPairs.length || !fields.length) {
return notFound;
@@ -243,9 +252,9 @@ export default class IconLayer extends Layer {
return {props};
}
- calculateDataAttribute({dataContainer, filteredIndex}, getPosition) {
+ calculateDataAttribute({dataContainer, filteredIndex}: KeplerTable, getPosition) {
const getIcon = this.getIconAccessor(dataContainer);
- const data = [];
+ const data: IconLayerData[] = [];
for (let i = 0; i < filteredIndex.length; i++) {
const index = filteredIndex[i];
@@ -355,7 +364,7 @@ export default class IconLayer extends Layer {
...layerProps,
...data,
parameters,
- getIconGeometry: id => this.iconGeometry[id],
+ getIconGeometry: id => this.iconGeometry?.[id],
// update triggers
updateTriggers,
@@ -372,7 +381,7 @@ export default class IconLayer extends Layer {
getPosition: data.getPosition,
getRadius: data.getRadius,
getFillColor: this.config.highlightColor,
- getIconGeometry: id => this.iconGeometry[id]
+ getIconGeometry: id => this.iconGeometry?.[id]
})
]
: []),
diff --git a/src/layers/index.d.ts b/src/layers/index.d.ts
index 23e2af103..797506353 100644
--- a/src/layers/index.d.ts
+++ b/src/layers/index.d.ts
@@ -3,7 +3,6 @@ export {LAYER_VIS_CONFIGS, LayerVisConfig} from './layer-factory';
export {default as Layer, OVERLAY_TYPE, LAYER_ID_LENGTH, colorMaker} from './base-layer';
export type {LayerBaseConfig, LayerColumns, LayerColumn} from './base-layer';
-export type {LayerVisConfig} from './layer-factory';
export type LayerClassesType = {
point: Layer;
@@ -23,4 +22,3 @@ export type LayerClassesType = {
export const LayerClasses: LayerClassesType;
export type OVERLAY_TYPE = {[key: string]: string};
-export const LAYER_ID_LENGTH: number;
diff --git a/src/layers/layer-text-label.js b/src/layers/layer-text-label.ts
similarity index 100%
rename from src/layers/layer-text-label.js
rename to src/layers/layer-text-label.ts
diff --git a/src/layers/layer-update.js b/src/layers/layer-update.ts
similarity index 95%
rename from src/layers/layer-update.js
rename to src/layers/layer-update.ts
index c74083a66..a2e70e2b3 100644
--- a/src/layers/layer-update.js
+++ b/src/layers/layer-update.ts
@@ -27,9 +27,8 @@
* @returns {boolean|object} `false` if nothing changed, or `triggerChanged` as an object
*/
export function diffUpdateTriggers(updateTriggers, oldUpdateTriggers = {}) {
- const triggerChanged = {};
- /** @type {boolean|object} */
- let reason = false;
+ const triggerChanged: {[key: string]: true} = {};
+ let reason: boolean | {[key: string]: true} = false;
for (const triggerName in updateTriggers) {
const newTriggers = updateTriggers[triggerName] || {};
diff --git a/src/layers/line-layer/line-layer.ts b/src/layers/line-layer/line-layer.ts
index 6a45df0ad..05d535035 100644
--- a/src/layers/line-layer/line-layer.ts
+++ b/src/layers/line-layer/line-layer.ts
@@ -33,6 +33,8 @@ import {
} from '../layer-factory';
import {ColorRange} from '../../constants/color-ranges';
import {Merge, RGBColor} from '../../reducers';
+import {DataContainerInterface} from 'utils/table-utils/data-container-interface';
+import {KeplerTable} from '../../utils';
export type LineLayerVisConfigSettings = {
opacity: VisConfigNumber;
@@ -66,20 +68,15 @@ export type LineLayerConfig = Merge<
{columns: LineLayerColumnsConfig; visConfig: LineLayerVisConfig}
>;
-export const linePosAccessor = ({
- lat0,
- lng0,
- lat1,
- lng1,
- alt0,
- alt1
-}: LineLayerColumnsConfig) => dc => d => [
+export const linePosAccessor = ({lat0, lng0, lat1, lng1, alt0, alt1}: LineLayerColumnsConfig) => (
+ dc: DataContainerInterface
+) => d => [
dc.valueAt(d.index, lng0.fieldIdx),
dc.valueAt(d.index, lat0.fieldIdx),
- alt0?.fieldIdx > -1 ? dc.valueAt(d.index, alt0.fieldIdx) : 0,
+ alt0 && alt0.fieldIdx > -1 ? dc.valueAt(d.index, alt0.fieldIdx) : 0,
dc.valueAt(d.index, lng1.fieldIdx),
dc.valueAt(d.index, lat1.fieldIdx),
- alt1?.fieldIdx > -1 ? dc.valueAt(d.index, alt1.fieldIdx) : 0
+ alt1 && alt1?.fieldIdx > -1 ? dc.valueAt(d.index, alt1.fieldIdx) : 0
];
export const lineRequiredColumns: ['lat0', 'lng0', 'lat1', 'lng1'] = [
@@ -99,7 +96,14 @@ export const lineColumnLabels = {
alt1: 'line.alt1'
};
-export const lineVisConfigs = {
+export const lineVisConfigs: {
+ opacity: 'opacity';
+ thickness: 'thickness';
+ colorRange: 'colorRange';
+ sizeRange: 'strokeWidthRange';
+ targetColor: 'targetColor';
+ elevationScale: VisConfigNumber;
+} = {
opacity: 'opacity',
thickness: 'thickness',
colorRange: 'colorRange',
@@ -119,7 +123,8 @@ export default class LineLayer extends ArcLayer {
super(props);
this.registerVisConfig(lineVisConfigs);
- this.getPositionAccessor = dataContainer => linePosAccessor(this.config.columns)(dataContainer);
+ this.getPositionAccessor = (dataContainer: DataContainerInterface) =>
+ linePosAccessor(this.config.columns)(dataContainer);
}
get type() {
@@ -153,7 +158,7 @@ export default class LineLayer extends ArcLayer {
};
}
- static findDefaultLayerProps({fieldPairs = []}) {
+ static findDefaultLayerProps({fieldPairs = []}: KeplerTable) {
if (fieldPairs.length < 2) {
return {props: []};
}
diff --git a/src/layers/mapbox-utils.ts b/src/layers/mapbox-utils.ts
index b29fb9a7c..ee38ce5f6 100644
--- a/src/layers/mapbox-utils.ts
+++ b/src/layers/mapbox-utils.ts
@@ -144,7 +144,7 @@ function updateSourceData(map, sourceId, data) {
* @returns FeatureCollection
*/
export function geoJsonFromData(
- filteredIndex = [],
+ filteredIndex: number[] = [],
getGeometry: {({index: number}): any},
getProperties: {({index: number}): any} = d => {}
) {
diff --git a/src/layers/mapboxgl-layer.ts b/src/layers/mapboxgl-layer.ts
index 98f9794a7..1daa6597d 100644
--- a/src/layers/mapboxgl-layer.ts
+++ b/src/layers/mapboxgl-layer.ts
@@ -44,7 +44,7 @@ class MapboxLayerGL extends Layer {
return OVERLAY_TYPE.mapboxgl;
}
- get type() {
+ get type(): string | null {
return null;
}
@@ -169,7 +169,7 @@ class MapboxLayerGL extends Layer {
// this layer is rendered at mapbox level
// todo: maybe need to find a better solution for this one
shouldRenderLayer() {
- return this.type && this.config.isVisible && this.hasAllColumns();
+ return typeof this.type === 'string' && this.config.isVisible && this.hasAllColumns();
}
}
diff --git a/src/layers/point-layer/point-layer.ts b/src/layers/point-layer/point-layer.ts
index 86660de9f..aa827ef50 100644
--- a/src/layers/point-layer/point-layer.ts
+++ b/src/layers/point-layer/point-layer.ts
@@ -43,6 +43,8 @@ import {
VisConfigRange
} from '../layer-factory';
import {ColorRange} from '../../constants/color-ranges';
+import {LAYER_VIS_CONFIGS} from '../layer-factory';
+import {KeplerTable} from '../../utils';
export type PointLayerVisConfigSettings = {
radius: VisConfigNumber;
@@ -84,6 +86,11 @@ export type PointLayerConfig = Merge<
> &
PointLayerVisualChannelConfig;
+export type PointLayerData = {
+ position: number[];
+ index: number;
+};
+
export const pointPosAccessor = ({lat, lng, altitude}: PointLayerColumnsConfig) => dc => d => [
dc.valueAt(d.index, lng.fieldIdx),
dc.valueAt(d.index, lat.fieldIdx),
@@ -95,7 +102,18 @@ export const pointOptionalColumns: ['altitude'] = ['altitude'];
const brushingExtension = new BrushingExtension();
-export const pointVisConfigs = {
+export const pointVisConfigs: {
+ radius: 'radius';
+ fixedRadius: 'fixedRadius';
+ opacity: 'opacity';
+ outline: 'outline';
+ thickness: 'thickness';
+ strokeColor: 'strokeColor';
+ colorRange: 'colorRange';
+ strokeColorRange: 'strokeColorRange';
+ radiusRange: 'radiusRange';
+ filled: VisConfigBoolean;
+} = {
radius: 'radius',
fixedRadius: 'fixedRadius',
opacity: 'opacity',
@@ -106,6 +124,7 @@ export const pointVisConfigs = {
strokeColorRange: 'strokeColorRange',
radiusRange: 'radiusRange',
filled: {
+ ...LAYER_VIS_CONFIGS.filled,
type: 'boolean',
label: 'layer.fillColor',
defaultValue: true,
@@ -197,7 +216,7 @@ export default class PointLayer extends Layer {
return this;
}
- static findDefaultLayerProps({fieldPairs = []}) {
+ static findDefaultLayerProps({fieldPairs = []}: KeplerTable) {
const props: {
label: string;
color?: RGBColor;
@@ -253,8 +272,8 @@ export default class PointLayer extends Layer {
};
}
- calculateDataAttribute({filteredIndex}, getPosition) {
- const data = [];
+ calculateDataAttribute({filteredIndex}: KeplerTable, getPosition) {
+ const data: PointLayerData[] = [];
for (let i = 0; i < filteredIndex.length; i++) {
const index = filteredIndex[i];
diff --git a/src/layers/s2-geometry-layer/s2-geometry-layer.ts b/src/layers/s2-geometry-layer/s2-geometry-layer.ts
index ae0601d29..7b7e606b2 100644
--- a/src/layers/s2-geometry-layer/s2-geometry-layer.ts
+++ b/src/layers/s2-geometry-layer/s2-geometry-layer.ts
@@ -21,6 +21,7 @@
import {S2Layer} from '@deck.gl/geo-layers';
import {HIGHLIGH_COLOR_3D, CHANNEL_SCALES} from 'constants/default-settings';
import {LAYER_VIS_CONFIGS} from 'layers/layer-factory';
+import {KeplerTable} from '../../utils';
import {createDataContainer} from 'utils/table-utils';
import {ColorRange} from '../../constants/color-ranges';
import {Merge, RGBColor} from '../../reducers';
@@ -89,6 +90,11 @@ export type S2GeometryLayerConfig = Merge<
> &
S2GeometryLayerVisualChannelConfig;
+export type S2GeometryLayerData = {
+ index: number;
+ token: any;
+};
+
const zoomFactorValue = 8;
export const S2_TOKEN_FIELDS: {
@@ -105,11 +111,33 @@ export const S2TokenAccessor = ({token}: S2GeometryLayerColumnsConfig) => (
export const defaultElevation = 500;
export const defaultLineWidth = 1;
-export const S2VisConfigs = {
+export const S2VisConfigs: {
+ // Filled color
+ opacity: 'opacity';
+ colorRange: 'colorRange';
+ filled: VisConfigBoolean;
+
+ // stroke
+ thickness: VisConfigNumber;
+ strokeColor: 'strokeColor';
+ strokeColorRange: 'strokeColorRange';
+ sizeRange: 'strokeWidthRange';
+ stroked: 'stroked';
+
+ // height
+ enable3d: 'enable3d';
+ elevationScale: 'elevationScale';
+ enableElevationZoomFactor: 'enableElevationZoomFactor';
+ heightRange: 'elevationRange';
+
+ // wireframe
+ wireframe: 'wireframe';
+} = {
// Filled color
opacity: 'opacity',
colorRange: 'colorRange',
filled: {
+ ...LAYER_VIS_CONFIGS.filled,
type: 'boolean',
label: 'Fill Color',
defaultValue: true,
@@ -143,7 +171,8 @@ export default class S2GeometryLayer extends Layer {
constructor(props) {
super(props);
this.registerVisConfig(S2VisConfigs);
- this.getPositionAccessor = dataContainer => S2TokenAccessor(this.config.columns)(dataContainer);
+ this.getPositionAccessor = (dataContainer: DataContainerInterface) =>
+ S2TokenAccessor(this.config.columns)(dataContainer);
}
get type(): 's2' {
@@ -221,7 +250,7 @@ export default class S2GeometryLayer extends Layer {
};
}
- static findDefaultLayerProps({fields = []}) {
+ static findDefaultLayerProps({fields = []}: KeplerTable) {
const foundColumns = this.findDefaultColumnField(S2_TOKEN_FIELDS, fields);
if (!foundColumns || !foundColumns.length) {
return {props: []};
@@ -236,8 +265,8 @@ export default class S2GeometryLayer extends Layer {
};
}
- calculateDataAttribute({dataContainer, filteredIndex}, getS2Token) {
- const data = [];
+ calculateDataAttribute({dataContainer, filteredIndex}: KeplerTable, getS2Token) {
+ const data: S2GeometryLayerData[] = [];
for (let i = 0; i < filteredIndex.length; i++) {
const index = filteredIndex[i];
const token = getS2Token({index});
@@ -310,7 +339,7 @@ export default class S2GeometryLayer extends Layer {
...defaultLayerProps,
...interactionConfig,
...data,
- getS2Token: d => d.token,
+ getS2Token: (d: any) => d.token,
autoHighlight: visConfig.enable3d,
highlightColor: HIGHLIGH_COLOR_3D,
diff --git a/src/layers/scenegraph-layer/scenegraph-layer.ts b/src/layers/scenegraph-layer/scenegraph-layer.ts
index 47dd98b3b..cc60e2464 100644
--- a/src/layers/scenegraph-layer/scenegraph-layer.ts
+++ b/src/layers/scenegraph-layer/scenegraph-layer.ts
@@ -30,6 +30,7 @@ import {VisConfigColorRange, VisConfigNumber} from '../layer-factory';
import {ColorRange} from '../../constants/color-ranges';
import {Merge} from '../../reducers';
import {DataContainerInterface} from '../../utils/table-utils/data-container-interface';
+import {KeplerTable} from '../../utils';
export type ScenegraphLayerVisConfigSettings = {
opacity: VisConfigNumber;
@@ -61,6 +62,8 @@ export type ScenegraphLayerConfig = Merge<
{columns: ScenegraphLayerColumnsConfig; visConfig: ScenegraphLayerVisConfig}
>;
+export type ScenegraphLayerData = {position: number[]; index: number};
+
export const scenegraphRequiredColumns: ['lat', 'lng'] = ['lat', 'lng'];
export const scenegraphOptionalColumns: ['altitude'] = ['altitude'];
@@ -80,7 +83,15 @@ export const scenegraphPosAccessor = ({lat, lng, altitude}: ScenegraphLayerColum
altitude && altitude.fieldIdx > -1 ? dc.valueAt(d.index, altitude.fieldIdx) : 0
];
-export const scenegraphVisConfigs = {
+export const scenegraphVisConfigs: {
+ opacity: 'opacity';
+ colorRange: 'colorRange';
+ //
+ sizeScale: 'sizeScale';
+ angleX: VisConfigNumber;
+ angleY: VisConfigNumber;
+ angleZ: VisConfigNumber;
+} = {
opacity: 'opacity',
colorRange: 'colorRange',
//
@@ -119,7 +130,7 @@ export default class ScenegraphLayer extends Layer {
super(props);
this.registerVisConfig(scenegraphVisConfigs);
- this.getPositionAccessor = dataContainer =>
+ this.getPositionAccessor = (dataContainer: DataContainerInterface) =>
scenegraphPosAccessor(this.config.columns)(dataContainer);
// prepare layer info modal
@@ -156,12 +167,12 @@ export default class ScenegraphLayer extends Layer {
};
}
- calculateDataAttribute({dataContainer, filteredIndex}, getPosition) {
- const data = [];
+ calculateDataAttribute({dataContainer, filteredIndex}: KeplerTable, getPosition) {
+ const data: ScenegraphLayerData[] = [];
for (let i = 0; i < filteredIndex.length; i++) {
const index = filteredIndex[i];
- const pos = getPosition({index});
+ const pos: number[] = getPosition({index});
// if doesn't have point lat or lng, do not add the point
// deck.gl can't handle position = null
diff --git a/src/layers/trip-layer/trip-layer.ts b/src/layers/trip-layer/trip-layer.ts
index 9fc976c48..852dc17b6 100644
--- a/src/layers/trip-layer/trip-layer.ts
+++ b/src/layers/trip-layer/trip-layer.ts
@@ -29,7 +29,8 @@ import TripLayerIcon from './trip-layer-icon';
import {
getGeojsonDataMaps,
getGeojsonBounds,
- getGeojsonFeatureTypes
+ getGeojsonFeatureTypes,
+ GeojsonDataMaps
} from 'layers/geojson-layer/geojson-utils';
import {isTripGeoJsonField, parseTripGeoJsonTimestamp} from './trip-utils';
@@ -38,6 +39,7 @@ import {DataContainerInterface} from '../../utils/table-utils/data-container-int
import {ColorRange} from '../../constants/color-ranges';
import {VisConfigColorRange, VisConfigNumber, VisConfigRange} from '../layer-factory';
import {Merge} from '../../reducers';
+import {KeplerTable} from '../../utils';
export type TripLayerVisConfigSettings = {
opacity: VisConfigNumber;
@@ -73,7 +75,13 @@ const zoomFactorValue = 8;
export const defaultThickness = 0.5;
export const defaultLineWidth = 1;
-export const tripVisConfigs = {
+export const tripVisConfigs: {
+ opacity: 'opacity';
+ thickness: VisConfigNumber;
+ colorRange: 'colorRange';
+ trailLength: 'trailLength';
+ sizeRange: 'strokeWidthRange';
+} = {
opacity: 'opacity',
thickness: {
type: 'number',
@@ -101,7 +109,7 @@ export default class TripLayer extends Layer {
declare config: TripLayerConfig;
declare meta: TripLayerMeta;
- dataToFeature: {}[];
+ dataToFeature: GeojsonDataMaps;
dataToTimeStamp: {}[];
getFeature: (columns: TripLayerColumnsConfig) => (dataContainer: DataContainerInterface) => any;
_layerInfoModal: () => JSX.Element;
@@ -177,7 +185,10 @@ export default class TripLayer extends Layer {
return this.getFeature(this.config.columns)(dataContainer);
}
- static findDefaultLayerProps({label, fields = [], dataContainer, id}, foundLayers) {
+ static findDefaultLayerProps(
+ {label, fields = [], dataContainer, id}: KeplerTable,
+ foundLayers: any[]
+ ) {
const geojsonColumns = fields.filter(f => f.type === 'geojson').map(f => f.name);
const defaultColumns = {
diff --git a/src/reducers/vis-state-updaters.ts b/src/reducers/vis-state-updaters.ts
index 19bf334df..6292957b0 100644
--- a/src/reducers/vis-state-updaters.ts
+++ b/src/reducers/vis-state-updaters.ts
@@ -691,6 +691,7 @@ export function layerDataIdChangeUpdater(
);
// if cant validate it with data create a new one
if (!validated) {
+ // @ts-expect-error TODO: checking oldLayer.type !== null
newLayer = new state.layerClasses[oldLayer.type]({dataId, id: oldLayer.id});
} else {
newLayer = validated;
diff --git a/src/utils/layer-utils.ts b/src/utils/layer-utils.ts
index 3d4129130..80afca6e8 100644
--- a/src/utils/layer-utils.ts
+++ b/src/utils/layer-utils.ts
@@ -69,6 +69,7 @@ export function findDefaultLayer(dataset: KeplerTable, layerClasses: LayerClasse
// go through all layerProps to create layer
return layerProps.map(props => {
+ // @ts-expect-error TODO: checking props.type !== null
const layer = new layerClasses[props.type](props);
return typeof layer.setInitialLayerConfig === 'function' && dataset.dataContainer
? layer.setInitialLayerConfig(dataset)