Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java @ 8339:d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 29 Sep 2014 15:49:04 +0200 |
parents | be7864b4fabb |
children | 8679875f2c09 |
comparison
equal
deleted
inserted
replaced
8338:ac7cb15e1946 | 8339:d6e71158222a |
---|---|
42 import org.dive4elements.river.artifacts.model.WstValueTable; | 42 import org.dive4elements.river.artifacts.model.WstValueTable; |
43 import org.dive4elements.river.artifacts.model.WstValueTableFactory; | 43 import org.dive4elements.river.artifacts.model.WstValueTableFactory; |
44 | 44 |
45 import org.dive4elements.river.artifacts.states.StaticState; | 45 import org.dive4elements.river.artifacts.states.StaticState; |
46 import org.dive4elements.river.artifacts.resources.Resources; | 46 import org.dive4elements.river.artifacts.resources.Resources; |
47 import org.dive4elements.river.exports.injector.InjectorConstants; | |
47 | 48 |
48 | 49 |
49 /** | 50 /** |
50 * Artifact to access main and extreme values of a river. | 51 * Artifact to access main and extreme values of a river. |
51 * This artifact neglects (Static)D4EArtifacts capabilities of interaction | 52 * This artifact neglects (Static)D4EArtifacts capabilities of interaction |
371 if (pnpObject instanceof Number) { | 372 if (pnpObject instanceof Number) { |
372 pnp = Double.valueOf(pnpObject.toString()); | 373 pnp = Double.valueOf(pnpObject.toString()); |
373 } | 374 } |
374 | 375 |
375 for (MainValue mv : orig) { | 376 for (MainValue mv : orig) { |
377 Gauge g = river.determineGaugeByStation( | |
378 kms[0] - InjectorConstants.GAUGE_EPSILON, | |
379 kms[0] + InjectorConstants.GAUGE_EPSILON); | |
376 if (pnpObject instanceof Number) { | 380 if (pnpObject instanceof Number) { |
377 if (mv.getMainValue().getType().getName().equals("W")) { | 381 if (mv.getMainValue().getType().getName().equals("W")) { |
378 filteredList.add(new NamedDouble( | 382 filteredList.add(new NamedDouble( |
379 mv.getMainValue().getName(), | 383 mv.getMainValue().getName(), |
380 mv.getValue().doubleValue()/100 + pnp | 384 mv.getValue().doubleValue()/100 + pnp |
381 )); | 385 )); |
382 } | 386 } |
383 } else | 387 } |
384 // We cannot interpolate the W values, so derive them | 388 else if (!(pnpObject instanceof Number) && |
385 // from given Q values. | 389 g != null |
386 if (mv.getMainValue().getType().getName().equals("Q")) { | 390 ) { |
387 interpolator.interpolate(mv.getValue().doubleValue(), | 391 if (mv.getMainValue().getType().getName().equals("W")) { |
388 gaugeStation, kms, w_out, q_out, c); | 392 filteredList.add(new NamedDouble( |
389 | 393 mv.getMainValue().getName(), |
390 filteredList.add(new NamedDouble( | 394 mv.getValue().doubleValue() |
391 "W(" + mv.getMainValue().getName() +")", | 395 )); |
392 w_out[0] | 396 } |
393 )); | 397 } |
398 else { | |
399 // We cannot interpolate the W values, so derive them | |
400 // from given Q values. | |
401 if (mv.getMainValue().getType().getName().equals("Q")) { | |
402 interpolator.interpolate(mv.getValue().doubleValue(), | |
403 gaugeStation, kms, w_out, q_out, c); | |
404 | |
405 filteredList.add(new NamedDouble( | |
406 "W(" + mv.getMainValue().getName() +")", | |
407 w_out[0] | |
408 )); | |
409 } | |
394 } | 410 } |
395 } | 411 } |
396 } | 412 } |
397 return filteredList; | 413 return filteredList; |
398 } | 414 } |