changeset 764:e09f00ecb915

river model: Added method to find gauge by a position lying in its range. flys-backend/trunk@2160 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 18 Jun 2011 20:13:31 +0000
parents 8076f6a689d0
children 763c4137d6e1
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/River.java
diffstat 2 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Wed Jun 15 09:22:00 2011 +0000
+++ b/flys-backend/ChangeLog	Sat Jun 18 20:13:31 2011 +0000
@@ -1,3 +1,8 @@
+2011-06-14	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/model/River.java:
+	  Added method to find gauge by a position lying in its range.
+
 2011-06-14	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	First part of flys/issue18
--- a/flys-backend/src/main/java/de/intevation/flys/model/River.java	Wed Jun 15 09:22:00 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/River.java	Sat Jun 18 20:13:31 2011 +0000
@@ -116,6 +116,17 @@
         return query.list();
     }
 
+    public Gauge determineGaugeByPosition(double p) {
+        Session session = SessionHolder.HOLDER.get();
+        Query query = session.createQuery(
+            "from Gauge where river=:river " +
+            "and :p between range.a and range.b");
+        query.setParameter("river", this);
+        query.setParameter("p", new BigDecimal(p));
+        List<Gauge> gauges = query.list();
+        return gauges.isEmpty() ? null : gauges.get(0);
+    }
+
     public Gauge determineGaugeByStation(double a, double b) {
 
         if (a > b) { double t = a; a = b; b = t; }

http://dive4elements.wald.intevation.org