comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java @ 9368:6f7e92c16050

Fixed U-Info salix mw calculation, added filtered themes, own y axis, warning report
author mschaefer
date Thu, 02 Aug 2018 16:11:12 +0200
parents 2aec052d4088
children a0a2e68a1e11
comparison
equal deleted inserted replaced
9367:8aa1605e58f1 9368:6f7e92c16050
47 private final RiverInfoProvider riverInfoProvider; 47 private final RiverInfoProvider riverInfoProvider;
48 48
49 private final Map<Gauge, QPosition> gaugeMwPos; 49 private final Map<Gauge, QPosition> gaugeMwPos;
50 private final Map<Gauge, QPosition> gaugeMnwPos; 50 private final Map<Gauge, QPosition> gaugeMnwPos;
51 private final Map<Gauge, QPosition> gaugeMhwPos; 51 private final Map<Gauge, QPosition> gaugeMhwPos;
52 private QPosition refGaugeMwPos;
53 private QPosition refGaugeMnwPos;
54 private QPosition refGaugeMhwPos;
52 55
53 private Calculation problems; 56 private Calculation problems;
54 57
55 private WstValueTable wst; 58 private WstValueTable wst;
56 59
94 */ 97 */
95 private void fetchGaugeMainValuePositions() { 98 private void fetchGaugeMainValuePositions() {
96 this.gaugeMwPos.clear(); 99 this.gaugeMwPos.clear();
97 this.gaugeMnwPos.clear(); 100 this.gaugeMnwPos.clear();
98 this.gaugeMhwPos.clear(); 101 this.gaugeMhwPos.clear();
102 boolean first = true;
99 for (final Gauge gauge : this.riverInfoProvider.getGauges()) { 103 for (final Gauge gauge : this.riverInfoProvider.getGauges()) {
100 this.gaugeMwPos.put(gauge, null); 104 this.gaugeMwPos.put(gauge, null);
101 this.gaugeMnwPos.put(gauge, null); 105 this.gaugeMnwPos.put(gauge, null);
102 this.gaugeMhwPos.put(gauge, null); 106 this.gaugeMhwPos.put(gauge, null);
103 final double gaugeKm = gauge.getStation().doubleValue(); 107 final double gaugeKm = gauge.getStation().doubleValue();
107 else if (mv.getMainValue().getName().equalsIgnoreCase("mnq")) 111 else if (mv.getMainValue().getName().equalsIgnoreCase("mnq"))
108 this.gaugeMnwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue())); 112 this.gaugeMnwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue()));
109 else if (mv.getMainValue().getName().equalsIgnoreCase("mhq")) 113 else if (mv.getMainValue().getName().equalsIgnoreCase("mhq"))
110 this.gaugeMhwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue())); 114 this.gaugeMhwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue()));
111 } 115 }
116 if (first) {
117 this.refGaugeMwPos = this.gaugeMwPos.get(gauge);
118 this.refGaugeMnwPos = this.gaugeMnwPos.get(gauge);
119 this.refGaugeMhwPos = this.gaugeMhwPos.get(gauge);
120 first = false;
121 }
122 }
123 if (this.refGaugeMwPos == null)
124 this.problems.addProblem("uinfo_salix_calc.warning.missing_mq");
125 else {
126 if (this.refGaugeMhwPos == null)
127 this.problems.addProblem("uinfo_salix_calc.warning.missing_mhq");
128 if (this.refGaugeMnwPos == null)
129 this.problems.addProblem("uinfo_salix_calc.warning.missing_mnq");
112 } 130 }
113 } 131 }
114 132
115 /** 133 /**
116 * Create a result row for a station and its gauge, and add w-q-values as selected 134 * Create a result row for a station and its gauge, and add w-q-values as selected
117 *
118 * @param rangeScenarios2
119 */ 135 */
120 private ResultRow createRow(final double station, final NavigableMap<Double, List<Double>> rangeScenarios) { 136 private ResultRow createRow(final double station, final NavigableMap<Double, List<Double>> rangeScenarios) {
121 137
122 final ResultRow row = ResultRow.create(); 138 final ResultRow row = ResultRow.create();
139 row.putValue(GeneralResultType.station, station);
123 // Find station's gauge 140 // Find station's gauge
124 final Gauge gauge = this.riverInfoProvider.getGauge(station, true); 141 // final Gauge gauge = this.riverInfoProvider.getGauge(station, true);
125 row.putValue(GeneralResultType.station, station);
126 // Interpolate mnw, mw, and mhw 142 // Interpolate mnw, mw, and mhw
127 final double mnw = interpolateW(station, this.gaugeMnwPos.get(gauge)); 143 // final double mnw = interpolateW(station, this.gaugeMnwPos.get(gauge));
128 final double mw = interpolateW(station, this.gaugeMwPos.get(gauge)); 144 // final double mw = interpolateW(station, this.gaugeMwPos.get(gauge));
129 final double mhw = interpolateW(station, this.gaugeMhwPos.get(gauge)); 145 // final double mhw = interpolateW(station, this.gaugeMhwPos.get(gauge));
146 final double mnw = interpolateW(station, this.refGaugeMnwPos);
147 final double mw = interpolateW(station, this.refGaugeMwPos);
148 final double mhw = interpolateW(station, this.refGaugeMhwPos);
130 row.putValue(SInfoResultType.waterlevel, mnw); 149 row.putValue(SInfoResultType.waterlevel, mnw);
131 row.putValue(SInfoResultType.waterlevel1, mw); 150 row.putValue(SInfoResultType.waterlevel1, mw);
132 row.putValue(SInfoResultType.waterlevel2, mhw); 151 row.putValue(SInfoResultType.waterlevel2, mhw);
133 // Calc salix-line and mw-mnw 152 // Calc salix-line and mw-mnw
134 row.putValue(UInfoResultType.salixline, calcSalix(mhw, mw)); 153 row.putValue(UInfoResultType.salixline, calcSalix(mhw, mw));
153 * Interpolates the W for a station with a fixed (virtual) wst column position 172 * Interpolates the W for a station with a fixed (virtual) wst column position
154 */ 173 */
155 private double interpolateW(final double station, final QPosition qPosition) { 174 private double interpolateW(final double station, final QPosition qPosition) {
156 if (qPosition != null) 175 if (qPosition != null)
157 return this.wst.interpolateW(station, qPosition, this.problems); 176 return this.wst.interpolateW(station, qPosition, this.problems);
158
159 return Double.NaN; 177 return Double.NaN;
160 } 178 }
161 179
162 /** 180 /**
163 * Calculates the salix value 181 * Calculates the salix value
173 return Formatter.roundW(mnw) - Formatter.roundW(mw); 191 return Formatter.roundW(mnw) - Formatter.roundW(mw);
174 } 192 }
175 193
176 /** 194 /**
177 * Gets the station-specific list of delta-ws of the active scenario, at least with one 0 item in any case 195 * Gets the station-specific list of delta-ws of the active scenario, at least with one 0 item in any case
178 *
179 * @param rangeScenarios
180 */ 196 */
181 private double[] getDeltaWs(final double station, final NavigableMap<Double, List<Double>> rangeScenarios) { 197 private double[] getDeltaWs(final double station, final NavigableMap<Double, List<Double>> rangeScenarios) {
182 final Entry<Double, List<Double>> stationScenarios = rangeScenarios.floorEntry(station); 198 final Entry<Double, List<Double>> stationScenarios = rangeScenarios.floorEntry(station);
183 if (stationScenarios == null) 199 if (stationScenarios == null)
184 return new double[] { 0.0 }; 200 return new double[] { 0.0 };

http://dive4elements.wald.intevation.org