Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java @ 709:3b7e9ddf6bb1
New model to transport data and error reports of calculations.
flys-artifacts/trunk@2165 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 20 Jun 2011 12:32:32 +0000 |
parents | eab5e5089d77 |
children | 08a3c3651e36 |
comparison
equal
deleted
inserted
replaced
708:757ff56b43b3 | 709:3b7e9ddf6bb1 |
---|---|
82 } // for all segments | 82 } // for all segments |
83 | 83 |
84 Collections.sort(segments, REF_CMP); | 84 Collections.sort(segments, REF_CMP); |
85 } | 85 } |
86 | 86 |
87 public WQKms [] calculate( | 87 public CalculationResult calculate( |
88 WstValueTable table, | 88 WstValueTable table, |
89 double from, double to, double step | 89 double from, double to, double step |
90 ) { | 90 ) { |
91 boolean debug = logger.isDebugEnabled(); | 91 boolean debug = logger.isDebugEnabled(); |
92 | 92 |
101 | 101 |
102 if (segments.isEmpty()) { | 102 if (segments.isEmpty()) { |
103 logger.debug("no segments found"); | 103 logger.debug("no segments found"); |
104 // TODO: I18N | 104 // TODO: I18N |
105 addProblem("no segments found"); | 105 addProblem("no segments found"); |
106 return new WQKms[0]; | 106 return new CalculationResult(new WQKms[0], this); |
107 } | 107 } |
108 | 108 |
109 int numResults = segments.get(0).values.length; | 109 int numResults = segments.get(0).values.length; |
110 | 110 |
111 if (numResults < 1) { | 111 if (numResults < 1) { |
112 logger.debug("no values given"); | 112 logger.debug("no values given"); |
113 // TODO: I18N | 113 // TODO: I18N |
114 addProblem("no values given"); | 114 addProblem("no values given"); |
115 return new WQKms[0]; | 115 return new CalculationResult(new WQKms[0], this); |
116 } | 116 } |
117 | 117 |
118 | 118 |
119 WQKms [] results = new WQKms[numResults]; | 119 WQKms [] results = new WQKms[numResults]; |
120 for (int i = 0; i < results.length; ++i) { | 120 for (int i = 0; i < results.length; ++i) { |
276 // name the curves | 276 // name the curves |
277 for (int i = 0; i < results.length; ++i) { | 277 for (int i = 0; i < results.length; ++i) { |
278 results[i].setName(createName(i)); | 278 results[i].setName(createName(i)); |
279 } | 279 } |
280 | 280 |
281 return results; | 281 return new CalculationResult(results, this); |
282 } | 282 } |
283 | 283 |
284 protected String createName(int index) { | 284 protected String createName(int index) { |
285 // TODO: I18N | 285 // TODO: I18N |
286 StringBuilder sb = new StringBuilder(isQ ? "Q" : "W"); | 286 StringBuilder sb = new StringBuilder(isQ ? "Q" : "W"); |