Mercurial > dive4elements > gnv-client
diff 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 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileOutputState.java Wed Dec 16 23:07:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileOutputState.java Thu Dec 17 10:20:05 2009 +0000 @@ -3,7 +3,11 @@ */ package de.intevation.gnv.state.profile.vertical; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; import java.util.Collection; +import java.util.Iterator; import java.util.Locale; import org.apache.log4j.Logger; @@ -13,6 +17,12 @@ import de.intevation.gnv.chart.Chart; import de.intevation.gnv.chart.ChartLabels; import de.intevation.gnv.chart.VerticalProfileChart; +import de.intevation.gnv.exports.DefaultExport; +import de.intevation.gnv.exports.DefaultDataCollector; +import de.intevation.gnv.exports.DefaultProfile; +import de.intevation.gnv.exports.Export.Profile; +import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.state.exception.StateException; import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; import de.intevation.gnv.statistics.Statistics; import de.intevation.gnv.statistics.VerticalProfileStatistics; @@ -22,6 +32,43 @@ * */ public class VerticalProfileOutputState extends TimeSeriesOutputState { + + public static final String [] VERTICAL_PROFILE_COLUMNS = { + "XORDINATE", // not quite sure if this is depth + "YORDINATE", + "GROUP1" + // "GROUP2", + // "GROUP3" + }; + + + public static final String [] VERTICAL_MESH_CSV_COLUMN_LABEL = { + "CentralDepth", + "Value", + "ParameterID" + // TODO "FeatureID", + // TODO "MeshID" + }; + + + public static final String [] VERTICAL_TIMESERIES_CSV_COLUMN_LABEL = { + "Depth", + "Value", + "ParameterID" + // TODO FeatureID missing + // TODO TimeseriesID missing + }; + + + public static final String [] VERTICAL_MEASUREMENT_CSV_COLUMN_LABEL = { + "Depth", + "Value", + "ParameterID" + // TODO FeatureID missing + // TODO SeriesID missing + }; + + /** * The UID of this class */ @@ -38,7 +85,7 @@ super.domainLable = "chart.verticalprofile.title.xaxis"; } - + @Override protected Chart getChart( ChartLabels chartLables, @@ -86,6 +133,58 @@ } + @Override + protected void createCSV(OutputStream out, Collection<Result> results) + throws UnsupportedEncodingException, IOException, StateException + { + Iterator iter = results.iterator(); + Result res = iter.hasNext() ? (Result) iter.next() : null; + + if (res == null) + return; + + Profile profile = null; + int dataid = res.getInteger("DATAID").intValue(); + + // on meshes + if (dataid == 2) { + profile = new DefaultProfile( + VERTICAL_MESH_CSV_COLUMN_LABEL, + ',', + '"', + '"', + "CSV", + "ISO-8859-1"); + } + + // on timeseries + else if (dataid == 1) { + profile = new DefaultProfile( + VERTICAL_TIMESERIES_CSV_COLUMN_LABEL, + ',', + '"', + '"', + "CSV", + "ISO-8859-1"); + } + + // on measurements + else { + profile = new DefaultProfile( + VERTICAL_MEASUREMENT_CSV_COLUMN_LABEL, + ',', + '"', + '"', + "CSV", + "ISO-8859-1"); + } + + DefaultExport export = new DefaultExport( + new DefaultDataCollector(VERTICAL_PROFILE_COLUMNS)); + export.create(profile, out, results); + } + + protected String createChartSubtitle(Locale locale, String uuid) { return getSelectedFeatureName(uuid); }