changeset 3743:51f76225823b

Extreme waterlevels: calculate the segments for Q km ranges. flys-artifacts/trunk@5426 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 10 Sep 2012 15:59:34 +0000
parents 467efea19d15
children b220287a171e
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/QRangeTree.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java
diffstat 4 files changed, 51 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Sep 10 14:38:58 2012 +0000
+++ b/flys-artifacts/ChangeLog	Mon Sep 10 15:59:34 2012 +0000
@@ -1,3 +1,15 @@
+2012-09-10	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/Range.java:
+	  Added disjoint method.
+
+	* src/main/java/de/intevation/flys/artifacts/model/QRangeTree.java:
+	  Find a list of segments intersecting a given range.
+
+	* src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java:
+	  Generate a list of ranges needed for the input of Qs
+	  in the "Auslagerung extremer Wasserspiegellagen.".
+
 2012-09-10	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/QRangeTree.java	Mon Sep 10 14:38:58 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/QRangeTree.java	Mon Sep 10 15:59:34 2012 +0000
@@ -212,6 +212,35 @@
         return root != null ? root.findQ(pos) : Double.NaN;
     }
 
+    protected Node head() {
+        Node head = root;
+        while (head.left != null) {
+            head = head.left;
+        }
+        return head;
+    }
+
+    public List<Range> findSegments(double a, double b) {
+        if (a > b) { double t = a; a = b; b = t; }
+        return findSegments(new Range(a, b));
+    }
+
+    public List<Range> findSegments(Range range) {
+        List<Range> segments = new ArrayList<Range>();
+
+        // Linear scan should be good enough here.
+        for (Node curr = head(); curr != null; curr = curr.next) {
+            if (!range.disjoint(curr.a, curr.b)) {
+                Range r = new Range(curr.a, curr.b);
+                if (r.clip(range)) {
+                    segments.add(r);
+                }
+            }
+        }
+
+        return segments;
+    }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java	Mon Sep 10 14:38:58 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java	Mon Sep 10 15:59:34 2012 +0000
@@ -30,6 +30,10 @@
         return end;
     }
 
+    public boolean disjoint(double ostart, double oend) {
+        return start > oend || ostart > end;
+    }
+
     public boolean disjoint(Range other) {
         return start > other.end || other.start > end;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java	Mon Sep 10 14:38:58 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java	Mon Sep 10 15:59:34 2012 +0000
@@ -1252,5 +1252,11 @@
         }
         return result;
     }
+
+    public List<Range> findSegments(double km1, double km2) {
+        return columns.length != 0
+            ? columns[columns.length-1].getQRangeTree().findSegments(km1, km2)
+            : Collections.<Range>emptyList();
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org