Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/GaugeMainValueFinder.java @ 9533:d9fda7af24ca
No discharge zone calculation and output for gauges unknown in flys for sinfo collision (Meilenstein 2, 2.2.1)
author | mschaefer |
---|---|
date | Thu, 04 Oct 2018 12:48:57 +0200 |
parents | b38be7ea53e2 |
children | 0c114309d2a0 |
comparison
equal
deleted
inserted
replaced
9532:8e6b9cb9486a | 9533:d9fda7af24ca |
---|---|
15 | 15 |
16 import org.dive4elements.river.artifacts.model.Calculation; | 16 import org.dive4elements.river.artifacts.model.Calculation; |
17 import org.dive4elements.river.model.Gauge; | 17 import org.dive4elements.river.model.Gauge; |
18 import org.dive4elements.river.model.MainValue; | 18 import org.dive4elements.river.model.MainValue; |
19 import org.dive4elements.river.model.MainValueType.MainValueTypeKey; | 19 import org.dive4elements.river.model.MainValueType.MainValueTypeKey; |
20 import org.dive4elements.river.model.River; | |
20 | 21 |
21 /** | 22 /** |
22 * Loading the main values of a gauge to find relative positions of a value and build a corresponding zone name | 23 * Loading the main values of a gauge to find relative positions of a value and build a corresponding zone name |
23 * | 24 * |
24 * @author Matthias Schäfer | 25 * @author Matthias Schäfer |
47 private double foundRelativeDistance; | 48 private double foundRelativeDistance; |
48 | 49 |
49 | 50 |
50 /***** CONSTRUCTORS *****/ | 51 /***** CONSTRUCTORS *****/ |
51 | 52 |
52 private GaugeMainValueFinder(final MainValueTypeKey keyType, final Gauge gauge, final Calculation problems) { | 53 private GaugeMainValueFinder(final MainValueTypeKey keyType, final Gauge gauge, final String gaugeName, final Calculation problems) { |
53 this.gauge = gauge; | 54 this.gauge = gauge; |
54 this.problems = problems; | 55 this.problems = problems; |
55 this.keyType = keyType; | 56 this.keyType = keyType; |
56 this.mainValues = new TreeMap<>(); | 57 this.mainValues = new TreeMap<>(); |
57 for (final MainValue mainValue : MainValue.getValuesOfGaugeAndType(gauge, keyType)) | 58 if (gauge != null) { |
58 this.mainValues.put(Double.valueOf(mainValue.getValue().doubleValue()), mainValue); | 59 for (final MainValue mainValue : MainValue.getValuesOfGaugeAndType(gauge, keyType)) |
60 this.mainValues.put(Double.valueOf(mainValue.getValue().doubleValue()), mainValue); | |
61 } | |
59 if (this.mainValues.isEmpty() && (this.problems != null)) { | 62 if (this.mainValues.isEmpty() && (this.problems != null)) { |
60 this.problems.addProblem("gauge_main_values.missing", gauge.getName()); | 63 this.problems.addProblem("gauge_main_values.missing", gaugeName); |
61 // Report only once | 64 // Report only once |
62 this.problems = null; | 65 this.problems = null; |
63 } | 66 } |
64 } | 67 } |
65 | 68 |
66 | 69 |
67 /***** METHODS *****/ | 70 /***** METHODS *****/ |
68 | 71 |
69 /** | 72 /** |
70 * Loads the the main values table of a type and a gauge (GAUGE.sta) | 73 * Loads the the main values table of a type and a gauge ({gauge}.sta) |
71 * | 74 * |
72 * @return The main values finder of a type and a gauge, or null | 75 * @return The main values finder of a type and a gauge, or null |
73 */ | 76 */ |
74 public static GaugeMainValueFinder loadValues(final MainValueTypeKey type, final Gauge gauge, final Calculation problems) { | 77 public static GaugeMainValueFinder loadValues(final MainValueTypeKey type, final Gauge gauge, final Calculation problems) { |
75 return new GaugeMainValueFinder(type, gauge, problems); | 78 return new GaugeMainValueFinder(type, gauge, gauge.getName(), problems); |
79 } | |
80 | |
81 /** | |
82 * Loads the the main values table of a type and a river's gauge ({gauge}.sta) | |
83 * | |
84 * @return The main values finder of the type and gauge, or null | |
85 */ | |
86 public static GaugeMainValueFinder loadValues(final MainValueTypeKey type, final River river, final String gaugeName, final Calculation problems) { | |
87 final Gauge gauge = river.determineGaugeByName(gaugeName); | |
88 return new GaugeMainValueFinder(type, gauge, gaugeName, problems); | |
76 } | 89 } |
77 | 90 |
78 /** | 91 /** |
79 * If this provider may return valid data at all. | 92 * If this provider may return valid data at all. |
80 */ | 93 */ |