Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.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/horizontal/HorizontalProfileOutputState.java Wed Dec 16 23:07:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java Thu Dec 17 10:20:05 2009 +0000 @@ -23,6 +23,10 @@ import de.intevation.gnv.chart.Chart; import de.intevation.gnv.chart.ChartLabels; import de.intevation.gnv.chart.HorizontalProfileChart; +import de.intevation.gnv.exports.DefaultExport; +import de.intevation.gnv.exports.ShapeDataCollector; +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.describedata.KeyValueDescibeData; import de.intevation.gnv.state.exception.StateException; @@ -30,17 +34,37 @@ import de.intevation.gnv.statistics.HorizontalProfileStatistics; import de.intevation.gnv.statistics.Statistics; -import de.intevation.gnv.exports.DefaultExport; -import de.intevation.gnv.exports.ShapeDataCollector; -import de.intevation.gnv.exports.DefaultProfile; -import de.intevation.gnv.exports.Export.Profile; - /** * @author Tim Englich <tim.englich@intevation.de> * */ -public class HorizontalProfileOutputState extends - TimeSeriesOutputState { +public class HorizontalProfileOutputState +extends TimeSeriesOutputState +{ + public static final String [] HORIZONTAL_PROFILE_COLUMNS = { + "SHAPE", + "YORDINATE", + "GROUP1" + // "GROUP2", + }; + + + public static final String [] HORIZONTAL_MESH_CSV_COLUMN_LABEL = { + "Longitude", + "Latitude", + "Value", + "ParameterID", + //"MeshID" + }; + + + public static final String [] HORIZONTAL_MEASUREMENT_CSV_COLUMN_LABEL = { + "Longitude", + "Latitude", + "Value", + "ParameterID", + //"SurveyID" + }; /** * The UID of this class */ @@ -145,18 +169,46 @@ return new HorizontalProfileStatistics(); } + @Override - protected void createCSV(OutputStream outputStream, - Collection<Result> chartResult) - throws UnsupportedEncodingException, - IOException, - StateException { - - log.debug("createCSV for HorizontalProfileOutputState."); + protected void createCSV(OutputStream out, Collection<Result> results) + throws UnsupportedEncodingException, IOException, StateException + { + log.debug("Create csv export for horizontal profiles."); + 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( + HORIZONTAL_MESH_CSV_COLUMN_LABEL, + ',', + '"', + '"', + "CSV", + "ISO-8859-1"); + } + + // on measurements + else { + profile = new DefaultProfile( + HORIZONTAL_MEASUREMENT_CSV_COLUMN_LABEL, + ',', + '"', + '"', + "CSV", + "ISO-8859-1"); + } + DefaultExport export = new DefaultExport( - new ShapeDataCollector(TIMESERIES_CSV_PROFILE_NAMES)); - - export.create(TIMESERIES_CSV_PROFILE, outputStream, chartResult); + new ShapeDataCollector(HORIZONTAL_PROFILE_COLUMNS)); + export.create(profile, out, results); }