[PATCH 1 of 4] Initial improved query to find matching cross section

Wald Commits scm-commit at wald.intevation.org
Thu Jul 4 12:03:17 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1372860591 -7200
# Node ID c155f8f57b7ec4714cdcf0605903f4ec1bde5c18
# Parent  8a425ee702e314705c38c38913c04363cdd2e4d9
Initial improved query to find matching cross section.

diff -r 8a425ee702e3 -r c155f8f57b7e backend/src/main/java/org/dive4elements/river/model/CrossSection.java
--- a/backend/src/main/java/org/dive4elements/river/model/CrossSection.java	Wed Jul 03 12:09:05 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/CrossSection.java	Wed Jul 03 16:09:51 2013 +0200
@@ -53,6 +53,16 @@
         "km between :from_km AND :to_km " +
         "ORDER BY csl.km, csl.id, csp.col_pos";
 
+    public static final String SQL_MIN_MAX =
+        "SELECT * FROM ( "+
+            "SELECT cross_section_id, MIN(km) AS minkm, MAX(km) AS maxkm " +
+            "FROM cross_section_lines " +
+            "WHERE cross_section_id IN " +
+            " (SELECT id FROM cross_sections WHERE river_id = :river_id) " +
+            "  GROUP BY cross_section_id" +
+        ") AS cs_ranges WHERE :km BETWEEN minkm AND maxkm ORDER BY :km - minkm "; 
+    // Order by time interval missing.
+
     private Integer                id;
     private River                  river;
     private TimeInterval           timeInterval;


More information about the Dive4elements-commits mailing list