Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java @ 9609:8232a3f5967b
#20 SinfoResultType
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Wed, 09 Oct 2019 15:43:39 +0200 |
parents | 8b457ca70512 |
children | d889ffe2fb05 |
comparison
equal
deleted
inserted
replaced
9608:96c41d4f4aba | 9609:8232a3f5967b |
---|---|
8 * documentation coming with Dive4Elements River for details. | 8 * documentation coming with Dive4Elements River for details. |
9 */ | 9 */ |
10 package org.dive4elements.river.artifacts.sinfo.common; | 10 package org.dive4elements.river.artifacts.sinfo.common; |
11 | 11 |
12 import java.text.NumberFormat; | 12 import java.text.NumberFormat; |
13 import java.text.ParseException; | |
13 | 14 |
14 import org.apache.commons.lang.StringUtils; | 15 import org.apache.commons.lang.StringUtils; |
15 import org.apache.log4j.Logger; | 16 import org.apache.log4j.Logger; |
16 import org.dive4elements.artifacts.CallContext; | 17 import org.dive4elements.artifacts.CallContext; |
17 import org.dive4elements.river.artifacts.common.AbstractResultType; | 18 import org.dive4elements.river.artifacts.common.AbstractResultType; |
62 private static final long serialVersionUID = 1L; | 63 private static final long serialVersionUID = 1L; |
63 | 64 |
64 @Override | 65 @Override |
65 public String exportValue(final CallContext context, final Object value) { | 66 public String exportValue(final CallContext context, final Object value) { |
66 final double doubleValue = asDouble(value); | 67 final double doubleValue = asDouble(value); |
67 return exportDoubleValue(context, doubleValue); | 68 final String significant = Formatter.SIGINIFICANT_FORMATTER_3.format(doubleValue); |
68 } | 69 try { |
69 | 70 final Number significantD = Formatter.SIGINIFICANT_FORMATTER_3.parse(significant); |
70 @Override | 71 return exportDoubleValue(context, asDouble(significantD)); |
71 protected NumberFormat createFormatter(final CallContext context) { | 72 } |
72 return Formatter.getWaterlevelQ(context); | 73 catch (final ParseException e) { |
74 e.printStackTrace(); | |
75 return ""; | |
76 } | |
77 } | |
78 | |
79 @Override | |
80 protected NumberFormat createFormatter(final CallContext context) { | |
81 return Formatter.getFormatter(context, 0, 3); | |
73 } | 82 } |
74 }; | 83 }; |
75 | 84 |
76 public static final SInfoResultType floodDuration = new SInfoResultType(null, "sinfo.export.flood_duration.csv.header.duration", | 85 public static final SInfoResultType floodDuration = new SInfoResultType(null, "sinfo.export.flood_duration.csv.header.duration", |
77 "sinfo.export.flood_duration.pdf.header.duration") { | 86 "sinfo.export.flood_duration.pdf.header.duration") { |
105 // digits. | 114 // digits. |
106 return Formatter.getFlowDepth(context); | 115 return Formatter.getFlowDepth(context); |
107 } | 116 } |
108 }; | 117 }; |
109 | 118 |
119 // TODO: check, if it is being used correctly | |
110 public static final SInfoResultType infrastructuretype = new SInfoResultType(I18NStrings.UNIT_NONE, | 120 public static final SInfoResultType infrastructuretype = new SInfoResultType(I18NStrings.UNIT_NONE, |
111 "sinfo.export.flood_duration.csv.header.infrastructure_type", "sinfo.export.flood_duration.pdf.header.infrastructure_type") { | 121 "sinfo.export.flood_duration.csv.header.infrastructure_type", "sinfo.export.flood_duration.pdf.header.infrastructure_type") { |
112 private static final long serialVersionUID = 1L; | 122 private static final long serialVersionUID = 1L; |
113 | 123 |
114 @Override | 124 @Override |
119 @Override | 129 @Override |
120 protected NumberFormat createFormatter(final CallContext context) { | 130 protected NumberFormat createFormatter(final CallContext context) { |
121 throw new UnsupportedOperationException(); | 131 throw new UnsupportedOperationException(); |
122 } | 132 } |
123 }; | 133 }; |
134 // | |
135 public static final SInfoResultType infrastructurepart = new SInfoResultType(I18NStrings.UNIT_NONE, | |
136 "sinfo.export.flood_duration.csv.header.infrastructure_part", "sinfo.export.flood_duration.pdf.header.infrastructure_part") { | |
137 private static final long serialVersionUID = 1L; | |
138 | |
139 @Override | |
140 public String exportValue(final CallContext context, final Object value) { | |
141 return exportStringValue(value); | |
142 } | |
143 | |
144 @Override | |
145 protected NumberFormat createFormatter(final CallContext context) { | |
146 throw new UnsupportedOperationException(); | |
147 } | |
148 }; | |
124 | 149 |
125 public static final SInfoResultType dischargeLong = new SInfoResultType(I18NStrings.UNIT_CUBIC_M, "sinfo.export.collision.csv.header.discharge_long") { | 150 public static final SInfoResultType dischargeLong = new SInfoResultType(I18NStrings.UNIT_CUBIC_M, "sinfo.export.collision.csv.header.discharge_long") { |
126 private static final long serialVersionUID = 1L; | 151 private static final long serialVersionUID = 1L; |
127 | 152 |
128 @Override | 153 @Override |
203 protected NumberFormat createFormatter(final CallContext context) { | 228 protected NumberFormat createFormatter(final CallContext context) { |
204 return Formatter.getWaterlevelQ(context); | 229 return Formatter.getWaterlevelQ(context); |
205 } | 230 } |
206 }; | 231 }; |
207 | 232 |
233 public static final SInfoResultType maxBedHeight = new SInfoResultType(null, null, null) { | |
234 private static final long serialVersionUID = 1L; | |
235 | |
236 @Override | |
237 public String exportValue(final CallContext context, final Object value) { | |
238 final double doubleValue = asDouble(value); | |
239 return exportDoubleValue(context, doubleValue); | |
240 } | |
241 | |
242 @Override | |
243 protected NumberFormat createFormatter(final CallContext context) { | |
244 return Formatter.getMeanBedHeight(context); | |
245 } | |
246 }; | |
247 | |
248 public static final SInfoResultType minBedHeight = new SInfoResultType(null, null, null) { | |
249 private static final long serialVersionUID = 1L; | |
250 | |
251 @Override | |
252 public String exportValue(final CallContext context, final Object value) { | |
253 final double doubleValue = asDouble(value); | |
254 return exportDoubleValue(context, doubleValue); | |
255 } | |
256 | |
257 @Override | |
258 protected NumberFormat createFormatter(final CallContext context) { | |
259 return Formatter.getMeanBedHeight(context); | |
260 } | |
261 }; | |
262 | |
208 public static final SInfoResultType meanBedHeight = new SInfoResultType(null, SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER, | 263 public static final SInfoResultType meanBedHeight = new SInfoResultType(null, SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER, |
209 SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER_SHORT) { | 264 SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER_SHORT) { |
210 private static final long serialVersionUID = 1L; | 265 private static final long serialVersionUID = 1L; |
211 | 266 |
212 @Override | 267 @Override |
278 protected NumberFormat createFormatter(final CallContext context) { | 333 protected NumberFormat createFormatter(final CallContext context) { |
279 return Formatter.getFlowDepth(context); | 334 return Formatter.getFlowDepth(context); |
280 } | 335 } |
281 }; | 336 }; |
282 | 337 |
283 public static final SInfoResultType riverside = new SInfoResultType(I18NStrings.UNIT_NONE, "sinfo.export.flood_duration.csv.header.riverside") { | 338 public static final SInfoResultType riverside = new SInfoResultType(I18NStrings.UNIT_NONE, "sinfo.export.flood_duration.csv.header.riverside", |
339 "sinfo.export.flood_duration.pdf.header.riverside") { | |
284 private static final long serialVersionUID = 1L; | 340 private static final long serialVersionUID = 1L; |
285 | 341 |
286 @Override | 342 @Override |
287 public String exportValue(final CallContext context, final Object value) { | 343 public String exportValue(final CallContext context, final Object value) { |
288 return localizeRiverside(context, (AttributeKey) value); | 344 return localizeRiverside(context, (AttributeKey) value); |