Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthUtils.java @ 8946:5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
author | gernotbelger |
---|---|
date | Tue, 13 Mar 2018 18:49:33 +0100 |
parents | |
children | 322b0e6298ea |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthUtils.java Tue Mar 13 18:49:33 2018 +0100 @@ -0,0 +1,61 @@ +/** 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.artifacts.states.WaterlevelData; + +/** + * @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 WaterlevelData waterlevel, final int soundingYear, final Calculation problems) { + + final int wstYear = waterlevel.getYear(); + 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, wstYear, 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; + } +} \ No newline at end of file