# HG changeset patch # User Felix Wolfsteller # Date 1351688428 -3600 # Node ID 09993be04c5e0b661e1377049f20f25f9631b714 # Parent 5948de9788d56abd0df1fb0c52ad2f90cc2b9e29 ExtremeCurveFacet: Set suggestedMaxQ in curve to be max value in segment + 5%. diff -r 5948de9788d5 -r 09993be04c5e flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCurveFacet.java --- 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);