comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentAccess.java @ 8951:322b0e6298ea

Work on SINFO FlowDepth-Development
author gernotbelger
date Fri, 16 Mar 2018 18:08:38 +0100
parents
children 611a523fc42f
comparison
equal deleted inserted replaced
8950:b0aeed4c97c1 8951:322b0e6298ea
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.apache.commons.lang.math.DoubleRange;
16 import org.dive4elements.river.artifacts.access.RangeAccess;
17 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
18 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode;
19 import org.dive4elements.river.artifacts.sinfo.flowdepth.WstSoundingIdPair;
20
21 /**
22 * Access to the flow depth calculation type specific SInfo artifact data.
23 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent
24 * reference to the artifact instance.
25 * Hence we do NOT cache any data.
26 *
27 * @author Gernot Belger
28 */
29 final class FlowDepthDevelopmentAccess extends RangeAccess {
30
31 static final String FIELD_DIFFID_CURRENT = "diffid_current";
32 static final String FIELD_DIFFID_HIST = "diffid_historical";
33
34 public FlowDepthDevelopmentAccess(final SINFOArtifact artifact) {
35 super(artifact);
36
37 /* assert calculation mode */
38 final SinfoCalcMode calculationMode = artifact.getCalculationMode();
39 assert (calculationMode == SinfoCalcMode.sinfo_calc_flow_depth_minmax);
40 }
41
42 public DoubleRange getRange() {
43 final double from = getFrom();
44 final double to = getTo();
45 return new DoubleRange(from, to);
46 }
47
48 public WstSoundingIdPair getCurrentPair() {
49 return getPair(FIELD_DIFFID_CURRENT);
50 }
51
52 public WstSoundingIdPair getHistoricalPair() {
53 return getPair(FIELD_DIFFID_HIST);
54 }
55
56 private WstSoundingIdPair getPair(final String field) {
57 final String diffids = getString(field);
58
59 /* fetch the raw configured pairs */
60 final List<WstSoundingIdPair> diffPairs = WstSoundingIdPair.parsePairs(diffids);
61
62 if (diffPairs.size() != 1)
63 return null;
64
65 return diffPairs.get(0);
66 }
67 }

http://dive4elements.wald.intevation.org