Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java @ 3080:dc2765e31e1f
Added getData method with an additional km parameter.
flys-artifacts/trunk@4676 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 15 Jun 2012 12:42:13 +0000 |
parents | d87aadaa4f7e |
children | 26119b7b3154 |
comparison
equal
deleted
inserted
replaced
3079:8ad8a227d983 | 3080:dc2765e31e1f |
---|---|
31 implements FacetTypes { | 31 implements FacetTypes { |
32 | 32 |
33 /** House logger. */ | 33 /** House logger. */ |
34 private static Logger logger = Logger.getLogger(FixDerivateFacet.class); | 34 private static Logger logger = Logger.getLogger(FixDerivateFacet.class); |
35 | 35 |
36 private double currentKm; | |
37 | |
36 /** Trivial Constructor. */ | 38 /** Trivial Constructor. */ |
37 public FixDerivateFacet() { | 39 public FixDerivateFacet() { |
38 } | 40 } |
39 | 41 |
40 | 42 |
41 /** | 43 /** |
42 * @param name | 44 * @param name |
43 */ | 45 */ |
44 public FixDerivateFacet(String name, String description) { | 46 public FixDerivateFacet(String name, String description) { |
45 super(0, name, description, ComputeType.ADVANCE, null, null); | 47 super(0, name, description, ComputeType.ADVANCE, null, null); |
48 } | |
49 | |
50 | |
51 public Object getData(Artifact artifact, CallContext context, double km) { | |
52 this.currentKm = km; | |
53 return getData(artifact, context); | |
46 } | 54 } |
47 | 55 |
48 | 56 |
49 /** | 57 /** |
50 * Returns the data this facet requires. | 58 * Returns the data this facet requires. |
66 ComputeType.ADVANCE, | 74 ComputeType.ADVANCE, |
67 false); | 75 false); |
68 | 76 |
69 FixResult result = (FixResult) res.getData(); | 77 FixResult result = (FixResult) res.getData(); |
70 | 78 |
71 double km = access.getCurrentKm(); | |
72 | |
73 String function = access.getFunction(); | 79 String function = access.getFunction(); |
74 Function ff = FunctionFactory.getInstance().getFunction(function); | 80 Function ff = FunctionFactory.getInstance().getFunction(function); |
75 Function.Derivative fd = ff.getDerivative(); | 81 Function.Derivative fd = ff.getDerivative(); |
76 | 82 |
77 Parameters params = result.getParameters(); | 83 Parameters params = result.getParameters(); |
78 int row = params.binarySearch("km", km, Math.pow(10, -4)); | 84 int row = params.binarySearch("km", currentKm, Math.pow(10, -4)); |
79 if(row < 0) { | 85 if(row < 0) { |
80 row = -row - 1; | 86 row = -row - 1; |
81 logger.debug("getData: no direct hit in params.binarySearch"); | 87 logger.debug("getData: no direct hit in params.binarySearch"); |
82 } | 88 } |
83 String[] paramNames = ff.getParameterNames(); | 89 String[] paramNames = ff.getParameterNames(); |
86 params.get(row, paramInd, coeffs); | 92 params.get(row, paramInd, coeffs); |
87 | 93 |
88 de.intevation.flys.artifacts.math.Function mf = | 94 de.intevation.flys.artifacts.math.Function mf = |
89 fd.instantiate(coeffs); | 95 fd.instantiate(coeffs); |
90 | 96 |
91 double maxQ = getMaxQ(result, km); | 97 double maxQ = getMaxQ(result, currentKm); |
92 | 98 |
93 FixFunction fix = new FixFunction( | 99 FixFunction fix = new FixFunction( |
94 "", | 100 "", |
95 ff.getDescription(), | 101 ff.getDescription(), |
96 mf, | 102 mf, |