Mercurial > dive4elements > river
changeset 2600:3f1cc396d253
Issue 506.
Use a complete date for istorical dischage curves instead of a year.
flys-artifacts/trunk@4177 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 20 Mar 2012 15:08:01 +0000 |
parents | fb7975828ffa |
children | 9e8459c2e7d4 |
files | flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java |
diffstat | 4 files changed, 51 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Mar 20 13:51:39 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue Mar 20 15:08:01 2012 +0000 @@ -1,3 +1,16 @@ +2012-03-20 Raimund Renkert <raimund.renkert@intevation.de> + + Issue 506. + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: + Create the date from long values instead of the year. + + * src/main/java/de/intevation/flys/utils/FLYSUtils.java: + Added method to transform a String into an array of long values. + + * doc/conf/artifacts/winfo.xml: + changed data type from intrange to longrange. + 2012-03-20 Ingo Weinzierl <ingo@intevation.de> flys/issue544 (Historische ATs: Eingabeunterstützung W/Q)
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml Tue Mar 20 13:51:39 2012 +0000 +++ b/flys-artifacts/doc/conf/artifacts/winfo.xml Tue Mar 20 15:08:01 2012 +0000 @@ -492,7 +492,7 @@ </transition> <state id="state.winfo.historicalq.timerange" description="state.winfo.historicalq.timerange" state="de.intevation.flys.artifacts.states.GaugeTimerangeState"> - <data name="year_range" type="intrange"/> + <data name="year_range" type="longrange"/> </state> <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue Mar 20 13:51:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue Mar 20 15:08:01 2012 +0000 @@ -759,11 +759,13 @@ String rawValues = getDataAsString("historical_values"); int mode = getDataAsInteger("historical_mode"); - int[] timerange = FLYSUtils.intArrayFromString(rawTimerange); + long[] timerange = FLYSUtils.longArrayFromString(rawTimerange); double[] values = FLYSUtils.doubleArrayFromString(rawValues); - Calendar start = new GregorianCalendar(timerange[0], 0, 1); - Calendar end = new GregorianCalendar(timerange[1], 0, 1); + Calendar start = new GregorianCalendar(); + start.setTimeInMillis(timerange[0]); + Calendar end = new GregorianCalendar(); + end.setTimeInMillis(timerange[1]); Calculation6 calc = new Calculation6( mode,
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Tue Mar 20 13:51:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Tue Mar 20 15:08:01 2012 +0000 @@ -18,6 +18,7 @@ import gnu.trove.TDoubleArrayList; import gnu.trove.TIntArrayList; +import gnu.trove.TLongArrayList; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; @@ -812,6 +813,37 @@ /** + * This method transform a string into a long array. Therefore, the string + * <i>raw</i> must consist of int values separated by a <i>';'</i>. + * + * @param raw The raw long array as string separated by a ';'. + * + * @return an array of int values. + */ + public static long[] longArrayFromString(String raw) { + String[] splitted = raw != null ? raw.split(";") : null; + + if (splitted == null || splitted.length == 0) { + logger.warn("No long values found in '" + raw + "'"); + return new long[0]; + } + + TLongArrayList longs = new TLongArrayList(splitted.length); + + for (String value: splitted) { + try { + longs.add(Long.valueOf(value)); + } + catch (NumberFormatException nfe) { + logger.warn("Parsing long failed: " + nfe); + } + } + + return longs.toNativeArray(); + } + + + /** * This method transform a string into an double array. Therefore, the * string <i>raw</i> must consist of double values separated by a * <i>';'</i>.