comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/GaugeMainValueFinder.java @ 9540:0c114309d2a0

Discharge zone for sinfo collision output without GLQ (Meilenstein 2, 2.1.4)
author mschaefer
date Wed, 17 Oct 2018 16:07:22 +0200
parents d9fda7af24ca
children
comparison
equal deleted inserted replaced
9539:4deb6b24f072 9540:0c114309d2a0
48 private double foundRelativeDistance; 48 private double foundRelativeDistance;
49 49
50 50
51 /***** CONSTRUCTORS *****/ 51 /***** CONSTRUCTORS *****/
52 52
53 private GaugeMainValueFinder(final MainValueTypeKey keyType, final Gauge gauge, final String gaugeName, final Calculation problems) { 53 private GaugeMainValueFinder(final MainValueTypeKey keyType, final Gauge gauge, final String gaugeName, final Calculation problems,
54 final String... excludingNames) {
54 this.gauge = gauge; 55 this.gauge = gauge;
55 this.problems = problems; 56 this.problems = problems;
56 this.keyType = keyType; 57 this.keyType = keyType;
57 this.mainValues = new TreeMap<>(); 58 this.mainValues = new TreeMap<>();
58 if (gauge != null) { 59 if (gauge != null) {
59 for (final MainValue mainValue : MainValue.getValuesOfGaugeAndType(gauge, keyType)) 60 boolean skip;
60 this.mainValues.put(Double.valueOf(mainValue.getValue().doubleValue()), mainValue); 61 for (final MainValue mainValue : MainValue.getValuesOfGaugeAndType(gauge, keyType)) {
62 skip = false;
63 for (final String excluding : excludingNames) {
64 if (mainValue.getMainValue().getName().equalsIgnoreCase(excluding)) {
65 skip = true;
66 break;
67 }
68 }
69 if (!skip)
70 this.mainValues.put(Double.valueOf(mainValue.getValue().doubleValue()), mainValue);
71 }
61 } 72 }
62 if (this.mainValues.isEmpty() && (this.problems != null)) { 73 if (this.mainValues.isEmpty() && (this.problems != null)) {
63 this.problems.addProblem("gauge_main_values.missing", gaugeName); 74 this.problems.addProblem("gauge_main_values.missing", gaugeName);
64 // Report only once 75 // Report only once
65 this.problems = null; 76 this.problems = null;
81 /** 92 /**
82 * Loads the the main values table of a type and a river's gauge ({gauge}.sta) 93 * Loads the the main values table of a type and a river's gauge ({gauge}.sta)
83 * 94 *
84 * @return The main values finder of the type and gauge, or null 95 * @return The main values finder of the type and gauge, or null
85 */ 96 */
86 public static GaugeMainValueFinder loadValues(final MainValueTypeKey type, final River river, final String gaugeName, final Calculation problems) { 97 public static GaugeMainValueFinder loadValues(final MainValueTypeKey type, final River river, final String gaugeName, final Calculation problems,
98 final String... excludingNames) {
87 final Gauge gauge = river.determineGaugeByName(gaugeName); 99 final Gauge gauge = river.determineGaugeByName(gaugeName);
88 return new GaugeMainValueFinder(type, gauge, gaugeName, problems); 100 return new GaugeMainValueFinder(type, gauge, gaugeName, problems, excludingNames);
89 } 101 }
90 102
91 /** 103 /**
92 * If this provider may return valid data at all. 104 * If this provider may return valid data at all.
93 */ 105 */

http://dive4elements.wald.intevation.org