diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java @ 5360:02f6741f80d4

DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 21 Mar 2013 10:49:38 +0100
parents f987d25627aa
children 2fe120e1e4df
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java	Thu Mar 21 10:11:24 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java	Thu Mar 21 10:49:38 2013 +0100
@@ -8,7 +8,6 @@
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 
 import org.apache.log4j.Logger;
 import org.hibernate.Session;
@@ -26,14 +25,13 @@
 import de.intevation.artifacts.CallMeta;
 import de.intevation.artifacts.GlobalContext;
 import de.intevation.flys.artifacts.model.DischargeTables;
-import de.intevation.flys.artifacts.model.GaugeFinder;
-import de.intevation.flys.artifacts.model.GaugeFinderFactory;
 import de.intevation.flys.artifacts.model.GaugeRange;
 import de.intevation.flys.artifacts.model.GaugesFactory;
 import de.intevation.flys.artifacts.resources.Resources;
 import de.intevation.flys.backend.SessionHolder;
 import de.intevation.flys.model.DischargeTable;
 import de.intevation.flys.model.Gauge;
+import de.intevation.flys.model.MainValue;
 import de.intevation.flys.model.TimeInterval;
 
 
@@ -131,8 +129,7 @@
 
         applyMainValueMarkers(
             plot,
-            gauge.getRiver().getName(),
-            gauge.getStation().doubleValue(),
+            gauge,
             callMeta);
 
         return chart;
@@ -161,40 +158,32 @@
     }
 
 
-    /** Add domain markers to plot that indicate (only some Q) mainvalues. */
+    /** Add domain markers to plot that indicate mainvalues. */
     protected static void applyMainValueMarkers(
         XYPlot   plot,
-        String   river,
-        double   km,
+        Gauge    gauge,
         CallMeta meta
     ) {
-        GaugeFinderFactory ggf = GaugeFinderFactory.getInstance();
-        GaugeFinder        gf  = ggf.getGaugeFinder(river);
-
-        if (gf == null) {
-            log.warn("No gauge finder found for river '" + river + "'");
-            return;
-        }
+        String river = gauge.getRiver().getName();
+        double km    = gauge.getStation().doubleValue();
 
-        GaugeRange gr = gf.find(km);
-        if (gr == null) {
-            log.debug("No gauge range found for km "
-                + km + " on river " + river + ".");
-            return;
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug(gr);
-        }
-
-        for (Map.Entry<String, Double> entry: gr.getMainValues().entrySet()) {
-            Marker m = FixingsKMChartService.createQSectorMarker(
-                entry.getValue(),
-                entry.getKey());
-
-            if (m != null) {
+        // Get Gauge s mainvalues.
+        List<MainValue> mainValues = gauge.getMainValues();
+        for (MainValue mainValue : mainValues) {
+            if (mainValue.getMainValue().getType().getName().equals("Q")) {
+                // Its a Q main value.
+                Marker m = FixingsKMChartService.createQSectorMarker(
+                    mainValue.getValue().doubleValue(),
+                    mainValue.getMainValue().getName());
                 plot.addDomainMarker(m);
             }
+            else if (mainValue.getMainValue().getType().getName().equals("W")) {
+                // Its a W main value.
+                Marker m = FixingsKMChartService.createQSectorMarker(
+                    mainValue.getValue().doubleValue(),
+                    mainValue.getMainValue().getName());
+                plot.addRangeMarker(m);
+            }
         }
     }
 

http://dive4elements.wald.intevation.org