[PATCH] Fetch missing values from database and show them in diagrams
Wald Commits
scm-commit at wald.intevation.org
Mon Sep 8 12:21:35 CEST 2014
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1410171692 -7200
# Node ID 204905c16ade24803211f822ec7e652c0273ce5a
# Parent ceeeaf228fe4c98dc28e8a1abba43c2e1977befb
Fetch missing values from database and show them in diagrams.
diff -r ceeeaf228fe4 -r 204905c16ade artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java Mon Sep 08 10:03:00 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java Mon Sep 08 12:21:32 2014 +0200
@@ -31,6 +31,18 @@
public static final String SUSPENDED_STRING = "Schwebstoff";
public static final String SQL_LOAD_RIVER_SEDIMENT_LOADS =
+ "WITH load_at_river AS (" +
+ "SELECT DISTINCT sl.id, " +
+ "sl.kind, " +
+ "sl.description, " +
+ "sl.time_interval_id, " +
+ "sl.grain_fraction_id, " +
+ "sl.sq_time_interval_id " +
+ "FROM sediment_load sl " +
+ "JOIN sediment_load_values slv ON sl.id = slv.sediment_load_id " +
+ "JOIN measurement_station ms ON ms.id = slv.measurement_station_id " +
+ "JOIN rivers r ON r.id = ms.river_id " +
+ "WHERE r.name = :river) " +
"SELECT " +
"sl.id AS sl_id, " +
"sl.kind AS sl_kind, " +
@@ -45,14 +57,23 @@
"ms.id AS ms_id, " +
"ms.station AS ms_station, " +
"ms.measurement_type AS ms_type " +
- "FROM sediment_load_values slv " +
- "JOIN sediment_load sl ON slv.sediment_load_id = sl.id " +
+ "FROM load_at_river sl " +
+ "CROSS JOIN measurement_station ms " +
"JOIN time_intervals ti ON sl.time_interval_id = ti.id " +
"LEFT JOIN time_intervals sqti ON sl.sq_time_interval_id = sqti.id " +
"JOIN grain_fraction gf ON sl.grain_fraction_id = gf.id " +
- "JOIN measurement_station ms ON slv.measurement_station_id = ms.id " +
"JOIN rivers r ON ms.river_id = r.id " +
- "WHERE r.name = :river " +
+ "LEFT JOIN sediment_load_values slv " +
+ "ON ms.id=slv.measurement_station_id AND sl.id=slv.sediment_load_id " +
+ "WHERE (" +
+ "(ms.measurement_type='Geschiebe' AND gf.name IN " +
+ "('coarse', 'fine_middle', 'sand', 'susp_sand', " +
+ "'susp_sand_bed', 'bed_load', 'bed_load_susp_sand', " +
+ "'suspended_load', 'total')) " +
+ "OR " +
+ "(ms.measurement_type='Schwebstoff' AND gf.name IN " +
+ "('suspended_sediment', 'suspended_load', 'total'))) " +
+ "AND r.name = :river " +
"ORDER BY sl.id";
public static final SedimentLoadDataFactory INSTANCE =
@@ -132,6 +153,7 @@
for (Object [] row: list) {
+ // Load
Integer sl_id = (Integer)row[0];
Integer sl_kind = (Integer)row[1];
String sl_description = (String)row[2];
@@ -140,8 +162,12 @@
Timestamp sq_start_time = (Timestamp)row[5];
Timestamp sq_stop_time = (Timestamp)row[6];
Integer sq_id = (Integer)row[7];
+
+ // Value
Double slv_value = (Double)row[8];
String gf_name = (String)row[9];
+
+ // Station
Integer ms_id = (Integer)row[10];
Double ms_station = (Double)row[11];
String ms_type = (String)row[12];
@@ -181,7 +207,9 @@
station.addValue(
grainFractionIndex,
- new SedimentLoadData.Value(load, slv_value));
+ new SedimentLoadData.Value(load, slv_value == null
+ ? Double.NaN
+ : slv_value));
}
SedimentLoadData sld = new SedimentLoadData(id2station.values(),
diff -r ceeeaf228fe4 -r 204905c16ade artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Mon Sep 08 10:03:00 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Mon Sep 08 12:21:32 2014 +0200
@@ -68,9 +68,6 @@
for (SedimentLoadData.Station sta: allLoadData.getStations()) {
double value = sta.findValueByLoadId(id);
- if (Double.isNaN(value)) {
- continue;
- }
xPos.add(sta.getStation());
yPos.add(value);
}
diff -r ceeeaf228fe4 -r 204905c16ade artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java Mon Sep 08 10:03:00 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java Mon Sep 08 12:21:32 2014 +0200
@@ -40,7 +40,7 @@
ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible) {
- log.debug("doOut " + bundle.getFacetName());
+
CallContext context = generator.getCallContext();
XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
false, // Handle NaN
More information about the Dive4Elements-commits
mailing list