comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.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 6502b17931b9
children 26119b7b3154
comparison
equal deleted inserted replaced
3079:8ad8a227d983 3080:dc2765e31e1f
28 implements FacetTypes { 28 implements FacetTypes {
29 29
30 /** House logger. */ 30 /** House logger. */
31 private static Logger logger = Logger.getLogger(FixWQCurveFacet.class); 31 private static Logger logger = Logger.getLogger(FixWQCurveFacet.class);
32 32
33 private double currentKm;
34
33 /** Trivial Constructor. */ 35 /** Trivial Constructor. */
34 public FixWQCurveFacet() { 36 public FixWQCurveFacet() {
37 currentKm = 0;
35 } 38 }
36 39
37 40
38 /** 41 /**
39 * @param name 42 * @param name
40 */ 43 */
41 public FixWQCurveFacet(String description) { 44 public FixWQCurveFacet(String description) {
42 super(0, FIX_WQ_CURVE, description, ComputeType.ADVANCE, null, null); 45 super(0, FIX_WQ_CURVE, description, ComputeType.ADVANCE, null, null);
46 }
47
48
49 public Object getData(Artifact artifact, CallContext context, double km) {
50 this.currentKm = km;
51 return getData(artifact, context);
43 } 52 }
44 53
45 54
46 /** 55 /**
47 * Returns the data this facet requires. 56 * Returns the data this facet requires.
63 ComputeType.ADVANCE, 72 ComputeType.ADVANCE,
64 false); 73 false);
65 74
66 FixResult result = (FixResult) res.getData(); 75 FixResult result = (FixResult) res.getData();
67 76
68 double km = access.getCurrentKm(); 77 logger.debug("FixWQCurveFacet.getData: km = " + currentKm);
69 logger.debug("FixWQCurveFacet.getData: km = " + km);
70 78
71 String function = access.getFunction(); 79 String function = access.getFunction();
72 Function ff = FunctionFactory.getInstance().getFunction(function); 80 Function ff = FunctionFactory.getInstance().getFunction(function);
73 81
74 if (ff == null) { 82 if (ff == null) {
76 } 84 }
77 85
78 Parameters params = result.getParameters(); 86 Parameters params = result.getParameters();
79 String[] paramNames = ff.getParameterNames(); 87 String[] paramNames = ff.getParameterNames();
80 88
81 double [] coeffs = params.interpolate("km", km, paramNames); 89 double [] coeffs = params.interpolate("km", currentKm, paramNames);
82 90
83 if (coeffs == null) { 91 if (coeffs == null) {
84 return null; 92 return null;
85 } 93 }
86 94
87 de.intevation.flys.artifacts.math.Function mf = 95 de.intevation.flys.artifacts.math.Function mf =
88 ff.instantiate(coeffs); 96 ff.instantiate(coeffs);
89 97
90 double maxQ = getMaxQ(params, km); 98 double maxQ = getMaxQ(params, currentKm);
91 99
92 logger.debug("getData: maxQ = " + maxQ); 100 logger.debug("getData: maxQ = " + maxQ);
93 101
94 FixFunction fix = new FixFunction( 102 FixFunction fix = new FixFunction(
95 ff.getName(), 103 ff.getName(),

http://dive4elements.wald.intevation.org