Mercurial > dive4elements > river
changeset 9503:83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
author | mschaefer |
---|---|
date | Fri, 28 Sep 2018 10:11:06 +0200 |
parents | 69a7edd7d1e1 |
children | 76c0665888a3 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthUtils.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java |
diffstat | 5 files changed, 11 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java Fri Sep 28 10:02:28 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java Fri Sep 28 10:11:06 2018 +0200 @@ -26,6 +26,7 @@ private NumberFormat floodDurationFormat = null; private NumberFormat salixScenFormat = null; private NumberFormat kmFormat = null; + private NumberFormat intFormat = null; /** The CallContext object. */ private final CallContext context; @@ -85,6 +86,13 @@ return this.salixScenFormat; } + public final NumberFormat getIntegerFormatter() { + if (this.intFormat == null) + this.intFormat = Formatter.getIntegerFormatter(this.context); + + return this.intFormat; + } + protected String msg(final String key) { return Resources.getMsg(this.context.getMeta(), key, key); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java Fri Sep 28 10:02:28 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java Fri Sep 28 10:11:06 2018 +0200 @@ -212,15 +212,6 @@ @Override public String exportValue(final CallContext context, final Object value) { final double doubleValue = asDouble(value); - String rm; - try { - rm = getFormatter(context).getRoundingMode().toString(); - } - catch (final Exception e) { - rm = "?"; - } - log.trace(String.format("meanBedHeight.exportValue roundingmode: %s value: %f doubleValue: %f formatted to: %s", - rm, value, doubleValue, exportDoubleValue(context, doubleValue))); return exportDoubleValue(context, doubleValue); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthUtils.java Fri Sep 28 10:02:28 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthUtils.java Fri Sep 28 10:11:06 2018 +0200 @@ -10,7 +10,6 @@ package org.dive4elements.river.artifacts.sinfo.flowdepth; import org.dive4elements.river.artifacts.model.Calculation; -import org.dive4elements.river.utils.Formatter; /** * @author Gernot Belger @@ -58,11 +57,11 @@ } /** - * Calculates a flow depth, rounded to the active scale + * Calculates a flow depth */ public static double calcFlowDepth(final double wst, final double bedHeight) { if (Double.isNaN(wst) || Double.isInfinite(wst) || Double.isNaN(bedHeight) || Double.isInfinite(bedHeight)) return Math.max(wst - bedHeight, 0.0); - return Math.max(Formatter.roundFlowDepth(wst).subtract(Formatter.roundFlowDepth(bedHeight)).doubleValue(), 0.0); + return Math.max(wst - bedHeight, 0.0); } } \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java Fri Sep 28 10:02:28 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java Fri Sep 28 10:11:06 2018 +0200 @@ -16,7 +16,6 @@ import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder; import org.dive4elements.river.model.River; -import org.dive4elements.river.utils.Formatter; /** * @author Gernot Belger @@ -140,7 +139,7 @@ if (Double.isNaN(meanBedHeight)) return TkhCalculateState.NO_BED_HEIGHT; - final double flowDepth = Formatter.roundFlowDepth(wst).subtract(Formatter.roundFlowDepth(meanBedHeight)).doubleValue(); + final double flowDepth = wst - meanBedHeight; row.putValue(SInfoResultType.flowdepth, flowDepth); final double discharge = this.dischargeProvider.getDischarge(km);
--- a/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java Fri Sep 28 10:02:28 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java Fri Sep 28 10:11:06 2018 +0200 @@ -8,8 +8,6 @@ package org.dive4elements.river.utils; -import java.math.BigDecimal; -import java.math.RoundingMode; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.NumberFormat; @@ -385,27 +383,11 @@ return Formatter.getFormatter(context, FLOWDEPTH_MAX_DIGITS, FLOWDEPTH_MAX_DIGITS); } - /** - * Decimal half even rounding of a flow depth value - * (ATTENTION: throws an exception for NaN or Infinity!) - */ - public static BigDecimal roundFlowDepth(final double value) { - return BigDecimal.valueOf(value).setScale(FLOWDEPTH_MAX_DIGITS, RoundingMode.HALF_EVEN); - } - public static NumberFormat getW(final CallContext context) { return Formatter.getFormatter(context, 2, 2); } /** - * Decimal half even rounding of a W value - * (ATTENTION: throws an exception for NaN or Infinity!) - */ - public static BigDecimal roundW(final double value) { - return BigDecimal.valueOf(value).setScale(WATERLEVEL_W_MAX_DIGITS, RoundingMode.HALF_EVEN); - } - - /** * Another waterlevel formatter with fixed digits (always 2) */ public static NumberFormat getWaterlevelW2(final CallMeta meta) {