# HG changeset patch # User Felix Wolfsteller # Date 1337716265 0 # Node ID ac9a03ed32c12d4b5549586e4452cceb9fc8a0ec # Parent 7311d033660003791dfd7d6dc62907e69df77bc3 More debugging of discharge-curve issue. flys-artifacts/trunk@4466 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 7311d0336600 -r ac9a03ed32c1 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue May 22 19:42:54 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue May 22 19:51:05 2012 +0000 @@ -1,3 +1,12 @@ +2012-05-22 Felix Wolfsteller + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java, + src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java + (getDischargeCurveData): Moved to more specific class. + + * src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeFacet.java: + Cosmetics, be louder in miscondition. + 2012-05-22 Felix Wolfsteller * doc/conf/meta-data.xml: Allow loading of fixations and thmatic diff -r 7311d0336600 -r ac9a03ed32c1 flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java Tue May 22 19:42:54 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java Tue May 22 19:51:05 2012 +0000 @@ -1,12 +1,15 @@ package de.intevation.flys.artifacts; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Map; import org.apache.log4j.Logger; import org.w3c.dom.Document; +import de.intevation.artifactdatabase.data.DefaultStateData; import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifacts.Artifact; @@ -17,9 +20,20 @@ import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.WQKms; import de.intevation.flys.artifacts.states.DefaultState; +import de.intevation.flys.artifacts.model.Calculation; +import de.intevation.flys.artifacts.model.CalculationResult; + +import de.intevation.flys.artifacts.model.DischargeTables; + +import de.intevation.flys.model.Gauge; +import de.intevation.flys.model.River; + +import de.intevation.flys.utils.FLYSUtils; + /** @@ -33,7 +47,7 @@ private static Logger logger = Logger.getLogger(GaugeDischargeArtifact.class); /** The name of the artifact. */ - public static final String ARTIFACT_NAME = "historicalq"; + public static final String ARTIFACT_NAME = "gaugedischarge"; // TODO make this one globally available public static final String XPATH_DATA = @@ -66,6 +80,7 @@ String ids = XMLUtils.xpathString( data, XPATH_DATA, ArtifactNamespaceContext.INSTANCE); logger.debug("id for gaugedischarge: " + ids); + } @@ -91,15 +106,20 @@ FLYSArtifact artifact = (FLYSArtifact) art; // Get the location(s) - importData(artifact, "ld_mode"); - importData(artifact, "ld_from"); - importData(artifact, "ld_to"); - importData(artifact, "ld_locations"); + //importData(artifact, "ld_mode"); + //importData(artifact, "ld_from"); + //importData(artifact, "ld_to"); + //importData(artifact, "ld_locations"); + addStringData("ld_from", "0"); + addStringData("ld_to", "1000"); + addStringData("ld_mode", "distance"); + DefaultState state = (DefaultState) getCurrentState(context); state.computeInit(this, hash(), context, meta, fs); if (!fs.isEmpty()) { - logger.debug("Facets to add in GaugeDischargeArtifact.initialize ."); + logger.debug("Facets to add in GaugeDischargeArtifact.initialize. (" + + state.getID() + ")."); facets.put(getCurrentStateId(), fs); } else { @@ -109,7 +129,6 @@ } - /** * Determines Facets initial disposition regarding activity (think of * selection in Client ThemeList GUI). This will be checked one time @@ -127,5 +146,62 @@ { return 1; } + + + /** + * Returns the data that is used to create discharge curves. + * + */ + public CalculationResult getDischargeCurveData() { + + River river = FLYSUtils.getRiver(this); + if (river == null) { + return error(new WQKms[0], "no.river.selected"); + } + + double [] distance = FLYSUtils.getKmRange(this); + logger.debug("getDischargeCurveData: get range"); + + if (distance == null) { + return error(new WQKms[0], "no.range.found"); + } + + List gauges = river.determineGauges(distance[0], distance[1]); + logger.debug("getDischargeCurveData: get gauges"); + + if (gauges.isEmpty()) { + return error(new WQKms[0], "no.gauge.selected"); + } + + String [] names = new String[gauges.size()]; + + for (int i = 0; i < names.length; ++i) { + names[i] = gauges.get(i).getName(); + logger.debug("getDischargeCurveData: name " + names[i]); + } + + DischargeTables dt = new DischargeTables(river.getName(), names); + + Map map = dt.getValues(100d); + + ArrayList res = new ArrayList(); + + for (Gauge gauge: gauges) { + String name = gauge.getName(); + double [][] values = map.get(name); + if (values == null) { + continue; + } + double [] kms = new double[values[0].length]; + Arrays.fill(kms, gauge.getStation().doubleValue()); + res.add(new WQKms(kms, values[0], values[1], name)); + logger.debug("getDischargeCurveData: add one res gauge"); + } + + return new CalculationResult( + res.toArray(new WQKms[res.size()]), + new Calculation()); + } + } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 7311d0336600 -r ac9a03ed32c1 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue May 22 19:42:54 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue May 22 19:51:05 2012 +0000 @@ -71,6 +71,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; + /** * The default WINFO artifact. * @@ -475,58 +476,6 @@ /** - * Returns the data that is used to create discharge curves. - * - */ - public CalculationResult getDischargeCurveData() { - - River river = FLYSUtils.getRiver(this); - if (river == null) { - return error(new WQKms[0], "no.river.selected"); - } - - double [] distance = FLYSUtils.getKmRange(this); - - if (distance == null) { - return error(new WQKms[0], "no.range.found"); - } - - List gauges = river.determineGauges(distance[0], distance[1]); - - if (gauges.isEmpty()) { - return error(new WQKms[0], "no.gauge.selected"); - } - - String [] names = new String[gauges.size()]; - - for (int i = 0; i < names.length; ++i) { - names[i] = gauges.get(i).getName(); - } - - DischargeTables dt = new DischargeTables(river.getName(), names); - - Map map = dt.getValues(100d); - - ArrayList res = new ArrayList(); - - for (Gauge gauge: gauges) { - String name = gauge.getName(); - double [][] values = map.get(name); - if (values == null) { - continue; - } - double [] kms = new double[values[0].length]; - Arrays.fill(kms, gauge.getStation().doubleValue()); - res.add(new WQKms(kms, values[0], values[1], name)); - } - - return new CalculationResult( - res.toArray(new WQKms[res.size()]), - new Calculation()); - } - - - /** * Returns the data that is computed by a discharge curve computation. * * @return the data computed by a discharge curve computation. diff -r 7311d0336600 -r ac9a03ed32c1 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeFacet.java Tue May 22 19:42:54 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeFacet.java Tue May 22 19:51:05 2012 +0000 @@ -12,6 +12,7 @@ /** + * Access Discharge Curve of a gauge. */ public class GaugeDischargeFacet extends DataFacet { @@ -43,7 +44,6 @@ @Override public Facet deepCopy() { - // TODO why waterlevel? GaugeDischargeFacet copy = new GaugeDischargeFacet(); copy.set(this); copy.type = type; @@ -60,10 +60,13 @@ index + " / stateId: " + stateId); } + if (stateId == null) { + logger.error("GaugeDischargeFacet.getData: stateId is null."); + } FLYSArtifact flys = (FLYSArtifact) artifact; CalculationResult res = (CalculationResult) - flys.compute(context, hash, stateId, type, false); + flys.compute(context, hash, stateId, type, false); WQKms[] discharge = (WQKms[]) res.getData();