-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): aggregated risk map layer (risk hotspots)
New raster layer showing aggregated risk values for: - variables: "exposure value", "population affected", "loss GDP", "demand affected". - hazards: "none", cyclone, "all flooding". Includes: - New aggregated risk map layer and params in `src/state/layers/modules/risks`. - New config in `src/config/risks`. Parameters defined in `src/config/risks/domains`. - New sidebar controls in `src/sidebar/risks`. - New legends and tooltips in `src/config/risks`. - Makes a start on generic formats for data values eg. financial or population.
- Loading branch information
1 parent
2d58835
commit ddb5d3a
Showing
22 changed files
with
422 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { FC } from 'react'; | ||
|
||
import { RasterHoverDescription } from 'lib/data-map/types'; | ||
import { RasterHoverDescription as RasterTooltip } from 'app/map/tooltip/content/RasterHoverDescription'; | ||
|
||
import * as RISKS_COLOR_MAPS from './color-maps'; | ||
import { RISKS_METADATA } from './metadata'; | ||
|
||
export const RiskHoverDescription: FC<RasterHoverDescription> = ({ target, viewLayer }) => { | ||
const { label, dataUnit, format } = RISKS_METADATA[viewLayer.id]; | ||
const { scheme, range } = RISKS_COLOR_MAPS[viewLayer.id]; | ||
return ( | ||
<RasterTooltip | ||
color={target.color} | ||
label={label} | ||
dataUnit={dataUnit} | ||
scheme={scheme} | ||
range={range} | ||
type={format} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { FC } from 'react'; | ||
|
||
import { RasterLegend } from 'app/map/legend/RasterLegend'; | ||
import { ViewLayer } from 'lib/data-map/view-layers'; | ||
|
||
import * as RISKS_COLOR_MAPS from './color-maps'; | ||
import { RISKS_METADATA } from './metadata'; | ||
|
||
export const RiskLegend: FC<{ viewLayer: ViewLayer }> = ({ viewLayer }) => { | ||
const { id } = viewLayer; | ||
const { label, dataUnit, format } = RISKS_METADATA[id]; | ||
const { scheme, range } = RISKS_COLOR_MAPS[id]; | ||
return ( | ||
<RasterLegend label={label} dataUnit={dataUnit} scheme={scheme} range={range} type={format} /> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const exposureValue = { | ||
scheme: 'reds', | ||
range: [0, 1e9], | ||
}; | ||
export const lossGdp = { | ||
scheme: 'blues', | ||
range: [0, 5e6], | ||
}; | ||
|
||
export const populationAffected = { | ||
scheme: 'purples', | ||
range: [0, 1e4], | ||
}; | ||
|
||
export const demandAffected = { | ||
scheme: 'greens', | ||
range: [0, 1e3], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { DataParamGroupConfig } from 'lib/controls/data-params'; | ||
|
||
export interface RiskParams { | ||
hazard: string; | ||
returnPeriod: number; | ||
epoch: number; | ||
rcp: string; | ||
confidence: string | number; | ||
} | ||
|
||
/* | ||
Default parameter ranges for each hazard type. | ||
These are used to define ranges for input controls in the sidebar. | ||
*/ | ||
const hazardParamDomains = { | ||
none: { | ||
returnPeriod: [0], | ||
epoch: [2010], | ||
rcp: ['baseline'], | ||
confidence: ['None'], | ||
}, | ||
cyclone: { | ||
returnPeriod: [0], | ||
epoch: [2010], | ||
rcp: ['baseline'], | ||
confidence: ['None'], | ||
}, | ||
fluvial: { | ||
returnPeriod: [0], | ||
epoch: [2010], | ||
rcp: ['baseline'], | ||
confidence: ['None'], | ||
}, | ||
}; | ||
|
||
export const RISK_DOMAINS: DataParamGroupConfig<RiskParams> = { | ||
/* | ||
Default parameter ranges for each risk type. | ||
*/ | ||
paramDomains: { | ||
hazard: ['none', 'cyclone', 'fluvial'], | ||
returnPeriod: [0], | ||
epoch: [2010], | ||
rcp: ['baseline'], | ||
confidence: ['None'], | ||
}, | ||
/* | ||
Default parameter values for each risk type. | ||
*/ | ||
paramDefaults: { | ||
hazard: 'none', | ||
returnPeriod: 0, | ||
epoch: 2010, | ||
rcp: 'baseline', | ||
confidence: 'None', | ||
}, | ||
/* | ||
Callback functions to define custom parameter ranges based on selected hazard etc. | ||
*/ | ||
paramDependencies: { | ||
rcp: ({ hazard }) => hazardParamDomains[hazard].rcp, | ||
epoch: ({ hazard }) => hazardParamDomains[hazard].epoch, | ||
returnPeriod: ({ hazard }) => hazardParamDomains[hazard].returnPeriod, | ||
confidence: ({ hazard }) => hazardParamDomains[hazard].confidence, | ||
}, | ||
}; |
Oops, something went wrong.