Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java @ 9495:bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
author | gernotbelger |
---|---|
date | Tue, 25 Sep 2018 16:43:51 +0200 |
parents | be9bd06a1e3f |
children | 967ca59cc11a |
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() { | |
9495
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9465
diff
changeset
|
75 if (isCalculateMissingVolume()) |
9323 | 76 return getDouble("ld_from_part"); |
77 else | |
78 return null; | |
79 } | |
80 | |
81 public Double getMissingVolTo() { | |
9495
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9465
diff
changeset
|
82 if (isCalculateMissingVolume()) |
9323 | 83 return getDouble("ld_to_part"); |
84 else | |
85 return null; | |
86 } | |
87 | |
9495
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9465
diff
changeset
|
88 public boolean isCalculateMissingVolume() { |
9323 | 89 return getBoolean("missing_volume"); |
90 } | |
91 | |
9465
be9bd06a1e3f
bezugswst sounding select for miss'vol only (calc crashes)
gernotbelger
parents:
9446
diff
changeset
|
92 public Integer getBedHeightID() { |
9432
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 |
9495
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9465
diff
changeset
|
96 if (data == null || !isCalculateMissingVolume()) { |
9432
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!"); |
9465
be9bd06a1e3f
bezugswst sounding select for miss'vol only (calc crashes)
gernotbelger
parents:
9446
diff
changeset
|
98 return null; |
be9bd06a1e3f
bezugswst sounding select for miss'vol only (calc crashes)
gernotbelger
parents:
9446
diff
changeset
|
99 } else { |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
100 log.debug("getBedHeightIDs(): data=" + data); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
101 } |
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 final String[] parts = data.split(";"); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
104 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
105 int singleID = 0; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
106 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
107 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
|
108 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
|
109 try { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
110 singleID = Integer.parseInt(tmp); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
111 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
112 catch (final NumberFormatException nfe) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
113 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
|
114 } |
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 return singleID; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
117 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9396
diff
changeset
|
118 |
9267 | 119 // /** Access the reference date period, return null in case of 'errors'. */ |
120 // public DateRange getReferencePeriod() { | |
121 // if (this.referencePeriod == null) { | |
122 // final StateData refStart = artifact.getData("ref_start"); | |
123 // final StateData refEnd = artifact.getData("ref_end"); | |
124 // | |
125 // if (refStart == null || refEnd == null) { | |
126 // log.warn("missing 'ref_start' or 'ref_start' value"); | |
127 // return null; | |
128 // } | |
129 // | |
130 // try { | |
131 // long rs = Long.parseLong((String) refStart.getValue()); | |
132 // long re = Long.parseLong((String) refEnd.getValue()); | |
133 // | |
134 // if (rs > re) { | |
135 // final long t = rs; | |
136 // rs = re; | |
137 // re = t; | |
138 // } | |
139 // | |
140 // final Date from = new Date(rs); | |
141 // final Date to = new Date(re); | |
142 // this.referencePeriod = new DateRange(from, to); | |
143 // } | |
144 // catch (final NumberFormatException nfe) { | |
145 // log.warn("ref_start or ref_end is not an integer."); | |
146 // } | |
147 // } | |
148 // | |
149 // return this.referencePeriod; | |
150 // } | |
151 | |
152 // @Override | |
153 // public DateRange[] getAnalysisPeriods() { | |
154 // if (this.analysisPeriods == null) { | |
155 // this.analysisPeriods = getDateRange("ana_data"); | |
156 // } | |
157 // | |
158 // return this.analysisPeriods; | |
159 // } | |
160 | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9432
diff
changeset
|
161 // /** |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9432
diff
changeset
|
162 // * @return DateRange object ranging from eldest to youngest date |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9432
diff
changeset
|
163 // * of analysis and reference periods. |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9432
diff
changeset
|
164 // */ |
9267 | 165 // @Override |
166 // public DateRange getDateRange() { | |
167 // final DateRange refP = getReferencePeriod(); | |
168 // | |
169 // if (refP == null) { | |
170 // return null; | |
171 // } | |
172 // | |
173 // Date from = refP.getFrom(); | |
174 // Date to = refP.getTo(); | |
175 // | |
176 // final DateRange[] rs = getAnalysisPeriods(); | |
177 // for (final DateRange r : rs) { | |
178 // if (r.getFrom().before(from)) { | |
179 // from = r.getFrom(); | |
180 // } | |
181 // if (r.getTo().after(to)) { | |
182 // to = r.getTo(); | |
183 // } | |
184 // } | |
185 // | |
186 // return new DateRange(from, to); | |
187 // } | |
188 | |
189 // @Override | |
190 // public double[] getQs() { | |
191 // if (this.qs == null) { | |
192 // this.qs = getDoubleArray("qs"); | |
193 // } | |
194 // | |
195 // if (log.isDebugEnabled() && this.qs != null) { | |
196 // log.debug("qs: " + Arrays.toString(this.qs)); | |
197 // } | |
198 // return this.qs; | |
199 // } | |
200 } | |
201 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |