Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java @ 9432:d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
author | mschaefer |
---|---|
date | Mon, 20 Aug 2018 09:46:02 +0200 |
parents | 6ebc9357550c |
children | e60584f2a531 |
rev | line source |
---|---|
9267 | 1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.artifacts.bundu.bezugswst; | |
10 | |
11 import org.apache.log4j.Logger; | |
12 import org.dive4elements.river.artifacts.D4EArtifact; | |
13 import org.dive4elements.river.artifacts.access.FixAnalysisAccess; | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
14 import org.dive4elements.river.artifacts.states.SoundingsSelect; |
9267 | 15 |
16 public class BunduAccess extends FixAnalysisAccess { | |
17 | |
18 private static Logger log = Logger.getLogger(BunduAccess.class); | |
19 | |
20 // Alles, was in super steht, auskommentiert. TODO: endgültig löschen, nachdem ich es etwas verstanden habe | |
21 | |
22 // protected DateRange referencePeriod; | |
23 // protected DateRange[] analysisPeriods; | |
24 // | |
25 // protected double[] qs; | |
26 | |
27 public BunduAccess(final D4EArtifact artifact) { | |
28 super(artifact); | |
29 } | |
30 | |
31 public boolean isAutoSelect() { | |
32 final String fixChoice = this.artifact.getDataAsString("fix_choice"); | |
9366 | 33 if (fixChoice != null && fixChoice.equals("state.bundu.wst.fix.auto")) { |
9267 | 34 return true; |
35 } | |
36 return false; | |
37 } | |
38 | |
39 public Integer getBezugsJahr() { | |
40 return this.artifact.getDataAsInteger("singleyear"); | |
41 } | |
42 | |
43 public int[] getEventsTemp() { | |
44 return getIntArray("events_temp"); | |
45 } | |
46 | |
9277 | 47 public int getQSeriesLength() { |
48 return this.artifact.getDataAsInteger("year_input_q_series"); | |
49 } | |
50 | |
9323 | 51 public int getStartYear() { |
9396 | 52 return this.getBezugsJahr() - this.getQSeriesLength() + 1; |
9323 | 53 } |
54 | |
55 public Integer getUd() { | |
56 if (getUd_Q_mode().equals("UD")) | |
57 return getInteger("bundu.wst.ud_value"); | |
58 else | |
59 return null; | |
60 } | |
61 | |
62 @Override | |
63 public double[] getQs() { | |
64 if (getUd_Q_mode().equals("Q")) | |
65 return super.getQs(); | |
66 else | |
67 return null; | |
68 } | |
69 | |
70 private String getUd_Q_mode() { | |
71 return getString("bundu.wst.mode"); | |
72 } | |
73 | |
74 public Double getMissingVolFrom() { | |
75 if (isCalculateMissingValue()) | |
76 return getDouble("ld_from_part"); | |
77 else | |
78 return null; | |
79 } | |
80 | |
81 public Double getMissingVolTo() { | |
82 if (isCalculateMissingValue()) | |
83 return getDouble("ld_to_part"); | |
84 else | |
85 return null; | |
86 } | |
87 | |
88 private boolean isCalculateMissingValue() { // probably public | |
89 return getBoolean("missing_volume"); | |
90 } | |
91 | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
92 public int getBedHeightID() { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
93 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
94 final String data = getString("soundings"); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
95 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
96 if (data == null) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
97 log.warn("No 'soundings' parameter specified!"); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
98 return 0; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
99 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
100 else { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
101 log.debug("getBedHeightIDs(): data=" + data); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
102 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
103 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
104 final String[] parts = data.split(";"); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
105 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
106 int singleID = 0; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
107 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
108 if (data.indexOf(SoundingsSelect.PREFIX_SINGLE) >= 0) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
109 final String tmp = data.replace(SoundingsSelect.PREFIX_SINGLE, ""); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
110 try { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
111 singleID = Integer.parseInt(tmp); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
112 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
113 catch (final NumberFormatException nfe) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
114 log.warn("Cannot parse int from string: '" + tmp + "'"); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
115 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
116 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
117 return singleID; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
118 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
119 |
9267 | 120 // /** Access the reference date period, return null in case of 'errors'. */ |
121 // public DateRange getReferencePeriod() { | |
122 // if (this.referencePeriod == null) { | |
123 // final StateData refStart = artifact.getData("ref_start"); | |
124 // final StateData refEnd = artifact.getData("ref_end"); | |
125 // | |
126 // if (refStart == null || refEnd == null) { | |
127 // log.warn("missing 'ref_start' or 'ref_start' value"); | |
128 // return null; | |
129 // } | |
130 // | |
131 // try { | |
132 // long rs = Long.parseLong((String) refStart.getValue()); | |
133 // long re = Long.parseLong((String) refEnd.getValue()); | |
134 // | |
135 // if (rs > re) { | |
136 // final long t = rs; | |
137 // rs = re; | |
138 // re = t; | |
139 // } | |
140 // | |
141 // final Date from = new Date(rs); | |
142 // final Date to = new Date(re); | |
143 // this.referencePeriod = new DateRange(from, to); | |
144 // } | |
145 // catch (final NumberFormatException nfe) { | |
146 // log.warn("ref_start or ref_end is not an integer."); | |
147 // } | |
148 // } | |
149 // | |
150 // return this.referencePeriod; | |
151 // } | |
152 | |
153 // @Override | |
154 // public DateRange[] getAnalysisPeriods() { | |
155 // if (this.analysisPeriods == null) { | |
156 // this.analysisPeriods = getDateRange("ana_data"); | |
157 // } | |
158 // | |
159 // return this.analysisPeriods; | |
160 // } | |
161 | |
162 /** | |
163 * @return DateRange object ranging from eldest to youngest date | |
164 * of analysis and reference periods. | |
165 */ | |
166 // @Override | |
167 // public DateRange getDateRange() { | |
168 // final DateRange refP = getReferencePeriod(); | |
169 // | |
170 // if (refP == null) { | |
171 // return null; | |
172 // } | |
173 // | |
174 // Date from = refP.getFrom(); | |
175 // Date to = refP.getTo(); | |
176 // | |
177 // final DateRange[] rs = getAnalysisPeriods(); | |
178 // for (final DateRange r : rs) { | |
179 // if (r.getFrom().before(from)) { | |
180 // from = r.getFrom(); | |
181 // } | |
182 // if (r.getTo().after(to)) { | |
183 // to = r.getTo(); | |
184 // } | |
185 // } | |
186 // | |
187 // return new DateRange(from, to); | |
188 // } | |
189 | |
190 // @Override | |
191 // public double[] getQs() { | |
192 // if (this.qs == null) { | |
193 // this.qs = getDoubleArray("qs"); | |
194 // } | |
195 // | |
196 // if (log.isDebugEnabled() && this.qs != null) { | |
197 // log.debug("qs: " + Arrays.toString(this.qs)); | |
198 // } | |
199 // return this.qs; | |
200 // } | |
201 } | |
202 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |