comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileOutputState.java @ 368:6491000407dd

Added column labels for csv export of timeseries, vertical and horizontal profiles. gnv-artifacts/trunk@444 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Dec 2009 10:20:05 +0000
parents 2f7a28f211c7
children bed9735adf84
comparison
equal deleted inserted replaced
367:8124e5de18b6 368:6491000407dd
1 /** 1 /**
2 * 2 *
3 */ 3 */
4 package de.intevation.gnv.state.profile.vertical; 4 package de.intevation.gnv.state.profile.vertical;
5 5
6 import java.io.IOException;
7 import java.io.OutputStream;
8 import java.io.UnsupportedEncodingException;
6 import java.util.Collection; 9 import java.util.Collection;
10 import java.util.Iterator;
7 import java.util.Locale; 11 import java.util.Locale;
8 12
9 import org.apache.log4j.Logger; 13 import org.apache.log4j.Logger;
10 14
11 import org.jfree.chart.ChartTheme; 15 import org.jfree.chart.ChartTheme;
12 16
13 import de.intevation.gnv.chart.Chart; 17 import de.intevation.gnv.chart.Chart;
14 import de.intevation.gnv.chart.ChartLabels; 18 import de.intevation.gnv.chart.ChartLabels;
15 import de.intevation.gnv.chart.VerticalProfileChart; 19 import de.intevation.gnv.chart.VerticalProfileChart;
20 import de.intevation.gnv.exports.DefaultExport;
21 import de.intevation.gnv.exports.DefaultDataCollector;
22 import de.intevation.gnv.exports.DefaultProfile;
23 import de.intevation.gnv.exports.Export.Profile;
24 import de.intevation.gnv.geobackend.base.Result;
25 import de.intevation.gnv.state.exception.StateException;
16 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; 26 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState;
17 import de.intevation.gnv.statistics.Statistics; 27 import de.intevation.gnv.statistics.Statistics;
18 import de.intevation.gnv.statistics.VerticalProfileStatistics; 28 import de.intevation.gnv.statistics.VerticalProfileStatistics;
19 29
20 /** 30 /**
21 * @author Tim Englich <tim.englich@intevation.de> 31 * @author Tim Englich <tim.englich@intevation.de>
22 * 32 *
23 */ 33 */
24 public class VerticalProfileOutputState extends TimeSeriesOutputState { 34 public class VerticalProfileOutputState extends TimeSeriesOutputState {
35
36 public static final String [] VERTICAL_PROFILE_COLUMNS = {
37 "XORDINATE", // not quite sure if this is depth
38 "YORDINATE",
39 "GROUP1"
40 // "GROUP2",
41 // "GROUP3"
42 };
43
44
45 public static final String [] VERTICAL_MESH_CSV_COLUMN_LABEL = {
46 "CentralDepth",
47 "Value",
48 "ParameterID"
49 // TODO "FeatureID",
50 // TODO "MeshID"
51 };
52
53
54 public static final String [] VERTICAL_TIMESERIES_CSV_COLUMN_LABEL = {
55 "Depth",
56 "Value",
57 "ParameterID"
58 // TODO FeatureID missing
59 // TODO TimeseriesID missing
60 };
61
62
63 public static final String [] VERTICAL_MEASUREMENT_CSV_COLUMN_LABEL = {
64 "Depth",
65 "Value",
66 "ParameterID"
67 // TODO FeatureID missing
68 // TODO SeriesID missing
69 };
70
71
25 /** 72 /**
26 * The UID of this class 73 * The UID of this class
27 */ 74 */
28 private static final long serialVersionUID = 4401516087492028840L; 75 private static final long serialVersionUID = 4401516087492028840L;
29 76
36 public VerticalProfileOutputState() { 83 public VerticalProfileOutputState() {
37 super(); 84 super();
38 super.domainLable = "chart.verticalprofile.title.xaxis"; 85 super.domainLable = "chart.verticalprofile.title.xaxis";
39 } 86 }
40 87
41 88
42 @Override 89 @Override
43 protected Chart getChart( 90 protected Chart getChart(
44 ChartLabels chartLables, 91 ChartLabels chartLables,
45 ChartTheme theme, 92 ChartTheme theme,
46 Collection parameters, 93 Collection parameters,
84 131
85 return chart; 132 return chart;
86 } 133 }
87 134
88 135
136 @Override
137 protected void createCSV(OutputStream out, Collection<Result> results)
138 throws UnsupportedEncodingException, IOException, StateException
139 {
140 Iterator iter = results.iterator();
141 Result res = iter.hasNext() ? (Result) iter.next() : null;
142
143 if (res == null)
144 return;
145
146 Profile profile = null;
147 int dataid = res.getInteger("DATAID").intValue();
148
149 // on meshes
150 if (dataid == 2) {
151 profile = new DefaultProfile(
152 VERTICAL_MESH_CSV_COLUMN_LABEL,
153 ',',
154 '"',
155 '"',
156 "CSV",
157 "ISO-8859-1");
158 }
159
160 // on timeseries
161 else if (dataid == 1) {
162 profile = new DefaultProfile(
163 VERTICAL_TIMESERIES_CSV_COLUMN_LABEL,
164 ',',
165 '"',
166 '"',
167 "CSV",
168 "ISO-8859-1");
169 }
170
171 // on measurements
172 else {
173 profile = new DefaultProfile(
174 VERTICAL_MEASUREMENT_CSV_COLUMN_LABEL,
175 ',',
176 '"',
177 '"',
178 "CSV",
179 "ISO-8859-1");
180 }
181
182 DefaultExport export = new DefaultExport(
183 new DefaultDataCollector(VERTICAL_PROFILE_COLUMNS));
184 export.create(profile, out, results);
185 }
186
187
89 protected String createChartSubtitle(Locale locale, String uuid) { 188 protected String createChartSubtitle(Locale locale, String uuid) {
90 return getSelectedFeatureName(uuid); 189 return getSelectedFeatureName(uuid);
91 } 190 }
92 191
93 192

http://dive4elements.wald.intevation.org