changeset 3014:e341606faeb4

FixA: Use KMIndex for outliers. flys-artifacts/trunk@4579 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 05 Jun 2012 09:11:24 +0000 (2012-06-05)
parents ba62c1751f07
children 9cea02b51241
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixResult.java
diffstat 3 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Jun 05 09:04:01 2012 +0000
+++ b/flys-artifacts/ChangeLog	Tue Jun 05 09:11:24 2012 +0000
@@ -1,3 +1,10 @@
+2012-06-05	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixResult.java:
+	  Now uses the KMIndex for outliers.
+	  TODO: Use KMIndex for DeltaWTs, too.
+
 2012-06-05	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/utils/KMIndex.java: New.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Tue Jun 05 09:04:01 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Tue Jun 05 09:11:24 2012 +0000
@@ -25,14 +25,13 @@
 
 import de.intevation.flys.utils.DateAverager;
 import de.intevation.flys.utils.DoubleUtil;
-import de.intevation.flys.utils.EpsilonComparator;
+import de.intevation.flys.utils.KMIndex;
 
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeMap;
 
 import org.apache.log4j.Logger;
 
@@ -206,8 +205,7 @@
             log.debug("number of kms: " + kms.length);
         }
 
-        TreeMap<Double, QW []> outliers =
-            new TreeMap<Double, QW []>(EpsilonComparator.INSTANCE);
+        KMIndex<QW []> outliers = new KMIndex<QW []>();
 
         int kmIndex             = results.columnIndex("km");
         int chiSqrIndex         = results.columnIndex("chi_sqr");
@@ -235,7 +233,7 @@
             }
 
             if (fitting.hasOutliers()) {
-                outliers.put(Double.valueOf(km), fitting.outliersToArray());
+                outliers.add(km, fitting.outliersToArray());
             }
 
             int row = results.newRow();
@@ -263,6 +261,8 @@
             overview,
             results);
 
+        outliers.sort();
+
         FixResult fr = new FixResult(results, deltaWTsKM, outliers);
 
         return new CalculationResult(fr, this);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixResult.java	Tue Jun 05 09:04:01 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixResult.java	Tue Jun 05 09:11:24 2012 +0000
@@ -2,7 +2,7 @@
 
 import de.intevation.flys.artifacts.model.Parameters;
 
-import java.util.TreeMap;
+import de.intevation.flys.utils.KMIndex;
 
 import java.io.Serializable;
 
@@ -11,15 +11,15 @@
 {
     protected Parameters parameters;
     protected DeltaWTsKM deltaWTsKM;
-    protected TreeMap<Double, QW []> outliers;
+    protected KMIndex<QW []> outliers;
 
     public FixResult() {
     }
 
     public FixResult(
-        Parameters             parameters,
-        DeltaWTsKM             deltaWTsKM,
-        TreeMap<Double, QW []> outliers
+        Parameters     parameters,
+        DeltaWTsKM     deltaWTsKM,
+        KMIndex<QW []> outliers
     ) {
         this.parameters = parameters;
         this.deltaWTsKM = deltaWTsKM;
@@ -42,11 +42,11 @@
         this.deltaWTsKM = deltaWTsKM;
     }
 
-    public TreeMap<Double, QW []> getOutliers() {
+    public KMIndex<QW []> getOutliers() {
         return outliers;
     }
 
-    public void setOutliers(TreeMap<Double, QW []> outliers) {
+    public void setOutliers(KMIndex<QW []> outliers) {
         this.outliers = outliers;
     }
 }

http://dive4elements.wald.intevation.org