Mercurial > dive4elements > river
changeset 6229:3fea9701d58d
Fix gauge determination.
If we look upstream ( a > b ) we still have to compare
the start value of our range against the gauge and not the end
value. The start value is always the relevant value as we
handle the direction by checking this against A or B of the gauge.
Also:
I will never compare doubles with == again.
I will never compare doubles with == again.
I will never compare doubles with == again.
I will never compare doubles with == again.
I will never compare doubles with == again.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 06 Jun 2013 18:23:17 +0200 |
parents | cb536a9a6c17 |
children | 954dbb0806f3 |
files | backend/src/main/java/org/dive4elements/river/model/River.java |
diffstat | 1 files changed, 2 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/River.java Thu Jun 06 18:10:19 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/River.java Thu Jun 06 18:23:17 2013 +0200 @@ -301,19 +301,17 @@ public Gauge determineGauge(double a, double b) { List<Gauge> gauges = determineGauges(a, b); - int idx = a < b ? 0 : gauges.size() - 1; - if (a > b) { for (int i = gauges.size() - 1; i >= 0; i--) { Gauge g = gauges.get(i); - if (g.getRange().getA().doubleValue() == b) + if (KM_CMP.compare(g.getRange().getA().doubleValue(), a) == 0) continue; return g; } } for (Gauge g: gauges) { - if ( g.getRange().getB().doubleValue() == a ) { + if (KM_CMP.compare(g.getRange().getB().doubleValue(), a) == 0) { continue; } return g;