Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java @ 1101:82798c992975
Interpolate Q main values, generate interpolated W main values on the fly from
Q main values.
flys-artifacts/trunk@2604 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 29 Aug 2011 09:07:55 +0000 |
parents | 29c67a76ad5d |
children | aeae4d20f32f |
comparison
equal
deleted
inserted
replaced
1100:29c67a76ad5d | 1101:82798c992975 |
---|---|
19 | 19 |
20 import de.intevation.flys.model.Gauge; | 20 import de.intevation.flys.model.Gauge; |
21 import de.intevation.flys.model.MainValue; | 21 import de.intevation.flys.model.MainValue; |
22 import de.intevation.flys.model.River; | 22 import de.intevation.flys.model.River; |
23 | 23 |
24 import de.intevation.flys.artifacts.model.Calculation; | |
24 import de.intevation.flys.artifacts.model.MainValuesQFacet; | 25 import de.intevation.flys.artifacts.model.MainValuesQFacet; |
25 import de.intevation.flys.artifacts.model.MainValuesWFacet; | 26 import de.intevation.flys.artifacts.model.MainValuesWFacet; |
26 import de.intevation.flys.artifacts.model.NamedDouble; | 27 import de.intevation.flys.artifacts.model.NamedDouble; |
27 import de.intevation.flys.artifacts.model.RiverFactory; | 28 import de.intevation.flys.artifacts.model.WstValueTable; |
29 import de.intevation.flys.artifacts.model.WstValueTableFactory; | |
30 | |
28 import de.intevation.flys.artifacts.states.StaticState; | 31 import de.intevation.flys.artifacts.states.StaticState; |
32 | |
29 import de.intevation.flys.utils.FLYSUtils; | 33 import de.intevation.flys.utils.FLYSUtils; |
30 | 34 |
31 | 35 |
32 /** | 36 /** |
33 * Artifact to access names of Points Of Interest along a segment of a river. | 37 * Artifact to access names of Points Of Interest along a segment of a river. |
171 return river.determineGaugeByPosition(location); | 175 return river.determineGaugeByPosition(location); |
172 } | 176 } |
173 | 177 |
174 | 178 |
175 /** | 179 /** |
176 * Get datum of Gauge. | 180 * Get current location. |
177 * @return datum of gauge. | 181 * @return the location. |
178 */ | 182 */ |
179 public double getGaugeDatum() { | 183 public double getLocation() { |
180 Gauge gauge = getGauge(); | 184 double location = Double.parseDouble( |
181 if (gauge == null) { return 0.0f; } | 185 (String)getData("location").getValue()); |
182 return gauge.getDatum().doubleValue(); | 186 return location; |
183 } | 187 } |
184 | 188 |
185 | 189 |
186 /** | 190 /** |
187 * Get a list of "Q" main values. | 191 * Get a list of "Q" main values. |
188 * @return list of Q main values. | 192 * @return list of Q main values. |
189 */ | 193 */ |
190 public List<NamedDouble> getMainValuesQ() { | 194 public List<NamedDouble> getMainValuesQ() { |
191 List<NamedDouble> filteredList = new ArrayList<NamedDouble>(); | 195 List<NamedDouble> filteredList = new ArrayList<NamedDouble>(); |
192 Gauge gauge = getGauge(); | 196 Gauge gauge = getGauge(); |
197 WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this)); | |
198 Calculation c = new Calculation(); | |
199 double w_out[] = {0.0f}; | |
200 double q_out[] = {0.0f}; | |
201 double kms[] = {getLocation()}; | |
202 double gaugeStation = gauge.getStation().doubleValue(); | |
193 if (gauge != null) { | 203 if (gauge != null) { |
194 List<MainValue> orig = gauge.getMainValues(); | 204 List<MainValue> orig = gauge.getMainValues(); |
195 for (MainValue mv : orig) { | 205 for (MainValue mv : orig) { |
196 if (mv.getMainValue().getType().getName().equals("Q")) { | 206 if (mv.getMainValue().getType().getName().equals("Q")) { |
207 interpolator.interpolate(mv.getValue().doubleValue(), | |
208 gaugeStation, kms, w_out, q_out, c); | |
197 filteredList.add(new NamedDouble( | 209 filteredList.add(new NamedDouble( |
198 mv.getMainValue().getName(), | 210 mv.getMainValue().getName(), |
199 mv.getValue().doubleValue() | 211 q_out[0] |
200 )); | 212 )); |
201 } | 213 } |
202 } | 214 } |
203 } | 215 } |
204 return filteredList; | 216 return filteredList; |
210 * @return list of W main values. | 222 * @return list of W main values. |
211 */ | 223 */ |
212 public List<NamedDouble> getMainValuesW() { | 224 public List<NamedDouble> getMainValuesW() { |
213 List<NamedDouble> filteredList = new ArrayList<NamedDouble>(); | 225 List<NamedDouble> filteredList = new ArrayList<NamedDouble>(); |
214 Gauge gauge = getGauge(); | 226 Gauge gauge = getGauge(); |
215 double datum = gauge.getDatum().doubleValue(); | 227 WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this)); |
228 Calculation c = new Calculation(); | |
229 double gaugeStation = gauge.getStation().doubleValue(); | |
230 double w_out[] = {0.0f}; | |
231 double q_out[] = {0.0f}; | |
232 double kms[] = {getLocation()}; | |
216 if (gauge != null) { | 233 if (gauge != null) { |
217 List<MainValue> orig = gauge.getMainValues(); | 234 List<MainValue> orig = gauge.getMainValues(); |
218 for (MainValue mv : orig) { | 235 for (MainValue mv : orig) { |
219 if (mv.getMainValue().getType().getName().equals("W")) { | 236 // We cannot interpolate the W values, so derive them |
237 // from given Q values. | |
238 if (mv.getMainValue().getType().getName().equals("Q")) { | |
239 interpolator.interpolate(mv.getValue().doubleValue(), | |
240 gaugeStation, kms, w_out, q_out, c); | |
220 filteredList.add(new NamedDouble( | 241 filteredList.add(new NamedDouble( |
221 mv.getMainValue().getName(), | 242 "W(" + mv.getMainValue().getName() +")", |
222 mv.getValue().doubleValue()/100.f + datum | 243 w_out[0] |
223 )); | 244 )); |
224 } | 245 } |
225 } | 246 } |
226 } | 247 } |
227 return filteredList; | 248 return filteredList; |