Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/WQKmsInterpolArtifact.java @ 6925:972ec1f6cf58
WQKmsInterpolArtifact: Add different facet if wst has only 'fake' Qs.
Minor refactoring.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 26 Aug 2013 15:35:39 +0200 |
parents | b87240ac9205 |
children | 8d5ca5175038 |
comparison
equal
deleted
inserted
replaced
6924:b87240ac9205 | 6925:972ec1f6cf58 |
---|---|
130 } | 130 } |
131 else if (parts[0].startsWith("flood")) { | 131 else if (parts[0].startsWith("flood")) { |
132 name = STATIC_WKMS_INTERPOL; | 132 name = STATIC_WKMS_INTERPOL; |
133 } | 133 } |
134 else { | 134 else { |
135 name = STATIC_WQ; | 135 // If all Qs are zero, add different facet to |
136 // signalize that we want data to be drawn as marks | |
137 // on axis. | |
138 if (wstValueHasZeroQ()) { | |
139 name = STATIC_W_INTERPOL; | |
140 } | |
141 else { | |
142 name = STATIC_WQ; | |
143 } | |
136 } | 144 } |
137 | 145 |
138 Facet wQFacet = new WQFacet(name, | 146 Facet wQFacet = new WQFacet(name, |
139 Resources.getMsg( | 147 Resources.getMsg( |
140 callMeta, | 148 callMeta, |
202 states.add(getState()); | 210 states.add(getState()); |
203 return states; | 211 return states; |
204 } | 212 } |
205 | 213 |
206 | 214 |
215 /** True if Wst has only 'fake' (zero) Q-ranges. */ | |
216 private boolean wstValueHasZeroQ() { | |
217 WstValueTable table = getValueTable(); | |
218 return table.hasEmptyQ(); | |
219 } | |
220 | |
221 | |
222 /** Get the WstValueTable that matches parameterization. */ | |
223 private WstValueTable getValueTable() { | |
224 // Get WstValueTable | |
225 int wstId = getDataAsInt("wst_id"); | |
226 if (getDataAsString("col_pos") != null) { | |
227 return WstValueTableFactory.getWstColumnTable( | |
228 wstId, getDataAsInt("col_pos")); | |
229 } | |
230 else { | |
231 return WstValueTableFactory.getTable(wstId); | |
232 } | |
233 } | |
234 | |
235 | |
236 /** | |
237 * Get WQ Values at a certain km, interpolating only if distance | |
238 * between two stations is smaller than given distance. | |
239 */ | |
240 public double [][] getWQAtKm( | |
241 Double currentKm, | |
242 double maxKmInterpolDistance | |
243 ) { | |
244 // TODO yet to be implemented (issue1378). | |
245 return null; | |
246 } | |
247 | |
248 | |
207 /** | 249 /** |
208 * Get WQ at a given km. | 250 * Get WQ at a given km. |
209 * | 251 * |
210 * @param currentKm the requested km. If NULL, ld_location data | 252 * @param currentKm the requested km. If NULL, ld_location data |
211 * will be used. | 253 * will be used. |
212 * @return [[q1,q2,q2],[w1,w2,w3]] ... | 254 * @return [[q1,q2,q2],[w1,w2,w3]] ... |
213 */ | 255 */ |
214 public double [][] getWQAtKm(Double currentKm) { | 256 public double [][] getWQAtKm(Double currentKm) { |
215 | 257 |
216 WstValueTable interpolator = null; | 258 // TODO issue1378: only interpolate if dist <= 100m |
217 // Get WstValueTable | 259 WstValueTable interpolator = getValueTable(); |
218 if (getDataAsString("col_pos") != null) { | |
219 interpolator = WstValueTableFactory.getWstColumnTable( | |
220 getDataAsInt("wst_id"), getDataAsInt("col_pos")); | |
221 } | |
222 else { | |
223 interpolator = WstValueTableFactory.getTable( | |
224 getDataAsInt("wst_id")); | |
225 } | |
226 | 260 |
227 Double tmp = (currentKm != null) | 261 Double tmp = (currentKm != null) |
228 ? currentKm | 262 ? currentKm |
229 : getDataAsDouble("ld_locations"); | 263 : getDataAsDouble("ld_locations"); |
230 | 264 |