changeset 757:c19d4c643526

River: add method to find gauge by its station position. flys-backend/trunk@2090 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 08 Jun 2011 19:03:44 +0000
parents ca13926b8871
children bf16268629d9
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/River.java
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Thu May 26 15:00:04 2011 +0000
+++ b/flys-backend/ChangeLog	Wed Jun 08 19:03:44 2011 +0000
@@ -1,3 +1,8 @@
+2011-06-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/model/River.java:
+	  Added method to find gauge only by station position.
+
 2011-05-24	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/model/River.java:
--- a/flys-backend/src/main/java/de/intevation/flys/model/River.java	Thu May 26 15:00:04 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/River.java	Wed Jun 08 19:03:44 2011 +0000
@@ -116,6 +116,23 @@
         return query.list();
     }
 
+    public Gauge determineGaugeByStation(double a, double b) {
+
+        if (a > b) { double t = a; a = b; b = t; }
+
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from Gauge where river.id=:river " +
+            "and station between :a and :b");
+        query.setParameter("river", getId());
+        query.setParameter("a", new BigDecimal(a));
+        query.setParameter("b", new BigDecimal(b));
+
+        List<Gauge> gauges = query.list();
+        return gauges.isEmpty() ? null : gauges.get(0);
+    }
+
 
     /**
      * This method returns the first gauge that is intersected by <i>a</i> and

http://dive4elements.wald.intevation.org