comparison 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
comparison
equal deleted inserted replaced
8531:3e6d4bd1c06e 8532:73a4c3c202e5
23 private String time; 23 private String time;
24 private String unit; 24 private String unit;
25 25
26 private int [][] epochs; 26 private int [][] epochs;
27 27
28 private int [] period; 28 private int [] years;
29 29
30 private Integer sqTiId; 30 private Integer sqTiId;
31 31
32 public SedimentLoadAccess(D4EArtifact artifact) { 32 public SedimentLoadAccess(D4EArtifact artifact) {
33 super(artifact); 33 super(artifact);
34 years = null;
34 } 35 }
35 36
36 public Double getLowerKM() { 37 public Double getLowerKM() {
37 // TODO update callers 38 // TODO update callers
38 return getFrom(); 39 return getFrom();
48 time = getString("ye_select"); 49 time = getString("ye_select");
49 } 50 }
50 return time; 51 return time;
51 } 52 }
52 53
53 /** [startyear, endyear] if its about years. */ 54 /** [year1, years2,..] if its about years. */
54 public int[] getPeriod() { 55 public int[] getYears() {
55 if (period != null) { 56 if (years != null) {
56 return period; 57 return years;
57 } 58 }
58 if (getYearEpoch().equals("year") ) { 59 if (getYearEpoch().equals("year") ) {
59 Integer start = getInteger("start"); 60 TIntArrayList ints = new TIntArrayList();
60 Integer end = getInteger("end"); 61 String yearsData = getString("years");
61 if (start == null || end == null) { 62 if (yearsData == null || yearsData.isEmpty()) {
62 log.warn("No 'start' or 'end' parameter specified!"); 63 log.warn("No years provided");
63 return null; 64 return null;
64 } 65 }
66 for (String sValue :yearsData.split(" ")) {
67 try {
68 ints.add(Integer.parseInt(sValue));
69 } catch (NumberFormatException e) {
70 /* Client should prevent this */
71 log.warn("Invalid year value: " + sValue);
72 continue;
73 }
74 }
65 75
66 period = new int[]{start.intValue(), end.intValue()}; 76 if (!ints.isEmpty()) {
67 return period; 77 ints.sort();
78 years = ints.toNativeArray();
79 }
80 return years;
68 } 81 }
69 return null; 82 return null;
70 } 83 }
71 84
72 public int[][] getEpochs() { 85 public int[][] getEpochs() {

http://dive4elements.wald.intevation.org