Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java @ 5744:5bb179d4fd5f
SedimentLoadFacet: Avoid weird steps, find correct measurement stations.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 17 Apr 2013 14:53:16 +0200 |
parents | 5231e6b849ce |
children | 4a1bd43e7aa6 |
comparison
equal
deleted
inserted
replaced
5743:80b9218ac007 | 5744:5bb179d4fd5f |
---|---|
103 int i = 0; | 103 int i = 0; |
104 for (Map.Entry<Double, Double> entry: sortData.entrySet()) { | 104 for (Map.Entry<Double, Double> entry: sortData.entrySet()) { |
105 boolean matchFound = false; | 105 boolean matchFound = false; |
106 // For now, ignore overlaps like (B> next A) | 106 // For now, ignore overlaps like (B> next A) |
107 for (MeasurementStation station: stations) { | 107 for (MeasurementStation station: stations) { |
108 if (Math.abs(station.getStation() - entry.getKey()) < EPSILON) { | 108 if (Math.abs(station.getStation() - entry.getKey()) < EPSILON || |
109 station.getRange().containsTolerant(entry.getKey())) { | |
110 // TODO: In rare cases, two matches can be found. | |
109 values[0][i*3] = station.getRange().getA().doubleValue() + EPSILON; | 111 values[0][i*3] = station.getRange().getA().doubleValue() + EPSILON; |
110 values[1][i*3] = entry.getValue(); | 112 values[1][i*3] = entry.getValue(); |
111 values[0][i*3+1] = station.getRange().getB().doubleValue() - EPSILON; | 113 values[0][i*3+1] = station.getRange().getB().doubleValue() - EPSILON; |
112 values[1][i*3+1] = entry.getValue(); | 114 values[1][i*3+1] = entry.getValue(); |
113 values[0][i*3+2] = station.getRange().getB().doubleValue(); | 115 values[0][i*3+2] = station.getRange().getB().doubleValue(); |
115 matchFound = true; | 117 matchFound = true; |
116 } | 118 } |
117 } | 119 } |
118 // Store points without match for later assessment. | 120 // Store points without match for later assessment. |
119 if (!matchFound) { | 121 if (!matchFound) { |
120 kmWithoutStation.add(new double[] {entry.getKey(), entry.getValue(), i}); | 122 logger.warn("measurement without station ("+entry.getKey()+")!"); |
121 } | 123 } |
122 i++; | 124 i++; |
123 } | 125 } |
124 | 126 |
125 // Find fitting measurement stations for values without match. | |
126 for (double misses[]: kmWithoutStation) { | |
127 int idc = Math.abs(Collections.binarySearch(sortedStarts, misses[0])); | |
128 double locationA = sortedStarts.get(idc-2); | |
129 double locationB = sortedStarts.get(idc-1); | |
130 values[0][(int)misses[2]*3] = locationA + EPSILON; | |
131 values[1][(int)misses[2]*3] = misses[1]; | |
132 values[0][(int)misses[2]*3+1] = locationB - EPSILON; | |
133 values[1][(int)misses[2]*3+1] = misses[1]; | |
134 values[0][(int)misses[2]*3+2] = locationB ; | |
135 values[1][(int)misses[2]*3+2] = misses[1]; | |
136 } | |
137 | |
138 | |
139 for (int x = 0; x < values[0].length-1; x++) { | 127 for (int x = 0; x < values[0].length-1; x++) { |
140 // Correct measurement stationo overlap. | |
141 if (values[0][x] > values[0][x+1]) { | |
142 values[0][x+1] = values[0][x] + EPSILON; | |
143 } | |
144 // Introduce gaps where no data in measurement station. | 128 // Introduce gaps where no data in measurement station. |
145 if (Math.abs(values[0][x+1] - values[0][x]) > 3*EPSILON | 129 if (Math.abs(values[0][x+1] - values[0][x]) > 3*EPSILON |
146 && values[1][x+1] != values[1][x]) { | 130 && values[1][x+1] != values[1][x]) { |
147 values[0][x] = Double.NaN; | 131 values[0][x] = Double.NaN; |
148 values[1][x] = Double.NaN; | 132 values[1][x] = Double.NaN; |