[PATCH] flys/issue1625: Changed default sediment density factor from 1.8 to 1.9 . The value can be changed by adusting conf.xml (/artifact-databae/options/sediment-density-factor/text())
Wald Commits
scm-commit at wald.intevation.org
Tue Oct 29 19:46:46 CET 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1383072401 -3600
# Node ID 2733b4aae74ba0d9d648a75cbbefac0f0ff0ad46
# Parent 9434437a1ef5b0682cf199aab0803010ec9c9ec6
flys/issue1625: Changed default sediment density factor from 1.8 to 1.9 . The value can be changed by adusting conf.xml (/artifact-databae/options/sediment-density-factor/text()).
diff -r 9434437a1ef5 -r 2733b4aae74b artifacts/doc/conf/conf.xml
--- a/artifacts/doc/conf/conf.xml Tue Oct 29 19:17:28 2013 +0100
+++ b/artifacts/doc/conf/conf.xml Tue Oct 29 19:46:41 2013 +0100
@@ -340,6 +340,8 @@
</zoom-scales>
<dgm-path>/path/to/rivers/</dgm-path>
+
+ <sediment-density-factor>1.9</sediment-density-factor>
</options>
<!-- base url for online help. -->
diff -r 9434437a1ef5 -r 2733b4aae74b artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Tue Oct 29 19:17:28 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Tue Oct 29 19:46:41 2013 +0100
@@ -8,6 +8,8 @@
package org.dive4elements.river.artifacts.model.minfo;
+import java.io.Serializable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -16,9 +18,9 @@
import java.util.Set;
import java.util.TreeMap;
-import java.io.Serializable;
+import org.apache.log4j.Logger;
-import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.common.utils.Config;
/** Sediment Densities for multiple years. */
@@ -27,9 +29,40 @@
private static final Logger logger = Logger
.getLogger(SedimentDensity.class);
+ public static final double DEFAULT_SEDIMNET_DENSITY_FACTOR = 1.9;
+
+ public static String SEDIMENT_DENSITY_FACTOR_XPATH =
+ "/artifact-database/options/sediment-density-factor/text()";
+
+ public static final double SEDIMNET_DENSITY_FACTOR =
+ getSedimentDensityFactor();
+
private Map<Integer, List<SedimentDensityValue>> densities;
private List<Integer> years;
+
+ /** Figures out the sediment density factor from global config. */
+ private static final double getSedimentDensityFactor() {
+
+ double factor = DEFAULT_SEDIMNET_DENSITY_FACTOR;
+
+ String factorString =
+ Config.getStringXPath(SEDIMENT_DENSITY_FACTOR_XPATH);
+
+ if (factorString != null) {
+ try {
+ factor = Double.parseDouble(factorString.trim());
+ }
+ catch (NumberFormatException nfe) {
+ logger.error(nfe);
+ }
+ }
+
+ logger.info("Sedmiment density factor: " + factor);
+
+ return factor;
+ }
+
public SedimentDensity() {
this.densities = new HashMap<Integer, List<SedimentDensityValue>>();
this.years = new ArrayList<Integer>();
@@ -80,7 +113,7 @@
logger.debug("get density from year " + year + " at km " + km);
return getDensityAtKm(densities.get(years.get(0)), km);
}
- else if (this.years.size() > 1) {
+ if (this.years.size() > 1) {
for (int i = 0, I = years.size()-1; i < I; i++) {
int y1 = years.get(i);
int y2 = years.get(i + 1);
@@ -92,7 +125,7 @@
}
}
}
- return 1.8d;
+ return SEDIMNET_DENSITY_FACTOR;
}
/** Get (sorted) map of km to density of all years. */
More information about the Dive4elements-commits
mailing list