# HG changeset patch # User Ingo Weinzierl # Date 1304575497 0 # Node ID b316d2106598bcbb79b57e862d3390893ea14f12 # Parent cf513cbe88c3b9c18241d77fe45ede201731c639 River got a new method that returns all gauges intersected by a given start and end point. flys-backend/trunk@1829 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r cf513cbe88c3 -r b316d2106598 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Tue May 03 17:40:02 2011 +0000 +++ b/flys-backend/ChangeLog Thu May 05 06:04:57 2011 +0000 @@ -1,3 +1,9 @@ +2011-05-05 Ingo Weinzierl + + * src/main/java/de/intevation/flys/model/River.java: Added a method that + returns all gauges of the river intersected by a given start and end + point. + 2011-05-03 Sascha L. Teichmann * src/main/java/de/intevation/flys/importer/ImportTimeInterval.java: diff -r cf513cbe88c3 -r b316d2106598 flys-backend/src/main/java/de/intevation/flys/model/River.java --- a/flys-backend/src/main/java/de/intevation/flys/model/River.java Tue May 03 17:40:02 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/River.java Thu May 05 06:04:57 2011 +0000 @@ -82,6 +82,29 @@ /** + * This method returns the gauges that intersect with a and + * b, + * + * @param a A start point. + * @param b An end point. + * + * @return the intersecting gauges. + */ + public List determineGauges(double a, double b) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from Gauge where river=:river " + + "and not (range.a > :b or range.b < :a) order by a"); + query.setParameter("river", this); + query.setParameter("a", new BigDecimal(a)); + query.setParameter("b", new BigDecimal(b)); + + return query.list(); + } + + + /** * This method returns the first gauge that is intersected by a and * b, * @@ -91,16 +114,7 @@ * @return the first intersecting gauge. */ public Gauge determineGauge(double a, double b) { - Session session = SessionHolder.HOLDER.get(); - - Query query = session.createQuery( - "from Gauge where river=:river " + - "and not (range.a > :b or range.b < :a) order by a"); - query.setParameter("river", this); - query.setParameter("a", new BigDecimal(a)); - query.setParameter("b", new BigDecimal(b)); - - List gauges = query.list(); + List gauges = determineGauges(a, b); return gauges != null && gauges.size() > 0 ? gauges.get(0) : null; }