changeset 4336:09993be04c5e

ExtremeCurveFacet: Set suggestedMaxQ in curve to be max value in segment + 5%.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 31 Oct 2012 14:00:28 +0100
parents 5948de9788d5
children 0a7594c0cbc2
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCurveFacet.java
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCurveFacet.java	Wed Oct 31 13:52:28 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCurveFacet.java	Wed Oct 31 14:00:28 2012 +0100
@@ -5,7 +5,7 @@
 
 import de.intevation.flys.artifacts.FLYSArtifact;
 
-import de.intevation.flys.artifacts.access.FixAnalysisAccess;
+import de.intevation.flys.artifacts.access.ExtremeAccess;
 
 import de.intevation.flys.artifacts.model.CalculationResult;
 import de.intevation.flys.artifacts.model.DataFacet;
@@ -15,6 +15,7 @@
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
 import de.intevation.flys.utils.KMIndex;
+import de.intevation.flys.utils.DoubleUtil;
 
 import org.apache.log4j.Logger;
 
@@ -60,6 +61,7 @@
         logger.debug("ExtremeCurveFacet.getData");
         if (artifact instanceof FLYSArtifact) {
             FLYSArtifact flys = (FLYSArtifact)artifact;
+            ExtremeAccess access = new ExtremeAccess(flys);
 
             CalculationResult res =
                 (CalculationResult) flys.compute(context,
@@ -76,7 +78,18 @@
 
             if (curveEntry != null) {
                 logger.debug("A curve at km = " + currentKm);
-                return curveEntry.getValue();
+                Curve c = curveEntry.getValue();
+                // Find segment in which the curr. km is located.
+                double[] ds = access.getValuesForRange(currentKm);
+
+                if (ds != null) {
+                    double m = DoubleUtil.maxInArray(ds);
+                    // Add 5 percent.
+                    m *= 1.05d;
+                    c.setSuggestedMaxQ(m);
+                }
+
+                return c;
             }
             else {
                 logger.debug("No curve at km = " + currentKm);

http://dive4elements.wald.intevation.org