annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/SedimentLoadAccess.java @ 4516:de4832ffde2a

Fix: Handle epochs like official epochs to get a year range.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 14 Nov 2012 17:04:01 +0100
parents 26afee1b8959
children a3dc382bc1ca
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() {
4516
de4832ffde2a Fix: Handle epochs like official epochs to get a year range.
Raimund Renkert <rrenkert@intevation.de>
parents: 4371
diff changeset
66 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
67 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
68 ) {
4371
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 String data = getString("epochs");
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 if (data == null) {
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 logger.warn("No 'epochs' parameter specified!");
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 return null;
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 }
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 String[] parts = data.split(";");
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 int[][] list = new int[parts.length][];
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80 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
81 String[] values = parts[i].split(",");
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82 TIntArrayList ints = new TIntArrayList();
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 try {
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 ints.add(Integer.parseInt(values[0]));
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 ints.add(Integer.parseInt(values[1]));
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 list[i] = ints.toNativeArray();
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 catch (NumberFormatException nfe) {
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 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
90 }
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 return list;
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 }
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 null;
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 public String getUnit () {
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 if (unit == null) {
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 unit = getString("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 return unit;
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 }
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 }
26afee1b8959 Added access object for artifact containing sediment load parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org