From 2322fb5561fadbb83b82ae0e02d1bdcf1f024231 Mon Sep 17 00:00:00 2001 From: j8seangel Date: Tue, 13 Aug 2024 16:01:49 +0200 Subject: [PATCH] fourwings static layer state typing and error handling --- .../heatmap/FourwingsHeatmapStaticLayer.ts | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libs/deck-layers/src/layers/fourwings/heatmap/FourwingsHeatmapStaticLayer.ts b/libs/deck-layers/src/layers/fourwings/heatmap/FourwingsHeatmapStaticLayer.ts index 895cd32d48..206e8e5b80 100644 --- a/libs/deck-layers/src/layers/fourwings/heatmap/FourwingsHeatmapStaticLayer.ts +++ b/libs/deck-layers/src/layers/fourwings/heatmap/FourwingsHeatmapStaticLayer.ts @@ -59,6 +59,7 @@ const defaultProps: DefaultProps = { export class FourwingsHeatmapStaticLayer extends CompositeLayer { static layerName = 'FourwingsHeatmapStaticLayer' static defaultProps = defaultProps + state!: Omit initializeState(context: LayerContext) { super.initializeState(context) @@ -76,7 +77,7 @@ export class FourwingsHeatmapStaticLayer extends CompositeLayer { @@ -84,8 +85,15 @@ export class FourwingsHeatmapStaticLayer extends CompositeLayer { + console.warn(error.message) + this.setState({ error: error.message }) + return true + } + getError(): string { - return (this.state as FourwingsTileLayerState).error + return this.state.error } _calculateColorDomain = () => { // TODO use to get the real bin value considering the NO_DATA_VALUE and negatives @@ -160,7 +168,7 @@ export class FourwingsHeatmapStaticLayer extends CompositeLayer) => { - const { scales } = this.state as FourwingsTileLayerState + const { scales } = this.state const scale = scales?.[0] if ( !scale || @@ -196,7 +204,7 @@ export class FourwingsHeatmapStaticLayer extends CompositeLayer | LayersList { const { tilesUrl, sublayers, resolution, minVisibleValue, maxVisibleValue, maxZoom } = this.props - const { colorDomain, colorRanges } = this.state as FourwingsTileLayerState + const { colorDomain, colorRanges } = this.state const { zoom } = this.context.viewport const params = { datasets: sublayers.flatMap((sublayer) => sublayer.datasets), @@ -214,6 +222,7 @@ export class FourwingsHeatmapStaticLayer extends CompositeLayer getLayerGroupOffset(LayerGroup.HeatmapStatic, params), getFillColor: this.getFillColor, @@ -303,11 +312,11 @@ export class FourwingsHeatmapStaticLayer extends CompositeLayer { - return (this.state as FourwingsTileLayerState).colorDomain + return this.state.colorDomain } getColorRange = () => { - return (this.state as FourwingsTileLayerState).colorRanges + return this.state.colorRanges } getColorScale = () => {