Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/MINFOArtifact.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 | 2f922be407ea |
children | a66df8e8d3df |
comparison
equal
deleted
inserted
replaced
3229:ad9640211db3 | 3230:b888c5eb65b3 |
---|---|
1 package de.intevation.flys.artifacts; | 1 package de.intevation.flys.artifacts; |
2 | 2 |
3 import de.intevation.flys.artifacts.model.FacetTypes; | 3 import de.intevation.flys.artifacts.model.FacetTypes; |
4 | |
5 import de.intevation.flys.artifacts.states.SoundingsSelect; | |
6 | |
7 import de.intevation.flys.utils.FLYSUtils; | |
8 | |
9 import gnu.trove.TIntArrayList; | |
10 | |
11 import org.apache.log4j.Logger; | |
12 | 4 |
13 /** | 5 /** |
14 * The default MINFO artifact. | 6 * The default MINFO artifact. |
15 * | 7 * |
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 8 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
17 */ | 9 */ |
18 public class MINFOArtifact | 10 public class MINFOArtifact |
19 extends FLYSArtifact | 11 extends FLYSArtifact |
20 implements FacetTypes { | 12 implements FacetTypes { |
21 | 13 |
22 /** The logger for this class. */ | |
23 private static Logger logger = Logger.getLogger(MINFOArtifact.class); | |
24 | |
25 /** The name of the artifact. */ | 14 /** The name of the artifact. */ |
26 public static final String ARTIFACT_NAME = "minfo"; | 15 public static final String ARTIFACT_NAME = "minfo"; |
27 | |
28 /** XPath */ | |
29 public static final String XPATH_STATIC_UI ="/art:result/art:ui/art:static"; | |
30 | 16 |
31 | 17 |
32 /** | 18 /** |
33 * The default constructor. | 19 * The default constructor. |
34 */ | 20 */ |
42 */ | 28 */ |
43 @Override | 29 @Override |
44 public String getName() { | 30 public String getName() { |
45 return ARTIFACT_NAME; | 31 return ARTIFACT_NAME; |
46 } | 32 } |
47 | |
48 public int[] getMainChannels() { | |
49 String data = getDataAsString("main.channel"); | |
50 | |
51 if (data == null) { | |
52 logger.warn("No 'main.channel' parameter specified!"); | |
53 return null; | |
54 } | |
55 | |
56 return FLYSUtils.intArrayFromString(data); | |
57 } | |
58 | |
59 | |
60 public int[] getTotalChannels() { | |
61 String data = getDataAsString("total.channel"); | |
62 | |
63 if (data == null) { | |
64 logger.warn("No 'total.channel' parameter specified!"); | |
65 return null; | |
66 } | |
67 | |
68 return FLYSUtils.intArrayFromString(data); | |
69 } | |
70 | |
71 | |
72 public int[] getBedHeightSingleIDs() { | |
73 String data = getDataAsString("soundings"); | |
74 | |
75 if (data == null) { | |
76 logger.warn("No 'soundings' parameter specified!"); | |
77 return null; | |
78 } | |
79 | |
80 String[] parts = data.split(";"); | |
81 | |
82 TIntArrayList ids = new TIntArrayList(); | |
83 | |
84 for (String part: parts) { | |
85 if (part.indexOf(SoundingsSelect.PREFIX_SINGLE) >= 0) { | |
86 String tmp = part.replace(SoundingsSelect.PREFIX_SINGLE, ""); | |
87 | |
88 try { | |
89 ids.add(Integer.parseInt(tmp)); | |
90 } | |
91 catch (NumberFormatException nfe) { | |
92 logger.warn("Cannot parse int from string: '" + tmp + "'"); | |
93 } | |
94 } | |
95 } | |
96 | |
97 return ids.toNativeArray(); | |
98 } | |
99 | |
100 | |
101 public int[] getBedHeightEpochIDs() { | |
102 String data = getDataAsString("soundings"); | |
103 | |
104 if (data == null) { | |
105 logger.warn("No 'soundings' parameter specified!"); | |
106 return null; | |
107 } | |
108 | |
109 String[] parts = data.split(";"); | |
110 | |
111 TIntArrayList ids = new TIntArrayList(); | |
112 | |
113 for (String part: parts) { | |
114 if (part.indexOf(SoundingsSelect.PREFIX_EPOCH) >= 0) { | |
115 String tmp = part.replace(SoundingsSelect.PREFIX_EPOCH, ""); | |
116 | |
117 try { | |
118 ids.add(Integer.parseInt(tmp)); | |
119 } | |
120 catch (NumberFormatException nfe) { | |
121 logger.warn("Cannot parse int from string: '" + tmp + "'"); | |
122 } | |
123 } | |
124 } | |
125 | |
126 return ids.toNativeArray(); | |
127 } | |
128 } | 33 } |
129 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 34 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |