Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java @ 3397:6d1740533810
FixA: Added discharge column to DeltaW(t) CSV export.
flys-artifacts/trunk@5030 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 18 Jul 2012 09:03:19 +0000 |
parents | 79dd823733e2 |
children | 7f9fe694f8d1 |
comparison
equal
deleted
inserted
replaced
3396:3bffbf670b49 | 3397:6d1740533810 |
---|---|
23 | 23 |
24 import java.text.DateFormat; | 24 import java.text.DateFormat; |
25 import java.text.NumberFormat; | 25 import java.text.NumberFormat; |
26 | 26 |
27 import java.util.ArrayList; | 27 import java.util.ArrayList; |
28 import java.util.Date; | |
29 import java.util.List; | 28 import java.util.List; |
30 import java.util.Locale; | 29 import java.util.Locale; |
31 | 30 |
32 import org.apache.log4j.Logger; | 31 import org.apache.log4j.Logger; |
33 | 32 |
42 "export.fixings.deltawt.csv.header.km"; | 41 "export.fixings.deltawt.csv.header.km"; |
43 | 42 |
44 public static final String CSV_DELTA_W_HEADER = | 43 public static final String CSV_DELTA_W_HEADER = |
45 "export.fixings.deltawt.csv.header.deltaw"; | 44 "export.fixings.deltawt.csv.header.deltaw"; |
46 | 45 |
46 public static final String CSV_Q_HEADER = | |
47 "export.fixings.deltawt.csv.header.q"; | |
48 | |
47 public static final String CSV_T_HEADER = | 49 public static final String CSV_T_HEADER = |
48 "export.fixings.deltawt.csv.header.t"; | 50 "export.fixings.deltawt.csv.header.t"; |
49 | 51 |
50 public static final String CSV_T_DESC_HEADER = | 52 public static final String CSV_T_DESC_HEADER = |
51 "export.fixings.deltawt.csv.header.description"; | 53 "export.fixings.deltawt.csv.header.description"; |
52 | 54 |
53 public static final String DEFAULT_CSV_KM_HEADER = "km"; | 55 public static final String DEFAULT_CSV_KM_HEADER = "km"; |
54 | 56 |
55 public static final String DEFAULT_CSV_DELTA_W_HEADER = "\u0394 W [cm]"; | 57 public static final String DEFAULT_CSV_DELTA_W_HEADER = "\u0394 W [cm]"; |
58 | |
59 public static final String DEFAULT_CSV_Q_HEADER = "Abfluss [m\u00b3/s]"; | |
56 | 60 |
57 public static final String DEFAULT_CSV_T_HEADER = "Datum"; | 61 public static final String DEFAULT_CSV_T_HEADER = "Datum"; |
58 | 62 |
59 public static final String DEFAULT_CSV_T_DESC_HEADER = "Beschreibung"; | 63 public static final String DEFAULT_CSV_T_DESC_HEADER = "Beschreibung"; |
60 | 64 |
94 | 98 |
95 writeCSVHeader(writer); | 99 writeCSVHeader(writer); |
96 | 100 |
97 NumberFormat kmF = getKMFormatter(); | 101 NumberFormat kmF = getKMFormatter(); |
98 NumberFormat dwF = getDeltaWFormatter(); | 102 NumberFormat dwF = getDeltaWFormatter(); |
103 NumberFormat qF = getQFormatter(); | |
99 | 104 |
100 CallMeta meta = context.getMeta(); | 105 CallMeta meta = context.getMeta(); |
101 Locale locale = Resources.getLocale(meta); | 106 Locale locale = Resources.getLocale(meta); |
102 DateFormat dF = DateFormat.getDateInstance(DateFormat.SHORT, locale); | 107 DateFormat dF = DateFormat.getDateInstance(DateFormat.SHORT, locale); |
103 | 108 |
105 | 110 |
106 for (KMIndex.Entry<QWD[]> kmEntry: reference) { | 111 for (KMIndex.Entry<QWD[]> kmEntry: reference) { |
107 | 112 |
108 String kmS = kmF.format(kmEntry.getKm()); | 113 String kmS = kmF.format(kmEntry.getKm()); |
109 for (QWD qwd: kmEntry.getValue()) { | 114 for (QWD qwd: kmEntry.getValue()) { |
110 double deltaW = qwd.getDeltaW(); | 115 String desc = qwd.getDescription(); |
111 Date date = qwd.getDate(); | 116 String deltaWS = dwF.format(qwd.getDeltaW()); |
112 String desc = qwd.getDescription(); | 117 String qS = qF.format(qwd.getQ()); |
113 | 118 String dateS = dF.format(qwd.getDate()); |
114 String deltaWS = dwF.format(deltaW); | |
115 String dateS = dF.format(date); | |
116 | 119 |
117 writer.writeNext(new String[] { | 120 writer.writeNext(new String[] { |
118 kmS, | 121 kmS, |
119 deltaWS, | 122 deltaWS, |
123 qS, | |
120 dateS, | 124 dateS, |
121 desc != null ? desc : "" }); | 125 desc != null ? desc : "" }); |
122 } | 126 } |
123 } | 127 } |
124 } | 128 } |
135 | 139 |
136 for (AnalysisPeriod period: kmEntry.getValue()) { | 140 for (AnalysisPeriod period: kmEntry.getValue()) { |
137 QWD [] qwds = period.getQWDs(); | 141 QWD [] qwds = period.getQWDs(); |
138 if (qwds != null) { | 142 if (qwds != null) { |
139 for (QWD qwd: qwds) { | 143 for (QWD qwd: qwds) { |
140 double deltaW = qwd.getDeltaW(); | 144 String desc = qwd.getDescription(); |
141 Date date = qwd.getDate(); | 145 String deltaWS = dwF.format(qwd.getDeltaW()); |
142 String desc = qwd.getDescription(); | 146 String qS = qF.format(qwd.getQ()); |
143 | 147 String dateS = dF.format(qwd.getDate()); |
144 String deltaWS = dwF.format(deltaW); | |
145 String dateS = dF.format(date); | |
146 | 148 |
147 writer.writeNext(new String[] { | 149 writer.writeNext(new String[] { |
148 kmS, | 150 kmS, |
149 deltaWS, | 151 deltaWS, |
152 qS, | |
150 dateS, | 153 dateS, |
151 desc != null ? desc : "" }); | 154 desc != null ? desc : "" }); |
152 } | 155 } |
153 } | 156 } |
154 } | 157 } |
164 | 167 |
165 protected NumberFormat getDeltaWFormatter() { | 168 protected NumberFormat getDeltaWFormatter() { |
166 return Formatter.getFixDeltaWDeltaW(context); | 169 return Formatter.getFixDeltaWDeltaW(context); |
167 } | 170 } |
168 | 171 |
172 protected NumberFormat getQFormatter() { | |
173 return Formatter.getFixDeltaWQ(context); | |
174 } | |
175 | |
169 protected void writeCSVHeader(CSVWriter writer) { | 176 protected void writeCSVHeader(CSVWriter writer) { |
170 log.debug("DeltaWtExporter.writeCSVHeader"); | 177 log.debug("DeltaWtExporter.writeCSVHeader"); |
171 | 178 |
172 writer.writeNext(new String[] { | 179 writer.writeNext(new String[] { |
173 msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), | 180 msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), |
174 msg(CSV_DELTA_W_HEADER, DEFAULT_CSV_DELTA_W_HEADER), | 181 msg(CSV_DELTA_W_HEADER, DEFAULT_CSV_DELTA_W_HEADER), |
182 msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER), | |
175 msg(CSV_T_HEADER, DEFAULT_CSV_T_HEADER), | 183 msg(CSV_T_HEADER, DEFAULT_CSV_T_HEADER), |
176 msg(CSV_T_DESC_HEADER, DEFAULT_CSV_T_DESC_HEADER) | 184 msg(CSV_T_DESC_HEADER, DEFAULT_CSV_T_DESC_HEADER) |
177 }); | 185 }); |
178 } | 186 } |
179 | 187 |