Mercurial > dive4elements > river
changeset 8914:e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/sinfo.xml Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/doc/conf/artifacts/sinfo.xml Tue Feb 27 18:06:52 2018 +0100 @@ -1,89 +1,131 @@ <?xml version="1.0" encoding="UTF-8"?> <artifact name="sinfo"> - <states> - <state id="state.sinfo.river" description="state.sinfo.river" state="org.dive4elements.river.artifacts.states.RiverSelect" helpText="help.state.sinfo.river"> - <data name="river" type="String" /> - </state> - - <transition transition="org.dive4elements.river.artifacts.transitions.DefaultTransition"> - <from state="state.sinfo.river"/> - <to state="state.sinfo.calculation_mode"/> - </transition> - - <state id="state.sinfo.calculation_mode" description="state.sinfo.calculation_mode" state="org.dive4elements.river.artifacts.sinfo.CalculationSelectSinfo" helpText="help.state.sinfo.calculation_mode"> - <data name="calculation_mode" type="String"/> - </state> - - <!-- Fliesstiefen --> - <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> - <from state="state.sinfo.calculation_mode"/> - <to state="state.sinfo.distance_only"/> - <condition data="calculation_mode" value="sinfo_calc_flow_depth" operator="equal"/> - </transition> - - <state id="state.sinfo.distance_only" description="state.sinfo.distance_only" state="org.dive4elements.river.artifacts.states.DistanceOnlySelect" helpText="help.state.sinfo.distance_only"> - <data name="ld_from" type="Double" /> - <data name="ld_to" type="Double" /> - </state> - - <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> - <from state="state.sinfo.distance_only"/> - <to state="state.sinfo.waterlevel_soundings_select"/> - <condition data="calculation_mode" value="sinfo_calc_flow_depth" operator="equal"/> - </transition> - - <state id="state.sinfo.waterlevel_soundings_select" description="state.sinfo.waterlevel_soundings_select" state="org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthPairSelectState" helpText="help.state.sinfo.waterlevel_soundings_select"> - <data name="diffids" type="String" /> - </state> - - <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> - <from state="state.sinfo.waterlevel_soundings_select"/> - <to state="state.sinfo.use_transport_bodies"/> - <condition data="calculation_mode" value="sinfo_calc_flow_depth" operator="equal"/> - </transition> + <states> + <state id="state.sinfo.river" description="state.sinfo.river" state="org.dive4elements.river.artifacts.states.RiverSelect" helpText="help.state.sinfo.river"> + <data name="river" type="String"/> + </state> - <!-- FIXME: Nur Anzeigen, wenn Transportkörperhöhen vorliegen! --> - <state id="state.sinfo.use_transport_bodies" description="state.sinfo.use_transport_bodies" state="org.dive4elements.river.artifacts.sinfo.flowdepth.UseTransportBodiesChoice" helpText="help.state.sinfo.use_transport_bodies"> - <data name="use_transport_bodies" type="Boolean" /> - </state> - - <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> - <from state="state.sinfo.use_transport_bodies"/> - <to state="state.sinfo.flow_depth"/> - <condition data="calculation_mode" value="sinfo_calc_flow_depth" operator="equal"/> - </transition> - - <state id="state.sinfo.flow_depth" description="state.sinfo.flow_depth" state="org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthState" helpText="help.state.sinfo.flow_depth"> - <outputmodes> - <outputmode name="sinfo_flow_depth" description="output.flow_depth" mime-type="image/png" type="chart"> - <facets> - <!-- REMARK: id's that ends with 'filtered' are handled differently ' --> - <facet name="sinfo_flow_depth.filtered" description="Facet for mean flow depth, filtered by current zoom state"/> - <facet name="sinfo_flow_depth.tkh.filtered" description="Facet for mean flow depth including tkh, filtered by current zoom state"/> - - <facet name="sinfo_flow_depth.tkh" description="Facet for tkh"/> + <transition transition="org.dive4elements.river.artifacts.transitions.DefaultTransition"> + <from state="state.sinfo.river"/> + <to state="state.sinfo.calculation_mode"/> + </transition> - <facet name="longitudinal_section.annotations" description="facet.longitudinal_section.annotations"/> - </facets> - </outputmode> + <state id="state.sinfo.calculation_mode" description="state.sinfo.calculation_mode" state="org.dive4elements.river.artifacts.sinfo.CalculationSelectSinfo" helpText="help.state.sinfo.calculation_mode"> + <data name="calculation_mode" type="String"/> + </state> - <outputmode name="sinfo_flowdepth_export" description="output.sinfo_flowdepth_export" mime-type="text/plain" type="export"> - <facets> - <facet name="csv" description="facet.sinfo_flowdepth_export.csv" /> - <facet name="pdf" description="facet.sinfo_flowdepth_export.pdf" /> - </facets> - </outputmode> + <!-- Calculation Mode: Fließtiefen (Flow Depth) --> + <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> + <from state="state.sinfo.calculation_mode"/> + <to state="state.sinfo.distance_only"/> + <condition data="calculation_mode" value="sinfo_calc_flow_depth" operator="equal"/> + </transition> - <outputmode name="sinfo_flowdepth_report" description="output.sinfo_flowdepth_report" mime-type="text/xml" type="report"> - <facets> - <facet name="report" description="facet.sinfo_flowdepth_report"/> - </facets> - </outputmode> + <state id="state.sinfo.distance_only" description="state.sinfo.distance_only" state="org.dive4elements.river.artifacts.states.DistanceOnlySelect" helpText="help.state.sinfo.distance_only"> + <data name="ld_from" type="Double"/> + <data name="ld_to" type="Double"/> + </state> - </outputmodes> - </state> + <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> + <from state="state.sinfo.distance_only"/> + <to state="state.sinfo.waterlevel_soundings_select"/> + <condition data="calculation_mode" value="sinfo_calc_flow_depth" operator="equal"/> + </transition> - </states> + <state id="state.sinfo.waterlevel_soundings_select" description="state.sinfo.waterlevel_soundings_select" state="org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthPairSelectState" helpText="help.state.sinfo.waterlevel_soundings_select"> + <data name="diffids" type="String"/> + </state> + + <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> + <from state="state.sinfo.waterlevel_soundings_select"/> + <to state="state.sinfo.use_transport_bodies"/> + <condition data="calculation_mode" value="sinfo_calc_flow_depth" operator="equal"/> + </transition> + + <!-- FIXME: Nur Anzeigen, wenn Transportkörperhöhen vorliegen! --> + <state id="state.sinfo.use_transport_bodies" description="state.sinfo.use_transport_bodies" state="org.dive4elements.river.artifacts.sinfo.flowdepth.UseTransportBodiesChoice" helpText="help.state.sinfo.use_transport_bodies"> + <data name="use_transport_bodies" type="Boolean"/> + </state> + + <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> + <from state="state.sinfo.use_transport_bodies"/> + <to state="state.sinfo.flow_depth"/> + <condition data="calculation_mode" value="sinfo_calc_flow_depth" operator="equal"/> + </transition> + + <state id="state.sinfo.flow_depth" description="state.sinfo.flow_depth" state="org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthState" helpText="help.state.sinfo.flow_depth"> + <outputmodes> + <outputmode name="sinfo_flow_depth" description="output.flow_depth" mime-type="image/png" type="chart"> + <facets> + <!-- REMARK: id's that ends with 'filtered' are handled differently ' --> + <facet name="sinfo_flow_depth.filtered" description="Facet for mean flow depth, filtered by current zoom state"/> + <facet name="sinfo_flow_depth.tkh.filtered" description="Facet for mean flow depth including tkh, filtered by current zoom state"/> + + <facet name="sinfo_flow_depth.tkh" description="Facet for tkh"/> + + <facet name="longitudinal_section.annotations" description="facet.longitudinal_section.annotations"/> + </facets> + </outputmode> + + <outputmode name="sinfo_flowdepth_export" description="output.sinfo_flowdepth_export" mime-type="text/plain" type="export"> + <facets> + <facet name="csv" description="facet.sinfo_flowdepth_export.csv"/> + <facet name="pdf" description="facet.sinfo_flowdepth_export.pdf"/> + </facets> + </outputmode> + + <outputmode name="sinfo_flowdepth_report" description="output.sinfo_flowdepth_report" mime-type="text/xml" type="report"> + <facets> + <facet name="report" description="facet.sinfo_flowdepth_report"/> + </facets> + </outputmode> + </outputmodes> + </state> + + <!-- Calculation Mode: Transportkörperhöhen --> + <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> + <from state="state.sinfo.calculation_mode"/> + <to state="state.sinfo.distance"/> + <condition data="calculation_mode" value="sinfo_calc_transport_bodies_heights" operator="equal"/> + </transition> + + <state id="state.sinfo.distance" description="state.sinfo.distance" state="org.dive4elements.river.artifacts.states.DistanceSelect" helpText="help.state.sinfo.distance"> + <data name="ld_from" type="Double"/> + <data name="ld_to" type="Double"/> + <data name="ld_step" type="Double"/> + </state> + + <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> + <from state="state.sinfo.distance"/> + <to state="state.sinfo.wq"/> + <condition data="calculation_mode" value="sinfo_calc_transport_bodies_heights" operator="equal"/> + </transition> + + <state id="state.sinfo.wq" description="state.winfo.wq" state="org.dive4elements.river.artifacts.states.WQSelect" helpText="help.state.sinfo.wq"> + <data name="wq_isq" type="Boolean"/> + <data name="wq_isfree" type="Boolean"/> + <data name="wq_isrange" type="Boolean"/> + <data name="wq_from" type="Double"/> + <data name="wq_to" type="Double"/> + <data name="wq_step" type="Double"/> + <data name="wq_single" type="Double[]"/> + </state> + + <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition"> + <from state="state.sinfo.wq"/> + <to state="state.sinfo.transport_bodies_heights"/> + <condition data="calculation_mode" value="sinfo_calc_transport_bodies_heights" operator="equal"/> + </transition> + + <state id="state.sinfo.transport_bodies_heights" description="state.sinfo.transport_bodies_heights" state="org.dive4elements.river.artifacts.sinfo.tkh.TkhState" helpText="help.state.sinfo.transport_bodies_heights"> + <outputmodes> + <!-- <outputmode name="sinfo_flow_depth" description="output.flow_depth" mime-type="image/png" type="chart"> <facets> <facet name="sinfo_flow_depth.filtered" description="Facet for mean flow depth, filtered by current zoom state"/> <facet name="sinfo_flow_depth.tkh.filtered" description="Facet for mean flow depth including tkh, filtered by current zoom state"/> <facet name="sinfo_flow_depth.tkh" description="Facet for tkh"/> <facet name="longitudinal_section.annotations" description="facet.longitudinal_section.annotations"/> + </facets> </outputmode> <outputmode name="sinfo_flowdepth_export" description="output.sinfo_flowdepth_export" mime-type="text/plain" type="export"> <facets> <facet name="csv" description="facet.sinfo_flowdepth_export.csv"/> <facet name="pdf" description="facet.sinfo_flowdepth_export.pdf"/> </facets> </outputmode> <outputmode name="sinfo_flowdepth_report" description="output.sinfo_flowdepth_report" mime-type="text/xml" type="report"> <facets> <facet name="report" description="facet.sinfo_flowdepth_report"/> + </facets> </outputmode> --> + </outputmodes> + </state> + + </states> </artifact> \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Tue Feb 27 18:06:52 2018 +0100 @@ -20,7 +20,7 @@ import org.dive4elements.river.artifacts.access.Calculation4Access; import org.dive4elements.river.artifacts.access.RangeAccess; - +import org.dive4elements.river.artifacts.access.ComputationRangeAccess; import org.dive4elements.river.artifacts.geom.Lines; import org.dive4elements.river.artifacts.model.Calculation1; @@ -808,48 +808,13 @@ * @return the selected kms. */ public double[] getKms() { - RangeAccess rangeAccess = new RangeAccess(this); - if (rangeAccess.isRange()) { - return rangeAccess.getKmSteps(); - } - else { - return LocationDistanceSelect.getLocations(this); - } + return new ComputationRangeAccess(this).getKms(); } - public double [] getFromToStep() { - RangeAccess rangeAccess = new RangeAccess(this); - if (!rangeAccess.isRange()) { - return null; - } - double [] fromTo = rangeAccess.getKmRange(); - - if (fromTo == null) { - return null; - } - - StateData dStep = getData("ld_step"); - if (dStep == null) { - return null; - } - - double [] result = new double[3]; - result[0] = fromTo[0]; - result[1] = fromTo[1]; - - try { - String step = (String)dStep.getValue(); - result[2] = DoubleUtil.round(Double.parseDouble(step) / 1000d); - } - catch (NumberFormatException nfe) { - return null; - } - - return result; + return new ComputationRangeAccess(this).getFromToStep(); } - /** * This method returns the Q values. *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/ComputationRangeAccess.java Tue Feb 27 18:06:52 2018 +0100 @@ -0,0 +1,64 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * 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.access; + +import org.dive4elements.artifactdatabase.data.StateData; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.states.ComputationRangeState; +import org.dive4elements.river.utils.DoubleUtil; + +/** + * Access to data handled by {@link ComputationRangeState}. + * + * @author Gernot Belger + */ +public class ComputationRangeAccess extends RangeAccess { + + public ComputationRangeAccess(final D4EArtifact artifact) { + super(artifact); + } + + public double[] getFromToStep() { + + if (!isRange()) + return null; + + final double[] fromTo = getKmRange(); + + if (fromTo == null) + return null; + + final StateData dStep = getArtifact().getData("ld_step"); + if (dStep == null) + return null; + + final double[] result = new double[3]; + result[0] = fromTo[0]; + result[1] = fromTo[1]; + + try { + final String dStepValue = (String) dStep.getValue(); + result[2] = DoubleUtil.round(Double.parseDouble(dStepValue) / 1000d); + return result; + } + catch (final NumberFormatException nfe) { + nfe.printStackTrace(); + return null; + } + } + + public double[] getKms() { + + if (isRange()) + return getKmSteps(); + + return getLocations(); + } +} \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/CalculationSelectSinfo.java Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/CalculationSelectSinfo.java Tue Feb 27 18:06:52 2018 +0100 @@ -1,13 +1,12 @@ /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde - * Software engineering by - * Björnsen Beratende Ingenieure GmbH + * Software engineering by + * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * 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.sinfo; import java.util.ArrayList; @@ -27,46 +26,31 @@ */ public class CalculationSelectSinfo extends DefaultState { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** The log that is used in this class. */ + /** The log that is used in this class. */ private static Logger log = Logger.getLogger(CalculationSelectSinfo.class); - public CalculationSelectSinfo() { - } - - @Override - protected Element[] createItems( - XMLUtils.ElementCreator cr, - Artifact artifact, - String name, - CallContext context) - { - final CallMeta meta = context.getMeta(); - + protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) { + final CallMeta meta = context.getMeta(); + final Collection<Element> calcs = new ArrayList<>(SinfoCalcMode.values().length); for (final SinfoCalcMode calcMode : SinfoCalcMode.values()) { - final String calc = calcMode.name(); - - final String label = Resources.getMsg(meta, calc, calc); - - final Element element = createItem( - cr, new String[] { - label, - calc - }); - calcs.add(element); - } - + final String calc = calcMode.name(); + + final String label = Resources.getMsg(meta, calc, calc); + + final Element element = createItem(cr, new String[] { label, calc }); + calcs.add(element); + } + return calcs.toArray(new Element[calcs.size()]); } @Override - public boolean validate(Artifact artifact) - throws IllegalArgumentException - { + public boolean validate(final Artifact artifact) throws IllegalArgumentException { log.debug("CalculationSelect.validate"); final SINFOArtifact sinfo = (SINFOArtifact) artifact; @@ -74,5 +58,4 @@ sinfo.getCalculationMode(); return true; } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : +} \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java Tue Feb 27 18:06:52 2018 +0100 @@ -19,7 +19,6 @@ import org.apache.commons.lang.math.DoubleRange; import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.analysis.UnivariateRealFunction; -import org.apache.log4j.Logger; import org.dive4elements.artifacts.ArtifactDatabase; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.BedHeightsArtifact; @@ -47,7 +46,7 @@ class FlowDepthCalculation { - private static Logger log = Logger.getLogger(FlowDepthCalculation.class); + // private static Logger log = Logger.getLogger(FlowDepthCalculation.class); private static final int VALID_BED_MEASUREMENT_YEARS = 20; @@ -172,14 +171,14 @@ if (doCalcTkh) { qInterpolator = DoubleUtil.getLinearInterpolator(((QKms) wstKms).allKms(), ((QKms) wstKms).allQs()); if (qInterpolator != null) - qRange = new DoubleRange( ((QKms) wstKms).allQs().min(), ((QKms) wstKms).allQs().max()); + qRange = new DoubleRange(((QKms) wstKms).allQs().min(), ((QKms) wstKms).allQs().max()); else { final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingQ", null, label); problems.addProblem(message); doCalcTkh = false; } } - + // FIXME: sort by station first, but in what direction? // FIXME: using river.getKmUp()? final List<BedHeightValue> values = bedHeight.getValues(); @@ -198,7 +197,7 @@ problems.addProblem(message); } } - + FlowVelocityModelKmValueFinder flowVelocitiesFinder = null; if (doCalcTkh) { flowVelocitiesFinder = new FlowVelocityModelKmValueFinder(); @@ -245,60 +244,43 @@ double d50 = Double.NaN; try { d50 = bedMeasurementsFinder.findD50(km); - } catch (Exception e) { + } + catch (final Exception e) { final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingD50", null, label); problems.addProblem(km, message); - //FIXME: cumulate problems to one message? + // FIXME: cumulate problems to one message? } if (!Double.isNaN(d50)) { if (flowVelocitiesFinder.findKmQValues(km, discharge)) { tkh = calculateTkh(wst - meanBedHeight, flowVelocitiesFinder.getFindVmainFound(), d50, flowVelocitiesFinder.getFindTauFound()); if (!Double.isNaN(tkh) && (tkh < 0)) tkh = 0; - /* log.debug(String.format("calculateTkh km %.3f q %.0f w %.2f mbh %.2f vm %.1f tau %.1f d50(mm) %.1f tkh(cm) %.1f", - km, discharge, wst, meanBedHeight, flowVelocitiesFinder.getFindVmainFound(), flowVelocitiesFinder.getFindTauFound(), d50*1000, tkh)); */ - } - else { + /* + * log.debug(String.format("calculateTkh km %.3f q %.0f w %.2f mbh %.2f vm %.1f tau %.1f d50(mm) %.1f tkh(cm) %.1f", + * km, discharge, wst, meanBedHeight, flowVelocitiesFinder.getFindVmainFound(), flowVelocitiesFinder.getFindTauFound(), + * d50*1000, tkh)); + */ + } else { final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingQ", null, label); problems.addProblem(km, message); - //FIXME: cumulate problems to one message? + // FIXME: cumulate problems to one message? } - } - else + } else tkh = Double.NaN; } - + // Soil kind SoilKind kind = SoilKind.mobil; if (doCalcTkh) { try { - kind = soilKindFinder.findSoilKind(km); - } catch (Exception e) { + kind = soilKindFinder.findSoilKind(km); + } + catch (final Exception e) { final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingSoilKind", null, label); problems.addProblem(km, message); - //FIXME: cumulate problems to one message? + // FIXME: cumulate problems to one message? } } - - /* // REMARK: bissl spielerei zum testen damit die sohlart nicht zu schnell wechselt - SoilKind kind; - final boolean changeKind = Math.random() > 0.95; - if (changeKind) { - switch (lastKind) { - case starr: - kind = SoilKind.mobil; - break; - case mobil: - default: - kind = SoilKind.starr; - break; - } - } else - kind = lastKind; - lastKind = kind; - */ - - //tkh = 100 + 10 * (Math.random() - 0.5); final double flowDepthTkh; final double tkhUp; @@ -326,15 +308,14 @@ final String gaugeLabel = gauge == null ? notinrange : gauge.getName(); - resultData.addRow(km, flowDepth, flowDepthTkh, kind, tkh, tkhUp, tkhDown, wst, discharge, wstLabel, - gaugeLabel, meanBedHeight, bedHeightLabel, location); + resultData.addRow(km, flowDepth, flowDepthTkh, kind, tkh, tkhUp, tkhDown, wst, discharge, wstLabel, gaugeLabel, meanBedHeight, bedHeightLabel, + location); } catch (final FunctionEvaluationException e) { /* should only happen if out of range */ e.printStackTrace(); /* simply ignore */ } - } return resultData; @@ -470,16 +451,21 @@ return BedHeight.getBedHeightById(bedheightId); } - + /** * Calculates a transport body height - * @param h flow depth in m - * @param vm flow velocity in m - * @param d50 grain diameter D50 in m (!) - * @param tau shear stress in N/m^2 + * + * @param h + * flow depth in m + * @param vm + * flow velocity in m + * @param d50 + * grain diameter D50 in m (!) + * @param tau + * shear stress in N/m^2 * @return transport body height in cm (!) */ - private double calculateTkh(double h, double vm, double d50, double tau) { + private double calculateTkh(final double h, final double vm, final double d50, final double tau) { final double PHYS_G = 9.81; final double PHYS_SPECGRAV_S = 2.6; final double PHYS_VELOCCOEFF_N = 6; @@ -487,10 +473,10 @@ final double PHYS_VISCOSITY_NUE = 1.3e-6; final double PHYS_GRAIN_DENSITY_RHOS = 2603; final double PHYS_WATER_DENSITY_RHO = 999.97; - + final double froude = vm / Math.sqrt(PHYS_G * h); final double partReynolds = Math.sqrt((PHYS_SPECGRAV_S - 1) * PHYS_G * d50) / PHYS_VISCOSITY_NUE * d50; - final double critShields = 0.22 * Math.pow(partReynolds, -0.6) + 0.06 * Math.pow(10, 7.7 * Math.pow(partReynolds, -0.6)); + final double critShields = 0.22 * Math.pow(partReynolds, -0.6) + 0.06 * Math.pow(10, 7.7 * Math.pow(partReynolds, -0.6)); final double critTau = critShields * (PHYS_GRAIN_DENSITY_RHOS - PHYS_WATER_DENSITY_RHO) * PHYS_G * d50; return 100 * h * (1 - Math.pow(froude, 2)) / (2 * PHYS_VELOCCOEFF_N * PHYS_FORMCOEFF_ALPHA) * (1 - critTau / tau); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java Tue Feb 27 18:06:52 2018 +0100 @@ -78,15 +78,10 @@ */ private Object compute(final SINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) { - final CalculationResult res; - if (old instanceof CalculationResult) - res = (CalculationResult) old; - else - res = new FlowDepthCalculation(context).calculate(sinfo); + final CalculationResult res = doCompute(sinfo, context, old); - if (facets == null) { + if (facets == null) return res; - } final FlowDepthCalculationResults results = (FlowDepthCalculationResults) res.getData(); @@ -140,4 +135,11 @@ return res; } + + private CalculationResult doCompute(final SINFOArtifact sinfo, final CallContext context, final Object old) { + if (old instanceof CalculationResult) + return (CalculationResult) old; + + return new FlowDepthCalculation(context).calculate(sinfo); + } } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkh/TkhState.java Tue Feb 27 18:06:52 2018 +0100 @@ -0,0 +1,161 @@ +/* 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.sinfo.tkh; + +import java.util.List; + +import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.ChartArtifact; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.WINFOArtifact; +import org.dive4elements.river.artifacts.model.Calculation; +import org.dive4elements.river.artifacts.model.CalculationResult; +import org.dive4elements.river.artifacts.model.EmptyFacet; +import org.dive4elements.river.artifacts.model.WQKms; +import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; +import org.dive4elements.river.artifacts.states.DefaultState; + +/** State in which a waterlevel has been calculated. */ +public class TkhState extends DefaultState { + + /// ** The log that is used in this state. */ + // private static Logger log = Logger.getLogger(FlowDepthState.class); + + private static final long serialVersionUID = 1L; + + private static final String I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.filtered.description"; + + private static final String I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.tkh.filtered.description"; + + private static final String I18N_FACET_TKH_DESCRIPTION = "sinfo.facet.tkh.description"; + + private static final String SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL = "sinfo.chart.flow_depth.yaxis.label"; + + private static final String SINFO_CHART_TKX_YAXIS_LABEL = "sinfo.chart.tkh.yaxis.label"; + + /** + * From this state can only be continued trivially. + */ + @Override + protected String getUIProvider() { + return "continue"; + } + + @Override + public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { + // FIXME: why is this necessary? + if (artifact instanceof ChartArtifact) { + facets.add(new EmptyFacet()); + return null; + } + + return compute((SINFOArtifact) artifact, context, hash, facets, old); + } + + @Override + public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { + if (artifact instanceof ChartArtifact) { + facets.add(new EmptyFacet()); + return null; + } + return compute((SINFOArtifact) artifact, context, hash, facets, old); + } + + /** + * Compute result or returned object from cache, create facets. + * + * @param old + * Object that was cached. + */ + private Object compute(final SINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) { + + final CalculationResult res = doCompute(sinfo, context, old); + + if (facets == null) + return res; + + // final FlowDepthCalculationResults results = (FlowDepthCalculationResults) res.getData(); + // + // /* add themes for chart, for each result */ + // final List<FlowDepthCalculationResult> resultList = results.getResults(); + // for (int index = 0; index < resultList.size(); index++) { + // + // final FlowDepthCalculationResult result = resultList.get(index); + // + // /* filtered (zoom dependent mean) flow depth */ + // final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), + // I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, + // I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, result.getLabel()); + // facets.add(new FlowDepthFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED, facetFlowDepthFilteredDescription, + // SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, this.id, hash)); + // + // if (results.isUseTkh()) { + // /* filtered (zoom dependent mean) flow depth including tkh */ + // final String facetFlowDepthTkhFilteredDescription = Resources.getMsg(context.getMeta(), + // I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION, + // I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION, result.getLabel()); + // facets.add(new FlowDepthFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_TKH_FILTERED, + // facetFlowDepthTkhFilteredDescription, + // SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, this.id, hash)); + // + // // FIXME: add other themes + // // - Streckenfavoriten + // + // // FIXME: + // // - Gemittelte Linie der Fließtiefe mitsamt TKH + // // - Transportkörperhöhen (oben/unten/schraffur) + // final String facetTkhDescription = Resources.getMsg(context.getMeta(), I18N_FACET_TKH_DESCRIPTION, + // I18N_FACET_TKH_DESCRIPTION, + // result.getLabel()); + // facets.add(new FlowDepthFacet(index, TkhProcessor.FACET_TKH, facetTkhDescription, SINFO_CHART_TKX_YAXIS_LABEL, + // ComputeType.ADVANCE, this.id, + // hash)); + // } + // + // // FIXME: Datenkorbkonfiguration + // } + // + // if (!resultList.isEmpty()) { + // final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); + // final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); + // + // facets.add(csv); + // facets.add(pdf); + // } + // + // final Calculation report = res.getReport(); + // + // if (report.hasProblems()) { + // facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); + // } + // + // return res; + return null; + } + + private CalculationResult doCompute(final SINFOArtifact sinfo, final CallContext context, final Object old) { + if (old instanceof CalculationResult) + return (CalculationResult) old; + + // res = new FlowDepthCalculation(context).calculate(sinfo); + + final WINFOArtifact winfo = new WinfoArtifactWrapper(sinfo); + + final CalculationResult waterlevelData = winfo.getWaterlevelData(context); + final Calculation winfoProblems = waterlevelData.getReport(); + + final WQKms[] kms = (WQKms[]) waterlevelData.getData(); + + final Object result = new Object(); + final Calculation problems = new Calculation(); + + return new CalculationResult(result, problems); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkh/WinfoArtifactWrapper.java Tue Feb 27 18:06:52 2018 +0100 @@ -0,0 +1,42 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * 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.sinfo.tkh; + +import java.util.Collection; + +import org.dive4elements.artifactdatabase.data.DefaultStateData; +import org.dive4elements.artifactdatabase.data.StateData; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.WINFOArtifact; + +/** + * Ugly wrapper around WINfoArtifact in order to a) not to break serialization of WInfoArtifact b) be able to copy data + * into it + * + * @author Gernot Belger + * + */ +class WinfoArtifactWrapper extends WINFOArtifact { + + private static final long serialVersionUID = 1L; + + public WinfoArtifactWrapper(final D4EArtifact dataSource) { + final Collection<StateData> allData = dataSource.getAllData(); + for (final StateData stateData : allData) { + + final DefaultStateData clonedData = new DefaultStateData(); + clonedData.set(stateData); + + addData(clonedData.getName(), clonedData); + } + + addStringData("calculation_mode", "calc.surface.curve"); + } +} \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java Tue Feb 27 18:06:52 2018 +0100 @@ -30,10 +30,9 @@ import org.dive4elements.river.model.Wst; import org.dive4elements.river.artifacts.D4EArtifact; -import org.dive4elements.river.artifacts.WINFOArtifact; import org.dive4elements.river.artifacts.access.RangeAccess; - +import org.dive4elements.river.artifacts.access.ComputationRangeAccess; import org.dive4elements.river.artifacts.model.WstFactory; import org.dive4elements.river.artifacts.model.WstValueTable; import org.dive4elements.river.artifacts.model.WstValueTableFactory; @@ -104,8 +103,6 @@ Boolean isQ = flys.getDataAsBoolean(WQ_MODE); Boolean isFree = flys.getDataAsBoolean(WQ_FREE); - WINFOArtifact winfo = (WINFOArtifact) flys; - Element dataElement = creator.create("data"); creator.addAttr(dataElement, "name", name, true); creator.addAttr(dataElement, "type", type, true); @@ -116,10 +113,10 @@ String label; if (!isQ || isFree) { - label = getLabel(winfo, cc, value); + label = getLabel(flys, cc, value); } else { - label = getSpecialLabel(winfo, cc, value); + label = getSpecialLabel(flys, cc, value); } creator.addAttr(itemElement, "label", label, true); @@ -131,7 +128,7 @@ protected static String getLabel( - WINFOArtifact winfo, + D4EArtifact winfo, CallContext cc, String raw ) { @@ -167,7 +164,7 @@ protected static String getSpecialLabel( - WINFOArtifact winfo, + D4EArtifact winfo, CallContext cc, String raw ) { @@ -250,12 +247,12 @@ String name, CallContext context ){ - WINFOArtifact winfo = (WINFOArtifact) artifact; + D4EArtifact flys = (D4EArtifact) artifact; - double[] minmaxW = determineMinMaxW(winfo); - double[] minmaxWFree = determineMinMaxWFree(winfo); - double[] minmaxQ = determineMinMaxQAtGauge(winfo); - double[] minmaxQFree = determineMinMaxQ(winfo); + double[] minmaxW = determineMinMaxW(flys); + double[] minmaxWFree = determineMinMaxWFree(flys); + double[] minmaxQ = determineMinMaxQAtGauge(flys); + double[] minmaxQFree = determineMinMaxQ(flys); if (name.equals("wq_from")) { Element minW = createItem(cr, new String[] { @@ -400,7 +397,7 @@ * * @return the min and max W values for the current gauge. */ - protected double[] determineMinMaxW(WINFOArtifact winfo) { + protected double[] determineMinMaxW(D4EArtifact winfo) { log.debug("WQSelect.determineCurrentGauge"); RangeAccess rangeAccess = new RangeAccess(winfo); @@ -425,22 +422,24 @@ * * @return the min and max W values. */ - protected double[] determineMinMaxWFree(WINFOArtifact winfo) { + protected double[] determineMinMaxWFree(D4EArtifact winfo) { log.debug("WQSelect.determineMinMaxWFree"); WstValueTable valueTable = WstValueTableFactory.getTable( RiverUtils.getRiver(winfo)); + ComputationRangeAccess access = new ComputationRangeAccess(winfo); + double[] minmaxW = null; if(valueTable != null) { double[] km = null; - if(new RangeAccess(winfo).isRange()) { - km = winfo.getFromToStep(); + if(access.isRange()) { + km = access.getFromToStep(); // Use the start km to determine the min max values. minmaxW = valueTable.getMinMaxW(km[0]); } else { - km = winfo.getKms(); + km = access.getKms(); minmaxW = valueTable.getMinMaxW(km[0]); } } @@ -459,7 +458,7 @@ * * @return the min and max Q values for the current gauge. */ - protected double[] determineMinMaxQAtGauge(WINFOArtifact winfo) { + protected double[] determineMinMaxQAtGauge(D4EArtifact winfo) { log.debug("WQSelect.determineMinMaxQAtGauge"); RangeAccess rangeAccess = new RangeAccess(winfo); @@ -488,21 +487,23 @@ * * @return the min and max Q values for the current kilometer range. */ - protected double[] determineMinMaxQ(WINFOArtifact winfo) { + protected double[] determineMinMaxQ(D4EArtifact winfo) { log.debug("WQSelect.determineMinMaxQ"); WstValueTable valueTable = WstValueTableFactory.getTable( RiverUtils.getRiver(winfo)); + ComputationRangeAccess access = new ComputationRangeAccess(winfo); + double[] minmaxQ = null; if(valueTable != null) { double[] km = null; - if(new RangeAccess(winfo).isRange()) { - km = winfo.getFromToStep(); + if(access.isRange()) { + km = new ComputationRangeAccess(winfo).getFromToStep(); minmaxQ = valueTable.getMinMaxQ(km[0], km[1], km[2]); } else { - km = winfo.getKms(); + km = access.getKms(); minmaxQ = valueTable.getMinMaxQ(km[0]); for (int i = 1; i < km.length; i++) { double[] tmp = valueTable.getMinMaxQ(km[i]); @@ -527,7 +528,7 @@ { log.debug("WQSelect.validate"); - WINFOArtifact flys = (WINFOArtifact) artifact; + D4EArtifact flys = (D4EArtifact) artifact; StateData data = getData(flys, WQ_SELECTION); boolean isRange = data != null @@ -567,7 +568,7 @@ } - protected boolean validateSingle(WINFOArtifact artifact) + protected boolean validateSingle(D4EArtifact artifact) throws IllegalArgumentException { log.debug("WQSelect.validateSingle"); @@ -623,7 +624,7 @@ } - protected boolean validateRange(WINFOArtifact artifact) + protected boolean validateRange(D4EArtifact artifact) throws IllegalArgumentException { log.debug("WQSelect.validateRange"); @@ -685,7 +686,7 @@ * @return true, if everything was fine, otherwise an exception is thrown. */ protected boolean validateGaugeW( - WINFOArtifact artifact, + D4EArtifact artifact, double from, double to, double step) @@ -711,7 +712,7 @@ * @return true, if everything was fine, otherwise an exception is thrown. */ protected boolean validateGaugeQ( - WINFOArtifact artifact, + D4EArtifact artifact, double from, double to, double step) @@ -737,7 +738,7 @@ * @return true, if everything was fine, otherwise an exception is thrown. */ protected boolean validateFreeQ( - WINFOArtifact artifact, + D4EArtifact artifact, double from, double to, double step) @@ -763,7 +764,7 @@ * @return true, if everything was fine, otherwise an exception is thrown. */ protected boolean validateFreeW( - WINFOArtifact artifact, + D4EArtifact artifact, double from, double to, double step)
--- a/artifacts/src/main/resources/messages.properties Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/resources/messages.properties Tue Feb 27 18:06:52 2018 +0100 @@ -788,7 +788,15 @@ help.state.sinfo.calculation_mode=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.calculation_mode state.sinfo.distance_only = Range selection -help.state.sinfo.distance_only=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only +help.state.sinfo.distance_only = ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only + +state.sinfo.distance = Choose the range +help.state.sinfo.distance = ${help.url}/OnlineHilfe/help.state.sinfo.distance + +help.state.sinfo.wq=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.wq + +state.sinfo.transport_bodies_heights=Transportk\u00f6rperh\u00f6hen +help.state.sinfo.transport_bodies_heights=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.transport_bodies_heights state.sinfo.waterlevel_soundings_select= Chosen Differences help.state.sinfo.waterlevel_soundings_select=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.waterlevel_soundings_select
--- a/artifacts/src/main/resources/messages_de.properties Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/resources/messages_de.properties Tue Feb 27 18:06:52 2018 +0100 @@ -794,7 +794,15 @@ help.state.sinfo.calculation_mode=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.calculation_mode state.sinfo.distance_only = Wahl der Berechnungsstrecke -help.state.sinfo.distance_only=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only +help.state.sinfo.distance_only = ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only + +state.sinfo.distance = Wahl der Berechnungsstrecke +help.state.sinfo.distance = ${help.url}/OnlineHilfe/help.state.sinfo.distance + +help.state.sinfo.wq=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.wq + +state.sinfo.transport_bodies_heights=Transportk\u00f6rperh\u00f6hen +help.state.sinfo.transport_bodies_heights=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.transport_bodies_heights state.sinfo.waterlevel_soundings_select= Ausgew\u00e4hlte Differenzen help.state.sinfo.waterlevel_soundings_select=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.waterlevel_soundings_select
--- a/artifacts/src/main/resources/messages_de_DE.properties Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/resources/messages_de_DE.properties Tue Feb 27 18:06:52 2018 +0100 @@ -792,7 +792,15 @@ help.state.sinfo.calculation_mode=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.calculation_mode state.sinfo.distance_only = Wahl der Berechnungsstrecke -help.state.sinfo.distance_only=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only +help.state.sinfo.distance_only = ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only + +state.sinfo.distance = Wahl der Berechnungsstrecke +help.state.sinfo.distance = ${help.url}/OnlineHilfe/help.state.sinfo.distance + +help.state.sinfo.wq=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.wq + +state.sinfo.transport_bodies_heights=Transportk\u00f6rperh\u00f6hen +help.state.sinfo.transport_bodies_heights=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.transport_bodies_heights state.sinfo.waterlevel_soundings_select= Ausgew\u00e4hlte Differenzen help.state.sinfo.waterlevel_soundings_select=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.waterlevel_soundings_select
--- a/artifacts/src/main/resources/messages_en.properties Mon Feb 26 18:10:03 2018 +0100 +++ b/artifacts/src/main/resources/messages_en.properties Tue Feb 27 18:06:52 2018 +0100 @@ -789,7 +789,15 @@ help.state.sinfo.calculation_mode=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.calculation_mode state.sinfo.distance_only = Range selection -help.state.sinfo.distance_only=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only +help.state.sinfo.distance_only = ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only + +state.sinfo.distance = Choose the range +help.state.sinfo.distance = ${help.url}/OnlineHilfe/help.state.sinfo.distance + +help.state.sinfo.wq=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.wq + +state.sinfo.transport_bodies_heights=Transportk\u00f6rperh\u00f6hen +help.state.sinfo.transport_bodies_heights=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.transport_bodies_heights state.sinfo.waterlevel_soundings_select= Chosen Differences help.state.sinfo.waterlevel_soundings_select=${help.url}/OnlineHilfe/SINFO#help.state.sinfo.waterlevel_soundings_select