comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 7180:e0b6b6cf4708

issue1435: Minor refactoring that will come handy to load SedimentLoads for "standalone" sedimentyield artifact.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 26 Sep 2013 21:30:19 +0200
parents 3a55f49be155
children 805021c04861
comparison
equal deleted inserted replaced
7179:6d4578fe4696 7180:e0b6b6cf4708
344 344
345 /** 345 /**
346 * Get sediment loads from db. 346 * Get sediment loads from db.
347 * @param river the river 347 * @param river the river
348 * @param type the sediment load type (year, epoch or off_epoch) 348 * @param type the sediment load type (year, epoch or off_epoch)
349 *
349 * @return according sediment loads. 350 * @return according sediment loads.
350 */ 351 */
351 public static SedimentLoad getSedimentLoadWithDataUncached( 352 public static SedimentLoad getSedimentLoadWithDataUncached(
352 String river, 353 String river,
353 String type, 354 String type,
549 if (range == null) { 550 if (range == null) {
550 log.warn("No measurement station for " + fraction + " km " + km); 551 log.warn("No measurement station for " + fraction + " km " + km);
551 continue; 552 continue;
552 } 553 }
553 double v = -1; 554 double v = -1;
555
554 if (row[2] != null) { 556 if (row[2] != null) {
555 v = ((Double)row[2]).doubleValue(); 557 v = ((Double)row[2]).doubleValue();
556 } 558 }
557 if (fraction.equals("coarse")) { 559
558 load.setCoarse(km, v, range); 560 setLoadFraction(load, km, v, range, fraction);
559 } 561 }
560 else if (fraction.equals("sand")) { 562
561 load.setSand(km, v, range); 563 if (results.isEmpty()) {
562 } 564 log.warn("No " + fraction + " values found.");
563 else if (fraction.equals("fine_middle")) {
564 load.setFineMiddle(km, v, range);
565 }
566 else if (fraction.equals("suspended_sediment")) {
567 load.setSuspSediment(km, v, range);
568 }
569 else if (fraction.equals("susp_sand")) {
570 load.setSuspSand(km, v, range);
571 }
572 else if (fraction.equals("susp_sand_bed")) {
573 load.setSuspSandBed(km, v, range);
574 }
575 } 565 }
576 566
577 return load; 567 return load;
568 }
569
570
571 /** Set a fraction value of load to given km, value and range. */
572 private static void setLoadFraction(
573 SedimentLoad load, double km, double v, Range range, String fraction) {
574 if (fraction.equals("coarse")) {
575 load.setCoarse(km, v, range);
576 }
577 else if (fraction.equals("sand")) {
578 load.setSand(km, v, range);
579 }
580 else if (fraction.equals("fine_middle")) {
581 load.setFineMiddle(km, v, range);
582 }
583 else if (fraction.equals("suspended_sediment")) {
584 load.setSuspSediment(km, v, range);
585 }
586 else if (fraction.equals("susp_sand")) {
587 load.setSuspSand(km, v, range);
588 }
589 else if (fraction.equals("susp_sand_bed")) {
590 load.setSuspSandBed(km, v, range);
591 }
592 else {
593 log.error("Unknown fraction type " + fraction);
594 }
578 } 595 }
579 596
580 public static SedimentLoad getLoadUnknown( 597 public static SedimentLoad getLoadUnknown(
581 String river, 598 String river,
582 String description 599 String description

http://dive4elements.wald.intevation.org