Mercurial > dive4elements > river
changeset 739:08a3c3651e36
Fix for flys/issue173
flys-artifacts/trunk@2236 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 26 Jun 2011 16:19:02 +0000 |
parents | 5abdb2fa8eb1 |
children | a1efe7d11423 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java |
diffstat | 2 files changed, 26 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Sun Jun 26 14:46:48 2011 +0000 +++ b/flys-artifacts/ChangeLog Sun Jun 26 16:19:02 2011 +0000 @@ -1,3 +1,16 @@ +2011-06-26 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/Calculation4.java: + Fixed the way the gauge was found for a given interval. + The old way does not work because it was just tested if + the station point was inside the segments which is not + necessarily true. The obvious solution to simply check + the overlapping intervals does not work either because + the gauge ranges touches each other and so more than + one gauge are returned in these cases. The River.maxOverlap() + is now used to find the gauge with the max overlapping + range. + 2011-06-26 Sascha L. Teichmann <sascha.teichmann@intevation.de> Fix for flys/issue147
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java Sun Jun 26 14:46:48 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java Sun Jun 26 16:19:02 2011 +0000 @@ -51,12 +51,20 @@ // assign reference points for (Segment segment: segments) { - Gauge gauge = river.determineGaugeByStation( - segment.getFrom(), segment.getTo()); + Gauge gauge = river.maxOverlap(segment.getFrom(), segment.getTo()); - segment.setReferencePoint(gauge != null - ? gauge.getStation().doubleValue() - : 0.5*(segment.getFrom() + segment.getTo())); + if (gauge == null) { + logger.warn("no gauge found. Defaults to mid point."); + segment.setReferencePoint( + 0.5*(segment.getFrom()+segment.getTo())); + } + else { + double ref = gauge.getStation().doubleValue(); + logger.debug( + "reference gauge: " + gauge.getName() + + " (km " + ref + ")"); + segment.setReferencePoint(ref); + } double [] values = segment.values;