Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java @ 8544:76113b975829
(Issue1754) Make BedDifference calculation range dependent.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 13 Feb 2015 16:17:46 +0100 |
parents | 706668b19b04 |
children | 078b07a94023 |
comparison
equal
deleted
inserted
replaced
8543:9a5b3079aad4 | 8544:76113b975829 |
---|---|
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(); | |
41 double toKm = access.getTo(); | |
40 | 42 |
41 BedDiffYearResult [] results = new BedDiffYearResult[heightIds.length]; | 43 BedDiffYearResult [] results = new BedDiffYearResult[heightIds.length]; |
42 for (int i = 0; i < heightIds.length; i++) { | 44 for (int i = 0; i < heightIds.length; i++) { |
43 BedHeightSingleData [] pair = getHeightPair(heightIds[i]); | 45 BedHeightSingleData [] pair = getHeightPair(heightIds[i], fromKm, toKm); |
44 if (pair[0].getYear() == null || pair[1].getYear() == null) { | 46 if (pair[0].getYear() == null || pair[1].getYear() == null) { |
45 addProblem("beddiff.missing.year"); | 47 addProblem("beddiff.missing.year"); |
46 } | 48 } |
47 results[i] = calculateYearDifference(pair, heightIds[i]); | 49 results[i] = calculateYearDifference(pair, heightIds[i]); |
48 } | 50 } |
49 | 51 |
50 return new CalculationResult(results, this); | 52 return new CalculationResult(results, this); |
51 } | 53 } |
52 | 54 |
53 /** Get two BedHeights from factory. */ | 55 /** Get two BedHeights from factory. */ |
54 private static BedHeightSingleData [] getHeightPair(int [] ids) { | 56 private static BedHeightSingleData [] getHeightPair(int [] ids, double from, double to) { |
55 return new BedHeightSingleData [] { | 57 return new BedHeightSingleData [] { |
56 (BedHeightSingleData)BedHeightFactory.getHeight("single", ids[0]), | 58 (BedHeightSingleData)BedHeightFactory.getHeight("single", ids[0], from, to), |
57 (BedHeightSingleData)BedHeightFactory.getHeight("single", ids[1]) | 59 (BedHeightSingleData)BedHeightFactory.getHeight("single", ids[1], from, to) |
58 }; | 60 }; |
59 } | 61 } |
60 | 62 |
61 private BedDiffYearResult calculateYearDifference( | 63 private BedDiffYearResult calculateYearDifference( |
62 BedHeightSingleData[] pair, | 64 BedHeightSingleData[] pair, |