[Dive4elements-commits] [PATCH] Backend: Import Flow Velocity Model: Use unique km for station

Wald Commits scm-commit at wald.intevation.org
Mon Apr 15 15:45:24 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1366033518 -7200
# Node ID 53134ccc4a645e873d967d352b8d1506a2bb7346
# Parent  8a198db28de0da4b0270daf1bd429edeb8c87f87
Backend: Import Flow Velocity Model: Use unique km for station.

diff -r 8a198db28de0 -r 53134ccc4a64 flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java	Mon Apr 15 12:56:43 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java	Mon Apr 15 15:45:18 2013 +0200
@@ -49,7 +49,7 @@
             Query query = session.createQuery(
                 "from FlowVelocityModelValue where " +
                 "   flowVelocity=:model and " +
-                "   station=:station"
+                "   station between :station - 0.00001 and :station + 0.00001"
             );
 
             query.setParameter("model", model);
diff -r 8a198db28de0 -r 53134ccc4a64 flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java	Mon Apr 15 12:56:43 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java	Mon Apr 15 15:45:18 2013 +0200
@@ -8,6 +8,7 @@
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.TreeSet;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -16,6 +17,7 @@
 import de.intevation.flys.importer.ImportDischargeZone;
 import de.intevation.flys.importer.ImportFlowVelocityModel;
 import de.intevation.flys.importer.ImportFlowVelocityModelValue;
+import de.intevation.flys.utils.EpsilonComparator;
 
 
 public class FlowVelocityModelParser extends LineParser {
@@ -54,9 +56,12 @@
 
     protected String description;
 
+    protected TreeSet<Double> kmExists;
+
 
     public FlowVelocityModelParser() {
         models = new ArrayList<ImportFlowVelocityModel>();
+        kmExists = new TreeSet<Double>(EpsilonComparator.CMP);
     }
 
 
@@ -231,7 +236,15 @@
         }
 
         try {
-            double km     = nf.parse(cols[0]).doubleValue();
+            double km = nf.parse(cols[0]).doubleValue();
+
+            Double key = Double.valueOf(km);
+
+            if (kmExists.contains(key)) {
+                log.warn("duplicate stattion '" + km + "': -> ignored");
+                return;
+            }
+
             double q      = nf.parse(cols[1]).doubleValue();
             double total  = nf.parse(cols[2]).doubleValue();
             double main   = nf.parse(cols[3]).doubleValue();
@@ -244,6 +257,8 @@
                 new BigDecimal(main),
                 new BigDecimal(stress)
             ));
+
+            kmExists.add(key);
         }
         catch (ParseException pe) {
             log.warn("Unparseable flow velocity values:", pe);


More information about the Dive4elements-commits mailing list