Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java @ 6685:09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 29 Jul 2013 09:30:44 +0200 |
parents | 202ac69e0db1 |
children | 6eb2b8087cfa |
rev | line source |
---|---|
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 * |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 */ |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 package org.dive4elements.river.exports.minfo; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import java.util.LinkedList; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import java.util.List; |
6685
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
13 import java.util.TreeSet; |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import java.io.OutputStream; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 import java.io.IOException; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 import java.text.NumberFormat; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 import org.w3c.dom.Document; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 import org.apache.log4j.Logger; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 import org.dive4elements.artifacts.CallContext; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 import org.dive4elements.river.artifacts.model.CalculationResult; |
6685
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
28 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction; |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadResult; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 import org.dive4elements.river.exports.AbstractExporter; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 import org.dive4elements.river.utils.Formatter; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 import au.com.bytecode.opencsv.CSVWriter; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 |
6676
202ac69e0db1
Cosmetics, docs, imports.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6668
diff
changeset
|
37 |
202ac69e0db1
Cosmetics, docs, imports.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6668
diff
changeset
|
38 /** Do CSV export for sediment load calculations (will also be shown in |
202ac69e0db1
Cosmetics, docs, imports.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6668
diff
changeset
|
39 * client). */ |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 public class SedimentLoadExporter |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 extends AbstractExporter |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 { |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 /** Private logger. */ |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 private static Logger logger = Logger.getLogger(SedimentLoadExporter.class); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 |
6685
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
46 // i18n keys. |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
47 public static final String CSV_KM = |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
48 "export.sedimentload_ls.csv.header.km"; |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 |
6685
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
50 public static final String CSV_YEAR = |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
51 "export.sedimentload_ls.csv.header.year"; |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
52 |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
53 public static final String CSV_COARSE = |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
54 "export.sedimentload_ls.csv.header.coarse"; |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
55 |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
56 public static final String CSV_FINEMIDDLE = |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
57 "export.sedimentload_ls.csv.header.finemiddle"; |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
58 |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
59 public static final String CSV_SAND = |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
60 "export.sedimentload_ls.csv.header.sand"; |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
61 |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
62 public static final String CSV_SUSP_SAND = |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
63 "export.sedimentload_ls.csv.header.suspsand"; |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
64 |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
65 public static final String CSV_SUSP_SEDIMENT = |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
66 "export.sedimentload_ls.csv.header.suspsediment"; |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
67 |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
68 public static final String CSV_TOTAL = |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
69 "export.sedimentload_ls.csv.header.total"; |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
70 |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
71 |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
72 /** Collected results. */ |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 private SedimentLoadResult[] results; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 |
6685
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
75 /** Empty constructor. */ |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 public SedimentLoadExporter() { |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 /** Trivial init. */ |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 @Override |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 public void init(Document request, OutputStream out, CallContext context) { |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 super.init(request, out, context); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
83 logger.debug("init"); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 results = new SedimentLoadResult[0]; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
87 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 /** Process all stored data and write csv. */ |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 @Override |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 protected void writeCSVData(CSVWriter writer) throws IOException { |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 writeCSVHeader(writer); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 |
6685
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
93 for (SedimentLoadResult result: results) { |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
94 SedimentLoad load = result.getLoad(); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
95 // Put load.getName()+load.getDescription()}); somewhere? |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
96 for (double km: new TreeSet<Double>(load.getKms())) { |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
97 SedimentLoadFraction fraction = load.getFraction(km); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
98 writeRecord(writer, km, result.getStartYear(), result.getEndYear(), fraction); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
99 } |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
100 } |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
101 } |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
102 |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
103 /** Write a line. */ |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
104 private void writeRecord(CSVWriter writer, double km, int fromYear, int toYear, SedimentLoadFraction fraction) { |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
105 // year, total, susp sed, susp sandbed suspsand, sand, finemiddle, coarse |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
106 String years = (toYear == 0) ? fromYear+"" : fromYear + "-" + toYear; |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 NumberFormat kmf = Formatter.getCalculationKm(context.getMeta()); |
6685
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
108 NumberFormat valf = Formatter.getFormatter(context.getMeta(), 0, 2); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
109 writer.writeNext(new String[] { |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
110 kmf.format(km), |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
111 years, |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
112 valf.format(fraction.getTotal()), |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
113 valf.format(fraction.getSand()), |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
114 valf.format(fraction.getFineMiddle()), |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
115 valf.format(fraction.getCoarse()), |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
116 valf.format(fraction.getSuspSand()), |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
117 //valf.format(fraction.getSuspSandBed()), |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
118 valf.format(fraction.getSuspSediment()) |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
119 }); |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 /** Writes i18ned header for csv file/stream. */ |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
123 protected void writeCSVHeader(CSVWriter writer) { |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
124 logger.debug("writeCSVHeader()"); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
125 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 List<String> header = new LinkedList<String>(); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
127 if (results != null) { |
6685
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
128 header.add(msg(CSV_KM, "km")); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
129 header.add(msg(CSV_YEAR, "Jahr")); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
130 header.add(msg(CSV_TOTAL, "Gesamt")); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
131 header.add(msg(CSV_SAND, "Sand")); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
132 header.add(msg(CSV_FINEMIDDLE,"Fein")); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
133 header.add(msg(CSV_COARSE, "Grob")); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
134 header.add(msg(CSV_SUSP_SAND, "Su.Sand")); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
135 header.add(msg(CSV_SUSP_SEDIMENT, "Schwebst.")); |
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
136 //header.add("Susp.Sand Bett"); |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
137 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
138 writer.writeNext(header.toArray(new String[header.size()])); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
139 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
140 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
141 /** Store data internally, accepting only SedimentLoadResults[] in |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 * calculationresults data. */ |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
143 @Override |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
144 protected void addData(Object data) { |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
145 if (!(data instanceof CalculationResult)) { |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 logger.warn("Invalid data type."); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 return; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
148 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
149 Object[] d = (Object[])((CalculationResult)data).getData(); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
150 |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
151 if (!(d instanceof SedimentLoadResult[])) { |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
152 logger.warn("Invalid result object."); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
153 return; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
154 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
155 logger.debug("addData: Data added."); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 results = (SedimentLoadResult[])d; |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
157 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
158 |
6685
09e70f01ed1e
issue1416: SedimentLoadExporter: Implemented rough output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6676
diff
changeset
|
159 /** Write PDF to outputstream (not implemented yet). */ |
6668
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
160 @Override |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
161 protected void writePDF(OutputStream out) { |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
162 logger.warn("Not implemented."); |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
163 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
164 } |
368db84f1241
issue1416: Move a stub new SedimentLoadExporter in place.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
165 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |