diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java @ 3421:c44ff50f4970

FixA: Added a list of gauges to the output of the fixings overview service which intersect the selected fixings. flys-artifacts/trunk@5075 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 19 Jul 2012 21:12:57 +0000
parents 086326be721c
children 278b5508567e
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java	Thu Jul 19 16:57:44 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java	Thu Jul 19 21:12:57 2012 +0000
@@ -78,7 +78,6 @@
         "    wst_column_id = :column_id";
 
 
-
     public static class QRange extends Range {
 
         protected double q;
@@ -688,6 +687,47 @@
         return allColumns;
     }
 
+    protected static Range realRange(List<Fixing.Column> columns) {
+        Range range = null;
+        for (Fixing.Column column: columns) {
+            if (range == null) {
+                range = new Range(column);
+            }
+            else {
+                range.extend(column);
+            }
+        }
+        return range;
+    }
+
+    protected Element intersectingGauges(Document document, Range range) {
+        Element gauges = document.createElement("gauges");
+
+        if (range == null) {
+            return gauges;
+        }
+
+        GaugeFinderFactory gff = GaugeFinderFactory.getInstance();
+
+        GaugeFinder gf = gff.getGaugeFinder(riverId, isKmUp);
+
+        if (gf == null) {
+            return gauges;
+        }
+
+        for (GaugeRange gr: gf.getGauges()) {
+            if (gr.intersects(range)) {
+                Element gauge = document.createElement("gauge");
+                gauge.setAttribute("from", String.valueOf(gr.getStart()));
+                gauge.setAttribute("to",   String.valueOf(gr.getEnd()));
+                gauge.setAttribute("name", gr.getName());
+                gauges.appendChild(gauge);
+            }
+        }
+
+        return gauges;
+    }
+
     public void generateOverview(
         Document      document,
         Range         range,
@@ -706,6 +746,11 @@
 
         fixingsElement.appendChild(riverElement);
 
+        fixingsElement.appendChild(
+            intersectingGauges(
+                document,
+                realRange(allColumns)));
+
         SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT);
 
         Element esE = document.createElement("events");

http://dive4elements.wald.intevation.org