comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/SedimentLoadAccess.java @ 4371:26afee1b8959

Added access object for artifact containing sediment load parameters.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 02 Nov 2012 14:49:20 +0100
parents
children de4832ffde2a
comparison
equal deleted inserted replaced
4370:6a65e7ef43c0 4371:26afee1b8959
1 package de.intevation.flys.artifacts.access;
2
3 import gnu.trove.TIntArrayList;
4
5 import org.apache.log4j.Logger;
6
7 import de.intevation.flys.artifacts.FLYSArtifact;
8
9
10 public class SedimentLoadAccess
11 extends RiverAccess
12 {
13 private static final Logger logger = Logger.getLogger(BedHeightAccess.class);
14
15 private int[] singleIDs;
16 private int[] epochIDs;
17
18 private Double lowerKM;
19 private Double upperKM;
20
21 private String time;
22 private String unit;
23
24 public SedimentLoadAccess(FLYSArtifact artifact) {
25 super(artifact);
26 }
27
28 public Double getLowerKM() {
29 if (lowerKM == null) {
30 lowerKM = getDouble("ld_from");
31 }
32
33 return lowerKM;
34 }
35
36 public Double getUpperKM() {
37 if (upperKM == null) {
38 upperKM = getDouble("ld_to");
39 }
40
41 return upperKM;
42 }
43
44 public String getYearEpoch() {
45 if (time == null) {
46 time = getString("ye_select");
47 }
48 return time;
49 }
50
51 public int[] getPeriod() {
52 if (getYearEpoch().equals("year") ) {
53 Integer start = getInteger("start");
54 Integer end = getInteger("end");
55 if (start == null || end == null) {
56 logger.warn("No 'start' or 'end' parameter specified!");
57 return null;
58 }
59
60 return new int[]{start.intValue(), end.intValue()};
61 }
62 return null;
63 }
64
65 public int[][] getEpochs() {
66 if (getYearEpoch().equals("epoch")) {
67 String data = getString("epochs");
68
69 if (data == null) {
70 logger.warn("No 'epochs' parameter specified!");
71 return null;
72 }
73
74 String[] parts = data.split(";");
75
76 int[][] list = new int[parts.length][];
77
78 for (int i = 0; i < parts.length; i++) {
79 String[] values = parts[i].split(",");
80 TIntArrayList ints = new TIntArrayList();
81 try {
82 ints.add(Integer.parseInt(values[0]));
83 ints.add(Integer.parseInt(values[1]));
84 list[i] = ints.toNativeArray();
85 }
86 catch (NumberFormatException nfe) {
87 logger.warn("Cannot parse int from string: '" + values + "'");
88 }
89 }
90 return list;
91 }
92
93 return null;
94 }
95
96 public String getUnit () {
97 if (unit == null) {
98 unit = getString("unit");
99 }
100 return unit;
101 }
102 }
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org