sascha@1046: sascha@1046: sascha@1046: ingo@1181: ingo@1181: ingo@1181: ingo@1181: SELECT id AS river_id, name as river_name FROM rivers ingo@1181: WHERE lower(name) LIKE lower(${river}) ingo@1181: ingo@1181: felix@1790: felix@1790: Base-data macros (mostly data imported from wst-files) felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: SELECT id AS prot_id, felix@1790: description AS prot_description felix@1790: FROM wsts WHERE kind = 0 AND river_id = ${river_id} felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: SELECT id AS prot_column_id, felix@1790: name AS prot_column_name, felix@1790: position AS prot_rel_pos felix@1790: FROM wst_columns WHERE wst_id = ${prot_id} felix@1790: ORDER by position felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: SELECT id AS prot_id, felix@1790: description AS prot_description felix@1790: FROM wsts WHERE kind = 1 AND river_id = ${river_id} felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: SELECT id AS prot_column_id, felix@1790: name AS prot_column_name, felix@1790: position AS prot_rel_pos felix@1790: FROM wst_columns WHERE wst_id = ${prot_id} felix@1790: ORDER by position felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1790: felix@1869: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: SELECT id AS prot_id, felix@1872: description AS prot_description felix@1872: FROM wsts WHERE kind = 2 AND river_id = ${river_id} felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: SELECT id AS prot_column_id, felix@1872: name AS prot_column_name, felix@1872: position AS prot_rel_pos felix@1872: FROM wst_columns WHERE wst_id = ${prot_id} felix@1872: ORDER by position felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: SELECT id AS prot_id, felix@1869: description AS prot_description felix@1869: FROM wsts WHERE kind = 4 AND river_id = ${river_id} felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: SELECT id AS prot_column_id, felix@1869: name AS prot_column_name, felix@1869: position AS prot_rel_pos felix@1869: FROM wst_columns WHERE wst_id = ${prot_id} felix@1869: ORDER by position felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1851: felix@1851: felix@1851: felix@1851: felix@1851: felix@1851: felix@1865: felix@1865: felix@1865: felix@1865: felix@1865: felix@1865: felix@1865: felix@1865: felix@1869: felix@1869: felix@1869: felix@1869: + River-Node felix@1869: felix@1869: felix@1869: ingo@1181: ingo@1181: felix@1865: felix@1865: felix@1865: felix@1865: felix@1865: Recommendations. felix@1865: felix@1865: felix@1865: felix@1865: felix@1865: felix@1865: felix@1869: felix@1869: Non - Recommendations. felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1869: felix@1865: felix@1865: felix@1872: felix@1764: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: SELECT id AS prot_id, felix@1728: description AS prot_description felix@1728: FROM wsts WHERE kind = 5 AND river_id = ${river_id} felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: SELECT id AS prot_column_id, felix@1728: name AS prot_column_name, felix@1728: position AS prot_rel_pos felix@1728: FROM wst_columns WHERE wst_id = ${prot_id} felix@1728: ORDER by position felix@1728: felix@1728: felix@1728: felix@1728: felix@1739: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1728: felix@1875: felix@1875: felix@1875: felix@1875: felix@1875: felix@1875: felix@1875: felix@1875: felix@1875: felix@1875: felix@1728: felix@1773: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: SELECT id AS gauge_id, ingo@1181: name AS gauge_name ingo@1181: FROM gauges WHERE river_id = ${river_id} ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: SELECT description AS gauge_desc, ingo@1181: d.id AS discharge_id, ingo@1181: ti.start_time AS g_start, ingo@1181: ti.stop_time AS g_stop ingo@1181: FROM discharge_tables d JOIN time_intervals ti ingo@1181: ON d.time_interval_id = ti.id ingo@1181: WHERE d.gauge_id = ${gauge_id} AND d.kind = 1 ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: SELECT id AS fix_id, ingo@1181: description AS fix_description ingo@1181: FROM wsts WHERE kind = 2 AND river_id = ${river_id} ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: SELECT id AS fix_column_id, ingo@1181: name AS fix_column_name ingo@1181: FROM wst_columns WHERE wst_id = ${fix_id} ingo@1181: ORDER by position ingo@1181: ingo@1181: ingo@1181: ingo@1181: felix@1728: felix@1728: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: SELECT id AS prot_id, ingo@1181: description AS prot_description ingo@1181: FROM wsts WHERE kind = 5 AND river_id = ${river_id} ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: SELECT id AS prot_column_id, ingo@1181: name AS prot_column_name ingo@1181: FROM wst_columns WHERE wst_id = ${prot_id} ingo@1181: ORDER by position ingo@1181: ingo@1181: ingo@1181: ingo@1181: felix@1728: felix@1728: felix@1728: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: felix@1872: ingo@1181: ingo@1181: ingo@1181: ingo@1181: felix@1851: ingo@1181: ingo@1181: felix@1851: felix@1851: felix@1851: felix@1872: ingo@1181: ingo@1181: felix@1865: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1185: ingo@1185: ingo@1185: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: FIXME: Following two macros look identical to me. ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1185: ingo@1185: ingo@1185: ingo@1185: ingo@1185: SELECT id AS dem_id, ingo@1185: lower AS dem_lower, ingo@1185: upper AS dem_upper ingo@1185: FROM dem WHERE river_id = ${river_id} ingo@1185: ingo@1185: ingo@1186: ingo@1186: ingo@1186: ingo@1186: ingo@1186: ingo@1185: ingo@1185: ingo@1185: ingo@1185: ingo@1805: ingo@1805: ingo@1805: ingo@1805: SELECT count(*) as km_exists ingo@1805: FROM river_axes_km WHERE river_id = ${river_id} ingo@1805: ingo@1805: ingo@1805: ingo@1805: ingo@1805: ingo@1805: ingo@1805: ingo@1805: ingo@1805: ingo@1805: ingo@1805: ingo@1836: ingo@1836: ingo@1836: ingo@1836: SELECT count(*) as km_exists ingo@1836: FROM cross_section_tracks WHERE river_id = ${river_id} ingo@1836: ingo@1836: ingo@1836: ingo@1836: ingo@1836: ingo@1836: ingo@1836: ingo@1836: ingo@1836: ingo@1836: ingo@1836: ingo@1855: ingo@1855: ingo@1855: ingo@1855: SELECT count(*) as km_exists ingo@1855: FROM hws WHERE river_id = ${river_id} ingo@1855: ingo@1855: ingo@1855: ingo@1855: ingo@1855: ingo@1855: ingo@1855: ingo@1855: ingo@1855: ingo@1855: ingo@1855: ingo@1856: ingo@1856: ingo@1856: ingo@1856: SELECT count(*) as km_exists ingo@1856: FROM catchment WHERE river_id = ${river_id} ingo@1856: ingo@1856: ingo@1856: ingo@1856: ingo@1856: ingo@1856: ingo@1856: ingo@1856: ingo@1856: ingo@1856: ingo@1856: ingo@1857: ingo@1857: ingo@1857: ingo@1857: SELECT count(*) as km_exists ingo@1857: FROM floodplain WHERE river_id = ${river_id} ingo@1857: ingo@1857: ingo@1857: ingo@1857: ingo@1857: ingo@1857: ingo@1857: ingo@1857: ingo@1857: ingo@1857: ingo@1857: ingo@1870: ingo@1870: ingo@1870: ingo@1870: SELECT count(*) as km_exists ingo@1870: FROM lines WHERE river_id = ${river_id} ingo@1870: ingo@1870: ingo@1870: ingo@1870: ingo@1870: ingo@1870: ingo@1870: ingo@1870: ingo@1870: ingo@1870: ingo@1870: ingo@1871: ingo@1871: ingo@1871: ingo@1871: SELECT count(*) as km_exists ingo@1871: FROM buildings WHERE river_id = ${river_id} ingo@1871: ingo@1871: ingo@1871: ingo@1871: ingo@1871: ingo@1871: ingo@1871: ingo@1871: ingo@1871: ingo@1871: ingo@1871: ingo@1873: ingo@1873: ingo@1873: ingo@1873: SELECT count(*) as km_exists ingo@1873: FROM fixpoints WHERE river_id = ${river_id} ingo@1873: ingo@1873: ingo@1873: ingo@1873: ingo@1873: ingo@1873: ingo@1873: ingo@1873: ingo@1873: ingo@1873: ingo@1873: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1805: ingo@1836: ingo@1855: ingo@1856: ingo@1857: ingo@1870: ingo@1871: ingo@1873: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: ingo@1181: sascha@1046: sascha@1046: sascha@1046: User specific part sascha@1046: ------------------ sascha@1046: sascha@1046: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: Get the user and collection-id. felix@1879: felix@1760: felix@1879: SELECT u.id AS user_id, c.id AS collection_id, c.name as collection_name felix@1879: FROM collections c JOIN users u ON c.user_id = u.id felix@1879: WHERE u.gid = CAST(${user-id} AS uuid) felix@1879: ORDER BY c.creation DESC felix@1760: ingo@1657: ingo@1657: felix@1879: felix@1879: SHOW W-DIFFERENCES felix@1879: ingo@1657: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation felix@1879: FROM master_artifacts m felix@1879: WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) felix@1879: AND EXISTS ( felix@1879: SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: SELECT a.gid as aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description as facet_description felix@1879: FROM outs as o, facets as f, artifacts as a felix@1879: WHERE f.name = 'w_differences' and f.out_id = o.id and o.artifact_id = ${a_id} and a.id = ${a_id} felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: ingo@1657: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation felix@1880: FROM master_artifacts m felix@1880: WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) felix@1880: AND EXISTS ( felix@1880: SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: SELECT a.gid as aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description as facet_description felix@1880: FROM outs as o, facets as f, artifacts as a felix@1880: WHERE f.name = 'computed_discharge_curve.q' and f.out_id = o.id and o.artifact_id = ${a_id} and a.id = ${a_id} felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1880: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation felix@1879: FROM master_artifacts m felix@1879: WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) felix@1879: AND EXISTS ( felix@1879: SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: SELECT id AS out_id felix@1879: FROM outs felix@1879: WHERE artifact_id = ${a_id} AND name = 'longitudinal_section' felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: SELECT name AS facet_name, num as facet_num, description AS facet_description felix@1879: FROM facets felix@1879: WHERE out_id = ${out_id} felix@1879: ORDER BY num ASC, name DESC felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: WATERLEVELS - ONLY SHOW Ws felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation felix@1879: FROM master_artifacts m felix@1879: WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) felix@1879: AND EXISTS ( felix@1879: SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: SELECT id AS out_id felix@1879: FROM outs felix@1879: WHERE artifact_id = ${a_id} AND name = 'longitudinal_section' felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: SELECT name AS facet_name, num as facet_num, description AS facet_description felix@1879: FROM facets felix@1879: WHERE out_id = ${out_id} and name = 'longitudinal_section.w' felix@1879: ORDER BY num ASC, name DESC felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: felix@1879: sascha@1046: ingo@1657: ingo@1657: ingo@1181: ingo@1657: Include System specific part when 'load-system' is in parameters. ingo@1657: ----------------------------------------------------------------- ingo@1181: ingo@1657: ingo@1657: ingo@1657: ingo@1657: ingo@1657: sascha@1046: ingo@1657: ingo@1657: sascha@1046: ingo@1657: Include System specific part only if no user ID is given. ingo@1657: --------------------------------------------------------- sascha@1046: sascha@1046: ingo@1181: sascha@1046: sascha@1046: sascha@1046: sascha@1046: