diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationMainValuesWFacet.java @ 9269:83ebeb620b5a

Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
author mschaefer
date Thu, 19 Jul 2018 08:07:03 +0200
parents 465347d12990
children b40fbca03024
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationMainValuesWFacet.java	Wed Jul 18 18:53:15 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationMainValuesWFacet.java	Thu Jul 19 08:07:03 2018 +0200
@@ -1,5 +1,7 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
  *
  * This file is Free Software under the GNU AGPL (>=v3)
  * and comes with ABSOLUTELY NO WARRANTY! Check out the
@@ -8,7 +10,7 @@
 
 package org.dive4elements.river.artifacts.sinfo.flood_duration;
 
-import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM;
+import java.util.List;
 
 import org.apache.log4j.Logger;
 import org.dive4elements.artifactdatabase.state.DefaultFacet;
@@ -16,8 +18,8 @@
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.model.CalculationResult;
-import org.dive4elements.river.artifacts.model.WQDay;
 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+import org.dive4elements.river.exports.fixings.FixChartGenerator;
 import org.dive4elements.river.jfree.RiverAnnotation;
 import org.dive4elements.river.jfree.StickyAxisAnnotation;
 
@@ -36,31 +38,8 @@
         this.index = 0;
     }
 
-
-    /**
-     * Set the hit-point in W where a line drawn from the axis would hit the
-     * curve in WQDay (if hit).
-     * Employ linear interpolation.
-     */
-    public static void setHitPoint(final WQDay wqday, final StickyAxisAnnotation annotation) {
-
-        final float w = annotation.getPos();
-        final Double day = wqday.interpolateDayByW(w);
-        if (day != null)
-            annotation.setHitPoint(day.floatValue());
-        else
-            log.debug("StickyAnnotation does not hit wqday curve: " + w);
-    }
-
-
     /**
      * Returns the data this facet provides.
-     *
-     * @param artifact the owner artifact.
-     * @param context  the CallContext (can be used to find out if in
-     *                 navigable fixation-setting, or durationcurve).
-     *
-     * @return the data.
      */
     @Override
     public Object getData(final Artifact artifact, final CallContext context) {
@@ -73,30 +52,12 @@
 
         final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData();
 
-        final double currentKm = getCurrentKm(context);
-
-        return new RiverAnnotation(this.description, data.getMainValueWAnnotations());
-    }
+        final double currentKm = FixChartGenerator.getCurrentKm(context);
 
-    /**
-     * Returns the current km from the context.
-     * If the context is null or doesn't contain a currentKm
-     * then a double value of -1 will be returned.
-     *
-     * @param context
-     *            The CallContext instance
-     * @return the current km as double
-     */
-    // FIXME: copied from org.dive4elements.river.artifacts.model.fixings.FixingsFacet
-    private double getCurrentKm(final CallContext context) {
-        if (context == null)
-            return Double.NaN;
+        final List<StickyAxisAnnotation> annotations = new FloodDurationCalculation(context).calcMainValueWAnnotations(currentKm,
+                data.getResults().get(0));
 
-        final Double dkm = (Double) context.getContextValue(CURRENT_KM);
-        if (dkm == null)
-            return Double.NaN;
-
-        return dkm.doubleValue();
+        return new RiverAnnotation(this.description, annotations);
     }
 
 
@@ -111,4 +72,4 @@
         return copy;
     }
 }
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+

http://dive4elements.wald.intevation.org