diff flys-aft/src/main/java/de/intevation/aft/SyncContext.java @ 5379:61bf64b102bc mapgenfix

Merge with default branch
author Christian Lins <christian.lins@intevation.de>
date Fri, 22 Mar 2013 11:25:54 +0100
parents 2b7f44c80857
children
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/SyncContext.java	Wed Mar 06 14:14:15 2013 +0100
+++ b/flys-aft/src/main/java/de/intevation/aft/SyncContext.java	Fri Mar 22 11:25:54 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