Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java @ 8608:0f6f702742b4
(issue1754) Check if start > end and handle this
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 24 Mar 2015 10:52:23 +0100 |
parents | fa57a2cb1dfa |
children | 5f60bd7c4b42 |
comparison
equal
deleted
inserted
replaced
8607:2010da0904b7 | 8608:0f6f702742b4 |
---|---|
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(); |
198 double to = rangeAccess.getTo(); | 198 double to = rangeAccess.getTo(); |
199 double start; | |
200 double end; | |
199 // Load the Artifacts/facets that we want to subtract and display. | 201 // Load the Artifacts/facets that we want to subtract and display. |
200 // Expected format is: | 202 // Expected format is: |
201 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] | 203 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] |
202 String diffids = winfo.getDataAsString("diffids"); | 204 String diffids = winfo.getDataAsString("diffids"); |
203 log.debug("WDifferencesState has: " + diffids); | 205 log.debug("WDifferencesState has: " + diffids); |
204 String datas[] = diffids.split("#"); | 206 String datas[] = diffids.split("#"); |
205 | 207 |
208 log.debug("Difference from: " + from + " to: " + to); | |
209 /* 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 | |
206 // Validate the Data-Strings. | 219 // Validate the Data-Strings. |
207 for (String s: datas) { | 220 for (String s: datas) { |
208 if (!WaterlevelSelectState.isValueValid(s)) { | 221 if (!WaterlevelSelectState.isValueValid(s)) { |
209 // TODO: escalate. | 222 // TODO: escalate. |
210 } | 223 } |
218 | 231 |
219 for(int i = 0; i < datas.length; i+=2) { | 232 for(int i = 0; i < datas.length; i+=2) { |
220 // e.g.: | 233 // e.g.: |
221 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1 | 234 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1 |
222 WKms minuendWKms = getWKms(StringUtil.unbracket(datas[i+0]), | 235 WKms minuendWKms = getWKms(StringUtil.unbracket(datas[i+0]), |
223 context, from, to); | 236 context, start, end); |
224 WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]), | 237 WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]), |
225 context, from, to); | 238 context, start, end); |
226 | 239 |
227 String facetName = "diff ()"; | 240 String facetName = "diff ()"; |
228 String minName = "min"; | 241 String minName = "min"; |
229 String subName = "sub"; | 242 String subName = "sub"; |
230 | 243 |