changeset 768:87ac543c7ab9

When looking up a gauge by km containment use precision of 1e-6. flys-backend/trunk@2232 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 26 Jun 2011 12:16:36 +0000
parents 5572d051347e
children 321b9e480f72
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/River.java
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Wed Jun 22 08:56:09 2011 +0000
+++ b/flys-backend/ChangeLog	Sun Jun 26 12:16:36 2011 +0000
@@ -1,3 +1,8 @@
+2011-06-26	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/model/River.java: When
+	looking up a gauge by km containment use precision of 1e-6.
+
 2011-06-22	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	Wed Jun 22 08:56:09 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/River.java	Sun Jun 26 12:16:36 2011 +0000
@@ -3,6 +3,7 @@
 import java.io.Serializable;
 
 import java.math.BigDecimal;
+import java.math.MathContext;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;
@@ -27,6 +28,8 @@
 public class River
 implements   Serializable
 {
+    public static final MathContext PRECISION = new MathContext(6);
+
     private Integer id;
 
     private String  name;
@@ -129,10 +132,10 @@
     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");
+            "from Gauge g where river=:river "  +
+            "and :p between g.range.a and g.range.b");
         query.setParameter("river", this);
-        query.setParameter("p", new BigDecimal(p));
+        query.setParameter("p", new BigDecimal(p, PRECISION));
         List<Gauge> gauges = query.list();
         return gauges.isEmpty() ? null : gauges.get(0);
     }

http://dive4elements.wald.intevation.org