[PATCH 1 of 3] issue1435: Minor refactoring that will come handy to load SedimentLoads
Wald Commits
scm-commit at wald.intevation.org
Thu Sep 26 21:53:12 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1380223819 -7200
# Node ID e0b6b6cf4708e54e8fca98d2d354a898d0f2ce8f
# Parent 6d4578fe46960415e505f38e27b5fef5d0393300
issue1435: Minor refactoring that will come handy to load SedimentLoads
for "standalone" sedimentyield artifact.
diff -r 6d4578fe4696 -r e0b6b6cf4708 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Thu Sep 26 19:55:49 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Thu Sep 26 21:30:19 2013 +0200
@@ -346,6 +346,7 @@
* Get sediment loads from db.
* @param river the river
* @param type the sediment load type (year, epoch or off_epoch)
+ *
* @return according sediment loads.
*/
public static SedimentLoad getSedimentLoadWithDataUncached(
@@ -551,32 +552,48 @@
continue;
}
double v = -1;
+
if (row[2] != null) {
v = ((Double)row[2]).doubleValue();
}
- if (fraction.equals("coarse")) {
- load.setCoarse(km, v, range);
- }
- else if (fraction.equals("sand")) {
- load.setSand(km, v, range);
- }
- else if (fraction.equals("fine_middle")) {
- load.setFineMiddle(km, v, range);
- }
- else if (fraction.equals("suspended_sediment")) {
- load.setSuspSediment(km, v, range);
- }
- else if (fraction.equals("susp_sand")) {
- load.setSuspSand(km, v, range);
- }
- else if (fraction.equals("susp_sand_bed")) {
- load.setSuspSandBed(km, v, range);
- }
+
+ setLoadFraction(load, km, v, range, fraction);
+ }
+
+ if (results.isEmpty()) {
+ log.warn("No " + fraction + " values found.");
}
return load;
}
+
+ /** Set a fraction value of load to given km, value and range. */
+ private static void setLoadFraction(
+ SedimentLoad load, double km, double v, Range range, String fraction) {
+ if (fraction.equals("coarse")) {
+ load.setCoarse(km, v, range);
+ }
+ else if (fraction.equals("sand")) {
+ load.setSand(km, v, range);
+ }
+ else if (fraction.equals("fine_middle")) {
+ load.setFineMiddle(km, v, range);
+ }
+ else if (fraction.equals("suspended_sediment")) {
+ load.setSuspSediment(km, v, range);
+ }
+ else if (fraction.equals("susp_sand")) {
+ load.setSuspSand(km, v, range);
+ }
+ else if (fraction.equals("susp_sand_bed")) {
+ load.setSuspSandBed(km, v, range);
+ }
+ else {
+ log.error("Unknown fraction type " + fraction);
+ }
+ }
+
public static SedimentLoad getLoadUnknown(
String river,
String description
More information about the Dive4elements-commits
mailing list