Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java @ 8932:8731c3dabb56
Extracting some winfo logic without breaking old code
author | gernotbelger |
---|---|
date | Tue, 06 Mar 2018 17:04:59 +0100 |
parents | 5e38e2924c07 |
children | 740d65e4aa14 0a5239a1e46e |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5986
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5986
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
9 package org.dive4elements.river.exports; |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.io.OutputStream; |
418
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
12 import java.text.NumberFormat; |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import java.util.ArrayList; |
701
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
664
diff
changeset
|
14 import java.util.Arrays; |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import java.util.List; |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
16 import java.util.Map; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
17 import java.util.HashMap; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
18 import java.util.Date; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
19 import java.text.DateFormat; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
20 import java.util.Locale; |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import org.apache.log4j.Logger; |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 import au.com.bytecode.opencsv.CSVWriter; |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
26 import net.sf.jasperreports.engine.JasperExportManager; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
27 import net.sf.jasperreports.engine.JasperFillManager; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
28 import net.sf.jasperreports.engine.JasperPrint; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
29 import net.sf.jasperreports.engine.JRException; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
30 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
31 import org.dive4elements.artifacts.common.utils.Config; |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
33 import org.dive4elements.artifacts.CallMeta; |
715
9665d6a48f7b
Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
701
diff
changeset
|
34 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
35 import org.dive4elements.river.artifacts.D4EArtifact; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
36 |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
37 import org.dive4elements.river.artifacts.access.RangeAccess; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
38 import org.dive4elements.river.artifacts.model.CalculationResult; |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
39 import org.dive4elements.river.artifacts.model.WQ; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
40 import org.dive4elements.river.artifacts.model.WQKms; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
41 import org.dive4elements.river.artifacts.model.WKmsJRDataSource; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
42 import org.dive4elements.river.artifacts.resources.Resources; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
43 |
5981
b740f0c4179e
Use 'W [cm]' as CSV header if discharge table is at a gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
5867
diff
changeset
|
44 import org.dive4elements.river.model.Gauge; |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
45 import org.dive4elements.river.model.River; |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
46 |
5865
73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
47 import org.dive4elements.river.utils.RiverUtils; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5421
diff
changeset
|
48 import org.dive4elements.river.utils.Formatter; |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 /** |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 */ |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 public class ComputedDischargeCurveExporter extends AbstractExporter { |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7088
diff
changeset
|
55 /** The log used in this exporter.*/ |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7088
diff
changeset
|
56 private static Logger log = |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 Logger.getLogger(ComputedDischargeCurveExporter.class); |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
416
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
59 public static final String CSV_W_HEADER = |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
60 "export.computed.discharge.curve.csv.header.w"; |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
61 |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
62 public static final String CSV_Q_HEADER = |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
63 "export.computed.discharge.curve.csv.header.q"; |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
64 |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
65 public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; |
664
e006da5679d2
s@m³/s@m\u00b3/s@
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
445
diff
changeset
|
66 public static final String DEFAULT_CSV_Q_HEADER = "Q [m\u00b3/s]"; |
416
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
67 |
8856 | 68 public static final String PDF_HEADER_MODE = |
69 "export.computed.discharge.pdf.mode"; | |
70 public static final String PDF_HEADER_CALC_MODE = | |
71 "export.computed.discharge.pdf.calc.mode"; | |
72 public static final String JASPER_FILE = | |
73 "export.computed.discharge.pdf.file"; | |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
394
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
75 protected List<WQKms> data; |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
76 |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
77 protected String wUnit; |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
78 protected String riverUnit; |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
79 protected String gaugeName; |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
80 protected double gaugeDatum; |
6317
294742a49c1c
Add gauge validity information to dischargecurve exporter
Andre Heinecke <aheinecke@intevation.de>
parents:
6315
diff
changeset
|
81 protected Date validSince; |
394
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
82 |
7077
0a337f0005c2
Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6317
diff
changeset
|
83 public ComputedDischargeCurveExporter() { |
0a337f0005c2
Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6317
diff
changeset
|
84 data = new ArrayList<WQKms>(); |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 } |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 |
701
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
664
diff
changeset
|
87 @Override |
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
664
diff
changeset
|
88 protected void addData(Object d) { |
715
9665d6a48f7b
Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
701
diff
changeset
|
89 if (d instanceof CalculationResult) { |
9665d6a48f7b
Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
701
diff
changeset
|
90 d = ((CalculationResult)d).getData(); |
701
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
664
diff
changeset
|
91 } |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
92 WQKms referenceWQ = null; // used for gauge / unit observations |
4585
b4a95290ec63
Refactor ComputedDischargeCurveExporter to support WQKms values and WQKms arrays
Björn Ricks <bjoern.ricks@intevation.de>
parents:
2185
diff
changeset
|
93 if (d instanceof WQKms[]){ |
b4a95290ec63
Refactor ComputedDischargeCurveExporter to support WQKms values and WQKms arrays
Björn Ricks <bjoern.ricks@intevation.de>
parents:
2185
diff
changeset
|
94 data.addAll(Arrays.asList((WQKms [])d)); |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
95 // If there is a unit mix in this list |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
96 // we are screwed anyway. |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
97 referenceWQ = ((WQKms[])d)[0]; |
4585
b4a95290ec63
Refactor ComputedDischargeCurveExporter to support WQKms values and WQKms arrays
Björn Ricks <bjoern.ricks@intevation.de>
parents:
2185
diff
changeset
|
98 } |
b4a95290ec63
Refactor ComputedDischargeCurveExporter to support WQKms values and WQKms arrays
Björn Ricks <bjoern.ricks@intevation.de>
parents:
2185
diff
changeset
|
99 else if (d instanceof WQKms) { |
b4a95290ec63
Refactor ComputedDischargeCurveExporter to support WQKms values and WQKms arrays
Björn Ricks <bjoern.ricks@intevation.de>
parents:
2185
diff
changeset
|
100 data.add((WQKms)d); |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
101 referenceWQ = (WQKms)d; |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
102 } else { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7088
diff
changeset
|
103 log.warn("Can't add data for export. Unkown data type " + |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
104 d.getClass().getName()); |
4610
497bc73ca64a
Fix: Don't show the warning if datatype is WQKms
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4585
diff
changeset
|
105 return; |
4585
b4a95290ec63
Refactor ComputedDischargeCurveExporter to support WQKms values and WQKms arrays
Björn Ricks <bjoern.ricks@intevation.de>
parents:
2185
diff
changeset
|
106 } |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
107 if (referenceWQ != null) { |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
108 D4EArtifact arti = (D4EArtifact)master; |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
109 River river = RiverUtils.getRiver(arti); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
110 riverUnit = river.getWstUnit().getName(); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
111 RangeAccess rangeAccess = new RangeAccess(arti); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
112 |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
113 double[] kms = rangeAccess.getKmRange(); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
114 |
8724
47199406994a
(issue1801) Determine gauge at a station always with same tolerance.
Tom Gottfried <tom@intevation.de>
parents:
8383
diff
changeset
|
115 Gauge gauge = river.determineGaugeAtStation(kms[0]); |
47199406994a
(issue1801) Determine gauge at a station always with same tolerance.
Tom Gottfried <tom@intevation.de>
parents:
8383
diff
changeset
|
116 if (gauge != null) { |
8362
839032ac1523
Purge obsolete representation of reference system for discharge tables.
Tom Gottfried <tom@intevation.de>
parents:
8202
diff
changeset
|
117 wUnit = "cm"; |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
118 gaugeName = gauge.getName(); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
119 gaugeDatum = gauge.getDatum().doubleValue(); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
120 |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
121 // Now convert the data to cm because we are at gauge |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
122 List<WQKms> newData = new ArrayList<WQKms>(); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
123 for (WQKms d2: data) { |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
124 newData.add(new WQKms(d2.getKms(), |
8383
4de385d58a3e
Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo.
Tom Gottfried <tom@intevation.de>
parents:
8363
diff
changeset
|
125 WQ.getFixedWQforExportAtGauge( |
4de385d58a3e
Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo.
Tom Gottfried <tom@intevation.de>
parents:
8363
diff
changeset
|
126 (WQ)d2, |
4de385d58a3e
Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo.
Tom Gottfried <tom@intevation.de>
parents:
8363
diff
changeset
|
127 gauge.getDatum() |
4de385d58a3e
Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo.
Tom Gottfried <tom@intevation.de>
parents:
8363
diff
changeset
|
128 ))); |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
129 } |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
130 data = newData; // All hail the garbage collector |
6317
294742a49c1c
Add gauge validity information to dischargecurve exporter
Andre Heinecke <aheinecke@intevation.de>
parents:
6315
diff
changeset
|
131 |
8383
4de385d58a3e
Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo.
Tom Gottfried <tom@intevation.de>
parents:
8363
diff
changeset
|
132 validSince = gauge.fetchMasterDischargeTable() |
4de385d58a3e
Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo.
Tom Gottfried <tom@intevation.de>
parents:
8363
diff
changeset
|
133 .getTimeInterval().getStartTime(); |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
134 } else { |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
135 gaugeName = ""; |
6317
294742a49c1c
Add gauge validity information to dischargecurve exporter
Andre Heinecke <aheinecke@intevation.de>
parents:
6315
diff
changeset
|
136 validSince = null; |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
137 gaugeDatum = Double.NaN; |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
138 } |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
139 } |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 } |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 protected void writeCSVData(CSVWriter writer) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7088
diff
changeset
|
143 log.info("ComputedDischargeCurveExporter.writeData"); |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 |
416
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
145 writeCSVHeader(writer); |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
146 |
418
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
147 NumberFormat wf = getWFormatter(); |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
148 NumberFormat qf = getQFormatter(); |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
149 |
394
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
150 double[] res = new double[3]; |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
151 |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
152 for (WQKms wqkms: data) { |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
153 int size = wqkms.size(); |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
154 |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
155 for (int i = 0; i < size; i++) { |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
156 res = wqkms.get(i, res); |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
157 |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
158 writer.writeNext(new String[] { |
418
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
159 wf.format(res[0]), |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
160 qf.format(res[1]) |
394
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
161 }); |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
162 } |
b9175ddea49b
Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
392
diff
changeset
|
163 } |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 } |
416
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
165 |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
166 |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
167 protected void writeCSVHeader(CSVWriter writer) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7088
diff
changeset
|
168 log.debug("ComputedDischargeCurveExporter.writeCSVHeader"); |
416
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
169 |
6101
a0078e5e3b39
Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
170 RangeAccess access = new RangeAccess((D4EArtifact)master); |
5981
b740f0c4179e
Use 'W [cm]' as CSV header if discharge table is at a gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
5867
diff
changeset
|
171 double[] km = access.getLocations(); |
6308
aa4c13220fa0
Use the river unit in csv export if not converted
Andre Heinecke <aheinecke@intevation.de>
parents:
6306
diff
changeset
|
172 // If we are not at gauge (cm) use the river unit |
8363 | 173 String realUnit = "cm".equals(wUnit) ? "cm" : riverUnit; |
5981
b740f0c4179e
Use 'W [cm]' as CSV header if discharge table is at a gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
5867
diff
changeset
|
174 String header = |
6308
aa4c13220fa0
Use the river unit in csv export if not converted
Andre Heinecke <aheinecke@intevation.de>
parents:
6306
diff
changeset
|
175 msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] {realUnit}); |
5985
2ec6fae23bba
Be more tolerant when try to find out if a location is at a gauge position.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5981
diff
changeset
|
176 |
416
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
177 writer.writeNext(new String[] { |
5981
b740f0c4179e
Use 'W [cm]' as CSV header if discharge table is at a gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
5867
diff
changeset
|
178 header, |
416
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
179 msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER) |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
180 }); |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
394
diff
changeset
|
181 } |
418
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
182 |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
183 |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
184 /** |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
185 * Returns the number formatter for W values. |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
186 * |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
187 * @return the number formatter for W values. |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
188 */ |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
189 protected NumberFormat getWFormatter() { |
8363 | 190 if ("cm".equals(wUnit)) { |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
191 return Formatter.getFormatter(context, 0, 0); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
192 } |
445
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
193 return Formatter.getComputedDischargeW(context); |
418
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
194 } |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
195 |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
196 |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
197 /** |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
198 * Returns the number formatter for Q values. |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
199 * |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
200 * @return the number formatter for Q values. |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
201 */ |
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
202 protected NumberFormat getQFormatter() { |
445
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
203 return Formatter.getComputedDischargeQ(context); |
418
e0fec407a280
ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
416
diff
changeset
|
204 } |
2176 | 205 |
206 | |
207 @Override | |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
208 protected void writePDF(OutputStream out) { |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
209 WKmsJRDataSource source = createJRData(); |
2185
a9a8df1473fd
Added i18n support to PDF report export.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2182
diff
changeset
|
210 |
a9a8df1473fd
Added i18n support to PDF report export.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2182
diff
changeset
|
211 String jasperFile = Resources.getMsg( |
a9a8df1473fd
Added i18n support to PDF report export.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2182
diff
changeset
|
212 context.getMeta(), |
a9a8df1473fd
Added i18n support to PDF report export.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2182
diff
changeset
|
213 JASPER_FILE, |
a9a8df1473fd
Added i18n support to PDF report export.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2182
diff
changeset
|
214 "/jasper/computed-discharge_en.jasper"); |
a9a8df1473fd
Added i18n support to PDF report export.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2182
diff
changeset
|
215 String confPath = Config.getConfigDirectory().toString(); |
a9a8df1473fd
Added i18n support to PDF report export.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2182
diff
changeset
|
216 |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
217 Map parameters = new HashMap(); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
218 parameters.put("ReportTitle", "Exported Data"); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
219 try { |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
220 JasperPrint print = JasperFillManager.fillReport( |
2185
a9a8df1473fd
Added i18n support to PDF report export.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2182
diff
changeset
|
221 confPath + jasperFile, |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
222 parameters, |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
223 source); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
224 JasperExportManager.exportReportToPdfStream(print, out); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
225 } |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
226 catch(JRException je) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7088
diff
changeset
|
227 log.warn("Error generating PDF Report!"); |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
228 je.printStackTrace(); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
229 } |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
230 } |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
231 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
232 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
233 protected WKmsJRDataSource createJRData() { |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
234 WKmsJRDataSource source = new WKmsJRDataSource(); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
235 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
236 addMetaData(source); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
237 addWQData(source); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
238 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
239 return source; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
240 } |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
241 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
242 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
243 protected void addMetaData(WKmsJRDataSource source) { |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
244 CallMeta meta = context.getMeta(); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
245 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
246 D4EArtifact flys = (D4EArtifact) master; |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
247 source.addMetaData("gauge", gaugeName); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
248 if (!Double.isNaN(gaugeDatum)) { |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
249 NumberFormat mf = Formatter.getMeterFormat(context); |
8856 | 250 source.addMetaData( |
251 "datum", mf.format(gaugeDatum) + " " + riverUnit); | |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
252 } else { |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
253 source.addMetaData("datum", ""); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
254 } |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
255 |
5865
73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
256 source.addMetaData ("river", RiverUtils.getRivername(flys)); |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
257 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
258 Locale locale = Resources.getLocale(meta); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
259 DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
260 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
261 source.addMetaData("date", df.format(new Date())); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
262 |
8363 | 263 source.addMetaData("wUnit", "cm".equals(wUnit) ? "cm" : riverUnit); |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
264 |
6101
a0078e5e3b39
Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
265 RangeAccess rangeAccess = new RangeAccess(flys); |
4856
d9ef525bff08
ChartGenerator, ComputedDischargeCurveExporter: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4610
diff
changeset
|
266 double[] kms = rangeAccess.getKmRange(); |
6311
c4c7ed0e5ffc
Format km's in computed discharge export
Andre Heinecke <aheinecke@intevation.de>
parents:
6308
diff
changeset
|
267 source.addMetaData("range", |
c4c7ed0e5ffc
Format km's in computed discharge export
Andre Heinecke <aheinecke@intevation.de>
parents:
6308
diff
changeset
|
268 Formatter.getCalculationKm(context.getMeta()).format(kms[0])); |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
269 |
8383
4de385d58a3e
Transform export in cm at gauge. TODO: don't transfrom twice if coming from PegelInfo.
Tom Gottfried <tom@intevation.de>
parents:
8363
diff
changeset
|
270 if (!"cm".equals(wUnit)) { |
6317
294742a49c1c
Add gauge validity information to dischargecurve exporter
Andre Heinecke <aheinecke@intevation.de>
parents:
6315
diff
changeset
|
271 source.addMetaData("valid_since", ""); |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
272 source.addMetaData("calculation", Resources.getMsg( |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
273 locale, |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
274 PDF_HEADER_CALC_MODE, |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
275 "Computed Discharge")); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
276 } else { |
8856 | 277 source.addMetaData( |
278 "valid_since", | |
279 validSince == null ? "" : df.format(validSince)); | |
6305
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
280 source.addMetaData("calculation", Resources.getMsg( |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
281 locale, |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
282 PDF_HEADER_MODE, |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
283 "Discharge")); |
40c77429319d
Update PDF/CSV export for discharge curves
Andre Heinecke <aheinecke@intevation.de>
parents:
6101
diff
changeset
|
284 } |
2177
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
285 } |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
286 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
287 protected void addWQData(WKmsJRDataSource source) { |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
288 NumberFormat wf = getWFormatter(); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
289 NumberFormat qf = getQFormatter(); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
290 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
291 double[] res = new double[3]; |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
292 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
293 for (WQKms wqkms: data) { |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
294 int size = wqkms.size(); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
295 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
296 for (int i = 0; i < size; i++) { |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
297 res = wqkms.get(i, res); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
298 |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
299 source.addData(new String[] { |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
300 "", // Empty, the WKmsJRDtasource stores km here. |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
301 wf.format(res[0]), |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
302 qf.format(res[1]) |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
303 }); |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
304 } |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
305 } |
28dbeb64ce7c
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
306 } |
392
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
307 } |
72177020db92
Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
308 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |