# HG changeset patch # User Sascha L. Teichmann # Date 1309105142 0 # Node ID 08a3c3651e36d0bb5dbae861fc4c19f93bb7ad40 # Parent 5abdb2fa8eb18d08ec65434eaf29367a7cc974ed Fix for flys/issue173 flys-artifacts/trunk@2236 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 5abdb2fa8eb1 -r 08a3c3651e36 flys-artifacts/ChangeLog --- 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 + + * 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 Fix for flys/issue147 diff -r 5abdb2fa8eb1 -r 08a3c3651e36 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java --- 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;