Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.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 | 787dff3fd634 |
children | 26dedebbe39f |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Fri Jun 19 17:42:23 2015 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Wed Jun 24 14:07:26 2015 +0200 @@ -258,7 +258,7 @@ log.debug("'free' calculation (km " + refKm + ")"); } else { - Gauge gauge = determineRefGauge(range, river); + Gauge gauge = river.determineRefGauge(range, rangeAccess.isRange()); if (gauge == null) { return error( @@ -730,7 +730,7 @@ log.debug("range: " + Arrays.toString(range)); } - Gauge g = determineRefGauge(range, rangeAccess.getRiver()); + Gauge g = rangeAccess.getRiver().determineRefGauge(range, rangeAccess.isRange()); if (g == null) { log.warn("no gauge found for km: " + range[0]); return null; @@ -782,36 +782,15 @@ /** - * Determine reference gauge dependent on direction of calculation - * for a range calculation, otherwise dependent on flow direction. - */ - public Gauge determineRefGauge(double[] range, River river) { - if (isRange()) { - return river.determineGaugeByPosition( - range[0], - range[0] > range[1]); - } - else { - return river.determineGaugeByPosition(range[0]); - } - } - - /** * Determines the selected mode of distance/range input. * + * Compatibility wrapper around RangeAccess. + * * @return true, if the range mode is selected otherwise false. */ public boolean isRange() { - StateData mode = getData("ld_mode"); - - if (mode == null) { - log.warn("No mode location/range chosen. Defaults to range."); - return true; - } - - String value = (String) mode.getValue(); - - return value.equals("distance"); + RangeAccess rangeAccess = new RangeAccess(this); + return rangeAccess.isRange(); }