Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/SedimentLoadLSGenerator.java @ 5631:ca4b6263996c
Added old calculations to datacage 'M-INFO Sedimentfracht'.
* Added facets to artifact config.
* Added macros to datacage config.
* Create subfolders for old calculations in datacage.
* New outputs in sediment load generator.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 10 Apr 2013 15:04:56 +0200 |
parents | a3dc382bc1ca |
children | 696d710470f5 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/SedimentLoadLSGenerator.java Wed Apr 10 14:51:57 2013 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/SedimentLoadLSGenerator.java Wed Apr 10 15:04:56 2013 +0200 @@ -1,5 +1,7 @@ package de.intevation.flys.exports.minfo; +import java.util.Arrays; + import org.apache.log4j.Logger; import org.jfree.data.xy.XYSeries; import org.w3c.dom.Document; @@ -7,13 +9,22 @@ import de.intevation.artifactdatabase.state.ArtifactAndFacet; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.access.RangeAccess; +import de.intevation.flys.artifacts.access.RiverAccess; import de.intevation.flys.artifacts.access.SedimentLoadAccess; import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.FlowVelocityData; +import de.intevation.flys.artifacts.model.WKms; +import de.intevation.flys.artifacts.model.minfo.BedDiffEpochResult; +import de.intevation.flys.artifacts.model.minfo.BedDiffYearResult; import de.intevation.flys.artifacts.model.minfo.SedimentLoadResult; import de.intevation.flys.exports.StyledSeriesBuilder; import de.intevation.flys.exports.XYChartGenerator; +import de.intevation.flys.jfree.Bounds; +import de.intevation.flys.jfree.DoubleBounds; import de.intevation.flys.jfree.FLYSAnnotation; import de.intevation.flys.jfree.StyledXYSeries; +import de.intevation.flys.utils.DataUtil; public class SedimentLoadLSGenerator @@ -21,7 +32,10 @@ implements FacetTypes { public enum YAXIS { - L(0); + L(0), + D(1), + DW(2), + V(3); protected int idx; @@ -30,17 +44,25 @@ } } /** The logger that is used in this generator. */ - private static Logger logger = Logger.getLogger(BedQualityGenerator.class); + private static Logger logger = Logger.getLogger(SedimentLoadLSGenerator.class); public static final String I18N_CHART_TITLE = "chart.sedimentload.ls.title"; public static final String I18N_XAXIS_LABEL = "chart.sedimentload.ls.xaxis.label"; public static final String I18N_YAXIS_LABEL_1 = "chart.sedimentload.ls.yaxis.label.tpera"; public static final String I18N_YAXIS_LABEL_2 = "chart.sedimentload.ls.yaxis.label.m3pera"; + public static final String I18N_YAXIS_D_LABEL = "chart.beddifference.yaxis.label.diff"; + public static final String I18N_YAXIS_V_LABEL = + "chart.flow_velocity.section.yaxis.label"; + public final static String I18N_WDIFF_YAXIS_LABEL = + "chart.w_differences.yaxis.label"; + public final static String I18N_WDIFF_YAXIS_LABEL_DEFAULT = "m"; public static final String I18N_CHART_TITLE_DEFAULT = "Sedimentfracht"; public static final String I18N_XAXIS_LABEL_DEFAULT = "Fluss-Km"; public static final String I18N_YAXIS_LABEL_DEFAULT_1 = "[t/a]"; public static final String I18N_YAXIS_LABEL_DEFAULT_2 = "[m\u00b3/a]"; + public static final String I18N_YAXIS_D_LABEL_DEFAULT = "delta S [m]"; + public static final String I18N_YAXIS_V_LABEL_DEFAULT = "Geschwindigkeit v [m/s]"; private FLYSArtifact artifact; @@ -78,7 +100,32 @@ if (facet == null) { return; } - + if (getXBounds(0) != null && getDomainAxisRange() != null) { + logger.debug(Arrays.toString(getDomainAxisRangeFromRequest())); + Bounds bounds = + calculateZoom(getXBounds(0), getDomainAxisRange()); + context.putContextValue("startkm", bounds.getLower()); + context.putContextValue("endkm", bounds.getUpper()); + } + else if (getXBounds(0) != null && getDomainAxisRange() == null) { + context.putContextValue("startkm", getXBounds(0).getLower()); + context.putContextValue("endkm", getXBounds(0).getUpper()); + } + else if (getXBounds(0) == null && getDomainAxisRange() == null) { + FLYSArtifact artifact = (FLYSArtifact)bundle.getArtifact(); + RangeAccess access = new RangeAccess(artifact, context); + context.putContextValue("startkm", access.getFrom()); + context.putContextValue("endkm", access.getTo()); + } + else if (getXBounds(0) == null && getDomainAxisRange() != null){ + FLYSArtifact artifact = (FLYSArtifact)bundle.getArtifact(); + RangeAccess access = new RangeAccess(artifact, context); + Bounds b = new DoubleBounds(access.getFrom(), access.getTo()); + Bounds bounds = + calculateZoom(b, getDomainAxisRange()); + context.putContextValue("startkm", bounds.getLower()); + context.putContextValue("endkm", bounds.getUpper()); + } if (name.equals(SEDIMENT_LOAD_COARSE)) { doSedimentLoadCoarseOut( (SedimentLoadResult) bundle.getData(context), @@ -135,6 +182,62 @@ attr, visible); } + else if (name.equals(FLOW_VELOCITY_TOTALCHANNEL)) { + doFlowVelocityTotalOut( + (FlowVelocityData) bundle.getData(context), + bundle, + attr, + visible); + } + else if (name.equals(FLOW_VELOCITY_TOTALCHANNEL_FILTERED)) { + doFlowVelocityTotalOut( + (FlowVelocityData) bundle.getData(context), + bundle, + attr, + visible); + } + else if (name.equals(FLOW_VELOCITY_MAINCHANNEL)) { + doFlowVelocityMainOut( + (FlowVelocityData) bundle.getData(context), + bundle, + attr, + visible); + } + else if (name.equals(FLOW_VELOCITY_MAINCHANNEL_FILTERED)) { + doFlowVelocityMainOut( + (FlowVelocityData) bundle.getData(context), + bundle, + attr, + visible); + } + else if (name.equals(BED_DIFFERENCE_YEAR)) { + doBedDifferenceYearOut( + (BedDiffYearResult) bundle.getData(context), + bundle, + attr, + visible); + } + else if (name.equals(BED_DIFFERENCE_YEAR_FILTERED)) { + doBedDifferenceYearOut( + (BedDiffYearResult) bundle.getData(context), + bundle, + attr, + visible); + } + else if (name.equals(BED_DIFFERENCE_EPOCH)) { + doBedDifferenceEpochOut( + (BedDiffEpochResult) bundle.getData(context), + bundle, + attr, + visible); + } + else if (name.equals(W_DIFFERENCES)) { + doWDifferencesOut( + (WKms) bundle.getData(context), + bundle, + attr, + visible); + } else if (name.equals(LONGITUDINAL_ANNOTATION)) { doAnnotations( (FLYSAnnotation) bundle.getData(context), @@ -174,6 +277,16 @@ label = msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1); } } + else if (pos == YAXIS.V.idx) { + label = msg(I18N_YAXIS_V_LABEL, I18N_YAXIS_V_LABEL_DEFAULT); + } + else if (pos == YAXIS.D.idx) { + label = msg(I18N_YAXIS_D_LABEL, I18N_YAXIS_D_LABEL_DEFAULT); + } + else if (pos == YAXIS.DW.idx) { + label = msg(I18N_WDIFF_YAXIS_LABEL, I18N_WDIFF_YAXIS_LABEL_DEFAULT); + } + return label; } @@ -249,4 +362,78 @@ addAxisSeries(series, YAXIS.L.idx, visible); } + protected void doFlowVelocityMainOut( + FlowVelocityData data, + ArtifactAndFacet aandf, + Document theme, + boolean visible + ) { + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); + StyledSeriesBuilder.addPoints(series, data.getMainChannelPoints(), true); + + addAxisSeries(series, YAXIS.V.idx, visible); + } + + protected void doFlowVelocityTotalOut( + FlowVelocityData data, + ArtifactAndFacet aandf, + Document theme, + boolean visible + ) { + if (data == null) { + logger.warn("No data to add to FlowVelocity chart."); + return; + } + + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); + StyledSeriesBuilder.addPoints(series, data.getTotalChannelPoints(), true); + + addAxisSeries(series, YAXIS.V.idx, visible); + } + + protected void doBedDifferenceYearOut( + BedDiffYearResult data, + ArtifactAndFacet aandf, + Document theme, + boolean visible + ) { + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); + StyledSeriesBuilder.addPoints(series, data.getDifferencesData(), true); + + addAxisSeries(series, YAXIS.D.idx, visible); + } + + protected void doBedDifferenceEpochOut( + BedDiffEpochResult data, + ArtifactAndFacet aandf, + Document theme, + boolean visible + ) { + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); + StyledSeriesBuilder.addPoints(series, data.getDifferencesData(), true); + + addAxisSeries(series, YAXIS.D.idx, visible); + } + + protected void doWDifferencesOut( + WKms wkms, + ArtifactAndFacet aandf, + Document theme, + boolean visible + ) { + if (wkms == null) { + logger.warn("No data to add to WDifferencesChart."); + return; + } + + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); + + StyledSeriesBuilder.addPoints(series, wkms); + + addAxisSeries(series, YAXIS.D.idx, visible); + if (DataUtil.guessWaterIncreasing(wkms.allWs())) { + setInverted(true); + } + } + }