changeset 8779:50ff99266e0e

Issue1854: Filter BedOverview down to river distance.
author Tom Gottfried <tom@intevation.de>
date Thu, 03 Dec 2015 14:44:35 +0100
parents bbf6cf555e89
children 85f36f9f1bd3
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedOverview.java
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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);
 

http://dive4elements.wald.intevation.org