annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileVectorOutputState.java @ 1115:f953c9a559d8

Added license file and license headers. gnv-artifacts/trunk@1260 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Nov 2010 17:46:55 +0000
parents 14370090a018
children
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1083
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1083
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1083
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1083
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1083
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1083
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1083
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1083
diff changeset
8
1071
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.state.profile.vertical;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import au.com.bytecode.opencsv.CSVWriter;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.artifacts.CallContext;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.gnv.artifacts.cache.CacheFactory;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import de.intevation.gnv.chart.Chart;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import de.intevation.gnv.chart.ChartLabels;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.gnv.chart.VerticalProfileVectorChart;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import de.intevation.gnv.exports.DefaultExport;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import de.intevation.gnv.exports.DefaultProfile;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import de.intevation.gnv.exports.Export;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import de.intevation.gnv.exports.Export.Profile;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.gnv.exports.SimpleOdvDataCollector;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 import de.intevation.gnv.geobackend.base.Result;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 import de.intevation.gnv.utils.VectorDataProcessor;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
1083
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
31 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
1071
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 import de.intevation.gnv.state.exception.StateException;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
1079
1657ee3ac054 Added statistics for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
34 import de.intevation.gnv.statistics.Statistics;
1657ee3ac054 Added statistics for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
35 import de.intevation.gnv.statistics.VerticalProfileVectorStatistics;
1657ee3ac054 Added statistics for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
36
1071
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 import java.io.IOException;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 import java.io.OutputStream;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 import java.util.Collection;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 import java.util.Locale;
1083
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
42 import java.util.Map;
1071
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 import net.sf.ehcache.Cache;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 import org.apache.log4j.Logger;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 import org.jfree.chart.ChartTheme;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 /**
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 */
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 public class VerticalProfileVectorOutputState
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 extends VerticalProfileOutputState
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 private static Logger logger =
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 Logger.getLogger(VerticalProfileVectorOutputState.class);
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 public static final String[] RESULT_COLUMNS = {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 "YORDINATE", "XORDINATE",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 "GROUP1", "GROUP2", "GROUP3",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 "DATAID", "FEATUREID", "TIMESERIESID",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 "SERIES"
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 };
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 public static final String[] ODV_COLUMN_HEADERS = {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 "Cruise",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 "Station",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 "Type",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 "yyyy-mm-dd hh:mm",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 "Lon (°E)",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 "Lat (°N)",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 "Bot. Depth [m]",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 "Depth [m]",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 "XComponent",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 "YComponent",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 "ZComponent",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 "Speed",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 "Direction",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 "QF"
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 };
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 public static final String[] ODV_PROFILE_NAMES = {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 "CRUISE",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 "STATION",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 "TYPE",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 "TIMEVALUE",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 "SHAPE",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 "BOTDEPTH",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 "DEPTH",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 "XCOMPONENT",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 "YCOMPONENT",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 "ZCOMPONENT",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 "SPEED",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 "QF",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 "DIRECTION",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 "QF"};
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 @Override
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 protected Object getChartResult(String uuid, CallContext callContext) {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 logger.debug("Fetch chart data for vertical profile with vector data.");
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 CacheFactory factory = CacheFactory.getInstance();
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 if (factory.isInitialized()) {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 // we use a cache
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 logger.info("Using cache.");
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 Cache cache = factory.getCache();
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 String key = "chart_" + getHash();
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 net.sf.ehcache.Element value = cache.get(key);
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 if (value != null) {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 logger.debug("Found element in cache.");
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 return value.getObjectValue();
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 }
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 else {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 logger.debug("Element not in cache, we ask the database");
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 Collection<Result> res = (Collection<Result>)getData(queryID);
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 logger.debug("Got " + res.size() + " elements from db.");
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 res = VectorDataProcessor.process(res, RESULT_COLUMNS);
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 cache.put(new net.sf.ehcache.Element(key, res));
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 return res;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 }
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 }
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 else {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 // we don't use a cache, so we have to query the database every
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 // single time
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140 logger.info("Not using a cache.");
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 return VectorDataProcessor.process(
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 getData(queryID), RESULT_COLUMNS);
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 }
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 }
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 @Override
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 protected Chart getChart(
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 ChartLabels chartLables,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 ChartTheme theme,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 Collection parameters,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 Collection measurements,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 Collection dates,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 Object result,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 Locale locale,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 String uuid,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 boolean linesVisible,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 boolean shapesVisible,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 CallContext callContext
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 ) {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 Chart chart = new VerticalProfileVectorChart(
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 chartLables,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 theme,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 parameters,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 measurements,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 dates,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 (Collection)result,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 timeGapDefinitions,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 locale,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 linesVisible,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 shapesVisible
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 );
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 chart.generateChart();
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 return chart;
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 }
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 @Override
1083
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
180 protected Chart[] getHistograms(
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
181 String uuid,
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
182 CallContext callContext,
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
183 Collection<KeyValueDescibeData> parameters,
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
184 Collection<KeyValueDescibeData> measurements,
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
185 Collection<KeyValueDescibeData> dates,
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
186 Map requestParameter
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
187 ) {
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
188 Collection results = (Collection) getChartResult(uuid, callContext);
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
189 ChartTheme theme = createStyle(callContext);
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
190
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
191 return VectorDataProcessor.getHistograms(
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
192 uuid, callContext, results, theme, requestParameter);
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
193 }
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
194
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
195
14370090a018 Enabled histogram creation for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1079
diff changeset
196 @Override
1071
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 protected void createODV(
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 OutputStream outputStream, Collection result, String uuid)
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 throws IOException, StateException
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 logger.info("Start exporting " + result.size() + " items to odv.");
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 Export export = new DefaultExport(
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 new SimpleOdvDataCollector(ODV_PROFILE_NAMES));
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 Profile profile = new DefaultProfile(
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 ODV_COLUMN_HEADERS,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 '\t',
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 CSVWriter.NO_QUOTE_CHARACTER,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 CSVWriter.NO_ESCAPE_CHARACTER,
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 "ODV",
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 "ISO-8859-1");
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 export.create(profile, outputStream, result);
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 }
1079
1657ee3ac054 Added statistics for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
215
1657ee3ac054 Added statistics for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
216
1657ee3ac054 Added statistics for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
217 protected Statistics getStatisticsGenerator() {
1657ee3ac054 Added statistics for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
218 return new VerticalProfileVectorStatistics();
1657ee3ac054 Added statistics for vectorial verticalprofiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
219 }
1071
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 }
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org