[Dive4elements-commits] [PATCH] Stations are now filtered by DiPS not AFT
Wald Commits
scm-commit at wald.intevation.org
Thu Mar 7 12:46:41 CET 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1362656797 -3600
# Node ID 2b7f44c80857e575c7cc03fcbf42f98e16263855
# Parent eec78b9f73b86dac2650bb38c45dc14913e8a0b2
Stations are now filtered by DiPS not AFT.
diff -r eec78b9f73b8 -r 2b7f44c80857 flys-aft/src/main/java/de/intevation/aft/DIPSGauge.java
--- a/flys-aft/src/main/java/de/intevation/aft/DIPSGauge.java Thu Mar 07 12:02:02 2013 +0100
+++ b/flys-aft/src/main/java/de/intevation/aft/DIPSGauge.java Thu Mar 07 12:46:37 2013 +0100
@@ -113,7 +113,7 @@
String stationString = element.getAttribute("STATIONIERUNG");
if (stationString.length() == 0) {
log.warn("DIPS: Setting station of gauge '" + name + "' to zero.");
- stationString = "0";
+ stationString = "-99999";
}
station = Double.parseDouble(stationString);
if (station == 0d) {
diff -r eec78b9f73b8 -r 2b7f44c80857 flys-aft/src/main/java/de/intevation/aft/River.java
--- a/flys-aft/src/main/java/de/intevation/aft/River.java Thu Mar 07 12:02:02 2013 +0100
+++ b/flys-aft/src/main/java/de/intevation/aft/River.java Thu Mar 07 12:46:37 2013 +0100
@@ -65,7 +65,8 @@
public boolean sync(SyncContext context) throws SQLException {
log.info("sync river: " + this);
- Map<Long, DIPSGauge> dipsGauges = context.getDIPSGauges();
+ // Only take relevant gauges into account.
+ Map<Long, DIPSGauge> dipsGauges = context.getDIPSGauges(name, from, to);
ConnectedStatements flysStatements = context.getFlysStatements();
ConnectedStatements aftStatements = context.getAftStatements();
@@ -78,14 +79,18 @@
.getStatement("select.messstelle")
.clearParameters()
.setInt("GEWAESSER_NR", id2)
- .setDouble("START_KM", from)
- .setDouble("END_KM", to)
.executeQuery();
try {
while (messstellenRs.next()) {
String name = messstellenRs.getString("NAME");
String num = messstellenRs.getString("MESSSTELLE_NR");
+ double station = messstellenRs.getDouble("STATIONIERUNG");
+
+ if (!messstellenRs.wasNull() && station < from && station > to) {
+ log.warn("Station found in AFT but in range: " + station);
+ continue;
+ }
Long number = SyncContext.numberToLong(num);
if (number == null) {
diff -r eec78b9f73b8 -r 2b7f44c80857 flys-aft/src/main/java/de/intevation/aft/SyncContext.java
--- 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");
diff -r eec78b9f73b8 -r 2b7f44c80857 flys-aft/src/main/resources/sql/aft-common.properties
--- a/flys-aft/src/main/resources/sql/aft-common.properties Thu Mar 07 12:02:02 2013 +0100
+++ b/flys-aft/src/main/resources/sql/aft-common.properties Thu Mar 07 12:46:37 2013 +0100
@@ -1,8 +1,9 @@
-select.gewaesser = SELECT GEWAESSER_NR, NAME FROM SL_GEWAESSER
+select.gewaesser = \
+ SELECT GEWAESSER_NR, NAME FROM SL_GEWAESSER
select.messstelle = \
- SELECT NAME, MESSSTELLE_NR \
+ SELECT NAME, MESSSTELLE_NR, STATIONIERUNG \
FROM MESSSTELLE \
- WHERE GEWAESSER_NR = :GEWAESSER_NR AND STATIONIERUNG BETWEEN :START_KM AND :END_KM
+ WHERE GEWAESSER_NR = :GEWAESSER_NR
select.abflusstafel = \
SELECT ABFLUSSTAFEL_NR, \
ABFLUSSTAFEL_BEZ, \
@@ -12,6 +13,7 @@
BFG_ID \
FROM ABFLUSSTAFEL \
WHERE MESSSTELLE_NR LIKE :number
-select.tafelwert = SELECT TAFELWERT_NR AS id, WASSERSTAND AS w, ABFLUSS AS q FROM TAFELWERT \
- WHERE ABFLUSSTAFEL_NR = :number
+select.tafelwert = \
+ SELECT TAFELWERT_NR AS id, WASSERSTAND AS w, ABFLUSS AS q FROM TAFELWERT \
+ WHERE ABFLUSSTAFEL_NR = :number
More information about the Dive4elements-commits
mailing list