comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedHeightAccess.java @ 3230:b888c5eb65b3

Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact. flys-artifacts/trunk@4859 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 03 Jul 2012 12:13:36 +0000
parents
children cdbc457e23e2
comparison
equal deleted inserted replaced
3229:ad9640211db3 3230:b888c5eb65b3
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 import de.intevation.flys.artifacts.states.SoundingsSelect;
9
10
11 public class BedHeightAccess extends Access {
12
13 private static final Logger logger = Logger.getLogger(BedHeightAccess.class);
14
15
16 private int[] singleIDs;
17 private int[] epochIDs;
18
19 private Double lowerKM;
20 private Double upperKM;
21
22
23 public BedHeightAccess(FLYSArtifact artifact) {
24 super(artifact);
25 }
26
27
28 public Double getLowerKM() {
29 if (lowerKM == null) {
30 lowerKM = getDouble("ld_from");
31 }
32
33 return lowerKM;
34 }
35
36
37 public Double getUpperKM() {
38 if (upperKM == null) {
39 upperKM = getDouble("ld_to");
40 }
41
42 return upperKM;
43 }
44
45
46 public int[] getBedHeightSingleIDs() {
47 if (singleIDs == null) {
48 String data = getString("soundings");
49
50 if (data == null) {
51 logger.warn("No 'soundings' parameter specified!");
52 return null;
53 }
54
55 String[] parts = data.split(";");
56
57 TIntArrayList ids = new TIntArrayList();
58
59 for (String part: parts) {
60 if (part.indexOf(SoundingsSelect.PREFIX_SINGLE) >= 0) {
61 String tmp = part.replace(SoundingsSelect.PREFIX_SINGLE, "");
62
63 try {
64 ids.add(Integer.parseInt(tmp));
65 }
66 catch (NumberFormatException nfe) {
67 logger.warn("Cannot parse int from string: '" + tmp + "'");
68 }
69 }
70 }
71
72 singleIDs = ids.toNativeArray();
73 }
74
75 return singleIDs;
76 }
77
78
79 public int[] getBedHeightEpochIDs() {
80 if (epochIDs == null) {
81 String data = getString("soundings");
82
83 if (data == null) {
84 logger.warn("No 'soundings' parameter specified!");
85 return null;
86 }
87
88 String[] parts = data.split(";");
89
90 TIntArrayList ids = new TIntArrayList();
91
92 for (String part: parts) {
93 if (part.indexOf(SoundingsSelect.PREFIX_EPOCH) >= 0) {
94 String tmp = part.replace(SoundingsSelect.PREFIX_EPOCH, "");
95
96 try {
97 ids.add(Integer.parseInt(tmp));
98 }
99 catch (NumberFormatException nfe) {
100 logger.warn("Cannot parse int from string: '" + tmp + "'");
101 }
102 }
103 }
104
105 epochIDs = ids.toNativeArray();
106 }
107
108 return epochIDs;
109 }
110 }

http://dive4elements.wald.intevation.org