annotate gnv-artifacts/src/main/java/de/intevation/gnv/exports/VerticalCrossODVExport.java @ 837:43f3c0cd60f2

First implementation of an odv export of a 'Profilschnitt' (issue217). gnv-artifacts/trunk@944 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 19 Apr 2010 10:55:25 +0000
parents
children 39d06d01825a
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.ArrayList;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import java.util.Collection;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import java.util.Date;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import java.util.HashMap;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import java.util.Iterator;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import java.util.Map;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 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
22
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 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
24 import de.intevation.gnv.geobackend.base.Result;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.gnv.math.Interpolation3D;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 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
28
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 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
31
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 * 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
34 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 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
36
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 * 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
39 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 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
41
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 * Source 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 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
46
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 * Target format.
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 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
51
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 /**
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 * 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
54 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 private static Logger logger =
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 Logger.getLogger(VerticalCrossODVExport.class);
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 * The path in coordinates.
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 protected Coordinate[] coordinates;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 /**
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 *
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 protected double cellHeight;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 /**
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 * 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
70 * specific depth.
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 protected double[] raster;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
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 * The raster 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 protected int width;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
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 * The raster 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 protected int height;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
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 * 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
86 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 protected String time;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88
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 * 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
91 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 public VerticalCrossODVExport(
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 Coordinate[] coordinates,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 double cellHeight,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 double[] raster,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 String time,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 int width,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 int height)
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 this.coordinates = coordinates;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 this.cellHeight = cellHeight;
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 /**
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 *
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
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 writeData(writer, time, coordinates, cellHeight, raster);
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,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 double[] raster)
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 if (logger.isDebugEnabled()) {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 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
146 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
147 logger.debug("+ raster height: " + height);
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 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
149 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
150 logger.debug("+++++++++++++++++++++++++++++++++++++++++");
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 String datetime = null;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 try {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 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
156 datetime = destFormat.format(tmp);
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 catch (ParseException pe) {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 logger.error(pe, pe);
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
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 String[] row = new String[10];
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 for (int i = 0; i < width; i++) {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 row[0] = "Station_" + i;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 //row[0] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 row[1] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 row[2] = "*";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 row[3] = datetime;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 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
170 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
171 row[6] = "0";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 for (int j = 0; j < height; j++) {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 if (j == 1) {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 row[0] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 //row[0] = "Station_";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 row[1] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 row[2] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 row[3] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180 row[4] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 row[5] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 row[6] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 // row[2] = Double.toString(depths[j]);
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 row[7] = Double.toString(j * cellHeight + cellHeight / 2d);
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 row[8] = "1";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 double value = raster[i+(j*height)];
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 if (Double.isNaN(value)) {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 break;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 row[9] = Double.toString(value);
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 writer.writeNext(row);
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 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org