[Dive4elements-commits] [PATCH 1 of 2] Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too
Wald Commits
scm-commit at wald.intevation.org
Thu Jan 3 14:39:55 CET 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1357219185 -3600
# Node ID a310aceb2e51dda4203de73b5e71aa13ffeeb27f
# Parent ce570c74aa942e51ad066f924a5d7c8e6edaff7e
Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
diff -r ce570c74aa94 -r a310aceb2e51 flys-aft/src/main/java/de/intevation/aft/IdPair.java
--- a/flys-aft/src/main/java/de/intevation/aft/IdPair.java Thu Jan 03 11:43:16 2013 +0100
+++ b/flys-aft/src/main/java/de/intevation/aft/IdPair.java Thu Jan 03 14:19:45 2013 +0100
@@ -8,8 +8,12 @@
public IdPair() {
}
+ public IdPair(int id1) {
+ this.id1 = id1;
+ }
+
public IdPair(int id1, int id2) {
- this.id1 = id1;
+ this(id1);
this.id2 = id2;
}
diff -r ce570c74aa94 -r a310aceb2e51 flys-aft/src/main/java/de/intevation/aft/River.java
--- a/flys-aft/src/main/java/de/intevation/aft/River.java Thu Jan 03 11:43:16 2013 +0100
+++ b/flys-aft/src/main/java/de/intevation/aft/River.java Thu Jan 03 14:19:45 2013 +0100
@@ -20,9 +20,19 @@
protected String name;
+ protected double from;
+ protected double to;
+
public River() {
}
+ public River(int id1, String name, double from, double to) {
+ super(id1);
+ this.name = name;
+ this.from = from;
+ this.to = to;
+ }
+
public River(int id1, int id2, String name) {
super(id1, id2);
this.name = name;
@@ -32,6 +42,25 @@
return name;
}
+ public double getFrom() {
+ return from;
+ }
+
+ public void setFrom(double from) {
+ this.from = from;
+ }
+
+ public double getTo() {
+ return to;
+ }
+
+ public void setTo(double to) {
+ this.to = to;
+ }
+
+ public boolean inside(double x) {
+ return x >= from && x <= to;
+ }
public boolean sync(SyncContext context) throws SQLException {
log.info("sync river: " + this);
diff -r ce570c74aa94 -r a310aceb2e51 flys-aft/src/main/java/de/intevation/aft/Rivers.java
--- a/flys-aft/src/main/java/de/intevation/aft/Rivers.java Thu Jan 03 11:43:16 2013 +0100
+++ b/flys-aft/src/main/java/de/intevation/aft/Rivers.java Thu Jan 03 14:19:45 2013 +0100
@@ -27,35 +27,44 @@
ConnectedStatements flysStatements = context.getFlysStatements();
ConnectedStatements aftStatements = context.getAftStatements();
- Map<String, Integer> flysRivers = new HashMap<String, Integer>();
+ Map<String, River> flysRivers = new HashMap<String, River>();
ResultSet flysRs = flysStatements
- .getStatement("select.river").executeQuery();
+ .getStatement("select.rivers").executeQuery();
- while (flysRs.next()) {
- Integer id = flysRs.getInt("id");
- String name = flysRs.getString("name").toLowerCase();
- flysRivers.put(name, id);
+ try {
+ while (flysRs.next()) {
+ int id = flysRs.getInt("id");
+ String name = flysRs.getString("name");
+ double from = flysRs.getDouble("min_km");
+ double to = flysRs.getDouble("max_km");
+ flysRivers.put(name.toLowerCase(), new River(id, name, from, to));
+ }
}
-
- flysRs.close();
+ finally {
+ flysRs.close();
+ }
List<River> commonRivers = new ArrayList<River>();
ResultSet aftRs = aftStatements
.getStatement("select.gewaesser").executeQuery();
- while (aftRs.next()) {
- String name = aftRs.getString("NAME");
- Integer id1 = flysRivers.get(name.toLowerCase());
- if (id1 != null) {
- int id2 = aftRs.getInt("GEWAESSER_NR");
- River river = new River(id1, id2, name);
- commonRivers.add(river);
+ try {
+ while (aftRs.next()) {
+ String name = aftRs.getString("NAME");
+ River river = flysRivers.get(name.toLowerCase());
+ if (river != null) {
+ int id2 = aftRs.getInt("GEWAESSER_NR");
+ river.setId2(id2);
+ commonRivers.add(river);
+ }
}
}
+ finally {
+ aftRs.close();
+ }
- aftRs.close();
boolean modified = false;
diff -r ce570c74aa94 -r a310aceb2e51 flys-aft/src/main/resources/sql/flys-common.properties
--- a/flys-aft/src/main/resources/sql/flys-common.properties Thu Jan 03 11:43:16 2013 +0100
+++ b/flys-aft/src/main/resources/sql/flys-common.properties Thu Jan 03 14:19:45 2013 +0100
@@ -1,4 +1,11 @@
-select.river = SELECT id, name FROM rivers
+select.rivers = \
+ SELECT r.id AS id, r.name AS name, min(wcv.position) AS min_km, max(wcv.position) AS max_km \
+ FROM rivers r \
+ JOIN wsts w ON r.id = w.river_id \
+ JOIN wst_columns wc ON w.id = wc.wst_id \
+ JOIN wst_column_values wcv ON wcv.wst_column_id = wc.id \
+ WHERE w.kind = 0 \
+ GROUP BY r.id, r.name
select.gauges = SELECT id, name, official_number FROM gauges WHERE river_id = :river_id
next.gauge.id = SELECT NEXTVAL('GAUGES_ID_SEQ') AS gauge_id
insert.gauge = INSERT INTO gauges (id, name, river_id, station, aeo, official_number, datum) \
More information about the Dive4elements-commits
mailing list