Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/Range.java @ 5777:e95427ed80e5
Merged
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 21 Apr 2013 10:46:59 +0200 |
parents | 80b9218ac007 |
children |
comparison
equal
deleted
inserted
replaced
5776:1126b9e00378 | 5777:e95427ed80e5 |
---|---|
17 @Entity | 17 @Entity |
18 @Table(name = "ranges") | 18 @Table(name = "ranges") |
19 public class Range | 19 public class Range |
20 implements Serializable | 20 implements Serializable |
21 { | 21 { |
22 public static final double EPSILON = 1e-5; | |
22 private Integer id; | 23 private Integer id; |
23 private BigDecimal a; | 24 private BigDecimal a; |
24 private BigDecimal b; | 25 private BigDecimal b; |
25 | 26 |
26 private River river; | 27 private River river; |
69 return b; | 70 return b; |
70 } | 71 } |
71 | 72 |
72 public void setB(BigDecimal b) { | 73 public void setB(BigDecimal b) { |
73 this.b = b; | 74 this.b = b; |
75 } | |
76 | |
77 public boolean containsTolerant(double x) { | |
78 return containsTolerant(x, EPSILON); | |
79 } | |
80 | |
81 public boolean containsTolerant(double x, double tolerance) { | |
82 BigDecimal b = this.b != null ? this.b : a; | |
83 double av = a.doubleValue(); | |
84 double bv = b.doubleValue(); | |
85 if (av > bv) { | |
86 double t = av; | |
87 av = bv; | |
88 bv = t; | |
89 } | |
90 return x+tolerance >= av && x-tolerance <= bv; | |
74 } | 91 } |
75 | 92 |
76 public boolean contains(double x) { | 93 public boolean contains(double x) { |
77 BigDecimal b = this.b != null ? this.b : a; | 94 BigDecimal b = this.b != null ? this.b : a; |
78 double av = a.doubleValue(); | 95 double av = a.doubleValue(); |