Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/Gauge.java @ 480:46bb2b9e0bdc
Introduced a 'scale' parameter in Gauge.determineMinMaxW().
flys-backend/trunk@1787 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 02 May 2011 11:33:32 +0000 |
parents | 8d76556c9616 |
children | 5a3109b8475f |
comparison
equal
deleted
inserted
replaced
479:f9653fc8ef7b | 480:46bb2b9e0bdc |
---|---|
26 @Entity | 26 @Entity |
27 @Table(name = "gauges") | 27 @Table(name = "gauges") |
28 public class Gauge | 28 public class Gauge |
29 implements Serializable | 29 implements Serializable |
30 { | 30 { |
31 public static final int DEFAULT_SCALE = 100; | |
32 | |
31 private Integer id; | 33 private Integer id; |
32 private String name; | 34 private String name; |
33 private River river; | 35 private River river; |
34 private BigDecimal station; | 36 private BigDecimal station; |
35 private BigDecimal aeo; | 37 private BigDecimal aeo; |
140 this.dischargeTables = dischargeTables; | 142 this.dischargeTables = dischargeTables; |
141 } | 143 } |
142 | 144 |
143 | 145 |
144 /** | 146 /** |
147 * Returns min and max W values of this gauge based with a DEFAULT_SCALE. | |
148 * | |
149 * @return min and max W value of this gauge [min,max]. | |
150 */ | |
151 public double[] determineMinMaxW() { | |
152 return determineMinMaxW(DEFAULT_SCALE); | |
153 } | |
154 | |
155 | |
156 /** | |
145 * Returns min and max W values of this gauge. | 157 * Returns min and max W values of this gauge. |
146 * | 158 * |
147 * @return the min and max W value of this gauge [min,max]. | 159 * @return the min and max W value of this gauge [min,max]. |
148 */ | 160 */ |
149 public double[] determineMinMaxW() { | 161 public double[] determineMinMaxW(int scale) { |
150 Session session = SessionHolder.HOLDER.get(); | 162 Session session = SessionHolder.HOLDER.get(); |
151 | 163 |
152 List<DischargeTable> tables = getDischargeTables(); | 164 List<DischargeTable> tables = getDischargeTables(); |
153 DischargeTable dischargeTable = null; | 165 DischargeTable dischargeTable = null; |
154 | 166 |
171 List results = query.list(); | 183 List results = query.list(); |
172 Object[] result = (Object[]) results.get(0); | 184 Object[] result = (Object[]) results.get(0); |
173 | 185 |
174 return result != null | 186 return result != null |
175 ? new double[] { | 187 ? new double[] { |
176 ((BigDecimal) result[0]).doubleValue(), | 188 ((BigDecimal) result[0]).doubleValue() * scale, |
177 ((BigDecimal) result[1]).doubleValue() } | 189 ((BigDecimal) result[1]).doubleValue() * scale} |
178 : null; | 190 : null; |
179 } | 191 } |
180 } | 192 } |
181 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 193 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |