Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9069:1ffd38826175
access uinfo.vegetationzones+inundation_duration
author | gernotbelger |
---|---|
date | Tue, 15 May 2018 12:00:26 +0200 |
parents | |
children | 611a523fc42f |
comparison
equal
deleted
inserted
replaced
9068:a5cf8d7bff3c | 9069:1ffd38826175 |
---|---|
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.uinfo.inundationduration; | |
12 | |
13 import java.util.ArrayList; | |
14 | |
15 import org.apache.commons.lang.math.DoubleRange; | |
16 import org.dive4elements.river.artifacts.access.RangeAccess; | |
17 import org.dive4elements.river.artifacts.common.AccessHelper; | |
18 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
19 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; | |
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 InundationDurationAccess extends RangeAccess { | |
30 | |
31 // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR | |
32 public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; | |
33 public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR"; | |
34 private final AccessHelper helper; | |
35 | |
36 // Fields from state: | |
37 // | |
38 // calculation_mode (String) | |
39 // ld_from, ld_to | |
40 // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year) | |
41 // singleyear (String) | |
42 // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier)) | |
43 // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe) | |
44 // sedimentheight String | |
45 // | |
46 // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen | |
47 | |
48 public InundationDurationAccess(final UINFOArtifact uinfo) { | |
49 super(uinfo); | |
50 | |
51 /* assert calculation mode */ | |
52 final UinfoCalcMode calculationMode = uinfo.getCalculationMode(); | |
53 this.helper = new AccessHelper(uinfo); | |
54 assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration); | |
55 } | |
56 | |
57 public DoubleRange getRange() { | |
58 final double from = getFrom(); | |
59 final double to = getTo(); | |
60 return new DoubleRange(from, to); | |
61 } | |
62 | |
63 public Double getSedimentHeight() { | |
64 if (super.getBoolean("use_scenario")) { | |
65 return super.getDouble("sedimentheight"); // TODO: INPUT Valdiation (nicht hier, sondern im Panel. Erinnerung) | |
66 } | |
67 return null; | |
68 } | |
69 | |
70 public Integer getYear() { | |
71 final int[] years = this.helper.getYears("state.uinfo.year", "singleyear"); | |
72 if (years != null) { | |
73 return years[0]; | |
74 } | |
75 return null; | |
76 } | |
77 | |
78 public int[] getTotalEpoch() { | |
79 final int[][] epochs = this.helper.getEpochs("state.uinfo.totalepoch", "totalepoch"); | |
80 if (epochs != null) { | |
81 return epochs[0]; | |
82 } | |
83 return null; | |
84 } | |
85 | |
86 public ArrayList<String[]> getVegZones() { | |
87 // TODO: MIT VegetationzonesAccess zusammenlegen | |
88 final ArrayList<String[]> results = new ArrayList<>(); | |
89 final String zonesRaw = super.getString("vegzones"); | |
90 if (zonesRaw.contains(TABLE_ROW_SEPARATOR)) { | |
91 final String[] rows = zonesRaw.split(TABLE_ROW_SEPARATOR); | |
92 for (final String row : rows) { | |
93 if (row.contains(TABLE_CELL_SEPARATOR)) { | |
94 final String[] result = row.split(TABLE_CELL_SEPARATOR); | |
95 results.add(result); | |
96 } | |
97 } | |
98 } | |
99 return results; | |
100 } | |
101 | |
102 } |