Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/exports/VerticalCrossODVExport.java @ 1052:b30361464775
The pdf format depends on the chart's aspect ratio (issue290).
gnv-artifacts/trunk@1126 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 26 May 2010 06:45:03 +0000 |
parents | dfd02f8d3602 |
children | f953c9a559d8 |
rev | line source |
---|---|
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.exports; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import com.vividsolutions.jts.geom.Coordinate; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import java.io.IOException; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import java.io.OutputStream; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import java.io.OutputStreamWriter; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import java.io.UnsupportedEncodingException; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import java.text.DateFormat; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.text.ParseException; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import java.text.SimpleDateFormat; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import java.util.Collection; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import java.util.Date; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import org.apache.log4j.Logger; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import au.com.bytecode.opencsv.CSVWriter; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.gnv.state.exception.StateException; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 public class VerticalCrossODVExport implements Export { |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 * Constant field which defines the source format of a given datetime. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 public static final String SRC_FORMAT = "yyyy.MM.dd HH:mm:ss"; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 * Constant field which defines the target format of a given datetime. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public static final String DEST_FORMAT = "yyyy-MM-dd HH:mm"; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 * Source format. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 public static DateFormat srcFormat = new SimpleDateFormat(SRC_FORMAT); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 * Target format. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 public static DateFormat destFormat = new SimpleDateFormat(DEST_FORMAT); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 * Logger used for logging via log4j. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 private static Logger logger = |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 Logger.getLogger(VerticalCrossODVExport.class); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 * The path in coordinates. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 protected Coordinate[] coordinates; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 * |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 protected double cellHeight; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 /** |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
62 * |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
63 */ |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
64 protected double cellWidth; |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
65 |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
66 /** |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 * The raster array storing the values for a specific coordinate in a |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 * specific depth. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 protected double[] raster; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 * The raster width. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 protected int width; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 * The raster height. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 protected int height; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 * The date of this export. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 protected String time; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 /** |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 * The constructor used to create a new export helper object. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 public VerticalCrossODVExport( |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 Coordinate[] coordinates, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 double cellHeight, |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
93 double cellWidth, |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 double[] raster, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 String time, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 int width, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 int height) |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 { |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 this.coordinates = coordinates; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 this.cellHeight = cellHeight; |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
101 this.cellWidth = cellWidth; |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 this.raster = raster; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 this.width = width; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 this.height = height; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 this.time = time; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 /** |
870
dfd02f8d3602
Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
869
diff
changeset
|
110 * |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 * @param profile The Profile used to create column headers. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 * @param outputStream The stream where the odv data are written to. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 * @param result Not used here, might be null. |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 */ |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 public void create( |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 Profile profile, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 OutputStream outputStream, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 Collection result) |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 throws |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 IOException, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 UnsupportedEncodingException, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 StateException |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 { |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 CSVWriter writer = new CSVWriter( |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 new OutputStreamWriter(outputStream, profile.getEncoding()), |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 profile.getSeparator(), |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 profile.getQuoteCharacter(), |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 profile.getEscapeCharacter()); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 writer.writeNext(profile.getHeader()); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
132 writeData(writer, time, coordinates, cellHeight, cellWidth, raster); |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 writer.close(); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 protected void writeData( |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 CSVWriter writer, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 String time, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 Coordinate[] coordinates, |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 double cellHeight, |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
142 double cellWidth, |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 double[] raster) |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 { |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 if (logger.isDebugEnabled()) { |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 logger.debug("+++++++ ODV Export information ++++++++++"); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 logger.debug("+ raster width: " + width); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 logger.debug("+ raster height: " + height); |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
149 logger.debug("+ cell height: " + cellHeight); |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
150 logger.debug("+ cell width: " + cellWidth); |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 logger.debug("+ items in raster: " + raster.length); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 logger.debug("+ number of coordinates: " + coordinates.length); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 logger.debug("+++++++++++++++++++++++++++++++++++++++++"); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 String datetime = null; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 try { |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 Date tmp = srcFormat.parse(time); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 datetime = destFormat.format(tmp); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 catch (ParseException pe) { |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 logger.error(pe, pe); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
165 double maxDepth = 0; |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
166 String[] row = new String[10]; |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 for (int i = 0; i < width; i++) { |
850
39d06d01825a
Finalized the odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
837
diff
changeset
|
168 row[0] = "GNVExport"; |
39d06d01825a
Finalized the odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
837
diff
changeset
|
169 row[1] = "Station_" + i; |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 row[2] = "*"; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 row[3] = datetime; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 row[4] = Double.toString(coordinates[i].x); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 row[5] = Double.toString(coordinates[i].y); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 row[6] = "0"; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
176 double depth = cellHeight * 0.5d; |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
177 for (int j = i; j < raster.length; j += width, depth += cellHeight) { |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
178 if (j == (i+width)) { |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 row[0] = ""; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 row[1] = ""; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 row[2] = ""; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 row[3] = ""; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 row[4] = ""; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 row[5] = ""; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 row[6] = ""; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
188 double value = raster[j]; |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
189 |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
190 row[7] = Double.toString(depth); |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 row[8] = "1"; |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
192 row[9] = Double.toString(value); |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
193 |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
194 maxDepth = maxDepth >= depth ? maxDepth : depth; |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 if (Double.isNaN(value)) { |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 break; |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
199 |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
200 writer.writeNext(row); |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
201 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 } |
852
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
203 |
b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
850
diff
changeset
|
204 logger.info("Detected max depth: " + maxDepth); |
837
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
205 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
206 } |
43f3c0cd60f2
First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
207 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |