Skip to content

Commit

Permalink
#100 proper handling of adaptation scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
p-a-s-c-a-l committed Aug 10, 2020
1 parent 27046dd commit 5ee7334
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class App extends React.Component {
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedRiskAndImpactMap/`} render={(props) => <RiskAndImpactMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedVulnerabilityMap/`} render={(props) => <VulnerabilityMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/AdaptationOptionsAppraisalMap/`} render={(props) => <RiskAndImpactMap {...props} isSynchronised={true} showAdaptationScenario={true}/>} />

<Route exact path={`${process.env.PUBLIC_URL}/AdaptationHazardLocalEffectsMap/`} render={(props) => <HazardLocalEffectsMap {...props} isSynchronised={true} showAdaptationScenario={true}/>} />
<Route exact path={process.env.PUBLIC_URL} component={GenericMap} />
</Switch>
</BrowserRouter>
Expand Down
39 changes: 39 additions & 0 deletions src/__fixtures__/studyInfo.json
Original file line number Diff line number Diff line change
@@ -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
}
9 changes: 4 additions & 5 deletions src/components/GenericMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<>
<LeafletMap
Expand All @@ -88,11 +88,11 @@ export default class GenericMap extends BasicMap {
mapId={'synchronisedMapB'}
ref={(mapComponent) => (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 (
<LeafletMap
loading={this.state.loading}
Expand All @@ -101,10 +101,9 @@ export default class GenericMap extends BasicMap {
overlays={this.state.overlays}
studyAreaPolygon={this.state.studyAreaPolygon}
exclusiveGroups={this.state.exclusiveGroups}
showAdaptationScenario={this.props.showAdaptationScenario}
/>
);
}


}
}
24 changes: 22 additions & 2 deletions src/components/commons/BasicMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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}`
Expand Down Expand Up @@ -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.`);
}
}

/**
Expand Down Expand Up @@ -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
};

/**
Expand All @@ -862,5 +880,7 @@ BasicMap.propTypes = {
*/
BasicMap.defaultProps = {
mapSelectionId: undefined,
groupingCriteria: undefined
groupingCriteria: undefined,
isSynchronised: false,
showAdaptationScenario:false
};
3 changes: 2 additions & 1 deletion src/components/commons/LeafletMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,5 +575,6 @@ LeafletMap.propTypes = {
baseLayers: PropTypes.array,
exclusiveGroups: PropTypes.array,
overlays: PropTypes.array,
studyAreaPolygon: PropTypes.object
studyAreaPolygon: PropTypes.object,
showAdaptationScenario: PropTypes.bool
};

0 comments on commit 5ee7334

Please sign in to comment.