Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/GaugeDischargeValuesFinder.java @ 9202:b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
author | mschaefer |
---|---|
date | Mon, 02 Jul 2018 07:33:53 +0200 |
parents | 1614cb14308f |
children | d9fda7af24ca |
comparison
equal
deleted
inserted
replaced
9201:491e1a434457 | 9202:b4402594213b |
---|---|
42 | 42 |
43 | 43 |
44 /***** CONSTRUCTORS *****/ | 44 /***** CONSTRUCTORS *****/ |
45 | 45 |
46 private GaugeDischargeValuesFinder(final Gauge gauge, final Calculation problems, final DischargeTable dischargeTable) { | 46 private GaugeDischargeValuesFinder(final Gauge gauge, final Calculation problems, final DischargeTable dischargeTable) { |
47 // Load W-Q-values from database | |
47 this.gauge = gauge; | 48 this.gauge = gauge; |
48 this.problems = problems; | 49 this.problems = problems; |
49 final TDoubleArrayList ws = new TDoubleArrayList(); | 50 final TDoubleArrayList ws = new TDoubleArrayList(); |
50 final TDoubleArrayList qs = new TDoubleArrayList(); | 51 final TDoubleArrayList qs = new TDoubleArrayList(); |
51 for (final DischargeTableValue v : DischargeTable.getValuesSortedByW(dischargeTable)) { | 52 for (final DischargeTableValue v : DischargeTable.fetchValuesSortedByW(dischargeTable)) { |
52 ws.add(v.getW().doubleValue()); | 53 ws.add(v.getW().doubleValue()); |
53 qs.add(v.getQ().doubleValue()); | 54 qs.add(v.getQ().doubleValue()); |
54 } | 55 } |
56 // Build interpolator | |
55 if (ws.size() >= 2) { | 57 if (ws.size() >= 2) { |
56 this.wInterpolator = new LinearInterpolator().interpolate(ws.toNativeArray(), qs.toNativeArray()); | 58 this.wInterpolator = new LinearInterpolator().interpolate(ws.toNativeArray(), qs.toNativeArray()); |
57 this.wRange = new DoubleRange(ws.get(0), ws.get(ws.size() - 1)); | 59 this.wRange = new DoubleRange(ws.get(0), ws.get(ws.size() - 1)); |
58 } | 60 } |
59 else { | 61 else { |
69 | 71 |
70 | 72 |
71 /***** METHODS *****/ | 73 /***** METHODS *****/ |
72 | 74 |
73 /** | 75 /** |
74 * Loads the the main discharge table of a gauge (GAUGE.at) | 76 * Loads the the main discharge table of a gauge ({gauge}.at) |
75 * | 77 * |
76 * @return The discharge table values finder of the gauge, or null | 78 * @return The discharge table values finder of the gauge, or null |
77 */ | 79 */ |
78 public static GaugeDischargeValuesFinder loadValues(final Gauge gauge, final Calculation problems) { | 80 public static GaugeDischargeValuesFinder loadValues(final Gauge gauge, final Calculation problems) { |
79 final DischargeTable table = DischargeTable.getGaugeMainDischargeTable(gauge); | 81 final DischargeTable table = gauge.fetchMasterDischargeTable(); |
80 if ((table == null) || (table.getDischargeTableValues().size() == 0)) { | 82 if ((table == null) || (table.getDischargeTableValues().size() == 0)) { |
81 problems.addProblem("gauge_discharge_table.missing", gauge.getName()); | 83 problems.addProblem("gauge_discharge_table.missing", gauge.getName()); |
82 return null; | 84 return null; |
83 } | 85 } |
84 else | 86 else |