Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java @ 6343:588e99129883
issue1235: Values are valid until next measurements station range start.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 14 Jun 2013 17:11:33 +0200 |
parents | b8cd8e2d0c35 |
children | 43ef4943e0c2 |
comparison
equal
deleted
inserted
replaced
6342:b8cd8e2d0c35 | 6343:588e99129883 |
---|---|
118 // Find station via its station (km). | 118 // Find station via its station (km). |
119 // TODO use a binarySearch instead of linear absdiff approach | 119 // TODO use a binarySearch instead of linear absdiff approach |
120 int i = 0; | 120 int i = 0; |
121 for (Map.Entry<Double, Double> kmLoad: sortedKmLoad.entrySet()) { | 121 for (Map.Entry<Double, Double> kmLoad: sortedKmLoad.entrySet()) { |
122 boolean matchFound = false; | 122 boolean matchFound = false; |
123 // For now, ignore overlaps like (B> next A) | 123 for (int k = 0; k < stations.size(); k++) { |
124 for (MeasurementStation station: stations) { | 124 MeasurementStation station = stations.get(k); |
125 if (Math.abs(station.getStation() - kmLoad.getKey()) < EPSILON || | 125 if (Math.abs(station.getStation() - kmLoad.getKey()) < EPSILON) { |
126 station.getRange().containsTolerant(kmLoad.getKey())) { | 126 // Value has been taken at measurement station. |
127 // TODO: In rare cases, two matches can be found. | 127 values[0][i*3] = station.getRange().getA().doubleValue() + EPSILON; |
128 values[0][i*3] = station.getRange().getA().doubleValue() + EPSILON; | 128 values[1][i*3] = kmLoad.getValue(); |
129 values[1][i*3] = kmLoad.getValue(); | 129 double endValue = 0d; |
130 values[0][i*3+1] = station.getRange().getB().doubleValue() - EPSILON; | 130 // Valid until next measurements stations begin of range, |
131 // or end of current range if last value. | |
132 if (k+2 <= stations.size()) { | |
133 endValue = stations.get(k+1).getRange().getA().doubleValue(); | |
134 } | |
135 else { | |
136 endValue = station.getRange().getB().doubleValue(); | |
137 } | |
138 values[0][i*3+1] = endValue; | |
131 values[1][i*3+1] = kmLoad.getValue(); | 139 values[1][i*3+1] = kmLoad.getValue(); |
132 values[0][i*3+2] = station.getRange().getB().doubleValue(); | 140 values[0][i*3+2] = endValue; |
133 values[1][i*3+2] = kmLoad.getValue(); | 141 values[1][i*3+2] = kmLoad.getValue(); |
134 matchFound = true; | 142 matchFound = true; |
135 } | 143 } |
136 } | 144 } |
137 // Store points without match for later assessment. | 145 // Store points without match for later assessment. |