Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java @ 8647:5f60bd7c4b42
(issue1754) Simplify code to handle a>b cases.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 30 Mar 2015 19:28:41 +0200 |
parents | 0f6f702742b4 |
children | 8c64617a7991 5e38e2924c07 |
comparison
equal
deleted
inserted
replaced
8646:8e5c026216fd | 8647:5f60bd7c4b42 |
---|---|
192 return null; | 192 return null; |
193 } | 193 } |
194 WINFOArtifact winfo = (WINFOArtifact) artifact; | 194 WINFOArtifact winfo = (WINFOArtifact) artifact; |
195 String id = getID(); | 195 String id = getID(); |
196 RangeAccess rangeAccess = new RangeAccess(artifact); | 196 RangeAccess rangeAccess = new RangeAccess(artifact); |
197 double from = rangeAccess.getFrom(); | 197 double from = rangeAccess.getFrom(true); |
198 double to = rangeAccess.getTo(); | 198 double to = rangeAccess.getTo(true); |
199 double start; | |
200 double end; | |
201 // Load the Artifacts/facets that we want to subtract and display. | 199 // Load the Artifacts/facets that we want to subtract and display. |
202 // Expected format is: | 200 // Expected format is: |
203 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] | 201 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] |
204 String diffids = winfo.getDataAsString("diffids"); | 202 String diffids = winfo.getDataAsString("diffids"); |
205 log.debug("WDifferencesState has: " + diffids); | 203 log.debug("WDifferencesState has: " + diffids); |
206 String datas[] = diffids.split("#"); | 204 String datas[] = diffids.split("#"); |
207 | 205 |
208 log.debug("Difference from: " + from + " to: " + to); | 206 log.debug("Difference from: " + from + " to: " + to); |
209 /* Check if we need to obtain the data in a different order */ | 207 /* Check if we need to obtain the data in a different order */ |
210 if ((!Double.isNaN(from) && !Double.isNaN(to)) && from > to) { | |
211 log.debug("Reordering range."); | |
212 start = to; | |
213 end = from; | |
214 } else { | |
215 start = from; | |
216 end = to; | |
217 } | |
218 | |
219 // Validate the Data-Strings. | 208 // Validate the Data-Strings. |
220 for (String s: datas) { | 209 for (String s: datas) { |
221 if (!WaterlevelSelectState.isValueValid(s)) { | 210 if (!WaterlevelSelectState.isValueValid(s)) { |
222 // TODO: escalate. | 211 // TODO: escalate. |
223 } | 212 } |
231 | 220 |
232 for(int i = 0; i < datas.length; i+=2) { | 221 for(int i = 0; i < datas.length; i+=2) { |
233 // e.g.: | 222 // e.g.: |
234 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1 | 223 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1 |
235 WKms minuendWKms = getWKms(StringUtil.unbracket(datas[i+0]), | 224 WKms minuendWKms = getWKms(StringUtil.unbracket(datas[i+0]), |
236 context, start, end); | 225 context, from, to); |
237 WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]), | 226 WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]), |
238 context, start, end); | 227 context, from, to); |
239 | 228 |
240 String facetName = "diff ()"; | 229 String facetName = "diff ()"; |
241 String minName = "min"; | 230 String minName = "min"; |
242 String subName = "sub"; | 231 String subName = "sub"; |
243 | 232 |