diff artifacts/doc/conf/meta-data.xml @ 8412:17db08570637

SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
author Tom Gottfried <tom@intevation.de>
date Wed, 15 Oct 2014 19:20:26 +0200
parents 1e1b08d033f4
children 6399ebc6fce9
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Wed Oct 15 14:58:46 2014 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Wed Oct 15 19:20:26 2014 +0200
@@ -1680,12 +1680,14 @@
                       ON sl.id = slv.sediment_load_id
                   JOIN measurement_station ms
                       ON ms.id = slv.measurement_station_id
-                  JOIN rivers r ON ms.river_id = r.id
+                  JOIN ranges ra ON ms.range_id = ra.id
+                  JOIN rivers r ON ra.river_id = r.id
                   JOIN time_intervals ti ON sl.time_interval_id = ti.id
                   LEFT JOIN time_intervals sq ON sl.sq_time_interval_id = sq.id
                   JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
               WHERE   r.id = ${river_id}
-                  AND ms.station BETWEEN ${fromkm} AND ${tokm}
+                  AND CASE WHEN r.km_up = 1 AND ra.b IS NOT NULL
+                      THEN ra.b ELSE ra.a END BETWEEN ${fromkm} AND ${tokm}
               ORDER BY sqstart DESC, sqstop DESC,
                   fraction, startyear DESC, endyear DESC
             </dc:statement>
@@ -3070,12 +3072,14 @@
                   ON sl.id = slv.sediment_load_id
               JOIN measurement_station ms
                   ON ms.id = slv.measurement_station_id
-              JOIN rivers r ON ms.river_id = r.id
+              JOIN ranges ra ON ms.range_id = ra.id
+              JOIN rivers r ON ra.river_id = r.id
               JOIN time_intervals ti ON sl.time_interval_id = ti.id
               JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
           WHERE r.id = ${river_id}
               AND sq_time_interval_id = ${sq_time_id}
-              AND ms.station BETWEEN ${fromkm} AND ${tokm}
+              AND CASE WHEN r.km_up = 1 AND ra.b IS NOT NULL
+                  THEN ra.b ELSE ra.a END BETWEEN ${fromkm} AND ${tokm}
               AND slk.kind = 'official'
         </dc:statement>
         <dc:call-macro name="sedimentload_off_epoch_filter">

http://dive4elements.wald.intevation.org