Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java @ 9527:7c8d62867876
Cleanup of MainWstValue code. Cache qPositions once determined.
author | gernotbelger |
---|---|
date | Tue, 02 Oct 2018 13:25:52 +0200 |
parents | ee6508687e3f |
children | 429b62373633 |
comparison
equal
deleted
inserted
replaced
9526:51212d40ff56 | 9527:7c8d62867876 |
---|---|
17 import org.dive4elements.river.artifacts.WINFOArtifact; | 17 import org.dive4elements.river.artifacts.WINFOArtifact; |
18 import org.dive4elements.river.artifacts.access.ComputationRangeAccess; | 18 import org.dive4elements.river.artifacts.access.ComputationRangeAccess; |
19 import org.dive4elements.river.artifacts.common.GeneralResultType; | 19 import org.dive4elements.river.artifacts.common.GeneralResultType; |
20 import org.dive4elements.river.artifacts.common.ResultRow; | 20 import org.dive4elements.river.artifacts.common.ResultRow; |
21 import org.dive4elements.river.artifacts.model.Calculation; | 21 import org.dive4elements.river.artifacts.model.Calculation; |
22 import org.dive4elements.river.artifacts.model.river.MainWstValuesCalculator; | 22 import org.dive4elements.river.artifacts.model.river.MainWstValues; |
23 import org.dive4elements.river.artifacts.model.river.RiverInfoProvider; | 23 import org.dive4elements.river.artifacts.model.river.RiverInfoProvider; |
24 import org.dive4elements.river.artifacts.sinfo.tkhstate.WinfoArtifactWrapper; | 24 import org.dive4elements.river.artifacts.sinfo.tkhstate.WinfoArtifactWrapper; |
25 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | 25 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; |
26 import org.dive4elements.river.artifacts.uinfo.common.UInfoResultType; | 26 import org.dive4elements.river.artifacts.uinfo.common.UInfoResultType; |
27 import org.dive4elements.river.artifacts.uinfo.salix.SalixLineAccess.ScenarioType; | 27 import org.dive4elements.river.artifacts.uinfo.salix.SalixLineAccess.ScenarioType; |
28 import org.dive4elements.river.model.River; | |
28 | 29 |
29 /** | 30 /** |
30 * Calculation of the result rows of the u-info salix line calc mode | 31 * Calculation of the result rows of the u-info salix line calc mode |
31 * | 32 * |
32 * @author Matthias Schäfer | 33 * @author Matthias Schäfer |
54 */ | 55 */ |
55 public void execute(final Calculation problems, final UINFOArtifact uinfo, final NavigableMap<Double, List<Double>> rangeScenarios, | 56 public void execute(final Calculation problems, final UINFOArtifact uinfo, final NavigableMap<Double, List<Double>> rangeScenarios, |
56 final ScenarioType scenarioType, final String[] scenarioLabels, final String rangeString, final String additionalString, | 57 final ScenarioType scenarioType, final String[] scenarioLabels, final String rangeString, final String additionalString, |
57 final SalixLineCalculationResults results) { | 58 final SalixLineCalculationResults results) { |
58 | 59 |
59 final MainWstValuesCalculator mainWstValues = fetchGaugeMainValuePositions2(problems); | 60 final MainWstValues mainWstValues = fetchWstMainValues(problems); |
60 | 61 |
61 final WINFOArtifact winfo = new WinfoArtifactWrapper(uinfo); | 62 final WINFOArtifact winfo = new WinfoArtifactWrapper(uinfo); |
62 winfo.addStringData("ld_mode", "distance"); | 63 winfo.addStringData("ld_mode", "distance"); |
63 winfo.addStringData("ld_step", "100"); | 64 winfo.addStringData("ld_step", "100"); |
64 | 65 |
85 default: | 86 default: |
86 return new SalixLineCalculationResult("Salix-simple", rows); | 87 return new SalixLineCalculationResult("Salix-simple", rows); |
87 } | 88 } |
88 } | 89 } |
89 | 90 |
90 private MainWstValuesCalculator fetchGaugeMainValuePositions2(final Calculation problems) { | 91 private MainWstValues fetchWstMainValues(final Calculation problems) { |
91 final MainWstValuesCalculator mainWstValues = MainWstValuesCalculator.forRiverInfo(this.riverInfoProvider, MAIN_VALUE_MQ, MAIN_VALUE_MNQ, | |
92 MAIN_VALUE_MHQ, MAIN_VALUE_HQ5); | |
93 | 92 |
94 if (!mainWstValues.hasPosition(MAIN_VALUE_MQ)) | 93 final MainWstValues values = MainWstValues.forRiver(this.riverInfoProvider.getRiver()); |
94 | |
95 if (!values.hasPosition(MAIN_VALUE_MQ)) | |
95 problems.addProblem("uinfo_salix_calc.warning.missing_mq"); | 96 problems.addProblem("uinfo_salix_calc.warning.missing_mq"); |
96 else { | 97 else { |
97 if (!mainWstValues.hasPosition(MAIN_VALUE_MHQ)) | 98 if (!values.hasPosition(MAIN_VALUE_MHQ)) |
98 problems.addProblem("uinfo_salix_calc.warning.missing_mhq"); | 99 problems.addProblem("uinfo_salix_calc.warning.missing_mhq"); |
99 if (!mainWstValues.hasPosition(MAIN_VALUE_MNQ)) | 100 if (!values.hasPosition(MAIN_VALUE_MNQ)) |
100 problems.addProblem("uinfo_salix_calc.warning.missing_mnq"); | 101 problems.addProblem("uinfo_salix_calc.warning.missing_mnq"); |
101 } | 102 } |
102 | 103 |
103 return mainWstValues; | 104 return values; |
104 } | 105 } |
105 | 106 |
106 /** | 107 /** |
107 * Create a result row for a station and its gauge, and add w-q-values as selected | 108 * Create a result row for a station and its gauge, and add w-q-values as selected |
108 */ | 109 */ |
109 private ResultRow createRow(final MainWstValuesCalculator mainWstValues, final double station, final NavigableMap<Double, List<Double>> rangeScenarios) { | 110 private ResultRow createRow(final MainWstValues mainWstValues, final double station, final NavigableMap<Double, List<Double>> rangeScenarios) { |
111 | |
112 final River river = this.riverInfoProvider.getRiver(); | |
110 | 113 |
111 final ResultRow row = ResultRow.create(); | 114 final ResultRow row = ResultRow.create(); |
112 row.putValue(GeneralResultType.station, station); | 115 row.putValue(GeneralResultType.station, station); |
113 // Find station's gauge (obsolete version which calculates gauge-wise) | 116 |
114 // final Gauge gauge = this.riverInfoProvider.getGauge(station, true); | 117 final double mnw = mainWstValues.getW(river, MAIN_VALUE_MNQ, station); |
115 // Interpolate mnw, mw, and mhw | 118 final double mw = mainWstValues.getW(river, MAIN_VALUE_MQ, station); |
116 // final double mnw = interpolateW(station, this.gaugeMnwPos.get(gauge)); | 119 final double mhw = mainWstValues.getW(river, MAIN_VALUE_MHQ, station); |
117 // final double mw = interpolateW(station, this.gaugeMwPos.get(gauge)); | 120 final double hw5 = mainWstValues.getW(river, MAIN_VALUE_HQ5, station); |
118 // final double mhw = interpolateW(station, this.gaugeMhwPos.get(gauge)); | |
119 final double mnw = mainWstValues.interpolateW(station, MAIN_VALUE_MNQ); | |
120 final double mw = mainWstValues.interpolateW(station, MAIN_VALUE_MQ); | |
121 final double mhw = mainWstValues.interpolateW(station, MAIN_VALUE_MHQ); | |
122 final double hw5 = mainWstValues.interpolateW(station, MAIN_VALUE_HQ5); | |
123 row.putValue(UInfoResultType.waterlevelMNW, mnw); | 121 row.putValue(UInfoResultType.waterlevelMNW, mnw); |
124 row.putValue(UInfoResultType.waterlevelMW, mw); | 122 row.putValue(UInfoResultType.waterlevelMW, mw); |
125 row.putValue(UInfoResultType.waterlevelMHW, mhw); | 123 row.putValue(UInfoResultType.waterlevelMHW, mhw); |
126 row.putValue(UInfoResultType.waterlevelMH5, hw5); | 124 row.putValue(UInfoResultType.waterlevelMH5, hw5); |
127 | 125 |