Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/verticalcrosssection/VerticalCrossSectionOutputTransition.java @ 333:19571fd1d0e8
Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
gnv-artifacts/trunk@399 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 07 Dec 2009 10:33:31 +0000 |
parents | 22a6493e8460 |
children |
line wrap: on
line source
/** * */ package de.intevation.gnv.transition.profile.verticalcrosssection; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.util.Collection; import java.util.Iterator; import java.util.Locale; import org.apache.log4j.Logger; import au.com.bytecode.opencsv.CSVWriter; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.io.WKTReader; import de.intevation.gnv.chart.Chart; import de.intevation.gnv.chart.ChartLabels; import de.intevation.gnv.chart.ChartStyle; import de.intevation.gnv.chart.VerticalCrossSectionChartFactory; import de.intevation.gnv.chart.exception.TechnicalChartException; import de.intevation.gnv.geobackend.base.Result; import de.intevation.gnv.statistics.Statistics; import de.intevation.gnv.statistics.VerticalProfileStatistics; import de.intevation.gnv.transition.describedata.KeyValueDescibeData; import de.intevation.gnv.transition.exception.TransitionException; import de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition; /** * @author Tim Englich <tim.englich@intevation.de> * */ public class VerticalCrossSectionOutputTransition extends TimeSeriesOutputTransition { private static Logger log = Logger .getLogger(VerticalCrossSectionOutputTransition.class); /** * The UID of this Class */ private static final long serialVersionUID = 3233620652465061860L; /** * Constructor */ public VerticalCrossSectionOutputTransition() { super(); super.domainLable = "Depth [m]"; } @Override protected Chart getChart( ChartLabels chartLables, Collection parameters, Collection measurements, Collection dates, Collection result, Locale locale, String uuid, boolean linesVisible, boolean shapesVisible ) { Chart chart = null; if (CACHE_CHART) { log.info("Try to get verticalcrosssection chart from cache."); chart = (Chart) getChartFromCache(uuid); } if (chart != null) return chart; log.info("Chart not in cache yet."); log.warn("This sort of chart is not implemented yet."); /* TODO Implement a special chart for this sort of charts. chart = new VerticalProfileChart( chartLables, chartTheme, parameters, measurements, result, dates, locale ); chart.generateChart(); if (CACHE_CHART) { log.info("Put chart into cache."); purifyChart(chart, uuid); } */ return chart; } /** * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#createChart(java.io.OutputStream, * java.util.Collection, java.util.Collection, java.lang.String, * de.intevation.gnv.chart.ChartStyle, * de.intevation.gnv.chart.ChartLabels) */ /* @Override protected void createChart(OutputStream outputStream, Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements, Collection<KeyValueDescibeData> dates, ChartStyle chartStyle, ChartLabels chartLables, String uuid) throws IOException, TechnicalChartException { new VerticalCrossSectionChartFactory().createProfileChart(chartLables, chartStyle, parameters, measurements, dates, outputStream, this .getChartResult(uuid)); } */ /** * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#getStatisticsGenerator() */ @Override protected Statistics getStatisticsGenerator() { return new VerticalProfileStatistics(); } /** * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#createCSV(java.io.OutputStream, java.util.Collection) */ @Override protected void createCSV(OutputStream outputStream, Collection<Result> chartResult) throws UnsupportedEncodingException, IOException, TransitionException { if (chartResult != null) { try { CSVWriter writer = new CSVWriter(new OutputStreamWriter( outputStream, "ISO-8859-1"), ','); // USE THIS ENCODING BECAUSE OF // PROBLEMS WITH EXCEL AND UTF-8 Iterator<Result> it = chartResult.iterator(); WKTReader wktReader = new WKTReader(); while (it.hasNext()) { Result result = it.next(); int i = 0; String[] entries = new String[8]; Point p = (Point)wktReader.read(result.getString("SHAPE")); entries[i++] = ""+p.getX(); entries[i++] = ""+p.getY(); entries[i++] = result.getString("YORDINATE"); entries[i++] = result.getString("GROUP1"); entries[i++] = result.getString("GROUP2"); entries[i++] = result.getString("IPOSITION"); entries[i++] = result.getString("JPOSITION"); entries[i++] = result.getString("KPOSITION"); writer.writeNext(entries); } writer.close(); } catch (ParseException e) { log.error(e,e); throw new TransitionException( "Exception occured while parsing an Point from WKT."); } } else { log.error("No Data given for generating an CSV-File."); throw new TransitionException( "No Data given for generating an CSV-File."); } } }