comparison artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java @ 6941:d322da01d862

(issue1451) Round Q's in the way it is done for AT's and localize KM
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 29 Aug 2013 11:28:55 +0200
parents b1e66ea7fc2b
children 0a337f0005c2
comparison
equal deleted inserted replaced
6940:274948f91dd6 6941:d322da01d862
148 public void init(Document request, OutputStream out, CallContext context) { 148 public void init(Document request, OutputStream out, CallContext context) {
149 logger.debug("WaterlevelExporter.init"); 149 logger.debug("WaterlevelExporter.init");
150 150
151 super.init(request, out, context); 151 super.init(request, out, context);
152 152
153 this.data = new ArrayList<WQKms[]>(); 153 data = new ArrayList<WQKms[]>();
154 } 154 }
155 155
156 156
157 @Override 157 @Override
158 public void generate() 158 public void generate()
592 NumberFormat wf = getWFormatter(); 592 NumberFormat wf = getWFormatter();
593 NumberFormat qf = getQFormatter(); 593 NumberFormat qf = getQFormatter();
594 writer.writeNext(new String[] { 594 writer.writeNext(new String[] {
595 kmf.format(wqkm[2]), 595 kmf.format(wqkm[2]),
596 wf.format(wqkm[0]), 596 wf.format(wqkm[0]),
597 qf.format(wqkm[1]), 597 qf.format(RiverUtils.roundQ(wqkm[1])),
598 RiverUtils.getLocationDescription(flys, wqkm[2]) 598 RiverUtils.getLocationDescription(flys, wqkm[2])
599 }); 599 });
600 } 600 }
601
602 601
603 /** Write an csv-row at gauge location. */ 602 /** Write an csv-row at gauge location. */
604 private void writeRow6(CSVWriter writer, double wqkm[], String wOrQDesc, 603 private void writeRow6(CSVWriter writer, double wqkm[], String wOrQDesc,
605 D4EArtifact flys, String gaugeName) { 604 D4EArtifact flys, String gaugeName) {
606 NumberFormat kmf = getKmFormatter(); 605 NumberFormat kmf = getKmFormatter();
608 NumberFormat qf = getQFormatter(); 607 NumberFormat qf = getQFormatter();
609 608
610 writer.writeNext(new String[] { 609 writer.writeNext(new String[] {
611 kmf.format(wqkm[2]), 610 kmf.format(wqkm[2]),
612 wf.format(wqkm[0]), 611 wf.format(wqkm[0]),
613 qf.format(wqkm[1]), 612 qf.format(RiverUtils.roundQ(wqkm[1])),
614 wOrQDesc, 613 wOrQDesc,
615 RiverUtils.getLocationDescription(flys, wqkm[2]), 614 RiverUtils.getLocationDescription(flys, wqkm[2]),
616 gaugeName 615 gaugeName
617 }); 616 });
618 } 617 }
911 910
912 source.addMetaData ("river", RiverUtils.getRivername(flys)); 911 source.addMetaData ("river", RiverUtils.getRivername(flys));
913 912
914 Locale locale = Resources.getLocale(meta); 913 Locale locale = Resources.getLocale(meta);
915 DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); 914 DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
915 NumberFormat kmf = getKmFormatter();
916 916
917 source.addMetaData("date", df.format(new Date())); 917 source.addMetaData("date", df.format(new Date()));
918 918
919 RangeAccess rangeAccess = new RangeAccess(flys); 919 RangeAccess rangeAccess = new RangeAccess(flys);
920 double[] kms = rangeAccess.getKmRange(); 920 double[] kms = rangeAccess.getKmRange();
921 source.addMetaData("range", kms[0] + " - " + kms[kms.length-1]); 921 source.addMetaData("range",
922 kmf.format(kms[0]) + " - " + kmf.format(kms[kms.length-1]));
922 923
923 source.addMetaData("gauge", RiverUtils.getGaugename(flys)); 924 source.addMetaData("gauge", RiverUtils.getGaugename(flys));
924 925
925 source.addMetaData("calculation", Resources.getMsg( 926 source.addMetaData("calculation", Resources.getMsg(
926 locale, 927 locale,
967 968
968 if (atGauge) { 969 if (atGauge) {
969 source.addData(new String[] { 970 source.addData(new String[] {
970 kmf.format(result[2]), 971 kmf.format(result[2]),
971 wf.format(result[0]), 972 wf.format(result[0]),
972 qf.format(result[1]), 973 qf.format(RiverUtils.roundQ(result[1])),
973 desc, 974 desc,
974 RiverUtils.getLocationDescription(flys, result[2]), 975 RiverUtils.getLocationDescription(flys, result[2]),
975 result[2] >= a && result[2] <= b 976 result[2] >= a && result[2] <= b
976 ? gaugeName 977 ? gaugeName
977 : notinrange 978 : notinrange
979 } 980 }
980 else { 981 else {
981 source.addData(new String[] { 982 source.addData(new String[] {
982 kmf.format(result[2]), 983 kmf.format(result[2]),
983 wf.format(result[0]), 984 wf.format(result[0]),
984 qf.format(result[1]), 985 qf.format(RiverUtils.roundQ(result[1])),
985 desc, 986 desc,
986 RiverUtils.getLocationDescription(flys, result[2]), 987 RiverUtils.getLocationDescription(flys, result[2]),
987 result[2] >= a && result[2] <= b 988 result[2] >= a && result[2] <= b
988 ? gaugeName 989 ? gaugeName
989 : notinrange 990 : notinrange

http://dive4elements.wald.intevation.org