comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java @ 3088:960307cf2adc

Moved current km to context and added an abstract generator for fix analysis charts. flys-artifacts/trunk@4686 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 18 Jun 2012 11:21:30 +0000
parents ba7df29264cd
children 179e38aa678d
comparison
equal deleted inserted replaced
3087:4a76da133144 3088:960307cf2adc
29 implements FacetTypes { 29 implements FacetTypes {
30 30
31 /** House logger. */ 31 /** House logger. */
32 private static Logger logger = Logger.getLogger(FixDerivateFacet.class); 32 private static Logger logger = Logger.getLogger(FixDerivateFacet.class);
33 33
34 private double currentKm;
35 private double maxQ; 34 private double maxQ;
36 35
37 /** Trivial Constructor. */ 36 /** Trivial Constructor. */
38 public FixDerivateFacet() { 37 public FixDerivateFacet() {
39 } 38 }
42 /** 41 /**
43 * @param name 42 * @param name
44 */ 43 */
45 public FixDerivateFacet(String name, String description) { 44 public FixDerivateFacet(String name, String description) {
46 super(0, name, description, ComputeType.ADVANCE, null, null); 45 super(0, name, description, ComputeType.ADVANCE, null, null);
47 }
48
49
50 public Object getData(Artifact artifact, CallContext context, double km) {
51 this.currentKm = km;
52 return getData(artifact, context);
53 } 46 }
54 47
55 48
56 /** 49 /**
57 * Returns the data this facet requires. 50 * Returns the data this facet requires.
72 (CalculationResult) flys.compute(context, 65 (CalculationResult) flys.compute(context,
73 ComputeType.ADVANCE, 66 ComputeType.ADVANCE,
74 false); 67 false);
75 68
76 FixResult result = (FixResult) res.getData(); 69 FixResult result = (FixResult) res.getData();
70 double currentKm =
71 ((Double)context.getContextValue("currentKm")).doubleValue();
77 72
78 String function = access.getFunction(); 73 String function = access.getFunction();
79 Function ff = FunctionFactory.getInstance().getFunction(function); 74 Function ff = FunctionFactory.getInstance().getFunction(function);
80 Function.Derivative fd = ff.getDerivative(); 75 Function.Derivative fd = ff.getDerivative();
81 76
82 Parameters params = result.getParameters(); 77 Parameters params = result.getParameters();
83 78
84 // Determine maxQ 79 // Determine maxQ
85 double[] maxQs = params 80 double[] maxQs = params
86 .interpolate("km", this.currentKm, new String [] { "max_q" }); 81 .interpolate("km", currentKm, new String [] { "max_q" });
87 if(maxQs != null) { 82 if(maxQs != null) {
88 maxQ = maxQs[0]; 83 maxQ = maxQs[0];
89 } 84 }
90 85
91 int row = params.binarySearch("km", currentKm, Math.pow(10, -4)); 86 int row = params.binarySearch("km", currentKm, Math.pow(10, -4));

http://dive4elements.wald.intevation.org