Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java @ 9397:6e7094368e97
Added gauge name column for uinfo iota
author | mschaefer |
---|---|
date | Mon, 13 Aug 2018 17:26:33 +0200 |
parents | 439699ff9b2d |
children | bd5f5d2220fa |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java Mon Aug 13 17:15:05 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java Mon Aug 13 17:26:33 2018 +0200 @@ -11,6 +11,7 @@ import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -19,6 +20,7 @@ import org.dive4elements.river.artifacts.WINFOArtifact; import org.dive4elements.river.artifacts.access.ComputationRangeAccess; +import org.dive4elements.river.artifacts.common.AbstractResultType; import org.dive4elements.river.artifacts.common.GeneralResultType; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.model.Calculation; @@ -54,6 +56,7 @@ private QPosition refGaugeMwPos; private QPosition refGaugeMnwPos; private QPosition refGaugeMhwPos; + private Gauge firstGauge; private Calculation problems; @@ -101,7 +104,7 @@ this.gaugeMwPos.clear(); this.gaugeMnwPos.clear(); this.gaugeMhwPos.clear(); - boolean first = true; + this.firstGauge = null; for (final Gauge gauge : this.riverInfoProvider.getGauges()) { this.gaugeMwPos.put(gauge, null); this.gaugeMnwPos.put(gauge, null); @@ -115,11 +118,11 @@ else if (mv.getMainValue().getName().equalsIgnoreCase("mhq")) this.gaugeMhwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue())); } - if (first) { + if (this.firstGauge == null) { this.refGaugeMwPos = this.gaugeMwPos.get(gauge); this.refGaugeMnwPos = this.gaugeMnwPos.get(gauge); this.refGaugeMhwPos = this.gaugeMhwPos.get(gauge); - first = false; + this.firstGauge = gauge; } } if (this.refGaugeMwPos == null) @@ -167,6 +170,7 @@ } } row.putValue(UInfoResultType.customMultiRowColSalixScenarios, scenarios); + row.putValue(GeneralResultType.gaugeLabel, this.riverInfoProvider.findGauge(station)); return row; } @@ -209,4 +213,28 @@ noScen.add(null); return noScen; } + + /** + * Find and return a height (iota, w main value) of a station in a previously calculated result + */ + public double fetchStationHeight(final Calculation problems, final double station, final AbstractResultType resultType, + final SalixLineCalculationResult result) { + + // Search the station in the previously calculated result rows + final ResultRow stationRow = searchStation(station, result.getRows()); + if (stationRow != null) + return stationRow.getDoubleValue(resultType); + return Double.NaN; + } + + /** + * Searches the row of a station in a result rows collection + */ + private ResultRow searchStation(final double station, final Collection<ResultRow> rows) { + for (final ResultRow row : rows) { + if (row.getDoubleValue(GeneralResultType.station) > station + 0.0001) + return row; + } + return null; + } } \ No newline at end of file