annotate gnv-artifacts/src/main/java/de/intevation/gnv/exports/VerticalCrossODVExport.java @ 852:b5f4b6073cde

Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217). gnv-artifacts/trunk@968 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 22 Apr 2010 08:54:36 +0000
parents 39d06d01825a
children 27112636e8bb
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 /**
852
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
69 *
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
70 */
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
71 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
72
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
73 /**
837
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 * 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
75 * specific depth.
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 double[] raster;
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 width.
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 width;
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 raster height.
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 int height;
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 date of this export.
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 protected String time;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 /**
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 * 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
96 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 public VerticalCrossODVExport(
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 Coordinate[] coordinates,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 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
100 double cellWidth,
837
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 double[] raster,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 String time,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 int width,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 int height)
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 this.coordinates = coordinates;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 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
108 this.cellWidth = cellWidth;
837
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 this.raster = raster;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 this.width = width;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 this.height = height;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 this.time = time;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 }
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
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 /**
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 *
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 * @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
119 * @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
120 * @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
121 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 public void create(
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 Profile profile,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 OutputStream outputStream,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 Collection result)
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 throws
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 IOException,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 UnsupportedEncodingException,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 StateException
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 CSVWriter writer = new CSVWriter(
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 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
133 profile.getSeparator(),
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 profile.getQuoteCharacter(),
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 profile.getEscapeCharacter());
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 writer.writeNext(profile.getHeader());
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138
852
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
139 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
140
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 writer.close();
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 }
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 protected void writeData(
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 CSVWriter writer,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 String time,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 Coordinate[] coordinates,
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 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
149 double cellWidth,
837
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 double[] raster)
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 if (logger.isDebugEnabled()) {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 logger.debug("+++++++++++++++++++++++++++++++++++++++++");
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
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 String datetime = null;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 try {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 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
166 datetime = destFormat.format(tmp);
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 catch (ParseException pe) {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 logger.error(pe, pe);
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171
852
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
172 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
173 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
174 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
175 row[0] = "GNVExport";
39d06d01825a Finalized the odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 837
diff changeset
176 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
177 row[2] = "*";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 row[3] = datetime;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 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
180 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
181 row[6] = "0";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182
852
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
183 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
184 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
185 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
186 row[0] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187 row[1] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 row[2] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 row[3] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 row[4] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 row[5] = "";
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 row[6] = "";
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
852
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
195 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
196
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
197 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
198 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
199 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
200
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
201 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
202
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 if (Double.isNaN(value)) {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 break;
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 writer.writeNext(row);
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 }
852
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
210
b5f4b6073cde Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
211 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
212 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org