# HG changeset patch # User Ingo Weinzierl # Date 1306240665 0 # Node ID 51b69bca45602f5356b35bece963a3856fd535ad # Parent 833290f16f097bde407014e2b339559b5bc1caed ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation. flys-artifacts/trunk@1993 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 833290f16f09 -r 51b69bca4560 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue May 24 11:27:37 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue May 24 12:37:45 2011 +0000 @@ -1,3 +1,16 @@ +2011-05-23 Ingo Weinzierl + + ISSUE-85 (part III/III) + + * src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java: + Added a static function that returns the kilometer values (double[]) + from locations input (whitespace separated double values). + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Adapted + the getKms() method. It will now return a computed array of kilometers + if we had inserted a range, or it will return the inserted kilometers if + we had inserted locations. + 2011-05-24 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java: diff -r 833290f16f09 -r 51b69bca4560 flys-artifacts/doc/conf/artifacts/winfo.xml --- a/flys-artifacts/doc/conf/artifacts/winfo.xml Tue May 24 11:27:37 2011 +0000 +++ b/flys-artifacts/doc/conf/artifacts/winfo.xml Tue May 24 12:37:45 2011 +0000 @@ -54,6 +54,8 @@ + + diff -r 833290f16f09 -r 51b69bca4560 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Tue May 24 11:27:37 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Tue May 24 12:37:45 2011 +0000 @@ -39,6 +39,7 @@ import de.intevation.flys.artifacts.model.DischargeTables; import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.artifacts.states.DefaultState; +import de.intevation.flys.artifacts.states.LocationDistanceSelect; /** @@ -475,7 +476,7 @@ String value = (String) mode.getValue(); - return value.equals("range"); + return value.equals("distance"); } @@ -593,8 +594,14 @@ * @return the selected kms. */ public double[] getKms() { - double[] distance = getDistance(); - return getKms(distance); + if (isRange()) { + double[] distance = getDistance(); + return getKms(distance); + + } + else { + return LocationDistanceSelect.getLocations(this); + } } diff -r 833290f16f09 -r 51b69bca4560 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java Tue May 24 11:27:37 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java Tue May 24 12:37:45 2011 +0000 @@ -1,9 +1,14 @@ package de.intevation.flys.artifacts.states; +import java.util.ArrayList; +import java.util.List; + import org.apache.log4j.Logger; import org.w3c.dom.Element; +import gnu.trove.TDoubleArrayList; + import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; @@ -261,5 +266,30 @@ return minmax; } + + + public static double[] getLocations(FLYSArtifact flys) { + StateData data = flys.getData("ld_locations"); + String value = data != null ? (String) data.getValue() : null; + + if (value == null || value.length() == 0) { + logger.warn("No location data given."); + return null; + } + + String[] splitted = value.split(" "); + TDoubleArrayList values = new TDoubleArrayList(); + + for (String split: splitted) { + try { + values.add(Double.valueOf(split)); + } + catch (NumberFormatException nfe) { + logger.warn(nfe, nfe); + } + } + + return values.toNativeArray(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :