# HG changeset patch # User dnt_bjoernsen # Date 1572539873 -3600 # Node ID 6c1ebf2220f54e469d45475637e33b3f2dc2336e # Parent a03c541298190dd202a5b3892b95811afd5f4f99 # 19b (check for usages of WaterlevelExporter.getWforGaugeAndQ) -> cleanup: removing calc.extreme.curve diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/doc/conf/artifacts/winfo.xml --- a/artifacts/doc/conf/artifacts/winfo.xml Thu Oct 31 15:24:23 2019 +0100 +++ b/artifacts/doc/conf/artifacts/winfo.xml Thu Oct 31 17:37:53 2019 +0100 @@ -56,13 +56,6 @@ - - - - - - - @@ -152,16 +145,12 @@ - - - - - + - + @@ -176,23 +165,6 @@ - - - - - - - - - - - - - - - - - @@ -672,79 +644,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/doc/conf/generators/generators.xml --- a/artifacts/doc/conf/generators/generators.xml Thu Oct 31 15:24:23 2019 +0100 +++ b/artifacts/doc/conf/generators/generators.xml Thu Oct 31 17:37:53 2019 +0100 @@ -12,12 +12,6 @@ - - diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Thu Oct 31 15:24:23 2019 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Thu Oct 31 17:37:53 2019 +0100 @@ -158,9 +158,6 @@ if (calculationMode.equals("calc.discharge.longitudinal.section")) return getDischargeLongitudinalSectionData(context.getMeta()); - if (calculationMode.equals("calc.extreme.curve")) - return (CalculationResult) this.compute(context, ComputeType.ADVANCE, false); - if (calculationMode.equals("calc.w.differences")) return (CalculationResult) this.compute(context, ComputeType.ADVANCE, true); diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/CalculationSelect.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/CalculationSelect.java Thu Oct 31 15:24:23 2019 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/CalculationSelect.java Thu Oct 31 17:37:53 2019 +0100 @@ -9,19 +9,14 @@ package org.dive4elements.river.artifacts.states; import org.apache.log4j.Logger; - -import org.w3c.dom.Element; - +import org.dive4elements.artifactdatabase.data.StateData; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; import org.dive4elements.artifacts.CallMeta; - import org.dive4elements.artifacts.common.utils.XMLUtils; - -import org.dive4elements.artifactdatabase.data.StateData; - import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.resources.Resources; +import org.w3c.dom.Element; /** * @author Ingo Weinzierl @@ -35,103 +30,68 @@ public static final String FIELD_MODE = "calculation_mode"; /** Constant value for the reference line calculation. */ - public static final String CALCULATION_SURFACE_CURVE = - "calc.surface.curve"; + public static final String CALCULATION_SURFACE_CURVE = "calc.surface.curve"; /** Constant value for the differences calculation. */ - public static final String CALCULATION_DURATION_CURVE = - "calc.duration.curve"; + public static final String CALCULATION_DURATION_CURVE = "calc.duration.curve"; /** Constant value for the flood map calculation. */ - public static final String CALCULATION_FLOOD_MAP = - "calc.flood.map"; + public static final String CALCULATION_FLOOD_MAP = "calc.flood.map"; /** Constant value for the profile calculation. */ - public static final String CALCULATION_DISCHARGE_LONGITUDINAL_CURVE = - "calc.discharge.longitudinal.section"; + public static final String CALCULATION_DISCHARGE_LONGITUDINAL_CURVE = "calc.discharge.longitudinal.section"; /** Constant value for the state discharge curve calculation. */ - public static final String CALCULATION_DISCHARGE_CURVE = - "calc.discharge.curve"; + public static final String CALCULATION_DISCHARGE_CURVE = "calc.discharge.curve"; /** Constant value for the state w differences calculation. */ - public static final String CALCULATION_W_DIFFERENCES = - "calc.w.differences"; + public static final String CALCULATION_W_DIFFERENCES = "calc.w.differences"; /** Constant value for the state reference curve calculation. */ - public static final String CALCULATION_REFERENCE_CURVE = - "calc.reference.curve"; + public static final String CALCULATION_REFERENCE_CURVE = "calc.reference.curve"; /** Constant value for the historical discharge curve calculation. */ - public static final String CALCULATION_HISTORICAL_DISCHARGE_CURVE = - "calc.historical.discharge.curve"; - - /** Constant value for the extreme W curve calculation. */ - public static final String CALCULATION_EXTREME = - "calc.extreme.curve"; + public static final String CALCULATION_HISTORICAL_DISCHARGE_CURVE = "calc.historical.discharge.curve"; /** An array that holds all available calculation modes. */ - public static final String[] CALCULATIONS = { - CALCULATION_SURFACE_CURVE, - CALCULATION_FLOOD_MAP, - CALCULATION_DISCHARGE_CURVE, - CALCULATION_HISTORICAL_DISCHARGE_CURVE, - CALCULATION_DURATION_CURVE, - CALCULATION_DISCHARGE_LONGITUDINAL_CURVE, - CALCULATION_W_DIFFERENCES, - CALCULATION_REFERENCE_CURVE //, -// CALCULATION_EXTREME - }; - + public static final String[] CALCULATIONS = { CALCULATION_SURFACE_CURVE, CALCULATION_FLOOD_MAP, CALCULATION_DISCHARGE_CURVE, + CALCULATION_HISTORICAL_DISCHARGE_CURVE, CALCULATION_DURATION_CURVE, CALCULATION_DISCHARGE_LONGITUDINAL_CURVE, CALCULATION_W_DIFFERENCES, + CALCULATION_REFERENCE_CURVE }; /** Error message that is thrown if no mode has been chosen. */ - public static final String ERROR_NO_CALCULATION_MODE = - "error_feed_no_calculation_mode"; + public static final String ERROR_NO_CALCULATION_MODE = "error_feed_no_calculation_mode"; - /** Error message that is thrown if an invalid calculation mode has been - * chosen. */ - public static final String ERROR_INVALID_CALCULATION_MODE = - "error_feed_invalid_calculation_mode"; - + /** + * Error message that is thrown if an invalid calculation mode has been + * chosen. + */ + public static final String ERROR_INVALID_CALCULATION_MODE = "error_feed_invalid_calculation_mode"; public CalculationSelect() { } - /** Create choices (i18ned). */ @Override - protected Element[] createItems( - XMLUtils.ElementCreator cr, - Artifact artifact, - String name, - CallContext context) - { - CallMeta meta = context.getMeta(); - Element[] calcs = new Element[CALCULATIONS.length]; + protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) { + final CallMeta meta = context.getMeta(); + final Element[] calcs = new Element[CALCULATIONS.length]; for (int i = 0; i < CALCULATIONS.length; ++i) { - String calc = CALCULATIONS[i]; - calcs[i] = createItem( - cr, new String[] { - Resources.getMsg(meta, calc, calc), - calc - }); + final String calc = CALCULATIONS[i]; + calcs[i] = createItem(cr, new String[] { Resources.getMsg(meta, calc, calc), calc }); } return calcs; } - /** Validate the chosen calculation. */ @Override - public boolean validate(Artifact artifact) - throws IllegalArgumentException - { + public boolean validate(final Artifact artifact) throws IllegalArgumentException { log.debug("CalculationSelect.validate"); - D4EArtifact flys = (D4EArtifact) artifact; + final D4EArtifact flys = (D4EArtifact) artifact; - StateData data = getData(flys, FIELD_MODE); - String calc = (data != null) ? (String) data.getValue() : null; + final StateData data = getData(flys, FIELD_MODE); + String calc = (data != null) ? (String) data.getValue() : null; if (calc == null) { throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); @@ -139,7 +99,7 @@ calc = calc.trim().toLowerCase(); - for (String mode: CALCULATIONS) { + for (final String mode : CALCULATIONS) { if (mode.equals(calc)) { return true; } diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/extreme/ExtremeCompute.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/extreme/ExtremeCompute.java Thu Oct 31 15:24:23 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.artifacts.states.extreme; - -import org.dive4elements.artifactdatabase.state.Facet; - -import org.dive4elements.artifacts.CallContext; - -import org.dive4elements.river.artifacts.D4EArtifact; - -import org.dive4elements.river.artifacts.access.ExtremeAccess; - -import org.dive4elements.river.artifacts.model.CalculationResult; -import org.dive4elements.river.artifacts.model.CrossSectionWaterLineFacet; -import org.dive4elements.river.artifacts.model.DataFacet; -import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.artifacts.model.ReportFacet; -import org.dive4elements.river.artifacts.model.WaterlevelFacet; -import org.dive4elements.river.artifacts.model.WQKms; - -import org.dive4elements.river.artifacts.model.extreme.ExtremeCurveFacet; -import org.dive4elements.river.artifacts.model.extreme.ExtremeCalculation; -import org.dive4elements.river.artifacts.model.extreme.ExtremeResult; - -import org.dive4elements.river.artifacts.resources.Resources; -import org.dive4elements.river.artifacts.states.DefaultState; - -import java.util.List; - -import org.apache.log4j.Logger; - - -/** State in which to deliver extreme value analysis result. */ -public class ExtremeCompute -extends DefaultState -implements FacetTypes -{ - /** Private log. */ - private static Logger log = Logger.getLogger(ExtremeCompute.class); - - - public ExtremeCompute() { - } - - - @Override - public Object computeAdvance( - D4EArtifact artifact, - String hash, - CallContext context, - List facets, - Object old - ) { - log.debug("ExtremeCompute.computeAdvance"); - - CalculationResult res; - - ExtremeAccess access = new ExtremeAccess(artifact); - - if (old instanceof CalculationResult) { - res = (CalculationResult)old; - } - else { - ExtremeCalculation calc = new ExtremeCalculation(access); - res = calc.calculate(); - } - - if (facets == null) { - return res; - } - - if (res.getReport().hasProblems()) { - facets.add(new ReportFacet()); - } - - ExtremeResult eres = (ExtremeResult) res.getData(); - WQKms [] wqkms = eres.getWQKms(); - - if (wqkms == null) { - log.error("No computation result!"); - return res; - } - - for (int i = 0; i < wqkms.length; i++) { - String name = wqkms[i].getName(); - // The name already contains "W(...)". - String qname = name.replace("W(","Q="); - qname = qname.substring(0,qname.length()-1); - - Facet w = new WaterlevelFacet( i, LONGITUDINAL_W, name, ComputeType.ADVANCE, id, hash ); - Facet q = new WaterlevelFacet( i, LONGITUDINAL_Q, qname, ComputeType.ADVANCE, id, hash ); - Facet csFacet = new CrossSectionWaterLineFacet( i, name, ComputeType.ADVANCE, hash, getID(), Integer.valueOf(i) ); - - facets.add(w); - facets.add(q); - facets.add(csFacet); - } - - - facets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); - facets.add(new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id)); - facets.add(new DataFacet(WST, "WST data", ComputeType.ADVANCE, hash, id)); - - facets.add(new ExtremeCurveFacet(Resources.getMsg(context.getMeta(), "extreme_wq_curve", "extreme_wq_curve"))); - facets.add(new ExtremeCurveFacet(Resources.getMsg(context.getMeta(), "extreme_wq_base_curve", "extreme_wq_base_curve"), true)); - - return res; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/extreme/ExtremeQInput.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/extreme/ExtremeQInput.java Thu Oct 31 15:24:23 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,256 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.artifacts.states.extreme; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -import org.w3c.dom.Element; - -import org.dive4elements.artifacts.Artifact; -import org.dive4elements.artifacts.CallContext; - -import org.dive4elements.river.artifacts.access.ExtremeAccess; - -import org.dive4elements.artifactdatabase.ProtocolUtils; -import org.dive4elements.artifactdatabase.data.StateData; - -import org.dive4elements.artifacts.common.utils.XMLUtils; - -import org.dive4elements.river.artifacts.model.WstValueTable; -/* -import org.dive4elements.river.model.Gauge; -import org.dive4elements.river.model.Wst; -import org.dive4elements.river.utils.RiverUtils; -*/ -import org.dive4elements.river.artifacts.model.Range; -import org.dive4elements.river.model.River; - -import org.dive4elements.river.artifacts.D4EArtifact; - -import org.dive4elements.river.artifacts.model.RangeWithValues; -import org.dive4elements.river.artifacts.states.DefaultState; -import org.dive4elements.river.artifacts.model.WstValueTableFactory; - - -/** TODO Subclass WQAdapted. */ - -/** - * State to input Q data in segments for extreme value calculations.. - * The data item ranges is expected to have this format - * ;;:;;:... - * (;;;:;;;:;;;:...) - */ -public class ExtremeQInput extends DefaultState { - - /** The log used in this state.*/ - private static Logger log = Logger.getLogger(ExtremeQInput.class); - - - /** Trivial, empty constructor. */ - public ExtremeQInput() { - } - - - /** - * Create one element for each 'segment' of the selected river that - * is within the given kilometer range (TODO). Each element is a tuple of - * (from;to) where from is the lower bounds of the segment or the - * lower kilometer range. to is the upper bounds of the segment or - * the upper kilometer range. - * - * @param cr The ElementCreator. - * @param artifact The FLYS artifact. - * @param name The name of the data item. - * @param context The CallContext. - * - * @return a list of elements that consist of tuples of the intersected - * segments of the selected river. - */ - @Override - protected Element[] createItems( - XMLUtils.ElementCreator cr, - Artifact artifact, - String name, - CallContext context) - { - log.debug("ExtremeQInput.createItems: " + name); - - D4EArtifact flysArtifact = (D4EArtifact) artifact; - - ExtremeAccess access = new ExtremeAccess(flysArtifact); - River river = access.getRiver(); - WstValueTable wstValueTable = WstValueTableFactory.getTable(river); - - List ranges = wstValueTable.findSegments(access.getFrom(), - access.getTo()); - - int num = ranges != null ? ranges.size() : 0; - - if (num == 0) { - log.warn("Selected distance matches no segments."); - return null; - } - - List elements = new ArrayList(); - - for (Range range: ranges) { - elements.add(createItem( - cr, - new String[] { range.getStart() + ";" + range.getEnd(), - ""}, - new double[] {0,100000})); - } - - Element[] els = new Element[elements.size()]; - - return elements.toArray(els); - } - - - /** Create sub-item ('row') of data thing. */ - protected Element createItem( - XMLUtils.ElementCreator cr, - Object obj, - double[] q - ) - { - Element item = ProtocolUtils.createArtNode(cr, "item", null, null); - Element label = ProtocolUtils.createArtNode(cr, "label", null, null); - Element value = ProtocolUtils.createArtNode(cr, "value", null, null); - - String[] arr = (String[]) obj; - - label.setTextContent(arr[0]); - value.setTextContent(arr[1]); - - item.appendChild(label); - item.appendChild(value); - - if (q != null) { - Element qRange = createRangeElement(cr, q, "Q"); - item.appendChild(qRange); - } - - return item; - } - - - /** - * Create elements to set min and max values of segments q (just min makes - * sense for extremes. - */ - protected Element createRangeElement( - XMLUtils.ElementCreator cr, - double[] mm, - String type) - { - Element range = ProtocolUtils.createArtNode( - cr, "range", - new String[] {"type"}, - new String[] {type}); - - Element min = ProtocolUtils.createArtNode(cr, "min", null, null); - min.setTextContent(String.valueOf(mm[0])); - - Element max = ProtocolUtils.createArtNode(cr, "max", null, null); - max.setTextContent(String.valueOf(mm[1])); - - range.appendChild(min); - range.appendChild(max); - - return range; - } - - - @Override - protected String getUIProvider() { - return "q_segmented_panel"; - } - - - /** Validate given data (return true). */ - @Override - public boolean validate(Artifact artifact) - throws IllegalArgumentException - { - log.debug("ExtremeQInput.validate"); - - D4EArtifact flys = (D4EArtifact) artifact; - log.debug("ExtremeQInput: " + getData(flys, "ranges")); - - /* - // TODO sort out what has to be validated (prevent negative values?). - RangeWithValues[] rwvs = extractInput(getData(flys, "ranges")); - - if (rwvs == null) { - throw new IllegalArgumentException("error_missing_wq_data"); - } - - List gauges = RiverUtils.getGauges(flys); - River river = RiverUtils.getRiver(flys); - Wst wst = WstFactory.getWst(river); - - for (Gauge gauge: gauges) { - Range range = gauge.getRange(); - double lower = range.getA().doubleValue(); - double upper = range.getB().doubleValue(); - - for (RangeWithValues rwv: rwvs) { - if (lower <= rwv.getStart() && upper >= rwv.getEnd()) { - compareQsWithGauge(wst, gauge, rwv.getValues()); - } - } - } - */ - - return true; - } - - - /** Form RangeWithValue-Array from state data. */ - protected RangeWithValues[] extractInput(StateData data) { - if (data == null) { - return null; - } - - String dataString = (String) data.getValue(); - String[] ranges = dataString.split(":"); - - List rwv = new ArrayList(); - - for (String range: ranges) { - String[] parts = range.split(";"); - - double lower = Double.parseDouble(parts[0]); - double upper = Double.parseDouble(parts[1]); - - String[] values = parts[2].split(","); - - int num = values.length; - double[] res = new double[num]; - - for (int i = 0; i < num; i++) { - try { - res[i] = Double.parseDouble(values[i]); - } - catch (NumberFormatException nfe) { - log.warn(nfe, nfe); - } - } - - rwv.add(new RangeWithValues(lower, upper, res)); - } - - return rwv.toArray(new RangeWithValues[rwv.size()]); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/java/org/dive4elements/river/artifacts/states/extreme/PercentInput.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/extreme/PercentInput.java Thu Oct 31 15:24:23 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.artifacts.states.extreme; - -import org.apache.log4j.Logger; - -import org.dive4elements.artifactdatabase.data.StateData; -import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.artifacts.states.DefaultState; - - -/** - * @author Raimund Renkert - */ -public class PercentInput extends DefaultState { - - /** The log used in this class. */ - private static Logger log = Logger.getLogger(PercentInput.class); - - public static final String PARAMETER_NAME = "percent"; - - - /** - * The default constructor that initializes an empty State object. - */ - public PercentInput () { - } - - - /** Tell UI what to display for input. */ - @Override - protected String getUIProvider() { - return "percent_input"; - } - - - @Override - protected String[] getDefaultsFor(CallContext context, StateData data) { - if (data != null && data.getName().equals(PARAMETER_NAME)) { - return new String[] {"5", "5"}; - } - - return null; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Thu Oct 31 15:24:23 2019 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Thu Oct 31 17:37:53 2019 +0100 @@ -1119,14 +1119,12 @@ final String key = gauge != null ? gauge.getName() + String.valueOf(q) : null; if (!this.gaugeQ_W_Map.containsKey(key) && key != null) { - final DischargeTable dt = gauge.fetchMasterDischargeTable(); + // (Pos 19.1 b) + final DischargeTable dt = gauge.fetchRecentDischargeTable(); final double[][] table = DischargeTables.loadDischargeTableValues(dt); final double[] qs = DischargeTables.getWsForQ(table, q); - // final DischargeTables dct = new DischargeTables(gauge.getRiver().getName(), gauge.getName()); - // final double[] qs = DischargeTables.getWsForQ(dct.getFirstTable(), q); // TODO: KLÄREN, welche Abflusstabelle - // genommen werden soll! if (qs != null && qs.length > 0) { this.gaugeQ_W_Map.put(key, qs[0]); } diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/java/org/dive4elements/river/exports/extreme/ExtremeWQCurveGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/extreme/ExtremeWQCurveGenerator.java Thu Oct 31 15:24:23 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,260 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.extreme; - -import java.awt.Color; - -import org.apache.log4j.Logger; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.Marker; -import org.jfree.chart.plot.ValueMarker; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.title.TextTitle; -import org.jfree.data.xy.XYSeries; - -import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; -import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.artifacts.access.FixAnalysisAccess; -import org.dive4elements.river.artifacts.D4EArtifact; -import org.dive4elements.river.artifacts.model.DateRange; -import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.artifacts.model.extreme.Curve; -import org.dive4elements.river.artifacts.model.extreme.ExtremeCurveFacet; -import org.dive4elements.river.artifacts.resources.Resources; -import org.dive4elements.river.exports.fixings.FixWQCurveGenerator; -import org.dive4elements.river.exports.StyledSeriesBuilder; -import org.dive4elements.river.jfree.JFreeUtil; -import org.dive4elements.river.jfree.StyledXYSeries; - -import org.dive4elements.river.themes.ThemeDocument; -import org.dive4elements.river.utils.RiverUtils; - - -/** - * Generator for WQ fixing charts. - * @author Christian Lins - */ -public class ExtremeWQCurveGenerator -extends FixWQCurveGenerator -implements FacetTypes -{ - /** Private log. */ - private static Logger log = - Logger.getLogger(ExtremeWQCurveGenerator.class); - - public static final String I18N_CHART_TITLE = - "chart.extreme.wq.title"; - - public static final String I18N_CHART_SUBTITLE = - "chart.extreme.wq.subtitle"; - - public static final String I18N_CHART_SUBTITLE1 = - "chart.extreme.wq.subtitle1"; - - public static final String I18N_XAXIS_LABEL = - "chart.extreme.wq.xaxis.label"; - - public static final String I18N_YAXIS_LABEL = - "chart.extreme.wq.yaxis.label"; - - public static final String I18N_CHART_TITLE_DEFAULT = - "Extremkurvenanalyse"; - - public static final String I18N_XAXIS_LABEL_DEFAULT = - "Q [m\u00B3/s]"; - - public static final String I18N_YAXIS_LABEL_DEFAULT = - "W [NN + m]"; - - - /** First, ask parent to add data, then handle extreme_wq_curve(_base) - * data.*/ - @Override - public boolean prepareChartData( - ArtifactAndFacet aaf, - ThemeDocument theme, - boolean visible - ) { - if (super.prepareChartData(aaf, theme, visible)) { - return true; - } - - String name = aaf.getFacetName(); - if (name.equals(EXTREME_WQ_CURVE)) { - doExtremeCurveOut(aaf, theme, visible); - return true; - } - else if (name.equals(EXTREME_WQ_CURVE_BASE)) { - doExtremeCurveBaseOut(aaf, theme, visible); - return true; - } - return false; - } - - /** Overriden to show second axis also if no visible data present. */ - @Override - protected void adjustAxes(XYPlot plot) { - super.adjustAxes(plot); - if (getCurrentGaugeDatum() != 0d) { - // Show the W[*m] axis even if there is no data. - plot.setRangeAxis(1, createYAxis(YAXIS.W.idx)); - } - } - - /** Do Extreme Curve nonextrapolated points out. */ - protected void doExtremeCurveBaseOut( - ArtifactAndFacet aaf, - ThemeDocument theme, - boolean visible - ) { - log.debug("doExtremeCurveBaseOut"); - ExtremeCurveFacet facet = (ExtremeCurveFacet) aaf.getFacet(); - Curve curve = (Curve) facet.getData(aaf.getArtifact(), getContext()); - if (curve == null) { - log.warn("doExtremeCurveBaseOut: Facet does not contain Curve"); - return; - } - - XYSeries qwseries = new StyledXYSeries(aaf.getFacetName(), - aaf.getFacetDescription(), theme); - - double gaugeDatum = getCurrentGaugeDatum(); - - if (gaugeDatum == 0d) { - StyledSeriesBuilder.addPointsQW( - qwseries, curve.getQs(), curve.getWs()); - addAxisSeries(qwseries, YAXIS.W.idx, visible); - } - else { - XYSeries series2 = - new StyledXYSeries(aaf.getFacetName(), aaf.getFacetDescription(), theme); - StyledSeriesBuilder.addPointsQW( - series2, curve.getQs(), curve.getWs()); - addAxisSeries(series2, YAXIS.W.idx, false); - - StyledSeriesBuilder.addPointsQW( - qwseries, curve.getQs(), curve.getWs(), -gaugeDatum, 100d); - - addAxisSeries(qwseries, YAXIS.WCm.idx, visible); - } - - //addAxisSeries(qwseries, YAXIS.W.idx, visible); - } - - - /** Do Extreme Curve out */ - protected void doExtremeCurveOut( - ArtifactAndFacet aaf, - ThemeDocument theme, - boolean visible - ) { - log.debug("doExtremeCurveOut"); - ExtremeCurveFacet facet = (ExtremeCurveFacet) aaf.getFacet(); - Curve curve = (Curve) facet.getData(aaf.getArtifact(), getContext()); - if (curve == null) { - log.warn("doExtremeCurveOut: Facet does not contain Curve"); - return; - } - - double maxQ = curve.getSuggestedMaxQ(); - if (maxQ == Double.MAX_VALUE) { - maxQ = 8000; - } - - StyledXYSeries series = JFreeUtil.sampleFunction2D( - aaf.getFacetName(), - curve, - theme, - aaf.getFacetDescription(), - 500, // number of samples - 0.0 , // start - maxQ); // end - - // Add marker from where on its extrapolated. - if (theme.parseShowExtraMark()) { - double[] qs = curve.getQs(); - double extrapolateFrom = qs[qs.length-1]; - - Marker m = new ValueMarker(extrapolateFrom); - m.setPaint(Color.black); - addDomainMarker(m); - } - - addAxisSeries(series, YAXIS.W.idx, visible); - } - - - @Override - protected String getChartTitle(final CallContext context) { - return Resources.format( - getContext().getMeta(), - I18N_CHART_TITLE, - I18N_CHART_TITLE_DEFAULT, - getContext().getContextValue(CURRENT_KM)); - } - - - @Override - protected String getDefaultChartTitle(final CallContext context) { - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); - } - - @Override - protected String getDefaultChartSubtitle(final CallContext context) { - FixAnalysisAccess access = new FixAnalysisAccess(artifact); - DateRange dateRange = access.getDateRange(); - DateRange refRange = access.getReferencePeriod(); - - if (dateRange != null && refRange != null) { - return Resources.format( - getContext().getMeta(), - I18N_CHART_SUBTITLE, - "", - access.getRiverName(), - dateRange.getFrom(), - dateRange.getTo(), - refRange.getFrom(), - refRange.getTo()); - } - - return null; - } - - @Override - protected void addSubtitles(final CallContext context, JFreeChart chart) { - String defaultSubtitle = getDefaultChartSubtitle(context); - - if (defaultSubtitle == null || defaultSubtitle.length() == 0) { - return; - } - - chart.addSubtitle(new TextTitle(defaultSubtitle)); - } - - @Override - protected String getDefaultXAxisLabel(final CallContext context) { - return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); - } - - @Override - protected String getDefaultYAxisLabel(int pos) { - D4EArtifact flys = getArtifact(); - - String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); - if (pos == 0) { - unit = "cm"; - } - - return msg( - I18N_YAXIS_LABEL, - I18N_YAXIS_LABEL_DEFAULT, - new Object[] { unit }); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/java/org/dive4elements/river/exports/extreme/ExtremeWQCurveInfoGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/extreme/ExtremeWQCurveInfoGenerator.java Thu Oct 31 15:24:23 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.extreme; - -import org.dive4elements.river.exports.ChartInfoGenerator; - -/** - * A ChartInfoGenerator that generates meta information for specific extreme - * analysis W/Q curves. - */ -public class ExtremeWQCurveInfoGenerator extends ChartInfoGenerator { - - public ExtremeWQCurveInfoGenerator() { - super(new ExtremeWQCurveGenerator()); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/resources/messages.properties --- a/artifacts/src/main/resources/messages.properties Thu Oct 31 15:24:23 2019 +0100 +++ b/artifacts/src/main/resources/messages.properties Thu Oct 31 17:37:53 2019 +0100 @@ -124,7 +124,6 @@ calc.w.differences = Differences calc.historical.discharge.curve = Historical Discharge Rating Curve calc.reference.curve = Reference Curve -calc.extreme.curve = Extreme Curves calc.fixation.default = Fixation calc.bed.middle = Mean Bed Level calc.bed.diff = Bed Level Difference diff -r a03c54129819 -r 6c1ebf2220f5 artifacts/src/main/resources/messages_de.properties --- a/artifacts/src/main/resources/messages_de.properties Thu Oct 31 15:24:23 2019 +0100 +++ b/artifacts/src/main/resources/messages_de.properties Thu Oct 31 17:37:53 2019 +0100 @@ -124,7 +124,6 @@ calc.w.differences = Differenzen calc.historical.discharge.curve = Hist. Abflusskurven calc.reference.curve = Bezugslinie -calc.extreme.curve = Auslagerung extremer Wasserspiegellagen calc.fixation.default = Fixierung calc.bed.middle = Mittlere Sohlh\u00f6he calc.bed.diff = Sohlh\u00f6hendifferenz