Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
8945:4a6b6a3c279c | 8946:5d5d482da3e9 |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.sinfo.flowdepth; | |
11 | |
12 import org.dive4elements.river.artifacts.model.Calculation; | |
13 import org.dive4elements.river.artifacts.states.WaterlevelData; | |
14 | |
15 /** | |
16 * @author Gernot Belger | |
17 */ | |
18 public final class FlowDepthUtils { | |
19 | |
20 private FlowDepthUtils() { | |
21 throw new UnsupportedOperationException(); | |
22 } | |
23 | |
24 /** | |
25 * Checks the year difference between waterlevels and sounding, and issues a warning if too big. | |
26 * | |
27 * Zeitraum Zeitliche Differenz [a] | |
28 * X ≥ 1998 ± 3 | |
29 * 1958 ≤ X < 1998 ± 6 | |
30 * 1918 ≤ X < 1958 ± 12 | |
31 * X < 1918 ± 25 | |
32 */ | |
33 public static void checkYearDifference(final String label, final WaterlevelData waterlevel, final int soundingYear, final Calculation problems) { | |
34 | |
35 final int wstYear = waterlevel.getYear(); | |
36 if (wstYear < 0) | |
37 return; | |
38 | |
39 final int maxDifference = getMaxDifferenceYears(soundingYear); | |
40 | |
41 final int difference = Math.abs(soundingYear - wstYear); | |
42 if (difference > maxDifference) { | |
43 problems.addProblem("sinfo_calc_flow_depth.warning.year_difference", label, wstYear, soundingYear); | |
44 } | |
45 } | |
46 | |
47 public static int getMaxDifferenceYears(final int year) { | |
48 | |
49 if (year < 1918) | |
50 return 25; | |
51 | |
52 if (1918 <= year && year < 1958) | |
53 return 12; | |
54 | |
55 if (1958 <= year && year < 1998) | |
56 return 6; | |
57 | |
58 /* >= 1998 */ | |
59 return 3; | |
60 } | |
61 } |