[PATCH 3 of 3] Issue1854: Filter BedOverview down to river distance

Wald Commits scm-commit at wald.intevation.org
Thu Dec 3 14:45:29 CET 2015


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1449150275 -3600
# Node ID 50ff99266e0e0dc6cd97858004d176e8cc8fc2c6
# Parent  bbf6cf555e89338e8d0db8a949a4215408d4b0e3
Issue1854: Filter BedOverview down to river distance.

diff -r bbf6cf555e89 -r 50ff99266e0e artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedOverview.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedOverview.java	Thu Dec 03 12:20:03 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedOverview.java	Thu Dec 03 14:44:35 2015 +0100
@@ -95,12 +95,14 @@
         "    JOIN gewaesser g " +
         "       ON s.gewaesserid = g.gewaesserid " +
         "WHERE" +
-        "    g.name = :name AND" +
-        "    so.km IS NOT NULL " +
+        "    g.name = :name" +
+        "    AND so.km IS NOT NULL" +
+        "    AND so.km BETWEEN :from AND :to " +
         "ORDER by" +
         "    so.km, so.datum";
 
-    protected String       riverName;
+    protected String riverName;
+    protected String SeddbRiverName;
 
     protected KMIndex<List<Date>> entries;
 
@@ -110,7 +112,8 @@
 
     public BedOverview(String riverName) {
         this();
-        this.riverName = RiverFactory.getRiver(riverName).nameForSeddb();
+        this.riverName = riverName;
+        this.SeddbRiverName = RiverFactory.getRiver(riverName).nameForSeddb();
     }
 
     private static final boolean epsilonEquals(double a, double b) {
@@ -118,16 +121,21 @@
     }
 
     protected void loadData(Session session) {
+        double [] fromTo = RiverFactory.getRiver(riverName)
+            .determineMinMaxDistance();
+
         SQLQuery query = session.createSQLQuery(SQL_SQ)
             .addScalar("km",    StandardBasicTypes.DOUBLE)
             .addScalar("datum", StandardBasicTypes.DATE);
 
-        query.setString("name", riverName);
+        query.setString("name", SeddbRiverName);
+        query.setDouble("from", fromTo[0]);
+        query.setDouble("to", fromTo[1]);
 
         List<Object []> list = query.list();
 
         if (list.isEmpty()) {
-            log.warn("No river '" + riverName + "' found.");
+            log.warn("No river '" + SeddbRiverName + "' found.");
         }
 
         Double prevKm = -Double.MAX_VALUE;
@@ -175,7 +183,7 @@
 
         Element riverElement = document.createElement("river");
 
-        riverElement.setAttribute("name", riverName);
+        riverElement.setAttribute("name", SeddbRiverName);
 
         sqElement.appendChild(riverElement);
 


More information about the Dive4Elements-commits mailing list