Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java @ 8610:1f6b30310360
(issue1754) Allow ranges where start > end also for beddifferences.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 24 Mar 2015 11:08:39 +0100 |
parents | 078b07a94023 |
children | 5f60bd7c4b42 |
comparison
equal
deleted
inserted
replaced
8609:421e5cceac84 | 8610:1f6b30310360 |
---|---|
35 public CalculationResult calculate(BedDifferencesAccess access, CallContext context) { | 35 public CalculationResult calculate(BedDifferencesAccess access, CallContext context) { |
36 log.info("BedDiffCalculation.calculate"); | 36 log.info("BedDiffCalculation.calculate"); |
37 | 37 |
38 this.river = access.getRiverName(); | 38 this.river = access.getRiverName(); |
39 this.heightIds = access.extractHeightIds(context); | 39 this.heightIds = access.extractHeightIds(context); |
40 double fromKm = access.getFrom(); | 40 double from = access.getFrom(); |
41 double toKm = access.getTo(); | 41 double to = access.getTo(); |
42 double start; | |
43 double end; | |
44 | |
45 if ((!Double.isNaN(from) && !Double.isNaN(to)) && from > to) { | |
46 log.debug("Reordering range."); | |
47 start = to; | |
48 end = from; | |
49 } else { | |
50 start = from; | |
51 end = to; | |
52 } | |
42 | 53 |
43 BedDiffYearResult [] results = new BedDiffYearResult[heightIds.length]; | 54 BedDiffYearResult [] results = new BedDiffYearResult[heightIds.length]; |
44 for (int i = 0; i < heightIds.length; i++) { | 55 for (int i = 0; i < heightIds.length; i++) { |
45 BedHeightData [] pair = getHeightPair(heightIds[i], fromKm, toKm); | 56 BedHeightData [] pair = getHeightPair(heightIds[i], start, end); |
46 if (pair[0].getYear() == null || pair[1].getYear() == null) { | 57 if (pair[0].getYear() == null || pair[1].getYear() == null) { |
47 addProblem("beddiff.missing.year"); | 58 addProblem("beddiff.missing.year"); |
48 } | 59 } |
49 results[i] = calculateYearDifference(pair, heightIds[i]); | 60 results[i] = calculateYearDifference(pair, heightIds[i]); |
50 } | 61 } |