[PATCH] (issue1451) Round Q's in the way it is done for AT's and localize KM
Wald Commits
scm-commit at wald.intevation.org
Thu Aug 29 11:47:39 CEST 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1377768535 -7200
# Node ID d322da01d86210c33b77df024355015cc9cdbd73
# Parent 274948f91dd65b61d23e34e292705fbd8dc38eb8
(issue1451) Round Q's in the way it is done for AT's and localize KM
diff -r 274948f91dd6 -r d322da01d862 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Thu Aug 29 11:33:30 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Thu Aug 29 11:28:55 2013 +0200
@@ -150,7 +150,7 @@
super.init(request, out, context);
- this.data = new ArrayList<WQKms[]>();
+ data = new ArrayList<WQKms[]>();
}
@@ -594,12 +594,11 @@
writer.writeNext(new String[] {
kmf.format(wqkm[2]),
wf.format(wqkm[0]),
- qf.format(wqkm[1]),
+ qf.format(RiverUtils.roundQ(wqkm[1])),
RiverUtils.getLocationDescription(flys, wqkm[2])
});
}
-
/** Write an csv-row at gauge location. */
private void writeRow6(CSVWriter writer, double wqkm[], String wOrQDesc,
D4EArtifact flys, String gaugeName) {
@@ -610,7 +609,7 @@
writer.writeNext(new String[] {
kmf.format(wqkm[2]),
wf.format(wqkm[0]),
- qf.format(wqkm[1]),
+ qf.format(RiverUtils.roundQ(wqkm[1])),
wOrQDesc,
RiverUtils.getLocationDescription(flys, wqkm[2]),
gaugeName
@@ -913,12 +912,14 @@
Locale locale = Resources.getLocale(meta);
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
+ NumberFormat kmf = getKmFormatter();
source.addMetaData("date", df.format(new Date()));
RangeAccess rangeAccess = new RangeAccess(flys);
double[] kms = rangeAccess.getKmRange();
- source.addMetaData("range", kms[0] + " - " + kms[kms.length-1]);
+ source.addMetaData("range",
+ kmf.format(kms[0]) + " - " + kmf.format(kms[kms.length-1]));
source.addMetaData("gauge", RiverUtils.getGaugename(flys));
@@ -969,7 +970,7 @@
source.addData(new String[] {
kmf.format(result[2]),
wf.format(result[0]),
- qf.format(result[1]),
+ qf.format(RiverUtils.roundQ(result[1])),
desc,
RiverUtils.getLocationDescription(flys, result[2]),
result[2] >= a && result[2] <= b
@@ -981,7 +982,7 @@
source.addData(new String[] {
kmf.format(result[2]),
wf.format(result[0]),
- qf.format(result[1]),
+ qf.format(RiverUtils.roundQ(result[1])),
desc,
RiverUtils.getLocationDescription(flys, result[2]),
result[2] >= a && result[2] <= b
diff -r 274948f91dd6 -r d322da01d862 artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java
--- a/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java Thu Aug 29 11:33:30 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java Thu Aug 29 11:28:55 2013 +0200
@@ -929,5 +929,14 @@
return river.determineGauges(dist[0], dist[1]);
}
+
+ /** Round a Q in the AT format style **/
+ public static double roundQ(double q) {
+ if (q < 10d) q = Math.rint((q*1000d)) / 1000d;
+ else if (q < 100d) q = Math.rint((q*100d)) / 100d;
+ else if (q < 1000d) q = Math.rint((q*10d)) / 10d;
+ else if (q >= 1000d) q = Math.rint(q);
+ return q;
+ }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4elements-commits
mailing list