comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationAccess.java @ 9145:e6b63b2b41b9

sinfo.flood_duration pdf, csv, ui
author gernotbelger
date Tue, 12 Jun 2018 10:23:23 +0200
parents 611a523fc42f
children 1614cb14308f
comparison
equal deleted inserted replaced
9144:7879c2ca8bd3 9145:e6b63b2b41b9
14 import org.dive4elements.river.artifacts.access.RangeAccess; 14 import org.dive4elements.river.artifacts.access.RangeAccess;
15 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper; 15 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper;
16 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; 16 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
17 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode; 17 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode;
18 18
19 import gnu.trove.TDoubleArrayList;
20
21 /** 19 /**
22 * Access to the flow depth calculation type specific SInfo artifact data. 20 * 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 21 * 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. 22 * reference to the artifact instance.
25 * Hence we do NOT cache any data. 23 * Hence we do NOT cache any data.
30 28
31 private static Logger log = Logger.getLogger(FloodDurationAccess.class); 29 private static Logger log = Logger.getLogger(FloodDurationAccess.class);
32 30
33 private final EpochYearAccessHelper helper; 31 private final EpochYearAccessHelper helper;
34 32
35 /// Fields from state:
36
37 // calculation_mode (String), sollte sinfo_calc_flood_duration sein
38 // ld_from, ld_to, ld_step
39 // riverside, mögliche werte: "state.sinfo.riverside.left" "state.sinfo.riverside.right" "state.sinfo.riverside.both"
40 // wspl
41 // State.sinfo.WQ:
42 // <data name="wq_isq" type="Boolean" />
43 // <data name="wq_isfree" type="Boolean" />
44 // <data name="wq_isrange" type="Boolean" />
45 // <data name="wq_from" type="Double" />
46 // <data name="wq_to" type="Double" />
47 // <data name="wq_step" type="Double" />
48 // <data name="wq_single" type="Double[]" />
49 public FloodDurationAccess(final SINFOArtifact artifact) { 33 public FloodDurationAccess(final SINFOArtifact artifact) {
50 super(artifact); 34 super(artifact);
51 35
52 /* assert calculation mode */ 36 /* assert calculation mode */
53 final SinfoCalcMode calculationMode = artifact.getCalculationMode(); 37 final SinfoCalcMode calculationMode = artifact.getCalculationMode();
62 46
63 public String getRiverside() { 47 public String getRiverside() {
64 return super.getString("riverside"); 48 return super.getString("riverside");
65 } 49 }
66 50
67 public Boolean getWspl() {
68 return super.getBoolean("wspl");
69 }
70
71 public Boolean getWqIsQ() {
72 if (!getWspl()) {
73 return null;//
74 }
75 return super.getBoolean("wq_isq");
76 }
77
78 public Boolean getWqIsFree() {
79 if (!getWspl()) {
80 return null;//
81 }
82 return super.getBoolean("wq_isfree");
83 }
84
85 public Boolean getWqIsRange() {
86 if (!getWspl()) {
87 return null;//
88 }
89 return super.getBoolean("wq_isrange");
90 }
91
92 public Double getWqFrom() {
93 if (!getWspl()) {
94 return null;//
95 }
96 if (!getWqIsRange())
97 return null;
98
99 return super.getDouble("wq_from");
100 }
101
102 public Double getWqTo() {
103 if (!getWspl()) {
104 return null;//
105 }
106 if (!getWqIsRange())
107 return null;
108 return super.getDouble("wq_to");
109 }
110
111 public Double getWqStep() {
112 if (!getWspl()) {
113 return null;
114 }
115 if (!getWqIsRange())
116 return null;
117
118 return super.getDouble("wq_step");
119 }
120
121 public double[] getWqSingle() {
122 if (!getWspl()) {
123 return null;//
124 }
125 if (getWqIsRange())
126 return null;
127
128 final String wqSingles = super.getString("wq_single");
129
130 if (wqSingles == null || wqSingles.isEmpty()) {
131 log.warn("No wqSingles provided");
132 return null;
133 }
134 final TDoubleArrayList doubles = new gnu.trove.TDoubleArrayList();
135 for (final String value : wqSingles.split(" ")) {
136 try {
137
138 doubles.add(Double.parseDouble(value));// Punkt/komma?
139 }
140 catch (final NumberFormatException e) {
141 /* Client should prevent this */
142 log.warn("Invalid wqsingle value: " + value);
143 continue;
144 }
145 }
146 return doubles.toNativeArray();
147 }
148
149 } 51 }

http://dive4elements.wald.intevation.org