Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java @ 8532:73a4c3c202e5
(issue1051) Use a list of single years in SedimentLoadYear mode
Instead of a range you can now select multiple distinct years
in the sedimentload calculation.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 11 Feb 2015 18:00:48 +0100 |
parents | b207eeb66edd |
children | 5e38e2924c07 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java Wed Feb 11 12:41:51 2015 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java Wed Feb 11 18:00:48 2015 +0100 @@ -25,12 +25,13 @@ private int [][] epochs; - private int [] period; + private int [] years; private Integer sqTiId; public SedimentLoadAccess(D4EArtifact artifact) { super(artifact); + years = null; } public Double getLowerKM() { @@ -50,21 +51,33 @@ return time; } - /** [startyear, endyear] if its about years. */ - public int[] getPeriod() { - if (period != null) { - return period; + /** [year1, years2,..] if its about years. */ + public int[] getYears() { + if (years != null) { + return years; } if (getYearEpoch().equals("year") ) { - Integer start = getInteger("start"); - Integer end = getInteger("end"); - if (start == null || end == null) { - log.warn("No 'start' or 'end' parameter specified!"); + TIntArrayList ints = new TIntArrayList(); + String yearsData = getString("years"); + if (yearsData == null || yearsData.isEmpty()) { + log.warn("No years provided"); return null; } + for (String sValue :yearsData.split(" ")) { + try { + ints.add(Integer.parseInt(sValue)); + } catch (NumberFormatException e) { + /* Client should prevent this */ + log.warn("Invalid year value: " + sValue); + continue; + } + } - period = new int[]{start.intValue(), end.intValue()}; - return period; + if (!ints.isEmpty()) { + ints.sort(); + years = ints.toNativeArray(); + } + return years; } return null; }