comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/QRangeTree.java @ 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 5642a83420f2
children 729a5edb0313
comparison
equal deleted inserted replaced
3742:467efea19d15 3743:51f76225823b
208 return parent; 208 return parent;
209 } 209 }
210 210
211 public double findQ(double pos) { 211 public double findQ(double pos) {
212 return root != null ? root.findQ(pos) : Double.NaN; 212 return root != null ? root.findQ(pos) : Double.NaN;
213 }
214
215 protected Node head() {
216 Node head = root;
217 while (head.left != null) {
218 head = head.left;
219 }
220 return head;
221 }
222
223 public List<Range> findSegments(double a, double b) {
224 if (a > b) { double t = a; a = b; b = t; }
225 return findSegments(new Range(a, b));
226 }
227
228 public List<Range> findSegments(Range range) {
229 List<Range> segments = new ArrayList<Range>();
230
231 // Linear scan should be good enough here.
232 for (Node curr = head(); curr != null; curr = curr.next) {
233 if (!range.disjoint(curr.a, curr.b)) {
234 Range r = new Range(curr.a, curr.b);
235 if (r.clip(range)) {
236 segments.add(r);
237 }
238 }
239 }
240
241 return segments;
213 } 242 }
214 243
215 @Override 244 @Override
216 public String toString() { 245 public String toString() {
217 StringBuilder sb = new StringBuilder(); 246 StringBuilder sb = new StringBuilder();

http://dive4elements.wald.intevation.org