comparison flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java @ 2045:d13be39cfd1d

#242 Added header with meta information into CSV exports. flys-artifacts/trunk@3531 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 22 Dec 2011 13:22:55 +0000
parents e5f01f2325c9
children 97a25b54eea3
comparison
equal deleted inserted replaced
2044:5d6e82abe859 2045:d13be39cfd1d
257 return locations.toNativeArray(); 257 return locations.toNativeArray();
258 } 258 }
259 259
260 260
261 /** 261 /**
262 * Returns the Qs for a given FLYSArtifact. This method currently accepts
263 * only instances of WINFOArtifact.
264 *
265 * @param flys A FLYSArtifact.
266 *
267 * @return the Qs.
268 */
269 public static double[] getQs(FLYSArtifact flys) {
270 double[] kmRange = getKmRange(flys);
271
272 // XXX this is not nice!
273 if (flys instanceof WINFOArtifact) {
274 return ((WINFOArtifact) flys).getQs(kmRange);
275 }
276
277 logger.warn("This method currently supports WINFOArtifact only!");
278
279 return null;
280 }
281
282
283 /**
284 * Returns the Ws for a given FLYSArtifact. This method currently accepts
285 * only instances of WINFOArtifact.
286 *
287 * @param flys A FLYSArtifact.
288 *
289 * @return the Ws.
290 */
291 public static double[] getWs(FLYSArtifact flys) {
292 double[] kmRange = getKmRange(flys);
293
294 // XXX this is not nice!
295 if (flys instanceof WINFOArtifact) {
296 return ((WINFOArtifact) flys).getWs(kmRange);
297 }
298
299 logger.warn("This method currently supports WINFOArtifact only!");
300
301 return null;
302 }
303
304
305 /**
262 * Returns the selected River object based on the 'river' data that might 306 * Returns the selected River object based on the 'river' data that might
263 * have been inserted by the user. 307 * have been inserted by the user.
264 * 308 *
265 * @return the selected River or null if no river has been chosen yet. 309 * @return the selected River or null if no river has been chosen yet.
266 */ 310 */
267 public static River getRiver(FLYSArtifact flys) { 311 public static River getRiver(FLYSArtifact flys) {
268 String sRiver = flys.getDataAsString("river"); 312 String sRiver = getRivername(flys);
269 313
270 return (sRiver != null) 314 return (sRiver != null)
271 ? RiverFactory.getRiver(sRiver) 315 ? RiverFactory.getRiver(sRiver)
272 : null; 316 : null;
317 }
318
319
320 /**
321 * Returns the name of the river specified in the given <i>flys</i>
322 * Artifact.
323 *
324 * @param flys The FLYSArtifact that stores a river relevant information.
325 *
326 * @return the name of the specified river or null.
327 */
328 public static String getRivername(FLYSArtifact flys) {
329 return flys != null ? flys.getDataAsString("river") : null;
273 } 330 }
274 331
275 332
276 /** 333 /**
277 * Extracts the SRID defined in the global configuration for the river 334 * Extracts the SRID defined in the global configuration for the river
305 null, 362 null,
306 variables); 363 variables);
307 } 364 }
308 365
309 366
367 public static Gauge getGauge(FLYSArtifact flys) {
368 River river = getRiver(flys);
369
370 if (river == null) {
371 logger.debug("no river found");
372 return null;
373 }
374
375 double[] dist = getKmRange(flys);
376
377 if (dist == null) {
378 logger.debug("no range found");
379 return null;
380 }
381
382 if (logger.isDebugEnabled()) {
383 logger.debug("Determine gauge for:");
384 logger.debug("... river: " + river.getName());
385 logger.debug("... distance: " + dist[0] + " - " + dist[1]);
386 }
387
388 Gauge gauge = river.determineGauge(dist[0], dist[1]);
389
390 String name = gauge != null ? gauge.getName() : "'n/a";
391 logger.debug("Found gauge: " + name);
392
393 return gauge;
394 }
395
396
397 public static String getGaugename(FLYSArtifact flys) {
398 Gauge gauge = getGauge(flys);
399
400 return gauge != null ? gauge.getName() : null;
401 }
402
403
310 public static String createWspWTitle( 404 public static String createWspWTitle(
311 WINFOArtifact winfo, 405 WINFOArtifact winfo,
312 CallContext cc, 406 CallContext cc,
313 String name 407 String name
314 ) { 408 ) {

http://dive4elements.wald.intevation.org