Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/LogSQ.java @ 6821:1c3b2f7dc9a4
S/Q relation: Added forgotten class.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 14 Aug 2013 11:01:16 +0200 |
parents | |
children | 84929f882fa2 |
comparison
equal
deleted
inserted
replaced
6820:f48d45e760d0 | 6821:1c3b2f7dc9a4 |
---|---|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.artifacts.model.sq; | |
10 | |
11 public class LogSQ extends SQ { | |
12 | |
13 public static final View LOG_SQ_VIEW = new View() { | |
14 @Override | |
15 public double getS(SQ sq) { | |
16 return ((LogSQ)sq).getLogS(); | |
17 } | |
18 | |
19 @Override | |
20 public double getQ(SQ sq) { | |
21 return ((LogSQ)sq).getLogQ(); | |
22 } | |
23 }; | |
24 | |
25 public static final Factory LOG_SQ_FACTORY = new Factory() { | |
26 @Override | |
27 public SQ createSQ(double s, double q) { | |
28 return new LogSQ(s, q); | |
29 } | |
30 }; | |
31 | |
32 protected double logS; | |
33 protected double logQ; | |
34 | |
35 protected boolean logTrans; | |
36 | |
37 public LogSQ() { | |
38 } | |
39 | |
40 public LogSQ(double s, double q) { | |
41 super(s, q); | |
42 } | |
43 | |
44 /** important: We cannot process negative s/q. */ | |
45 @Override | |
46 public boolean isValid() { | |
47 return super.isValid() && s > 0d && q > 0d; | |
48 } | |
49 | |
50 protected void ensureLogTrans() { | |
51 if (!logTrans) { | |
52 logTrans = true; | |
53 logS = Math.log(s); | |
54 logQ = Math.log(q); | |
55 } | |
56 } | |
57 | |
58 public double getLogS() { | |
59 ensureLogTrans(); | |
60 return logS; | |
61 } | |
62 | |
63 public double getLogQ() { | |
64 ensureLogTrans(); | |
65 return logQ; | |
66 } | |
67 } | |
68 |