Mercurial > dive4elements > river
changeset 5603:47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 08 Apr 2013 17:23:20 +0200 |
parents | a586153a277a |
children | 7e837c5c377b |
files | flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java |
diffstat | 1 files changed, 34 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java Mon Apr 08 17:14:57 2013 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java Mon Apr 08 17:23:20 2013 +0200 @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.TreeMap; import org.apache.log4j.Logger; @@ -131,20 +132,32 @@ DateFormat dF = getDateFormatter(); + TreeMap<Double, ArrayList<String []>> sorted = + new TreeMap<Double, ArrayList<String []>>(); + String referenceS = getReference(); for (KMIndex<QWD[]> reference: referenceEvents) { for (KMIndex.Entry<QWD[]> kmEntry: reference) { - String kmS = kmF.format(kmEntry.getKm()); - for (QWD qwd: kmEntry.getValue()) { + Double km = kmEntry.getKm(); + + ArrayList<String []> list = sorted.get(km); + + if (list == null) { + list = new ArrayList<String []>(); + sorted.put(km, list); + } + + String kmS = kmF.format(kmEntry.getKm()); + for (QWD qwd: kmEntry.getValue()) { String deltaWS = dwF.format(qwd.getDeltaW()); String qS = qF.format(qwd.getQ()); String wS = wF.format(qwd.getW()); String dateS = dF.format(qwd.getDate()); - writer.writeNext(new String[] { + list.add(new String[] { kmS, dateS, qS, @@ -152,7 +165,7 @@ referenceS, deltaWS }); - } + } } } @@ -166,6 +179,15 @@ for (KMIndex.Entry<AnalysisPeriod []> kmEntry: periods) { + Double km = kmEntry.getKm(); + + ArrayList<String []> list = sorted.get(km); + + if (list == null) { + list = new ArrayList<String []>(); + sorted.put(km, list); + } + String kmS = kmF.format(kmEntry.getKm()); int analysisCount = 1; @@ -182,7 +204,7 @@ String wS = wF.format(qwd.getW()); String dateS = dF.format(qwd.getDate()); - writer.writeNext(new String[] { + list.add(new String[] { kmS, dateS, qS, @@ -195,6 +217,13 @@ } } } + + for (ArrayList<String []> list: sorted.values()) { + for (String [] row: list) { + writer.writeNext(row); + } + } + writer.flush(); }