Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelDescriptionBuilder.java @ 9040:5294114b1df4
Fixed/changed some FIXMEs/TODOs
author | gernotbelger |
---|---|
date | Wed, 02 May 2018 12:19:31 +0200 |
parents | 05b5588bdd94 |
children | 86d2cbfe7f7f |
comparison
equal
deleted
inserted
replaced
9039:13b5b515c61f | 9040:5294114b1df4 |
---|---|
27 * | 27 * |
28 * @author Gernot Belger | 28 * @author Gernot Belger |
29 */ | 29 */ |
30 public final class WaterlevelDescriptionBuilder { | 30 public final class WaterlevelDescriptionBuilder { |
31 | 31 |
32 private static final String CSV_META_Q = "export.waterlevel.csv.meta.q"; | |
33 | |
34 // FIXME: unit 'NN + m' is wrong: | |
35 // - use river-elevation system in case of absolute heights | |
36 // - use 'cm am Pegel' in other cases | |
37 private static final String CSV_META_W = "export.waterlevel.csv.meta.w"; | |
38 | |
32 private static final String CSV_Q_DESC_HEADER = "export.waterlevel.csv.header.q.desc"; | 39 private static final String CSV_Q_DESC_HEADER = "export.waterlevel.csv.header.q.desc"; |
33 | 40 |
34 // FIXME: missing in resource-files! hence always the default is used... | 41 // FIXME: missing in resource-files! hence always the default is used... |
35 private static final String CSV_W_DESC_HEADER = "export.waterlevel.csv.header.w.desc"; | 42 private static final String CSV_W_DESC_HEADER = "export.waterlevel.csv.header.w.desc"; |
36 | 43 |
59 this.artifact = artifact; | 66 this.artifact = artifact; |
60 } | 67 } |
61 | 68 |
62 public boolean isAtGauge() { | 69 public boolean isAtGauge() { |
63 return this.atGauge; | 70 return this.atGauge; |
71 } | |
72 | |
73 public String getMetadata() { | |
74 | |
75 switch (this.mode) { | |
76 case QFREE: | |
77 case QGAUGE: { | |
78 final String data = getMetadataQ(); | |
79 if (data == null) | |
80 return null; | |
81 | |
82 return Resources.getMsg(this.context.getMeta(), CSV_META_Q, CSV_META_Q, data); | |
83 } | |
84 | |
85 // TODO: probably none, default is wrong here, but this how it was implemented in WaterlevelExporter. | |
86 case WFREE: | |
87 case WGAUGE: | |
88 case NONE: | |
89 default: | |
90 final double[] ws = RiverUtils.getWs(this.artifact); | |
91 | |
92 if (ws == null || ws.length <= 0) | |
93 return null; | |
94 | |
95 // FIXME: we also have here a case single?! | |
96 | |
97 // FIXME: use correct wst unit! | |
98 | |
99 // FIXME: bad formatting ofd values. Use the correct Formatter! | |
100 final String lower = String.valueOf(ws[0]); | |
101 final String upper = String.valueOf(ws[ws.length - 1]); | |
102 | |
103 return Resources.getMsg(this.context.getMeta(), CSV_META_W, CSV_META_W, lower, upper); | |
104 } | |
105 } | |
106 | |
107 private String getMetadataQ() { | |
108 | |
109 final double[] qs = RiverUtils.getQs(this.artifact); | |
110 if (qs == null || qs.length == 0) | |
111 return null; | |
112 | |
113 final RiverUtils.WQ_INPUT input = RiverUtils.getWQInputMode(this.artifact); | |
114 | |
115 switch (input) { | |
116 case ADAPTED: | |
117 case RANGE: | |
118 return String.valueOf(qs[0]) + " - " + String.valueOf(qs[qs.length - 1]); | |
119 | |
120 case SINGLE: | |
121 String data = String.valueOf(qs[0]); | |
122 for (int i = 1; i < qs.length; i++) | |
123 data += ", " + String.valueOf(qs[i]); | |
124 return data; | |
125 | |
126 default: | |
127 return null; | |
128 } | |
64 } | 129 } |
65 | 130 |
66 public String getColumnHeader() { | 131 public String getColumnHeader() { |
67 | 132 |
68 if (!this.atGauge) | 133 if (!this.atGauge) |