From ca5d65c02be903b68094b40f98f5c5f173abc937 Mon Sep 17 00:00:00 2001 From: helllth Date: Sat, 4 Jul 2020 18:32:39 +0200 Subject: [PATCH] :sparkles: wo #43: switch the animation according to the selected simulation --- .../starkregen/VectorFieldAnimation.js | 18 +++++++++++++----- src/containers/Starkregen.js | 7 +++++++ src/redux/modules/starkregen.js | 4 ++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/components/starkregen/VectorFieldAnimation.js b/src/components/starkregen/VectorFieldAnimation.js index 8ed7d8f6..8efa4255 100644 --- a/src/components/starkregen/VectorFieldAnimation.js +++ b/src/components/starkregen/VectorFieldAnimation.js @@ -39,8 +39,10 @@ class VectorFieldAnimation extends MapLayer { const bbox = this.props.bbox; //BBOX=7.1954778,51.2743996,7.2046701,51.2703213 - let url_u = `${service}/gdalProcessor?REQUEST=translate&SRS=EPSG:4326&BBOX=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}&LAYERS=docs/regen/u84.tif&FORMAT=text/raster.asc`; - let url_v = `${service}/gdalProcessor?REQUEST=translate&SRS=EPSG:4326&BBOX=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}&LAYERS=docs/regen/v84.tif&FORMAT=text/raster.asc`; + let url_u = `${service}/gdalProcessor?REQUEST=translate&SRS=EPSG:4326&BBOX=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}&LAYERS=docs/regen/${this + .props.layerPrefix}u84.tif&FORMAT=text/raster.asc`; + let url_v = `${service}/gdalProcessor?REQUEST=translate&SRS=EPSG:4326&BBOX=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}&LAYERS=docs/regen/${this + .props.layerPrefix}v84.tif&FORMAT=text/raster.asc`; var urls = [ url_u, url_v ]; console.log('VFA: ', urls); @@ -69,7 +71,11 @@ class VectorFieldAnimation extends MapLayer { this.leafletElement.timer.stop(); } } - super.componentWillUnmount(); + try { + super.componentWillUnmount(); + } catch (e) { + console.log('could be already unmounted'); + } } superComponentDidMount() { @@ -88,8 +94,10 @@ class VectorFieldAnimation extends MapLayer { const bbox = getBBoxForBounds(bounds); //BBOX=7.1954778,51.2743996,7.2046701,51.2703213 - let url_u = `${service}/gdalProcessor?REQUEST=translate&SRS=EPSG:4326&BBOX=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}&LAYERS=docs/regen/u84.tif&FORMAT=text/raster.asc`; - let url_v = `${service}/gdalProcessor?REQUEST=translate&SRS=EPSG:4326&BBOX=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}&LAYERS=docs/regen/v84.tif&FORMAT=text/raster.asc`; + let url_u = `${service}/gdalProcessor?REQUEST=translate&SRS=EPSG:4326&BBOX=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}&LAYERS=docs/regen/${this + .props.layerPrefix}u84.tif&FORMAT=text/raster.asc`; + let url_v = `${service}/gdalProcessor?REQUEST=translate&SRS=EPSG:4326&BBOX=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}&LAYERS=docs/regen/${this + .props.layerPrefix}v84.tif&FORMAT=text/raster.asc`; var urls = [ url_u, url_v ]; if (this.leafletElement.url_u === url_u && this.leafletElement.url_v === url_v) { diff --git a/src/containers/Starkregen.js b/src/containers/Starkregen.js index 844828d7..a2036bb2 100644 --- a/src/containers/Starkregen.js +++ b/src/containers/Starkregen.js @@ -429,11 +429,18 @@ export class Starkregen_ extends React.Component { '.' + // JSON.stringify(currentBBox) + // '.' + + this.props.starkregen.selectedSimulation + + '.' + JSON.stringify( this.props.match.params.layers || this.props.starkregen.backgrounds[validBackgroundIndex].layerkey ) } + layerPrefix={ + this.props.starkregen.simulations[ + this.props.starkregen.selectedSimulation + ].animation + } bbox={currentBBox} settings={vectorFieldAnimationSettings} /> diff --git a/src/redux/modules/starkregen.js b/src/redux/modules/starkregen.js index 0fe310c3..fc1d9dd8 100644 --- a/src/redux/modules/starkregen.js +++ b/src/redux/modules/starkregen.js @@ -32,6 +32,7 @@ export const initialState = { simulations: [ { layer: 'R102:50md', + animation: '', name: 'Stärke 6', title: 'Starkregen SRI 6 (38,5 l/m² in 2h)', icon: 'bar-chart', @@ -40,6 +41,7 @@ export const initialState = { }, { layer: 'R102:100md', + animation: 'S7_', name: 'Stärke 7', icon: 'bar-chart', title: 'Starkregen SRI 7 (42 l/m² in 2h)', @@ -48,6 +50,7 @@ export const initialState = { }, { layer: 'R102:90md', + animation: 'S10_', name: 'Stärke 10', icon: 'bitbucket', title: 'Starkregen SRI 10 (90 l/m² in 1h)', @@ -56,6 +59,7 @@ export const initialState = { }, { layer: 'R102:SRmd', + animation: 'S29.05.2018_', name: '29.05.18', icon: 'calendar', title: 'Regen vom 29.05.2018 (SRI 11)',