comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 383:dcc3cd962c0e

Enhanced the transition model to reach a state that creates duration curves. flys-artifacts/trunk@1799 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 02 May 2011 16:58:04 +0000
parents c21fb8de54f8
children 435058da0eae
comparison
equal deleted inserted replaced
382:e07d1c3f7667 383:dcc3cd962c0e
468 * Returns the selected distance of points. 468 * Returns the selected distance of points.
469 * 469 *
470 * @return the selected distance or points. 470 * @return the selected distance or points.
471 */ 471 */
472 public double[] getDistance() { 472 public double[] getDistance() {
473 StateData dFrom = getData("ld_from"); 473 StateData dFrom = getData("ld_from");
474 StateData dTo = getData("ld_to"); 474 StateData dTo = getData("ld_to");
475 475 StateData dLocations = getData("ld_locations");
476
477 if (dFrom != null && dTo != null) {
478 return getDistanceByRange(dFrom, dTo);
479 }
480 else if (dLocations != null) {
481 double[] locations = getLocations();
482 return new double[] { locations[0], locations[locations.length-1] };
483 }
484
485 logger.warn("No data found for distance determination!");
486
487 return null;
488 }
489
490
491 /**
492 * Returns the selected locations based on a given array of locations.
493 *
494 * @param locations The StateData that contains the locations.
495 *
496 * @return the selected locations.
497 */
498 public double[] getLocations() {
499 StateData dLocations = getData("ld_locations");
500 String locationStr = dLocations != null
501 ? (String) dLocations.getValue()
502 : "";
503
504 if (locationStr == null || locationStr.length() == 0) {
505 logger.warn("No valid location string found!");
506 return null;
507 }
508
509 String[] tmp = locationStr.split(" ");
510 TDoubleArrayList locations = new TDoubleArrayList();
511
512 for (String l: tmp) {
513 try {
514 locations.add(Double.parseDouble(l));
515 }
516 catch (NumberFormatException nfe) {
517 logger.warn(nfe, nfe);
518 }
519 }
520
521 locations.sort();
522
523 return locations.toNativeArray();
524 }
525
526
527 /**
528 * Returns the selected distance based on a given range (from, to).
529 *
530 * @param dFrom The StateData that contains the lower value.
531 * @param dTo The StateData that contains the upper value.
532 *
533 * @return the selected distance.
534 */
535 protected double[] getDistanceByRange(StateData dFrom, StateData dTo) {
476 double from = Double.parseDouble((String) dFrom.getValue()); 536 double from = Double.parseDouble((String) dFrom.getValue());
477 double to = Double.parseDouble((String) dTo.getValue()); 537 double to = Double.parseDouble((String) dTo.getValue());
478
479 // TODO take point selection into account
480 538
481 return new double[] { from, to }; 539 return new double[] { from, to };
482 } 540 }
483 541
484 542

http://dive4elements.wald.intevation.org