[PATCH] Fixed flow velocity query by distinct clause to avoid duplicates
Wald Commits
scm-commit at wald.intevation.org
Fri May 25 16:03:38 CEST 2018
# HG changeset patch
# User mschaefer
# Date 1527256995 -7200
# Node ID 1b24fdbf7fe2ab18e8d2fccb542c4176992fdb78
# Parent 5488166d32ee6d45ce96d3b93c59ddd9b2eb4e3f
Fixed flow velocity query by distinct clause to avoid duplicates
diff -r 5488166d32ee -r 1b24fdbf7fe2 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/FlowVelocityModelKmValueFinder.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/FlowVelocityModelKmValueFinder.java Fri May 25 15:41:51 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/FlowVelocityModelKmValueFinder.java Fri May 25 16:03:15 2018 +0200
@@ -52,7 +52,7 @@
* (Might be several 10000 rows if many stations and large q range)
*/
private static final String SQL_SELECT_ALL = //
- "SELECT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau"
+ "SELECT DISTINCT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau"
+ " FROM (discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id)"
+ " INNER JOIN flow_velocity_model_values fvmv ON fvm.id = fvmv.flow_velocity_model_id"
+ " WHERE (dz.river_id = :river_id) AND (fvmv.station BETWEEN :kmfrom - 0.0001 AND :kmto + 0.0001)"
@@ -63,9 +63,10 @@
* Query for a river's max km below a limit with all its q, main-v and tau values.
*/
private static final String SQL_SELECT_KMLOWER = //
- "SELECT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau" + " FROM flow_velocity_model_values fvmv"
+ "SELECT DISTINCT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau"
+ + " FROM flow_velocity_model_values fvmv"
+ " INNER JOIN (SELECT MAX(fvmvi.station) AS kmmax"
- + " FROM(discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id)"
+ + " FROM discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id"
+ " INNER JOIN flow_velocity_model_values fvmvi ON fvm.id = fvmvi.flow_velocity_model_id"
+ " WHERE (dz.river_id = :river_id) AND (fvmvi.station < :kmfrom - 0.0001)) finf ON fvmv.station = finf.kmmax"
+ " ORDER BY fvmv.q ASC";
@@ -74,9 +75,10 @@
* Query for a river's min km above a limit with all its q, main-v and tau values.
*/
private static final String SQL_SELECT_KMUPPER = //
- "SELECT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau" + " FROM flow_velocity_model_values fvmv"
+ "SELECT DISTINCT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau"
+ + " FROM flow_velocity_model_values fvmv"
+ " INNER JOIN (SELECT MIN(fvmvi.station) AS kmmin"
- + " FROM(discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id)"
+ + " FROM discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id"
+ " INNER JOIN flow_velocity_model_values fvmvi ON fvm.id = fvmvi.flow_velocity_model_id"
+ " WHERE (dz.river_id = :river_id) AND (fvmvi.station > :kmto + 0.0001)) fsup ON fvmv.station = fsup.kmmin"
+ " ORDER BY fvmv.q ASC";
More information about the Dive4Elements-commits
mailing list