diff flys-aft/src/main/java/de/intevation/aft/SyncContext.java @ 5188:2b7f44c80857

Stations are now filtered by DiPS not AFT.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 07 Mar 2013 12:46:37 +0100
parents f939e1e6cfa4
children
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/SyncContext.java	Thu Mar 07 12:02:02 2013 +0100
+++ b/flys-aft/src/main/java/de/intevation/aft/SyncContext.java	Thu Mar 07 12:46:37 2013 +0100
@@ -87,6 +87,36 @@
         return numberToGauge;
     }
 
+    public Map<Long, DIPSGauge> getDIPSGauges(
+        String riverName,
+        double from,
+        double to
+    ) {
+        if (from > to) {
+            double t = from;
+            from = to;
+            to = t;
+        }
+
+        riverName = riverName.toLowerCase();
+
+        Map<Long, DIPSGauge> result = new HashMap<Long, DIPSGauge>();
+
+        for (Map.Entry<Long, DIPSGauge> entry: numberToGauge.entrySet()) {
+            DIPSGauge gauge = entry.getValue();
+            // XXX: Maybe a bit too sloppy.
+            if (!riverName.contains(gauge.getRiverName().toLowerCase())) {
+                continue;
+            }
+            double station = gauge.getStation();
+            if (station >= from && station <= to) {
+                result.put(entry.getKey(), gauge);
+            }
+        }
+
+        return result;
+    }
+
     protected static Map<Long, DIPSGauge> indexByNumber(Document document) {
         Map<Long, DIPSGauge> map = new HashMap<Long, DIPSGauge>();
         NodeList nodes = document.getElementsByTagName("PEGELSTATION");

http://dive4elements.wald.intevation.org