Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java @ 3215:750e98fc8b76
FixA: Tweaked the derivate diagram a bit and added chart info.
flys-artifacts/trunk@4838 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 29 Jun 2012 15:40:43 +0000 |
parents | 1b9f791937c3 |
children | 50d61a2494cb |
comparison
equal
deleted
inserted
replaced
3214:3287019ad04b | 3215:750e98fc8b76 |
---|---|
58 * | 58 * |
59 * @return the data. | 59 * @return the data. |
60 */ | 60 */ |
61 @Override | 61 @Override |
62 public Object getData(Artifact artifact, CallContext context) { | 62 public Object getData(Artifact artifact, CallContext context) { |
63 | |
63 logger.debug("FixDerivateFacet.getData"); | 64 logger.debug("FixDerivateFacet.getData"); |
64 if (artifact instanceof FLYSArtifact) { | 65 if (!(artifact instanceof FLYSArtifact)) { |
65 FLYSArtifact flys = (FLYSArtifact)artifact; | |
66 FixationArtifactAccess access = new FixationArtifactAccess(flys); | |
67 | |
68 CalculationResult res = | |
69 (CalculationResult) flys.compute(context, | |
70 ComputeType.ADVANCE, | |
71 false); | |
72 | |
73 FixResult result = (FixResult) res.getData(); | |
74 double currentKm = | |
75 ((Double)context.getContextValue("currentKm")).doubleValue(); | |
76 | |
77 String function = access.getFunction(); | |
78 Function ff = FunctionFactory.getInstance().getFunction(function); | |
79 Function.Derivative fd = ff.getDerivative(); | |
80 | |
81 Parameters params = result.getParameters(); | |
82 double maxQ = FixFacetUtils.getMaxQ(params, currentKm); | |
83 | |
84 String[] paramNames = ff.getParameterNames(); | |
85 | |
86 double[] coeffs = params.interpolate("km", currentKm, paramNames); | |
87 if(coeffs == null) { | |
88 logger.warn("getData: coeffs == null"); | |
89 return null; | |
90 } | |
91 | |
92 de.intevation.flys.artifacts.math.Function mf = | |
93 fd.instantiate(coeffs); | |
94 | |
95 FixFunction fix = new FixFunction( | |
96 "", | |
97 ff.getDescription(), | |
98 mf, | |
99 maxQ); | |
100 | |
101 return fix; | |
102 } | |
103 else { | |
104 logger.debug("Not an instance of FixationArtifact."); | 66 logger.debug("Not an instance of FixationArtifact."); |
105 return null; | 67 return null; |
106 } | 68 } |
69 | |
70 FLYSArtifact flys = (FLYSArtifact)artifact; | |
71 FixationArtifactAccess access = new FixationArtifactAccess(flys); | |
72 | |
73 CalculationResult res = | |
74 (CalculationResult) flys.compute(context, | |
75 ComputeType.ADVANCE, | |
76 false); | |
77 | |
78 FixResult result = (FixResult) res.getData(); | |
79 double currentKm = | |
80 ((Double)context.getContextValue("currentKm")).doubleValue(); | |
81 | |
82 String function = access.getFunction(); | |
83 Function ff = FunctionFactory.getInstance().getFunction(function); | |
84 Function.Derivative fd = ff.getDerivative(); | |
85 | |
86 Parameters params = result.getParameters(); | |
87 double maxQ = FixFacetUtils.getMaxQ(params, currentKm); | |
88 | |
89 String[] paramNames = ff.getParameterNames(); | |
90 | |
91 double[] coeffs = params.interpolate("km", currentKm, paramNames); | |
92 if (coeffs == null) { | |
93 logger.warn("getData: coeffs == null"); | |
94 return null; | |
95 } | |
96 | |
97 de.intevation.flys.artifacts.math.Function mf = | |
98 fd.instantiate(coeffs); | |
99 | |
100 FixFunction fix = new FixFunction( | |
101 "", | |
102 fd.getDescription(), | |
103 mf, | |
104 maxQ); | |
105 | |
106 return fix; | |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 /** | 110 /** |
111 * Create a deep copy of this Facet. | 111 * Create a deep copy of this Facet. |