Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/VectorDataProcessor.java @ 1071:9bb1979aabbe
Added a new output state and chart type for vertical profiles using vector data.
gnv-artifacts/trunk@1168 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 07 Jun 2010 15:00:23 +0000 |
parents | 70653c29fc1d |
children | 846b2b70b2e0 |
comparison
equal
deleted
inserted
replaced
1070:7096a2e13676 | 1071:9bb1979aabbe |
---|---|
19 */ | 19 */ |
20 public final class VectorDataProcessor { | 20 public final class VectorDataProcessor { |
21 | 21 |
22 private static Logger logger = Logger.getLogger(VectorDataProcessor.class); | 22 private static Logger logger = Logger.getLogger(VectorDataProcessor.class); |
23 | 23 |
24 public static final String[] COLUMNS = { | 24 public static Collection<Result> process( |
25 "YORDINATE", "XORDINATE", "GROUP1", "GROUP2", "GROUP3", "GAPID", "SERIES" | 25 Collection<Result> input, String[] columnNames) |
26 }; | 26 { |
27 | |
28 public static Collection<Result> process(Collection<Result> input) { | |
29 logger.info("Process vector data (" + input.size() + " items)"); | 27 logger.info("Process vector data (" + input.size() + " items)"); |
30 | 28 |
31 ResultDescriptor outDescriptor = initResultDescriptor(); | 29 ResultDescriptor outDescriptor = initResultDescriptor(columnNames); |
32 ResultDescriptor inDescriptor = null; | 30 ResultDescriptor inDescriptor = null; |
33 int[] inIndices = null; | 31 int[] inIndices = null; |
34 int columns = -1; | 32 int columns = -1; |
35 | 33 |
36 Map series = new HashMap(); | 34 Map series = new HashMap(); |
37 | 35 |
38 // for each result of the incoming result | 36 // for each result of the incoming result |
39 for (Result result: input) { | 37 for (Result result: input) { |
40 if (inDescriptor == null || inIndices == null) { | 38 if (inDescriptor == null || inIndices == null) { |
41 inDescriptor = result.getResultDescriptor(); | 39 inDescriptor = result.getResultDescriptor(); |
42 inIndices = inDescriptor.getColumnIndices(COLUMNS); | 40 inIndices = inDescriptor.getColumnIndices(columnNames); |
43 columns = inDescriptor.getColumnCount(); | 41 columns = inDescriptor.getColumnCount(); |
44 } | 42 } |
45 | 43 |
46 // for each column of the incoming result object | 44 // for each column of the incoming result object |
47 for (int i = 0; i < columns; i++) { | 45 for (int i = 0; i < columns; i++) { |
48 String name = inDescriptor.getColumnName(i); | 46 String name = inDescriptor.getColumnName(i); |
49 | 47 |
50 if (!StringUtils.contains(COLUMNS, name)) { | 48 if (!StringUtils.contains(columnNames, name)) { |
51 List list = (List) series.get(name); | 49 List list = (List) series.get(name); |
52 if (list == null) | 50 if (list == null) |
53 list = new ArrayList(); | 51 list = new ArrayList(); |
54 | 52 |
55 Result out = new DefaultResult(outDescriptor); | 53 Result out = new DefaultResult(outDescriptor); |
88 logger.info("Data processing created " + output.size() + " elements."); | 86 logger.info("Data processing created " + output.size() + " elements."); |
89 return output; | 87 return output; |
90 } | 88 } |
91 | 89 |
92 | 90 |
93 public static ResultDescriptor initResultDescriptor() { | 91 public static ResultDescriptor initResultDescriptor(String[] columnNames) { |
94 logger.debug("Init ResultDescriptor for outgoing results."); | 92 logger.debug("Init ResultDescriptor for outgoing results."); |
95 | 93 |
96 ResultDescriptor desc = new DefaultResultDescriptor(); | 94 ResultDescriptor desc = new DefaultResultDescriptor(); |
97 | 95 |
98 for (String name: COLUMNS) { | 96 for (String name: columnNames) { |
99 desc.addColumn(name, "java.lang.String"); | 97 desc.addColumn(name, "java.lang.String"); |
100 } | 98 } |
101 | 99 |
102 logger.debug("Outgoing ResultDescriptor has " + desc.getColumnCount() + | 100 logger.debug("Outgoing ResultDescriptor has " + desc.getColumnCount() + |
103 " columns"); | 101 " columns"); |