8951
|
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 |
|
11 package org.dive4elements.river.artifacts.sinfo.flowdepthdev; |
|
12 |
|
13 import java.util.List; |
|
14 |
|
15 import org.dive4elements.river.artifacts.access.RangeAccess; |
|
16 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; |
|
17 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; |
|
18 import org.dive4elements.river.artifacts.sinfo.flowdepth.WstSoundingIdPair; |
|
19 |
|
20 /** |
|
21 * Access to the flow depth calculation type specific SInfo artifact data. |
|
22 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent |
|
23 * reference to the artifact instance. |
|
24 * Hence we do NOT cache any data. |
|
25 * |
|
26 * @author Gernot Belger |
|
27 */ |
|
28 final class FlowDepthDevelopmentAccess extends RangeAccess { |
|
29 |
|
30 static final String FIELD_DIFFID_CURRENT = "diffid_current"; |
|
31 static final String FIELD_DIFFID_HIST = "diffid_historical"; |
|
32 |
|
33 public FlowDepthDevelopmentAccess(final SINFOArtifact artifact) { |
|
34 super(artifact); |
|
35 |
|
36 /* assert calculation mode */ |
|
37 final SinfoCalcMode calculationMode = artifact.getCalculationMode(); |
|
38 assert (calculationMode == SinfoCalcMode.sinfo_calc_flow_depth_minmax); |
|
39 } |
|
40 |
|
41 public WstSoundingIdPair getCurrentPair() { |
|
42 return getPair(FIELD_DIFFID_CURRENT); |
|
43 } |
|
44 |
|
45 public WstSoundingIdPair getHistoricalPair() { |
|
46 return getPair(FIELD_DIFFID_HIST); |
|
47 } |
|
48 |
|
49 private WstSoundingIdPair getPair(final String field) { |
|
50 final String diffids = getString(field); |
|
51 |
|
52 /* fetch the raw configured pairs */ |
|
53 final List<WstSoundingIdPair> diffPairs = WstSoundingIdPair.parsePairs(diffids); |
|
54 |
|
55 if (diffPairs.size() != 1) |
|
56 return null; |
|
57 |
|
58 return diffPairs.get(0); |
|
59 } |
|
60 } |