Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/SedimentLoadAccess.java @ 5366:8605ceae8476
winfo.xml: Little formatting, adding mainvalues to compat list.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 22 Mar 2013 09:05:11 +0100 |
parents | a3dc382bc1ca |
children |
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 |
4826
a3dc382bc1ca
BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4516
diff
changeset
|
7 import de.intevation.artifacts.CallContext; |
a3dc382bc1ca
BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4516
diff
changeset
|
8 |
4371
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.artifacts.FLYSArtifact; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 public class SedimentLoadAccess |
4826
a3dc382bc1ca
BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4516
diff
changeset
|
13 extends RangeAccess |
4371
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 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
|
16 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 private int[] singleIDs; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 private int[] epochIDs; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 private String time; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 private String unit; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 |
4826
a3dc382bc1ca
BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4516
diff
changeset
|
23 public SedimentLoadAccess(FLYSArtifact artifact, CallContext context) { |
a3dc382bc1ca
BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4516
diff
changeset
|
24 super(artifact, context); |
4371
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 } |
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 public Double getLowerKM() { |
4826
a3dc382bc1ca
BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4516
diff
changeset
|
28 // TODO update callers |
a3dc382bc1ca
BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4516
diff
changeset
|
29 return getFrom(); |
4371
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 } |
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 public Double getUpperKM() { |
4826
a3dc382bc1ca
BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4516
diff
changeset
|
33 // TODO update callers |
a3dc382bc1ca
BedHeightAccess, FlowVelocityAccess, SedimentLoadAccess: Inherit from RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4516
diff
changeset
|
34 return getTo(); |
4371
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 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 public String getYearEpoch() { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 if (time == null) { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 time = getString("ye_select"); |
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 time; |
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 int[] getPeriod() { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 if (getYearEpoch().equals("year") ) { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 Integer start = getInteger("start"); |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 Integer end = getInteger("end"); |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 if (start == null || end == null) { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 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
|
50 return null; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 } |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 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
|
54 } |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 return null; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 } |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 public int[][] getEpochs() { |
4516
de4832ffde2a
Fix: Handle epochs like official epochs to get a year range.
Raimund Renkert <rrenkert@intevation.de>
parents:
4371
diff
changeset
|
59 if (getYearEpoch().equals("epoch") || |
de4832ffde2a
Fix: Handle epochs like official epochs to get a year range.
Raimund Renkert <rrenkert@intevation.de>
parents:
4371
diff
changeset
|
60 getYearEpoch().equals("off_epoch") |
de4832ffde2a
Fix: Handle epochs like official epochs to get a year range.
Raimund Renkert <rrenkert@intevation.de>
parents:
4371
diff
changeset
|
61 ) { |
4371
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 String data = getString("epochs"); |
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 if (data == null) { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 logger.warn("No 'epochs' parameter specified!"); |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 return null; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 } |
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 String[] parts = data.split(";"); |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
71 int[][] list = new int[parts.length][]; |
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 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
|
74 String[] values = parts[i].split(","); |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 TIntArrayList ints = new TIntArrayList(); |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 try { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
77 ints.add(Integer.parseInt(values[0])); |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 ints.add(Integer.parseInt(values[1])); |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 list[i] = ints.toNativeArray(); |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 } |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 catch (NumberFormatException nfe) { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 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
|
83 } |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 } |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
85 return list; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 } |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 return null; |
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 |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
91 public String getUnit () { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
92 if (unit == null) { |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
93 unit = getString("unit"); |
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 return unit; |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
96 } |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
97 } |
26afee1b8959
Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
98 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |