[Dive4elements-commits] [PATCH] FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163

Wald Commits scm-commit at wald.intevation.org
Mon Apr 8 17:23:24 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# 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<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();
     }
 


More information about the Dive4elements-commits mailing list