[PATCH 1 of 2] issue1436: Towards finding the best match in years for densities

Wald Commits scm-commit at wald.intevation.org
Wed Aug 28 11:52:37 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1377683714 -7200
# Node ID 0a3dd5be6f818865c78b3849aedf987a8d2a14e3
# Parent  332d2dfa783f43042c939a88f823dd72d428b54c
issue1436: Towards finding the best match in years for densities.

diff -r 332d2dfa783f -r 0a3dd5be6f81 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	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);


More information about the Dive4elements-commits mailing list