comparison artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.artifacts.access;
2
3 import gnu.trove.TIntArrayList;
4
5 import org.apache.log4j.Logger;
6
7 import org.dive4elements.artifacts.CallContext;
8
9 import org.dive4elements.river.artifacts.FLYSArtifact;
10
11
12 public class SedimentLoadAccess
13 extends RangeAccess
14 {
15 private static final Logger logger = Logger.getLogger(BedHeightAccess.class);
16
17 private int[] singleIDs;
18 private int[] epochIDs;
19
20 private String time;
21 private String unit;
22
23 public SedimentLoadAccess(FLYSArtifact artifact, CallContext context) {
24 super(artifact, context);
25 }
26
27 public Double getLowerKM() {
28 // TODO update callers
29 return getFrom();
30 }
31
32 public Double getUpperKM() {
33 // TODO update callers
34 return getTo();
35 }
36
37 public String getYearEpoch() {
38 if (time == null) {
39 time = getString("ye_select");
40 }
41 return time;
42 }
43
44 public int[] getPeriod() {
45 if (getYearEpoch().equals("year") ) {
46 Integer start = getInteger("start");
47 Integer end = getInteger("end");
48 if (start == null || end == null) {
49 logger.warn("No 'start' or 'end' parameter specified!");
50 return null;
51 }
52
53 return new int[]{start.intValue(), end.intValue()};
54 }
55 return null;
56 }
57
58 public int[][] getEpochs() {
59 if (getYearEpoch().equals("epoch") ||
60 getYearEpoch().equals("off_epoch")
61 ) {
62 String data = getString("epochs");
63
64 if (data == null) {
65 logger.warn("No 'epochs' parameter specified!");
66 return null;
67 }
68
69 String[] parts = data.split(";");
70
71 int[][] list = new int[parts.length][];
72
73 for (int i = 0; i < parts.length; i++) {
74 String[] values = parts[i].split(",");
75 TIntArrayList ints = new TIntArrayList();
76 try {
77 ints.add(Integer.parseInt(values[0]));
78 ints.add(Integer.parseInt(values[1]));
79 list[i] = ints.toNativeArray();
80 }
81 catch (NumberFormatException nfe) {
82 logger.warn("Cannot parse int from string: '" + values + "'");
83 }
84 }
85 return list;
86 }
87
88 return null;
89 }
90
91 public String getUnit () {
92 if (unit == null) {
93 unit = getString("unit");
94 }
95 return unit;
96 }
97 }
98 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org