Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java @ 474:ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
gnv-artifacts/trunk@540 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 14 Jan 2010 10:34:05 +0000 |
parents | 06887e2e3f7a |
children | 211cad2fb5ba |
comparison
equal
deleted
inserted
replaced
473:a6a33ef35809 | 474:ab29e4ff2fda |
---|---|
1 /** | 1 /** |
2 * | 2 * |
3 */ | 3 */ |
4 package de.intevation.gnv.state.profile.horizontalcrosssection; | 4 package de.intevation.gnv.state.profile.horizontalcrosssection; |
5 | 5 |
6 import java.io.File; | |
6 import java.io.IOException; | 7 import java.io.IOException; |
7 import java.io.OutputStream; | 8 import java.io.OutputStream; |
8 import java.io.OutputStreamWriter; | 9 import java.io.OutputStreamWriter; |
9 import java.io.UnsupportedEncodingException; | 10 import java.io.UnsupportedEncodingException; |
11 | |
10 import java.util.Arrays; | 12 import java.util.Arrays; |
11 import java.util.Collection; | 13 import java.util.Collection; |
12 import java.util.Iterator; | 14 import java.util.Iterator; |
13 import java.util.List; | 15 import java.util.List; |
14 import java.util.Locale; | 16 import java.util.Locale; |
15 | 17 |
16 import org.apache.log4j.Logger; | 18 import org.apache.log4j.Logger; |
17 | 19 |
18 import org.jfree.chart.ChartTheme; | 20 import org.jfree.chart.ChartTheme; |
21 | |
19 import org.w3c.dom.Node; | 22 import org.w3c.dom.Node; |
20 | 23 |
21 import com.vividsolutions.jts.geom.Coordinate; | 24 import com.vividsolutions.jts.geom.Coordinate; |
22 import com.vividsolutions.jts.geom.Envelope; | 25 import com.vividsolutions.jts.geom.Envelope; |
23 import com.vividsolutions.jts.geom.Polygon; | 26 import com.vividsolutions.jts.geom.Polygon; |
24 import com.vividsolutions.jts.io.ParseException; | |
25 import com.vividsolutions.jts.io.WKTReader; | |
26 | 27 |
27 import au.com.bytecode.opencsv.CSVWriter; | 28 import au.com.bytecode.opencsv.CSVWriter; |
29 | |
28 import de.intevation.gnv.artifacts.cache.CacheFactory; | 30 import de.intevation.gnv.artifacts.cache.CacheFactory; |
29 import de.intevation.gnv.artifacts.context.GNVArtifactContext; | 31 import de.intevation.gnv.artifacts.context.GNVArtifactContext; |
32 | |
30 import de.intevation.gnv.chart.Chart; | 33 import de.intevation.gnv.chart.Chart; |
31 import de.intevation.gnv.chart.ChartLabels; | 34 import de.intevation.gnv.chart.ChartLabels; |
35 | |
32 import de.intevation.gnv.geobackend.base.Result; | 36 import de.intevation.gnv.geobackend.base.Result; |
37 | |
33 import de.intevation.gnv.geobackend.base.query.QueryExecutor; | 38 import de.intevation.gnv.geobackend.base.query.QueryExecutor; |
34 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory; | 39 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory; |
35 import de.intevation.gnv.geobackend.base.query.exception.QueryException; | 40 import de.intevation.gnv.geobackend.base.query.exception.QueryException; |
41 | |
36 import de.intevation.gnv.state.InputData; | 42 import de.intevation.gnv.state.InputData; |
43 | |
37 import de.intevation.gnv.state.exception.StateException; | 44 import de.intevation.gnv.state.exception.StateException; |
45 | |
38 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; | 46 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; |
47 | |
39 import de.intevation.gnv.statistics.Statistics; | 48 import de.intevation.gnv.statistics.Statistics; |
49 | |
40 import de.intevation.gnv.utils.StringUtils; | 50 import de.intevation.gnv.utils.StringUtils; |
41 import de.intevation.gnv.utils.WKTUtils; | 51 import de.intevation.gnv.utils.WKTUtils; |
42 | 52 |
43 import de.intevation.artifactdatabase.Config; | 53 import de.intevation.artifactdatabase.Config; |
54 | |
44 import de.intevation.artifacts.CallContext; | 55 import de.intevation.artifacts.CallContext; |
45 | 56 |
57 import de.intevation.gnv.geobackend.sde.datasources.RasterObject; | |
58 | |
46 /** | 59 /** |
47 * @author Tim Englich <tim.englich@intevation.de> | 60 * @author Tim Englich (tim.englich@intevation.de) |
48 * | 61 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) |
49 */ | 62 */ |
50 public class HorizontalCrossSectionMeshOutputState | 63 public class HorizontalCrossSectionMeshOutputState |
51 extends TimeSeriesOutputState { | 64 extends TimeSeriesOutputState |
52 | 65 { |
53 private static Logger log = Logger | 66 private static Logger log = Logger |
54 .getLogger(HorizontalCrossSectionMeshOutputState.class); | 67 .getLogger(HorizontalCrossSectionMeshOutputState.class); |
55 | 68 |
56 /** | 69 /** |
57 * The UID of this Class | 70 * The UID of this Class |
58 */ | 71 */ |
59 private static final long serialVersionUID = 3233620652465061860L; | 72 private static final long serialVersionUID = 3233620652465061860L; |
93 return chart; | 106 return chart; |
94 | 107 |
95 log.info("Chart not in cache yet."); | 108 log.info("Chart not in cache yet."); |
96 | 109 |
97 log.warn("This sort of chart is not implemented yet."); | 110 log.warn("This sort of chart is not implemented yet."); |
98 /* TODO Implement a special chart for this sort of charts. | |
99 chart = new HorizontalProfileChart( | |
100 chartLables, | |
101 chartTheme, | |
102 parameters, | |
103 measurements, | |
104 result, | |
105 dates, | |
106 locale | |
107 ); | |
108 chart.generateChart(); | |
109 | |
110 if (CACHE_CHART) { | |
111 log.info("Put chart into cache."); | |
112 purifyChart(chart, uuid); | |
113 } | |
114 */ | |
115 | 111 |
116 InputData meshPolygon = inputData.get("mesh_polygon"); | 112 InputData meshPolygon = inputData.get("mesh_polygon"); |
117 String meshPolygonWkt = null; | 113 String meshPolygonWkt = null; |
118 if (meshPolygon != null){ | 114 if (meshPolygon != null){ |
119 meshPolygonWkt = meshPolygon.getValue(); | 115 meshPolygonWkt = meshPolygon.getValue(); |
224 /** | 220 /** |
225 * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#createCSV(java.io.OutputStream, | 221 * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#createCSV(java.io.OutputStream, |
226 * java.util.Collection) | 222 * java.util.Collection) |
227 */ | 223 */ |
228 @Override | 224 @Override |
229 protected void createCSV(OutputStream outputStream, | 225 protected void createCSV( |
230 Collection<Result> chartResult) | 226 OutputStream outputStream, |
231 throws UnsupportedEncodingException, | 227 Collection<Result> chartResult |
232 IOException, | 228 ) throws UnsupportedEncodingException, IOException, StateException |
233 StateException { | 229 { |
230 /* | |
234 if (chartResult != null) { | 231 if (chartResult != null) { |
235 try { | 232 try { |
236 CSVWriter writer = new CSVWriter(new OutputStreamWriter( | 233 CSVWriter writer = new CSVWriter(new OutputStreamWriter( |
237 outputStream, "ISO-8859-1"), ','); | 234 outputStream, "ISO-8859-1"), ','); |
238 // USE THIS ENCODING BECAUSE OF | 235 // USE THIS ENCODING BECAUSE OF |
258 } else { | 255 } else { |
259 log.error("No Data given for generating an CSV-File."); | 256 log.error("No Data given for generating an CSV-File."); |
260 throw new StateException( | 257 throw new StateException( |
261 "No Data given for generating an CSV-File."); | 258 "No Data given for generating an CSV-File."); |
262 } | 259 } |
260 */ | |
263 } | 261 } |
264 | 262 |
265 /** | 263 /** |
266 * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#setup(org.w3c.dom.Node) | 264 * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#setup(org.w3c.dom.Node) |
267 */ | 265 */ |
280 return samples != null | 278 return samples != null |
281 ? samples.intValue() | 279 ? samples.intValue() |
282 : GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_SAMPLES; | 280 : GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_SAMPLES; |
283 } | 281 } |
284 | 282 |
283 private static File shapefileDirectory(CallContext callContext) { | |
284 GNVArtifactContext context = | |
285 (GNVArtifactContext)callContext.globalContext(); | |
286 File dir = (File)context.get( | |
287 GNVArtifactContext.HORIZONTAL_CROSS_SECTION_RESULT_SHAPEFILE_PATH_KEY); | |
288 return dir != null | |
289 ? dir | |
290 : GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SHAPEFILE_PATH; | |
291 } | |
292 | |
293 private static int getGroundInterpolation(CallContext callContext) { | |
294 GNVArtifactContext context = | |
295 (GNVArtifactContext)callContext.globalContext(); | |
296 | |
297 String interpolation = (String)context.get( | |
298 GNVArtifactContext.HORIZONTAL_CROSS_SECTION_GROUND_INTERPOLATION_KEY); | |
299 | |
300 return RasterObject.getInterpolationType(interpolation); | |
301 } | |
285 } | 302 } |
303 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |