# HG changeset patch # User Sascha L. Teichmann # Date 1365434600 -7200 # Node ID 47e5bc64d3de13a7c18af6040865f39449804cfc # Parent a586153a277a3fcaa2acc5ff8c121da0cebb864f FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163 diff -r a586153a277a -r 47e5bc64d3de flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java --- 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> sorted = + new TreeMap>(); + String referenceS = getReference(); for (KMIndex reference: referenceEvents) { for (KMIndex.Entry kmEntry: reference) { - String kmS = kmF.format(kmEntry.getKm()); - for (QWD qwd: kmEntry.getValue()) { + Double km = kmEntry.getKm(); + + ArrayList list = sorted.get(km); + + if (list == null) { + list = new ArrayList(); + 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 kmEntry: periods) { + Double km = kmEntry.getKm(); + + ArrayList list = sorted.get(km); + + if (list == null) { + list = new ArrayList(); + 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 list: sorted.values()) { + for (String [] row: list) { + writer.writeNext(row); + } + } + writer.flush(); }