Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthUtils.java @ 9454:4cccbd32b680
Bundu.wst.UD -> Q-Values are set on Client side now
author | gernotbelger |
---|---|
date | Thu, 23 Aug 2018 16:32:28 +0200 |
parents | 8ae7137b67d7 |
children | 83e6acdf8fc6 |
line wrap: on
line source
/** 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.flowdepth; import org.dive4elements.river.artifacts.model.Calculation; import org.dive4elements.river.utils.Formatter; /** * @author Gernot Belger */ public final class FlowDepthUtils { private FlowDepthUtils() { throw new UnsupportedOperationException(); } /** * Checks the year difference between waterlevels and sounding, and issues a warning if too big. * * Zeitraum Zeitliche Differenz [a] * X ≥ 1998 ± 3 * 1958 ≤ X < 1998 ± 6 * 1918 ≤ X < 1958 ± 12 * X < 1918 ± 25 */ public static void checkYearDifference(final String label, final int wstYear, final int soundingYear, final Calculation problems) { if (wstYear < 0) return; final int maxDifference = getMaxDifferenceYears(soundingYear); final int difference = Math.abs(soundingYear - wstYear); if (difference > maxDifference) problems.addProblem("sinfo_calc_flow_depth.warning.year_difference", label, Integer.toString(wstYear), Integer.toString(soundingYear)); } public static int getMaxDifferenceYears(final int year) { if (year < 1918) return 25; if (1918 <= year && year < 1958) return 12; if (1958 <= year && year < 1998) return 6; /* >= 1998 */ return 3; } /** * Calculates a flow depth, rounded to the active scale */ 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); } }