changeset 8782:4289930e276c

Issue1854: Adapt to QualityMeasurementFactory and filter with river distance.
author Tom Gottfried <tom@intevation.de>
date Tue, 08 Dec 2015 16:03:30 +0100
parents 9530a00056dd
children b251a6ad46bb
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedloadOverview.java
diffstat 1 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedloadOverview.java	Tue Dec 08 15:56:12 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedloadOverview.java	Tue Dec 08 16:03:30 2015 +0100
@@ -94,12 +94,14 @@
         "    JOIN gewaesser g " +
         "       ON s.gewaesserid = g.gewaesserid " +
         "WHERE" +
-        "    g.name = :name AND " +
-        "    m.km IS NOT NULL " +
-        "ORDER by" +
-        "    m.km, m.datum";
+        "    g.name = :name" +
+        "    AND m.km IS NOT NULL" +
+        "    AND m.km BETWEEN :from AND :to " +
+        "    AND m.d10 IS NOT NULL" +
+        "ORDER BY m.km, m.datum";
 
-    protected String       riverName;
+    protected String riverName;
+    protected String SeddbRiverName;
 
     protected KMIndex<List<Date>> entries;
 
@@ -109,7 +111,8 @@
 
     public BedloadOverview(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) {
@@ -117,16 +120,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;
@@ -174,7 +182,7 @@
 
         Element riverElement = document.createElement("river");
 
-        riverElement.setAttribute("name", riverName);
+        riverElement.setAttribute("name", SeddbRiverName);
 
         sqElement.appendChild(riverElement);
 

http://dive4elements.wald.intevation.org