comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java @ 8948:a4f1ac81f26d

Work on SINFO-FlowDepthMinMax. Also rework of result row stuff, in order to reduce abstraction, using result type concept
author gernotbelger
date Wed, 14 Mar 2018 14:10:32 +0100
parents 5d5d482da3e9
children b5600453bb8f
comparison
equal deleted inserted replaced
8947:86650594f051 8948:a4f1ac81f26d
12 import java.util.ArrayList; 12 import java.util.ArrayList;
13 import java.util.Collection; 13 import java.util.Collection;
14 14
15 import org.apache.commons.lang.math.DoubleRange; 15 import org.apache.commons.lang.math.DoubleRange;
16 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; 16 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider;
17 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.Tkh; 17 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultRow;
18 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
18 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.TkhCalculator; 19 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.TkhCalculator;
19 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder; 20 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder;
20 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; 21 import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
21 22
22 /** 23 /**
23 * @author Gernot Belger 24 * @author Gernot Belger
24 */ 25 */
25 final class FlowDepthCalculator { 26 final class FlowDepthCalculator {
26 27
27 private final Collection<FlowDepthRow> rows = new ArrayList<>(); 28 private final Collection<SInfoResultRow> rows = new ArrayList<>();
28 29
29 private final BedHeightsFinder bedHeight; 30 private final BedHeightsFinder bedHeight;
30 31
31 private final TkhCalculator tkhCalculator; 32 private final TkhCalculator tkhCalculator;
32 33
61 return new FlowDepthCalculationResult(label, wstInfo, this.bedHeight.getInfo(), hasTkh, this.rows); 62 return new FlowDepthCalculationResult(label, wstInfo, this.bedHeight.getInfo(), hasTkh, this.rows);
62 } 63 }
63 64
64 private void calculateResultRow(final double station) { 65 private void calculateResultRow(final double station) {
65 66
66 final Tkh tkh = this.tkhCalculator.getTkh(station); 67 final SInfoResultRow row = SInfoResultRow.create();
68
69 row.putValue(SInfoResultType.waterlevelLabel, this.wstLabel);
70 row.putValue(SInfoResultType.soundingLabel, this.bedHeightLabel);
71
72 // REMARK: access the gauge once only during calculation
73 final String gaugeLabel = this.riverInfoProvider.findGauge(station);
74 row.putValue(SInfoResultType.gaugeLabel, gaugeLabel);
67 75
68 // REMARK: access the location once only during calculation 76 // REMARK: access the location once only during calculation
69 final String location = this.riverInfoProvider.getLocation(station); 77 final String location = this.riverInfoProvider.getLocation(station);
78 row.putValue(SInfoResultType.location, location);
70 79
71 // REMARK: access the gauge once only during calculation 80 this.tkhCalculator.calculateTkh(station, row);
72 final String gaugeLabel = this.riverInfoProvider.findGauge(station);
73 81
74 this.rows.add(new FlowDepthRow(tkh, this.wstLabel, gaugeLabel, this.bedHeightLabel, location)); 82 this.rows.add(row);
75 } 83 }
76 } 84 }

http://dive4elements.wald.intevation.org