comparison artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java @ 8755:30b1ddadf275

(issue1801) Unify reference gauge finding code The basic way as described in the method comment of the determineRefGauge method is now used in the WINFOArtifact, MainValuesService and RiverUtils.getGauge method. RiverUtils.getGauge previously just returned the first gauge found. While this is now a behavior change I believe that it is always more correct then the undeterministic behavior of the previous implmenentation.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 24 Jun 2015 14:07:26 +0200
parents e4606eae8ea5
children 5e38e2924c07
comparison
equal deleted inserted replaced
8754:574f8b80799f 8755:30b1ddadf275
30 import org.dive4elements.river.model.Range; 30 import org.dive4elements.river.model.Range;
31 import org.dive4elements.river.model.River; 31 import org.dive4elements.river.model.River;
32 32
33 import org.dive4elements.river.artifacts.model.RiverFactory; 33 import org.dive4elements.river.artifacts.model.RiverFactory;
34 34
35 import static org.dive4elements.river.backend.utils.EpsilonComparator.CMP;
36
35 37
36 /** 38 /**
37 * This service returns the main values of a river's gauge based on the start 39 * This service returns the main values of a river's gauge based on the start
38 * and end point of the river. 40 * and end point of the river.
39 * 41 *
82 if (river == null) { 84 if (river == null) {
83 return error("no river found."); 85 return error("no river found.");
84 } 86 }
85 87
86 double[] minmax = getRequestedStartEnd(data, river); 88 double[] minmax = getRequestedStartEnd(data, river);
87 Gauge gauge = river.determineGauge(minmax[0], minmax[1]); 89 Gauge gauge = river.determineRefGauge(minmax,
90 CMP.compare(minmax[0], minmax[1]) != 0);
88 91
89 if (gauge == null) { 92 if (gauge == null) {
90 return error("no gauge found."); 93 return error("no gauge found.");
91 } 94 }
92 95

http://dive4elements.wald.intevation.org