# HG changeset patch # User Felix Wolfsteller # Date 1314608875 0 # Node ID 82798c992975388b3f1034278e6cce614009ed31 # Parent 29c67a76ad5dedbb162d91a2aa87110616db6878 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 diff -r 29c67a76ad5d -r 82798c992975 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Aug 29 09:04:48 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon Aug 29 09:07:55 2011 +0000 @@ -1,3 +1,14 @@ +2011-08-29 Felix Wolfsteller + + Interpolate Q main values, generate interpolated W main values on the fly from + Q main values. + + * src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java: + (getGaugeDatum): removed, obsolete + (getLocation): new, gets location + Use WstValueTable to look up interpolated Qs of MainValues. In absence of + the same functionality for Ws, generate W Main Values from Q Main Values. + 2011-08-29 Felix Wolfsteller Use new helper class FLYSUtils, minor refactorization. diff -r 29c67a76ad5d -r 82798c992975 flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Mon Aug 29 09:04:48 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Mon Aug 29 09:07:55 2011 +0000 @@ -21,11 +21,15 @@ import de.intevation.flys.model.MainValue; import de.intevation.flys.model.River; +import de.intevation.flys.artifacts.model.Calculation; import de.intevation.flys.artifacts.model.MainValuesQFacet; import de.intevation.flys.artifacts.model.MainValuesWFacet; import de.intevation.flys.artifacts.model.NamedDouble; -import de.intevation.flys.artifacts.model.RiverFactory; +import de.intevation.flys.artifacts.model.WstValueTable; +import de.intevation.flys.artifacts.model.WstValueTableFactory; + import de.intevation.flys.artifacts.states.StaticState; + import de.intevation.flys.utils.FLYSUtils; @@ -173,13 +177,13 @@ /** - * Get datum of Gauge. - * @return datum of gauge. + * Get current location. + * @return the location. */ - public double getGaugeDatum() { - Gauge gauge = getGauge(); - if (gauge == null) { return 0.0f; } - return gauge.getDatum().doubleValue(); + public double getLocation() { + double location = Double.parseDouble( + (String)getData("location").getValue()); + return location; } @@ -190,13 +194,21 @@ public List getMainValuesQ() { List filteredList = new ArrayList(); Gauge gauge = getGauge(); + WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this)); + Calculation c = new Calculation(); + double w_out[] = {0.0f}; + double q_out[] = {0.0f}; + double kms[] = {getLocation()}; + double gaugeStation = gauge.getStation().doubleValue(); if (gauge != null) { List orig = gauge.getMainValues(); for (MainValue mv : orig) { if (mv.getMainValue().getType().getName().equals("Q")) { + interpolator.interpolate(mv.getValue().doubleValue(), + gaugeStation, kms, w_out, q_out, c); filteredList.add(new NamedDouble( mv.getMainValue().getName(), - mv.getValue().doubleValue() + q_out[0] )); } } @@ -212,14 +224,23 @@ public List getMainValuesW() { List filteredList = new ArrayList(); Gauge gauge = getGauge(); - double datum = gauge.getDatum().doubleValue(); + WstValueTable interpolator = WstValueTableFactory.getTable(FLYSUtils.getRiver(this)); + Calculation c = new Calculation(); + double gaugeStation = gauge.getStation().doubleValue(); + double w_out[] = {0.0f}; + double q_out[] = {0.0f}; + double kms[] = {getLocation()}; if (gauge != null) { List orig = gauge.getMainValues(); for (MainValue mv : orig) { - if (mv.getMainValue().getType().getName().equals("W")) { + // We cannot interpolate the W values, so derive them + // from given Q values. + if (mv.getMainValue().getType().getName().equals("Q")) { + interpolator.interpolate(mv.getValue().doubleValue(), + gaugeStation, kms, w_out, q_out, c); filteredList.add(new NamedDouble( - mv.getMainValue().getName(), - mv.getValue().doubleValue()/100.f + datum + "W(" + mv.getMainValue().getName() +")", + w_out[0] )); } }