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