Mercurial > dive4elements > river
changeset 5879:895b80728095
Merged
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 29 Apr 2013 16:04:14 +0200 |
parents | a7b56219b362 (diff) 7e48f7a64182 (current diff) |
children | 1f52b2bff737 |
files | |
diffstat | 1 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/River.java Mon Apr 29 13:42:20 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/River.java Mon Apr 29 16:04:14 2013 +0200 @@ -200,6 +200,8 @@ double c = r.getA().doubleValue(); double d = r.getB().doubleValue(); + if (c > d) { double t = c; c = d; d = t; } + double start = c >= a ? c : a; double stop = d <= b ? d : b; @@ -228,7 +230,9 @@ Session session = SessionHolder.HOLDER.get(); Query query = session.createQuery( "from Gauge g where river=:river " + - "and :p between g.range.a and g.range.b"); + "and :p between " + + "least(g.range.a, g.range.b) and " + + "greatest(g.range.a, g.range.b)"); query.setParameter("river", this); query.setParameter("p", new BigDecimal(p, PRECISION)); List<Gauge> gauges = query.list(); @@ -265,7 +269,7 @@ query.setParameter("river", getId()); - double minmax[] = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; + double minmax[] = new double[] { Double.MAX_VALUE, -Double.MAX_VALUE }; List<Object> results = query.list(); @@ -312,7 +316,7 @@ return null; } - double minmax[] = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; + double minmax[] = new double[] { Double.MAX_VALUE, -Double.MAX_VALUE }; for (Gauge g: gauges) { Range r = g.getRange(); @@ -321,13 +325,23 @@ continue; } - double a = r.getA().doubleValue(); - minmax[0] = minmax[0] < a ? minmax[0] : a; + double a = r.getA().doubleValue(); + if (a < minmax[0]) { + minmax[0] = a; + } + if (a > minmax[1]) { + minmax[1] = a; + } BigDecimal bigB = r.getB(); if (bigB != null) { - double b = bigB.doubleValue(); - minmax[1] = minmax[1] > b ? minmax[1] : b; + double b = bigB.doubleValue(); + if (b < minmax[0]) { + minmax[0] = b; + } + if (b > minmax[1]) { + minmax[1] = b; + } } } @@ -336,7 +350,7 @@ public Map<Double, Double> queryGaugeDatumsKMs() { List<Gauge> gauges = getGauges(); - Map result = new TreeMap<Double, Double>(KM_CMP); + Map<Double, Double> result = new TreeMap<Double, Double>(KM_CMP); for (Gauge gauge: gauges) { BigDecimal km = gauge.getStation();