From 5ee7334f6f1195bbc4a9e079343a47bd367bf590 Mon Sep 17 00:00:00 2001 From: p-a-s-c-a-l Date: Mon, 10 Aug 2020 10:55:57 +0200 Subject: [PATCH] #100 proper handling of adaptation scenarios --- src/App.js | 2 +- src/__fixtures__/studyInfo.json | 39 ++++++++++++++++++++++++++++ src/components/GenericMap.js | 9 +++---- src/components/commons/BasicMap.js | 24 +++++++++++++++-- src/components/commons/LeafletMap.js | 3 ++- 5 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 src/__fixtures__/studyInfo.json diff --git a/src/App.js b/src/App.js index 911518a..a734258 100644 --- a/src/App.js +++ b/src/App.js @@ -44,7 +44,7 @@ export default class App extends React.Component { } /> } /> } /> - + } /> diff --git a/src/__fixtures__/studyInfo.json b/src/__fixtures__/studyInfo.json new file mode 100644 index 0000000..1590157 --- /dev/null +++ b/src/__fixtures__/studyInfo.json @@ -0,0 +1,39 @@ +{ + "id": "33", + "uuid": "3d8327f4-c47f-4c9e-bbc3-fb9018ea9607", + "write_permissions": 1, + "name": null, + "step": "1515", + "step_uuid": "70ebd885-5694-4163-93b9-cae4e7a0df9a", + "step_name": "adaptation_identification", + "study": "33", + "study_uuid": "3d8327f4-c47f-4c9e-bbc3-fb9018ea9607", + "study_emikat_id": 3209, + "calculation_status": "3", + "study_datapackage_uuid": "2434ce93-93d4-4ca2-8618-a2de768d3f16", + "study_area": "POLYGON ((23.551602 46.063544, 23.551602 46.080375, 23.577619 46.080375, 23.577619 46.063544, 23.551602 46.063544))", + "eea_city_name": "Alba Iulia", + "city_code": "RO014", + "study_presets": { + "time_period": "Baseline", + "emission_scenario": "Baseline", + "event_frequency": "Frequent" + }, + "study_scenarios": [ + { + "label": "Baseline Scenario, Frequent", + "time_period": "Baseline", + "emission_scenario": "Baseline", + "event_frequency": "Frequent" + }, + { + "label": "Worst Case by Century's End", + "time_period": "20710101-21001231", + "emission_scenario": "rcp85", + "event_frequency": "Frequent" + } + ], + "has_adapted_scenario": true, + "is_anonymous": false, + "is_member": true +} \ No newline at end of file diff --git a/src/components/GenericMap.js b/src/components/GenericMap.js index 36bc221..42db670 100644 --- a/src/components/GenericMap.js +++ b/src/components/GenericMap.js @@ -63,7 +63,7 @@ export default class GenericMap extends BasicMap { } if (this.props.isSynchronised === true) { - log.info('rendering two sychronised maps: ' + this.props.isSynchronised); + log.info(`rendering two sychronised maps with AdaptationScenario = ${this.props.showAdaptationScenario}`); return (<> (this.mapComponentB = mapComponent)} fly={false} - showAdaptationScenario={true} + showAdaptationScenario={this.props.showAdaptationScenario} /> ); } else { - log.info('rendering one simple map: ' + this.props.isSynchronised); + log.info(`rendering one simple map with AdaptationScenario = ${this.props.showAdaptationScenario}`); return ( ); } - - } } diff --git a/src/components/commons/BasicMap.js b/src/components/commons/BasicMap.js index a4ca40d..24aeb10 100644 --- a/src/components/commons/BasicMap.js +++ b/src/components/commons/BasicMap.js @@ -50,6 +50,8 @@ export default class BasicMap extends React.Component { this.overlayLayersGroupingTagType = undefined; this.overlayLayersGroupName = 'Default'; //default group name + this.hasAdaptedScenario = false; + /** * Base Layers * @@ -133,6 +135,8 @@ export default class BasicMap extends React.Component { this.initialBounds[1][0] = this.queryParams.maxx; this.initialBounds[1][1] = this.queryParams.maxy; + this.hasAdaptedScenario = this.queryParams.has_adapted_scenario ? true : false; + log.info( `creating new ${props.mapSelectionId} map with layer group from ${this .overlayLayersGroupingTagType} and initial bbox ${this.queryParams.study_area}` @@ -236,6 +240,10 @@ export default class BasicMap extends React.Component { } else { log.warn(`cannot load additional resource layers`); } + + if(this.hasAdaptedScenario === true && this.props.showAdaptationScenario === true) { + log.warn(`want to show AdaptedScenario but no AdaptedScenarios are available! EMIKAT Map Layers will be empty.`); + } } /** @@ -853,7 +861,17 @@ BasicMap.propTypes = { /** * Taxonomy for Layer Groups, e.g. 'taxonomy_term--hazards' */ - groupingCriteria: PropTypes.string + groupingCriteria: PropTypes.string, + + /** + * show two synchronised maps (GenericMap will take care about this) + */ + isSynchronised: PropTypes.bool, + + /** + * tell LeafletMap to load STUDY_VARIANT='ADAPTATION-01' + */ + showAdaptationScenario: PropTypes.bool }; /** @@ -862,5 +880,7 @@ BasicMap.propTypes = { */ BasicMap.defaultProps = { mapSelectionId: undefined, - groupingCriteria: undefined + groupingCriteria: undefined, + isSynchronised: false, + showAdaptationScenario:false }; diff --git a/src/components/commons/LeafletMap.js b/src/components/commons/LeafletMap.js index f62f667..ada4db6 100644 --- a/src/components/commons/LeafletMap.js +++ b/src/components/commons/LeafletMap.js @@ -575,5 +575,6 @@ LeafletMap.propTypes = { baseLayers: PropTypes.array, exclusiveGroups: PropTypes.array, overlays: PropTypes.array, - studyAreaPolygon: PropTypes.object + studyAreaPolygon: PropTypes.object, + showAdaptationScenario: PropTypes.bool };