Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthUtils.java @ 9382:8ae7137b67d7
Fixed: avoiding NaN exception in BigDecimal rounding
author | mschaefer |
---|---|
date | Tue, 07 Aug 2018 14:06:49 +0200 |
parents | b194fa64506a |
children | 83e6acdf8fc6 |
comparison
equal
deleted
inserted
replaced
9381:a9e6b0a75bde | 9382:8ae7137b67d7 |
---|---|
8 * documentation coming with Dive4Elements River for details. | 8 * documentation coming with Dive4Elements River for details. |
9 */ | 9 */ |
10 package org.dive4elements.river.artifacts.sinfo.flowdepth; | 10 package org.dive4elements.river.artifacts.sinfo.flowdepth; |
11 | 11 |
12 import org.dive4elements.river.artifacts.model.Calculation; | 12 import org.dive4elements.river.artifacts.model.Calculation; |
13 import org.dive4elements.river.utils.Formatter; | |
13 | 14 |
14 /** | 15 /** |
15 * @author Gernot Belger | 16 * @author Gernot Belger |
16 */ | 17 */ |
17 public final class FlowDepthUtils { | 18 public final class FlowDepthUtils { |
53 return 6; | 54 return 6; |
54 | 55 |
55 /* >= 1998 */ | 56 /* >= 1998 */ |
56 return 3; | 57 return 3; |
57 } | 58 } |
59 | |
60 /** | |
61 * Calculates a flow depth, rounded to the active scale | |
62 */ | |
63 public static double calcFlowDepth(final double wst, final double bedHeight) { | |
64 if (Double.isNaN(wst) || Double.isInfinite(wst) || Double.isNaN(bedHeight) || Double.isInfinite(bedHeight)) | |
65 return Math.max(wst - bedHeight, 0.0); | |
66 return Math.max(Formatter.roundFlowDepth(wst).subtract(Formatter.roundFlowDepth(bedHeight)).doubleValue(), 0.0); | |
67 } | |
58 } | 68 } |