changeset 6937:0a3dd5be6f81

issue1436: Towards finding the best match in years for densities.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 28 Aug 2013 11:55:14 +0200
parents 332d2dfa783f
children 4c0222d94055
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java	Wed Aug 28 11:22:40 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java	Wed Aug 28 11:55:14 2013 +0200
@@ -65,13 +65,18 @@
         this.years = years;
     }
 
+    /**
+     * Get the density at year.
+     * measured densities are valid until the next measurement.
+     * if no measurement was found 1.8 is returned.
+     */
     public double getDensity(double km, int year) {
         Collections.sort(this.years);
-        if (this.years.size() == 1) {
+        if (this.years.size() == 1 && years.get(0) <= year) {
             logger.debug("get density from year " + year + " at km " + km);
-            return getDensityAtKm(densities.get(year), km);
+            return getDensityAtKm(densities.get(years.get(0)), km);
         }
-        else {
+        else if (this.years.size() > 1) {
             for (int i = 0; i < years.size() -1; i++) {
                 int y1 = years.get(i);
                 int y2 = years.get(i + 1);

http://dive4elements.wald.intevation.org