Mercurial > dive4elements > river
diff flys-artifacts/doc/conf/meta-data.xml @ 5379:61bf64b102bc mapgenfix
Merge with default branch
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 22 Mar 2013 11:25:54 +0100 |
parents | d43ef9f709cd |
children | 51db7fbc2e77 |
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/meta-data.xml Wed Mar 06 14:14:15 2013 +0100 +++ b/flys-artifacts/doc/conf/meta-data.xml Fri Mar 22 11:25:54 2013 +0100 @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <dc:template xmlns:dc="http://www.intevation.org/2011/Datacage"> <datacage> -<dc:macro name="SQL-wst_columns_statement"> + <dc:comment> + Statement to load data from wsts. + </dc:comment> + <dc:macro name="SQL-wst_columns_statement"> <dc:statement> SELECT wst_columns.id AS prot_column_id, wst_columns.name AS prot_column_name, @@ -10,10 +13,49 @@ wst_ranges.a AS deffrom, wst_ranges.b AS defto FROM wst_columns, wst_ranges - WHERE wst_columns.wst_id = ${prot_id} AND wst_ranges.wst_column_id = wst_columns.id + WHERE wst_columns.wst_id = ${prot_id} + AND wst_ranges.wst_column_id = wst_columns.id + AND (${fromkm} BETWEEN wst_ranges.a AND wst_ranges.b + OR ${tokm} BETWEEN wst_ranges.a AND wst_ranges.b + OR wst_ranges.a BETWEEN ${fromkm} AND ${tokm} + OR wst_ranges.b BETWEEN ${fromkm} AND ${tokm}) ORDER by wst_columns.position </dc:statement> -</dc:macro> + </dc:macro> + + <dc:comment> + Load user specific distance information from artifact. + </dc:comment> + <dc:macro name="user-range"> + <dc:choose> + <dc:when test="dc:contains($parameters, 'user-id')"> + <dc:context connection="user"> + <dc:statement> + SELECT COALESCE(ld_mode, '') AS ldm, + COALESCE(ld_locations, '') AS ldl, + COALESCE(ld_from, '') AS ldf, + COALESCE(ld_to, '') AS ldt + FROM master_artifacts_range + WHERE gid = CAST(${artifact-id} as uuid) + </dc:statement> + <dc:elements> + <dc:variable name="fromkm" type="number" expr="dc:fromValue($ldm, $ldl, $ldf)"/> + <dc:variable name="tokm" type="number" expr="dc:toValue($ldm, $ldl, $ldt)"/> + <dc:macro-body/> + </dc:elements> + </dc:context> + </dc:when> + <dc:otherwise> + <dc:variable name="fromkm" type="number" expr="dc:fromValue('', '', '')"/> + <dc:variable name="tokm" type="number" expr="dc:toValue('', '', '')"/> + <dc:macro-body/> + </dc:otherwise> + </dc:choose> + </dc:macro> + + <dc:comment> + System part. Load data for the given river. + </dc:comment> <dc:macro name="load-system"> <dc:context connection="system"> <dc:statement> @@ -21,13 +63,15 @@ WHERE lower(name) LIKE lower(${river}) </dc:statement> <dc:elements> + <dc:comment> - Base-data macros (mostly data imported from wst-files) + Base-data macros (mostly data imported from wst-files). </dc:comment> <dc:macro name="basedata_0"> + <dc:call-macro name="user-range"> <dc:comment comment=" BASEDATA ---------------------------"/> <basedata> - <dc:context> + <dc:context connection="system"> <dc:statement> SELECT id AS prot_id, description AS prot_description @@ -51,11 +95,14 @@ </dc:elements> </dc:context> </basedata> + </dc:call-macro> </dc:macro> + <dc:macro name="basedata_0_wq"> + <dc:call-macro name="user-range"> <dc:comment comment=" BASEDATA ---------------------------"/> <basedata> - <dc:context> + <dc:context connection="system"> <dc:statement> SELECT id AS prot_id, description AS prot_description @@ -79,12 +126,14 @@ </dc:elements> </dc:context> </basedata> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_1_additionals_marks"> + <dc:call-macro name="user-range"> <dc:comment comment=".ZUS -------------------------------"/> <additionals> - <dc:context> + <dc:context connection="system"> <dc:statement> SELECT id AS prot_id, description AS prot_description @@ -108,12 +157,14 @@ </dc:elements> </dc:context> </additionals> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_1_additionals"> + <dc:call-macro name="user-range"> <dc:comment comment=".ZUS -------------------------------"/> <additionals> - <dc:context> + <dc:context connection="system"> <dc:statement> SELECT id AS prot_id, description AS prot_description @@ -137,12 +188,14 @@ </dc:elements> </dc:context> </additionals> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_1_additionals-relative_point"> + <dc:call-macro name="user-range"> <dc:comment comment=".ZUS -------------------------------"/> <additionals> - <dc:context> + <dc:context connection="system"> <dc:statement> SELECT id AS prot_id, description AS prot_description @@ -166,125 +219,135 @@ </dc:elements> </dc:context> </additionals> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_2_fixations_wst"> - <fixations> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM wsts WHERE kind = 2 AND river_id = ${river_id} - </dc:statement> - <dc:elements> - <fixation> - <dc:attribute name="name" value="${prot_description}"/> - <!--dc:attribute name="ids" value="fixations-wstv-A-${prot_id}"/--> - <dc:context> - <dc:call-macro name="SQL-wst_columns_statement"/> - <dc:elements> - <column> - <dc:attribute name="name" value="${prot_column_name}"/> - <dc:attribute name="ids" value="fixations-wstv-${prot_rel_pos}-${prot_id}"/> - <dc:attribute name="factory" value="wqinterpol"/> - <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> - </column> - </dc:elements> - </dc:context> - </fixation> - </dc:elements> - </dc:context> - </fixations> + <dc:call-macro name="user-range"> + <fixations> + <dc:context connection="system"> + <dc:statement> + SELECT id AS prot_id, + description AS prot_description + FROM wsts WHERE kind = 2 AND river_id = ${river_id} + </dc:statement> + <dc:elements> + <fixation> + <dc:attribute name="name" value="${prot_description}"/> + <!--dc:attribute name="ids" value="fixations-wstv-A-${prot_id}"/--> + <dc:context> + <dc:call-macro name="SQL-wst_columns_statement"/> + <dc:elements> + <column> + <dc:attribute name="name" value="${prot_column_name}"/> + <dc:attribute name="ids" value="fixations-wstv-${prot_rel_pos}-${prot_id}"/> + <dc:attribute name="factory" value="wqinterpol"/> + <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> + </column> + </dc:elements> + </dc:context> + </fixation> + </dc:elements> + </dc:context> + </fixations> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_2_fixations_wqkms"> - <fixations> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM wsts WHERE kind = 2 AND river_id = ${river_id} - </dc:statement> - <dc:elements> - <fixation> - <dc:attribute name="name" value="${prot_description}"/> - <dc:context> - <dc:call-macro name="SQL-wst_columns_statement"/> - <dc:elements> - <column> - <dc:attribute name="name" value="${prot_column_name}"/> - <dc:attribute name="ids" value="fixations-wstv-${prot_rel_pos}-${prot_id}"/> - <dc:attribute name="factory" value="wqinterpol"/> - <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> - </column> - </dc:elements> - </dc:context> - </fixation> - </dc:elements> - </dc:context> - </fixations> + <dc:call-macro name="user-range"> + <fixations> + <dc:context connection="system"> + <dc:statement> + SELECT id AS prot_id, + description AS prot_description + FROM wsts WHERE kind = 2 AND river_id = ${river_id} + </dc:statement> + <dc:elements> + <fixation> + <dc:attribute name="name" value="${prot_description}"/> + <dc:context> + <dc:call-macro name="SQL-wst_columns_statement"/> + <dc:elements> + <column> + <dc:attribute name="name" value="${prot_column_name}"/> + <dc:attribute name="ids" value="fixations-wstv-${prot_rel_pos}-${prot_id}"/> + <dc:attribute name="factory" value="wqinterpol"/> + <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> + </column> + </dc:elements> + </dc:context> + </fixation> + </dc:elements> + </dc:context> + </fixations> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_2_fixations"> - <fixations> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM wsts WHERE kind = 2 AND river_id = ${river_id} - </dc:statement> - <dc:elements> - <fixation> - <dc:attribute name="name" value="${prot_description}"/> - <dc:context> - <dc:call-macro name="SQL-wst_columns_statement"/> - <dc:elements> - <column> - <dc:attribute name="name" value="${prot_column_name}"/> - <dc:attribute name="ids" value="fixations-wstv-${prot_rel_pos}-${prot_id}"/> - <dc:attribute name="factory" value="staticwkms"/> - <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> - </column> - </dc:elements> - </dc:context> - </fixation> - </dc:elements> - </dc:context> - </fixations> + <dc:call-macro name="user-range"> + <fixations> + <dc:context connection="system"> + <dc:statement> + SELECT id AS prot_id, + description AS prot_description + FROM wsts WHERE kind = 2 AND river_id = ${river_id} + </dc:statement> + <dc:elements> + <fixation> + <dc:attribute name="name" value="${prot_description}"/> + <dc:context> + <dc:call-macro name="SQL-wst_columns_statement"/> + <dc:elements> + <column> + <dc:attribute name="name" value="${prot_column_name}"/> + <dc:attribute name="ids" value="fixations-wstv-${prot_rel_pos}-${prot_id}"/> + <dc:attribute name="factory" value="staticwkms"/> + <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> + </column> + </dc:elements> + </dc:context> + </fixation> + </dc:elements> + </dc:context> + </fixations> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_2_fixations_relative_point"> - <fixations> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM wsts WHERE kind = 2 AND river_id = ${river_id} - </dc:statement> - <dc:elements> - <relativepoint> - <dc:attribute name="name" value="${prot_description}"/> - <dc:context> - <dc:call-macro name="SQL-wst_columns_statement"/> - <dc:elements> - <column> - <dc:attribute name="name" value="${prot_column_name}"/> - <dc:attribute name="ids" value="fixations-wstv-${prot_rel_pos}-${prot_id}"/> - <dc:attribute name="factory" value="staticwkms"/> - <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> - </column> - </dc:elements> - </dc:context> - </relativepoint> - </dc:elements> - </dc:context> - </fixations> + <dc:call-macro name="user-range"> + <fixations> + <dc:context connection="system"> + <dc:statement> + SELECT id AS prot_id, + description AS prot_description + FROM wsts WHERE kind = 2 AND river_id = ${river_id} + </dc:statement> + <dc:elements> + <relativepoint> + <dc:attribute name="name" value="${prot_description}"/> + <dc:context> + <dc:call-macro name="SQL-wst_columns_statement"/> + <dc:elements> + <column> + <dc:attribute name="name" value="${prot_column_name}"/> + <dc:attribute name="ids" value="fixations-wstv-${prot_rel_pos}-${prot_id}"/> + <dc:attribute name="factory" value="staticwkms"/> + <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> + </column> + </dc:elements> + </dc:context> + </relativepoint> + </dc:elements> + </dc:context> + </fixations> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_3_officials"> + <dc:call-macro name="user-range"> <dc:comment comment=".wst -------------------------------"/> <officiallines> - <dc:context> + <dc:context connection="system"> <dc:statement> SELECT id AS prot_id, description AS prot_description @@ -308,107 +371,149 @@ </dc:elements> </dc:context> </officiallines> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_4_heightmarks-points-relative_points"> - <heightmarks> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM wsts WHERE kind = 4 AND river_id = ${river_id} - </dc:statement> - <dc:elements> - <relativepoint> - <dc:attribute name="name" value="${prot_description}"/> - <dc:context> - <dc:call-macro name="SQL-wst_columns_statement"/> - <dc:elements> - <column> - <dc:attribute name="name" value="${prot_column_name}"/> - <dc:attribute name="ids" value="heightmarks_points-wstv-${prot_rel_pos}-${prot_id}"/> - <dc:attribute name="factory" value="staticwkms"/> - <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> - </column> - </dc:elements> - </dc:context> - </relativepoint> - </dc:elements> - </dc:context> - </heightmarks> + <dc:call-macro name="user-range"> + <heightmarks> + <dc:context connection="system"> + <dc:statement> + SELECT id AS prot_id, + description AS prot_description + FROM wsts WHERE kind = 4 AND river_id = ${river_id} + </dc:statement> + <dc:elements> + <relativepoint> + <dc:attribute name="name" value="${prot_description}"/> + <dc:context> + <dc:call-macro name="SQL-wst_columns_statement"/> + <dc:elements> + <column> + <dc:attribute name="name" value="${prot_column_name}"/> + <dc:attribute name="ids" value="heightmarks_points-wstv-${prot_rel_pos}-${prot_id}"/> + <dc:attribute name="factory" value="staticwkms"/> + <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> + </column> + </dc:elements> + </dc:context> + </relativepoint> + </dc:elements> + </dc:context> + </heightmarks> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_4_heightmarks-points"> - <heightmarks> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM wsts WHERE kind = 4 AND river_id = ${river_id} - </dc:statement> - <dc:elements> - <heightmark> - <dc:attribute name="name" value="${prot_description}"/> - <dc:context> - <dc:call-macro name="SQL-wst_columns_statement"/> - <dc:elements> - <column> - <dc:attribute name="name" value="${prot_column_name}"/> - <dc:attribute name="ids" value="heightmarks_points-wstv-${prot_rel_pos}-${prot_id}"/> - <dc:attribute name="factory" value="staticwkms"/> - <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> - </column> - </dc:elements> - </dc:context> - </heightmark> - </dc:elements> - </dc:context> - </heightmarks> + <dc:call-macro name="user-range"> + <heightmarks> + <dc:context connection="system"> + <dc:statement> + SELECT id AS prot_id, + description AS prot_description + FROM wsts WHERE kind = 4 AND river_id = ${river_id} + </dc:statement> + <dc:elements> + <heightmark> + <dc:attribute name="name" value="${prot_description}"/> + <dc:context> + <dc:call-macro name="SQL-wst_columns_statement"/> + <dc:elements> + <column> + <dc:attribute name="name" value="${prot_column_name}"/> + <dc:attribute name="ids" value="heightmarks_points-wstv-${prot_rel_pos}-${prot_id}"/> + <dc:attribute name="factory" value="staticwkms"/> + <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> + </column> + </dc:elements> + </dc:context> + </heightmark> + </dc:elements> + </dc:context> + </heightmarks> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_4_heightmarks-wq"> - <heightmarks> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM wsts WHERE kind = 4 AND river_id = ${river_id} - </dc:statement> - <dc:elements> - <heightmark> - <dc:attribute name="name" value="${prot_description}"/> - <dc:context> - <dc:call-macro name="SQL-wst_columns_statement"/> - <dc:elements> - <column> - <dc:attribute name="name" value="${prot_column_name}"/> - <dc:attribute name="ids" value="heightmarks_annotations-wstv-${prot_rel_pos}-${prot_id}"/> - <dc:attribute name="factory" value="wqinterpol"/> - <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> - </column> - </dc:elements> - </dc:context> - </heightmark> - </dc:elements> - </dc:context> - </heightmarks> + <dc:call-macro name="user-range"> + <heightmarks> + <dc:context connection="system"> + <dc:statement> + SELECT id AS prot_id, + description AS prot_description + FROM wsts WHERE kind = 4 AND river_id = ${river_id} + </dc:statement> + <dc:elements> + <heightmark> + <dc:attribute name="name" value="${prot_description}"/> + <dc:context> + <dc:call-macro name="SQL-wst_columns_statement"/> + <dc:elements> + <column> + <dc:attribute name="name" value="${prot_column_name}"/> + <dc:attribute name="ids" value="heightmarks_annotations-wstv-${prot_rel_pos}-${prot_id}"/> + <dc:attribute name="factory" value="wqinterpol"/> + <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> + </column> + </dc:elements> + </dc:context> + </heightmark> + </dc:elements> + </dc:context> + </heightmarks> + </dc:call-macro> </dc:macro> <dc:macro name="basedata_5_flood-protections_relative_points"> - <flood_protections> - <dc:attribute name="id" value="flood-protections-${river_id}"/> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM wsts WHERE kind = 5 AND river_id = ${river_id} - </dc:statement> - <dc:elements> - <relativepoint> - <dc:attribute name="name" value="${prot_description}"/> - <dc:attribute name="db-id" value="${prot_id}"/> - <dc:attribute name="factory" value="staticwkms"/> - <columns> + <dc:call-macro name="user-range"> + <flood_protections> + <dc:attribute name="id" value="flood-protections-${river_id}"/> + <dc:context connection="system"> + <dc:statement> + SELECT id AS prot_id, + description AS prot_description + FROM wsts WHERE kind = 5 AND river_id = ${river_id} + </dc:statement> + <dc:elements> + <relativepoint> + <dc:attribute name="name" value="${prot_description}"/> + <dc:attribute name="db-id" value="${prot_id}"/> + <dc:attribute name="factory" value="staticwkms"/> + <columns> + <dc:context> + <dc:call-macro name="SQL-wst_columns_statement"/> + <dc:elements> + <column> + <dc:attribute name="name" value="${prot_column_name}"/> + <dc:attribute name="ids" value="flood_protection-wstv-${prot_rel_pos}-${prot_id}"/> + <dc:attribute name="factory" value="staticwkms"/> + <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> + </column> + </dc:elements> + </dc:context> + </columns> + </relativepoint> + </dc:elements> + </dc:context> + </flood_protections> + </dc:call-macro> + </dc:macro> + + <dc:macro name="basedata_5_flood-protections"> + <dc:call-macro name="user-range"> + <flood_protections> + <dc:attribute name="id" value="flood-protections-${river_id}"/> + <dc:context connection="system"> + <dc:statement> + SELECT id AS prot_id, + description AS prot_description + FROM wsts WHERE kind = 5 AND river_id = ${river_id} + </dc:statement> + <dc:elements> + <flood_protection> + <dc:attribute name="name" value="${prot_description}"/> + <dc:attribute name="db-id" value="${prot_id}"/> + <dc:attribute name="factory" value="staticwkms"/> <dc:context> <dc:call-macro name="SQL-wst_columns_statement"/> <dc:elements> @@ -420,42 +525,11 @@ </column> </dc:elements> </dc:context> - </columns> - </relativepoint> - </dc:elements> - </dc:context> - </flood_protections> - </dc:macro> - - <dc:macro name="basedata_5_flood-protections"> - <flood_protections> - <dc:attribute name="id" value="flood-protections-${river_id}"/> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM wsts WHERE kind = 5 AND river_id = ${river_id} - </dc:statement> - <dc:elements> - <flood_protection> - <dc:attribute name="name" value="${prot_description}"/> - <dc:attribute name="db-id" value="${prot_id}"/> - <dc:attribute name="factory" value="staticwkms"/> - <dc:context> - <dc:call-macro name="SQL-wst_columns_statement"/> - <dc:elements> - <column> - <dc:attribute name="name" value="${prot_column_name}"/> - <dc:attribute name="ids" value="flood_protection-wstv-${prot_rel_pos}-${prot_id}"/> - <dc:attribute name="factory" value="staticwkms"/> - <dc:attribute name="info" value="${info} [km ${deffrom} - ${defto}]"/> - </column> - </dc:elements> - </dc:context> - </flood_protection> - </dc:elements> - </dc:context> - </flood_protections> + </flood_protection> + </dc:elements> + </dc:context> + </flood_protections> + </dc:call-macro> </dc:macro> <dc:macro name="mainvalues"> @@ -512,97 +586,129 @@ </dc:macro> <dc:macro name="cross_sections"> - <cross_sections> - <dc:attribute name="id" value="flood-protections-${river_id}"/> - <dc:context> - <dc:statement> - SELECT id AS prot_id, - description AS prot_description - FROM cross_sections WHERE river_id = ${river_id} - </dc:statement> - <dc:elements> - <cross_section> - <dc:attribute name="name" value="${prot_description}"/> - <dc:attribute name="ids" value="${prot_id}"/> - <dc:attribute name="factory" value="crosssections"/> - </cross_section> - </dc:elements> - </dc:context> - </cross_sections> + <dc:call-macro name="user-range"> + <cross_sections> + <dc:attribute name="id" value="flood-protections-${river_id}"/> + <dc:context connection="system"> + <dc:statement> + SELECT DISTINCT + cs.id AS prot_id, + cs.description AS prot_description + FROM cross_sections cs + JOIN cross_section_lines csl ON csl.cross_section_id = cs.id + WHERE cs.river_id = ${river_id} + AND csl.km BETWEEN ${fromkm} AND ${tokm} + </dc:statement> + <dc:elements> + <cross_section> + <dc:attribute name="name" value="${prot_description}"/> + <dc:attribute name="ids" value="${prot_id}"/> + <dc:attribute name="factory" value="crosssections"/> + </cross_section> + </dc:elements> + </dc:context> + </cross_sections> + </dc:call-macro> </dc:macro> <dc:macro name="hyks"> - <hyks> - <dc:attribute name="id" value="hyk-${river_id}"/> - <dc:context> - <dc:statement> - SELECT id AS hyk_id, - description AS hyk_description - FROM hyks WHERE river_id = ${river_id} - </dc:statement> - <dc:elements> - <hyk> - <dc:attribute name="name" value="${hyk_description}"/> - <dc:attribute name="ids" value="${hyk_id}"/> - <dc:attribute name="factory" value="hyk"/> - </hyk> - </dc:elements> - </dc:context> - </hyks> + <dc:call-macro name="user-range"> + <hyks> + <dc:attribute name="id" value="hyk-${river_id}"/> + <dc:context connection="system"> + <dc:statement> + SELECT DISTINCT + h.id AS hyk_id, + h.description AS hyk_description + FROM hyks h + JOIN hyk_entries he ON he.hyk_id = h.id + WHERE river_id = ${river_id} + AND he.km BETWEEN ${fromkm} AND ${tokm} + </dc:statement> + <dc:elements> + <hyk> + <dc:attribute name="name" value="${hyk_description}"/> + <dc:attribute name="ids" value="${hyk_id}"/> + <dc:attribute name="factory" value="hyk"/> + </hyk> + </dc:elements> + </dc:context> + </hyks> + </dc:call-macro> </dc:macro> <dc:macro name="flow_velocity_measurements"> - <flowvelocitymeasurement> - <dc:context> - <dc:statement> - SELECT id AS fvmid, - description AS fvmd - FROM flow_velocity_measurements WHERE river_id = ${river_id} - </dc:statement> - <dc:elements> - <flow_velocity_measurement> - <dc:attribute name="name" value="${fvmd}"/> - <dc:attribute name="ids" value="${fvmid}"/> - <dc:attribute name="factory" value="flowvelocity"/> - <dc:context> - <dc:statement> - SELECT id, description, station, datetime, v, w, q - FROM flow_velocity_measure_values - WHERE measurements_id = ${fvmid} - </dc:statement> - <dc:elements> - <measurement_value> - <dc:attribute name="name" value="${id}-${description}-${station}-${datetime}"/> - <dc:attribute name="ids" value="${id}"/> - <dc:attribute name="factory" value="flowvelocity"/> - </measurement_value> - </dc:elements> - </dc:context> - </flow_velocity_measurement> + <dc:call-macro name="user-range"> + <flowvelocitymeasurement> + <dc:context connection="system"> + <dc:statement> + SELECT id AS fvmid, + description AS fvmd + FROM flow_velocity_measurements WHERE river_id = ${river_id} + </dc:statement> + <dc:elements> + <flow_velocity_measurement> + <dc:attribute name="name" value="${fvmd}"/> + <dc:attribute name="ids" value="${fvmid}"/> + <dc:attribute name="factory" value="flowvelocity"/> + <dc:context> + <dc:statement> + SELECT id, description, station, datetime, v, w, q + FROM flow_velocity_measure_values + WHERE measurements_id = ${fvmid} + AND station BETWEEN ${fromkm} AND ${tokm} + </dc:statement> + <dc:elements> + <measurement_value> + <dc:attribute name="name" value="${id}-${description}-${station}-${datetime}"/> + <dc:attribute name="ids" value="${id}"/> + <dc:attribute name="factory" value="flowvelocity"/> + </measurement_value> + </dc:elements> + </dc:context> + </flow_velocity_measurement> </dc:elements> </dc:context> </flowvelocitymeasurement> + </dc:call-macro> + </dc:macro> + + <dc:macro name="sounding-width"> + <soundings_width> + <dc:context> + <dc:statement> + SELECT id AS bedh_id, + year AS bedh_year, + description AS bedh_descr + FROM bed_height_single WHERE river_id = ${river_id} + </dc:statement> + <dc:elements> + <height> + <dc:attribute name="factory" value="bedheight"/> + <dc:attribute name="ids" value="bedheight-singlevalues-${bedh_id}-${bedh_year}"/> + <dc:attribute name="description" value="${bedh_descr}"/> + </height> + </dc:elements> + </dc:context> + </soundings_width> </dc:macro> <dc:macro name="longitudinal-section-prototype"> - <dc:call-macro name="basedata_0"/> - <dc:call-macro name="basedata_1_additionals"/> - <dc:comment comment=" FIXATIONS ---------------------------"/> - <dc:call-macro name="basedata_2_fixations"/> - <dc:comment comment=" HOEHENMARKEN ---------------------------"/> - <dc:call-macro name="basedata_4_heightmarks-points"/> - <dc:comment comment=" AMTL LINIEN ---------------------------"/> - <dc:call-macro name="basedata_3_officials"/> - <dc:call-macro name="basedata_5_flood-protections"/> - <dc:call-macro name="annotations_per_type"/> + <dc:call-macro name="basedata_0"/> + <dc:call-macro name="basedata_1_additionals"/> + <dc:comment comment=" FIXATIONS ---------------------------"/> + <dc:call-macro name="basedata_2_fixations"/> + <dc:comment comment=" HOEHENMARKEN ---------------------------"/> + <dc:call-macro name="basedata_4_heightmarks-points"/> + <dc:comment comment=" AMTL LINIEN ---------------------------"/> + <dc:call-macro name="basedata_3_officials"/> + <dc:call-macro name="basedata_5_flood-protections"/> + <dc:call-macro name="annotations_per_type"/> </dc:macro> <dc:comment> - + River-Node - </dc:comment> - <river> <dc:attribute name="name" value="${river_name}"/> @@ -631,6 +737,9 @@ <dc:if test="dc:contains($artifact-outs, 'fix_wq_curve')"> <dc:call-macro name="qsectors"/> </dc:if> + <dc:if test="dc:contains($artifact-outs, 'longitudinal_section')"> + <dc:call-macro name="annotations"/> + </dc:if> <dc:if test="dc:contains($artifact-outs, 'fix_longitudinal_section_curve')"> <dc:call-macro name="annotations"/> </dc:if> @@ -709,23 +818,7 @@ MINFO bedheight middle </dc:comment> <dc:if test="dc:contains($artifact-outs, 'bedheight_middle')"> - <soundings_width> - <dc:context> - <dc:statement> - SELECT id AS bedh_id, - year AS bedh_year, - description AS bedh_descr - FROM bed_height_single WHERE river_id = ${river_id} - </dc:statement> - <dc:elements> - <height> - <dc:attribute name="factory" value="bedheight"/> - <dc:attribute name="ids" value="bedheight-singlevalues-${bedh_id}-${bedh_year}"/> - <dc:attribute name="description" value="${bedh_descr}"/> - </height> - </dc:elements> - </dc:context> - </soundings_width> + <dc:call-macro name="sounding-width"/> </dc:if> <dc:comment comment="--- non-recommendations---"/> </dc:otherwise> @@ -844,7 +937,7 @@ </discharge_table_nn> </dc:if> - <dc:if test="dc:contains($artifact-outs, 'floodmap')"> + <dc:if test="dc:contains($artifact-outs, 'floodmap') or dc:contains($artifact-outs, 'floodmap-hws')"> <floodmap> <dc:choose> <dc:when test="dc:contains($parameters, 'recommended')"> @@ -858,6 +951,13 @@ </dc:otherwise> </dc:choose> </floodmap> + <dc:if test="dc:contains($parameters, 'hws')"> + <hws> + <dc:call-macro name="flood-map-hws-lines" /> + <dc:call-macro name="flood-map-hws-points" /> + </hws> + </dc:if> + <dc:macro name="flood-map-recommended"> <dc:comment> FIXME: Following two macros look identical to me. @@ -879,12 +979,15 @@ <dems> <dc:context> <dc:statement> - SELECT id AS dem_id, - lower AS dem_lower, - upper AS dem_upper, - name AS name, - projection || ' | ' || year_from || ' - ' || year_to AS info - FROM dem WHERE river_id = ${river_id} + SELECT d.id AS dem_id, + r.a AS dem_lower, + r.b AS dem_upper, + d.name AS name, + d.projection || ' | ' || t.start_time || ' - ' || t.stop_time AS info + FROM dem d + JOIN ranges r ON d.range_id = r.id + JOIN time_intervals t ON d.time_interval_id = t.id + WHERE d.river_id = ${river_id} </dc:statement> <dc:elements> <dem> @@ -897,6 +1000,138 @@ </dc:context> </dems> </dc:macro> + <dc:macro name="flood-map-hws-lines"> + <dc:context> + <dc:statement> + SELECT DISTINCT + name AS hws_name, + official AS hws_official, + kind_id AS hws_kind + FROM hws_lines + WHERE river_id = ${river_id} + </dc:statement> + <lines> + <official> + <Durchlass> + <dc:elements filter="$hws_kind=1 and $hws_official=1"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_name}"/> + </hws> + </dc:elements> + </Durchlass> + <Damm> + <dc:elements filter="$hws_kind=2 and $hws_official=1"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_name}"/> + </hws> + </dc:elements> + </Damm> + <Graben> + <dc:elements filter="$hws_kind=3 and $hws_official=1"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_name}"/> + </hws> + </dc:elements> + </Graben> + </official> + <inofficial> + <Durchlass> + <dc:elements filter="$hws_kind=1 and $hws_official=0"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_name}"/> + </hws> + </dc:elements> + </Durchlass> + <Damm> + <dc:elements filter="$hws_kind=2 and $hws_official=0"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_name}"/> + </hws> + </dc:elements> + </Damm> + <Graben> + <dc:elements filter="$hws_kind=3 and $hws_official=0"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_name}"/> + </hws> + </dc:elements> + </Graben> + </inofficial> + </lines> + </dc:context> + </dc:macro> + <dc:macro name="flood-map-hws-points"> + <dc:context> + <dc:statement> + SELECT DISTINCT + name AS hws_points_name, + official AS hws_points_official, + kind_id AS hws_points_kind + FROM hws_points + WHERE river_id = ${river_id} + </dc:statement> + <points> + <official> + <Durchlass> + <dc:elements filter="$hws_points_kind=1 and $hws_points_official=1"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_points_name}"/> + </hws> + </dc:elements> + </Durchlass> + <Damm> + <dc:elements filter="$hws_points_kind=2 and $hws_points_official=1"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_points_name}"/> + </hws> + </dc:elements> + </Damm> + <Graben> + <dc:elements filter="$hws_kind=3 and $hws_official=1"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_points_name}"/> + </hws> + </dc:elements> + </Graben> + </official> + <inofficial> + <Durchlass> + <dc:elements filter="$hws_points_kind=1 and $hws_points_official=0"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_points_name}"/> + </hws> + </dc:elements> + </Durchlass> + <Damm> + <dc:elements filter="$hws_points_kind=2 and $hws_points_official=0"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_points_name}"/> + </hws> + </dc:elements> + </Damm> + <Graben> + <dc:elements filter="$hws_points_kind=3 and $hws_points_official=0"> + <hws> + <dc:attribute name="factory" value="hwsfactory"/> + <dc:attribute name="name" value="${hws_points_name}"/> + </hws> + </dc:elements> + </Graben> + </inofficial> + </points> + </dc:context> + </dc:macro> <dc:macro name="flood-map-km"> <dc:context> <dc:statement> @@ -929,23 +1164,6 @@ </dc:elements> </dc:context> </dc:macro> - <dc:macro name="flood-map-hws"> - <dc:context> - <dc:statement> - SELECT count(*) as km_exists, name as name - FROM hws WHERE river_id = ${river_id} GROUP BY name - </dc:statement> - <dc:elements> - <dc:if test="$km_exists>0"> - <hws> - <dc:attribute name="factory" value="wmshwsfactory"/> - <dc:attribute name="ids" value="${river_id};${name}"/> - <dc:attribute name="name" value="${name}"/> - </hws> - </dc:if> - </dc:elements> - </dc:context> - </dc:macro> <dc:macro name="flood-map-hydr-boundaries"> <hydr_boundaries_lines> <dc:call-macro name="flood-map-hydr-boundaries-lines"/> @@ -1026,23 +1244,6 @@ </dc:context> </land> </dc:macro> - <dc:macro name="flood-map-catchments"> - <dc:context> - <dc:statement> - SELECT count(*) as km_exists, name as name - FROM catchment WHERE river_id = ${river_id} GROUP BY name - </dc:statement> - <dc:elements> - <dc:if test="$km_exists>0"> - <catchment> - <dc:attribute name="factory" value="wmscatchmentfactory"/> - <dc:attribute name="ids" value="${river_id};${name}"/> - <dc:attribute name="name" value="${name}"/> - </catchment> - </dc:if> - </dc:elements> - </dc:context> - </dc:macro> <dc:macro name="flood-map-floodplain"> <dc:context> <dc:statement> @@ -1059,16 +1260,33 @@ </dc:elements> </dc:context> </dc:macro> - <dc:macro name="flood-map-lines"> + <dc:macro name="hwslines"> <dc:context> <dc:statement> SELECT count(*) as km_exists, name as name - FROM lines WHERE river_id = ${river_id} GROUP BY name + FROM hws_lines WHERE river_id = ${river_id} GROUP BY name </dc:statement> <dc:elements> <dc:if test="$km_exists>0"> <line> - <dc:attribute name="factory" value="wmslinefactory"/> + <dc:attribute name="factory" value="wmshwslinesfactory"/> + <dc:attribute name="ids" value="${river_id};${name}"/> + <dc:attribute name="name" value="${name}"/> + </line> + </dc:if> + </dc:elements> + </dc:context> + </dc:macro> + <dc:macro name="hwspoints"> + <dc:context> + <dc:statement> + SELECT count(*) as km_exists, name as name + FROM hws_points WHERE river_id = ${river_id} GROUP BY name + </dc:statement> + <dc:elements> + <dc:if test="$km_exists>0"> + <line> + <dc:attribute name="factory" value="wmshwspointsfactory"/> <dc:attribute name="ids" value="${river_id};${name}"/> <dc:attribute name="name" value="${name}"/> </line> @@ -1223,9 +1441,6 @@ <fixpoints> <dc:call-macro name="flood-map-fixpoints"/> </fixpoints> - <hws> - <dc:call-macro name="flood-map-hws"/> - </hws> <hydrboundaries> <dc:call-macro name="flood-map-hydr-boundaries"/> <dc:call-macro name="flood-map-floodplain"/> @@ -1238,9 +1453,14 @@ <dc:call-macro name="flood-map-km"/> <dc:call-macro name="flood-map-qps"/> </kilometrage> - <lines> - <dc:call-macro name="flood-map-lines"/> - </lines> + <hws> + <hws_lines> + <dc:call-macro name="hwslines"/> + </hws_lines> + <hws_points> + <dc:call-macro name="hwspoints"/> + </hws_points> + </hws> <dc:call-macro name="flood-map-uesk"/> <gaugelocations> <dc:call-macro name="flood-map-gaugelocations"/> @@ -1318,18 +1538,45 @@ <dc:when test="dc:contains($parameters, 'user-id')"> - <old_calculations> - <dc:context connection="user"> - <dc:comment> - Get the user and collection-id. - </dc:comment> - <dc:statement> + <old_calculations> + <!-- <dc:macro name="load-user">--> + <dc:call-macro name="user-range"> + <dc:context connection="user"> + <dc:comment> + Get the user and collection-id. + </dc:comment> + <dc:statement> SELECT u.id AS user_id, c.id AS collection_id, c.name as collection_name FROM collections c JOIN users u ON c.user_id = u.id WHERE u.gid = CAST(${user-id} AS uuid) ORDER BY c.creation DESC </dc:statement> + + <dc:macro name="range-filter"> + <dc:statement> + SELECT m.id AS a_id, + m.state AS a_state, + m.gid AS a_gid, + m.creation AS a_creation, + COALESCE(ld_mode, '') AS ld_m, + COALESCE(ld_locations, '') AS ld_l, + COALESCE(ld_from, '') AS ld_f, + COALESCE(ld_to, '') AS ld_t + FROM master_artifacts_range m + WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) + AND EXISTS ( + SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) + </dc:statement> + <dc:elements> + <dc:variable name="from" type="number" expr="dc:fromValue($ld_m, $ld_l, $ld_f)"/> + <dc:variable name="to" type="number" expr="dc:toValue($ld_m, $ld_l, $ld_t)"/> + <dc:if test="($from >= $fromkm and $from <= $tokm) or ($to <= $tokm and $to >= $fromkm) or ($from <= $fromkm and $to >= $tokm)"> + <dc:macro-body/> + </dc:if> + </dc:elements> + </dc:macro> + <!-- OFFICIAL LINES --> <dc:if test="dc:contains($artifact-outs, 'longitudinal_section')"> <dc:comment comment=".wst -------------------------------"/> @@ -1337,11 +1584,27 @@ <dc:elements> <dc:context> <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation, ardg.v as gaugy, arv.v as wqsingle - FROM master_artifacts m, artifact_data ardg, artifact_data arv - WHERE m.collection_id = ${collection_id} AND m.gid = CAST(${artifact-id} AS uuid) AND ardg.artifact_id = m.id AND ardg.k = 'ld_gaugename' AND arv.artifact_id = m.id AND arv.k = 'wq_single' - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) + SELECT m.id AS a_id, + m.state AS a_state, + m.gid AS a_gid, + m.creation AS a_creation, + ardg.v AS gaugy, + arv.v AS wqsingle + FROM master_artifacts m, + artifact_data ardg, + artifact_data arv + WHERE m.collection_id = ${collection_id} + AND m.gid = CAST(${artifact-id} AS uuid) + AND ardg.artifact_id = m.id + AND ardg.k = 'ld_gaugename' + AND arv.artifact_id = m.id + AND arv.k = 'wq_single' + AND EXISTS ( + SELECT id + FROM artifact_data ad + WHERE ad.artifact_id = m.id + AND k = 'river' + AND v = ${river}) </dc:statement> <dc:elements> <dc:context connection="system"> @@ -1369,18 +1632,11 @@ SHOW W-DIFFERENCES </dc:comment> - <dc:if test="dc:contains($artifact-outs, 'longitudinal_section') or (dc:contains($artifact-outs, 'w_differences') or (dc:contains($artifact-outs, 'discharge_longitudinal_section')))"> + <dc:macro name="differences"> <differences> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT a.gid as aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description as facet_description @@ -1397,28 +1653,22 @@ </dc:element> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </differences> - </dc:if> + </dc:macro> <dc:comment> SHOW REFERENCE CURVE </dc:comment> - <dc:if test="dc:contains($artifact-outs, 'reference_curve')"> + + <dc:macro name="reference-curves"> <reference_curves> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> + <dc:call-macro name="user-range"> <dc:context> <dc:statement> SELECT a.gid as aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description as facet_description @@ -1435,28 +1685,21 @@ </dc:element> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </reference_curves> - </dc:if> + </dc:macro> <dc:comment> SHOW COMPUTED DISCHARGE CURVES </dc:comment> - <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve')"> + <dc:macro name="computed-discharge-curve"> <computed_discharge_curves> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT a.gid as aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description as facet_description @@ -1473,43 +1716,37 @@ </dc:element> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </computed_discharge_curves> - </dc:if> + </dc:macro> <dc:comment> CROSS SECTION </dc:comment> - <dc:if test="dc:contains($artifact-outs, 'cross_section')"> + + <dc:macro name="waterlevels"> <waterlevels> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} AND name = 'cross_section' - </dc:statement> - <dc:elements> - <dc:context> - <dc:statement> - SELECT name AS facet_name, num as facet_num, description AS facet_description - FROM facets - WHERE out_id = ${out_id} - ORDER BY num ASC, name DESC - </dc:statement> - <longitudinal_section_columns> + <dc:call-macro name="range-filter"> + <dc:context> + <dc:statement> + SELECT id AS out_id + FROM outs + WHERE artifact_id = ${a_id} AND name = 'cross_section' + </dc:statement> + <dc:elements> + <dc:context> + <dc:statement> + SELECT name AS facet_name, num as facet_num, description AS facet_description + FROM facets + WHERE out_id = ${out_id} + ORDER BY num ASC, name DESC + </dc:statement> + <longitudinal_section_columns> <dc:attribute name="description" value="${river} ${a_creation}"/> <dc:elements> <dc:element name="${facet_name}"> @@ -1520,30 +1757,23 @@ <dc:attribute name="out" value="cross_section"/> </dc:element> </dc:elements> - </longitudinal_section_columns> - </dc:context> - </dc:elements> - </dc:context> - </dc:elements> + </longitudinal_section_columns> + </dc:context> + </dc:elements> + </dc:context> + </dc:call-macro> </dc:context> </dc:elements> </waterlevels> - </dc:if> + </dc:macro> - <dc:if test="dc:contains($artifact-outs, 'longitudinal_section') or (dc:contains($artifact-outs, 'discharge_longitudinal_section') or (dc:contains($artifact-outs, 'w_differences')))"> + <dc:macro name="longitudinal"> <waterlevels> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> - <dc:context> + <dc:call-macro name="range-filter"> + <dc:context> <dc:statement> SELECT id AS out_id FROM outs @@ -1572,25 +1802,18 @@ </dc:context> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </waterlevels> - </dc:if> + </dc:macro> - <dc:if test="dc:contains($artifact-outs, 'fix_longitudinal_section_curve')"> + + <dc:macro name="longitudinal-section"> <waterlevels> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> - + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT id AS out_id @@ -1621,25 +1844,17 @@ </dc:context> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </waterlevels> - </dc:if> + </dc:macro> - <dc:if test="dc:contains($artifact-outs, 'fix_deltawt_curve')"> + <dc:macro name="delta-wt"> <waterlevels> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> - + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT id AS out_id @@ -1669,25 +1884,18 @@ </dc:context> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </waterlevels> - </dc:if> + </dc:macro> - <dc:if test="dc:contains($artifact-outs, 'fix_derivate_curve')"> + + <dc:macro name="fix-derivate-curve"> <waterlevels> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> - + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT id AS out_id @@ -1717,25 +1925,18 @@ </dc:context> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </waterlevels> - </dc:if> + </dc:macro> - <dc:if test="dc:contains($artifact-outs, 'fix_wq_curve')"> + + <dc:macro name="fix-wq-curve"> <waterlevels> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> - + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT id AS out_id @@ -1765,24 +1966,18 @@ </dc:context> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </waterlevels> - </dc:if> + </dc:macro> - <dc:if test="dc:contains($artifact-outs, 'duration_curve')"> + + <dc:macro name="duration-curve"> <computed_discharge_curves> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT a.gid as aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description as facet_description @@ -1799,29 +1994,23 @@ </dc:element> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </computed_discharge_curves> - </dc:if> + </dc:macro> + <dc:comment> WATERLEVELS - ONLY SHOW Ws </dc:comment> <!-- TODO doesnt work nicely for fix/wq-diags. --> - <dc:if test="dc:contains($artifact-outs, 'waterlevels') or (dc:contains($artifact-outs, 'fix_wq_curve'))"> + + <dc:macro name="waterlevels-fix"> <waterlevels> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> - + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT id AS out_id @@ -1851,28 +2040,22 @@ </dc:context> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </waterlevels> - </dc:if> + </dc:macro> <dc:comment> SHOW FLOODMAPS </dc:comment> - <dc:if test="dc:contains($artifact-outs, 'floodmap') or dc:contains($artifact-outs, 'map')"> + + <dc:macro name="flood-map"> <floodmap> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT a.gid as aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description as facet_description @@ -1889,28 +2072,21 @@ </dc:element> </dc:elements> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </floodmap> - </dc:if> + </dc:macro> <dc:comment> MINFO bedheight difference </dc:comment> - <dc:if test="dc:contains($artifact-outs, 'bed_difference_year') or dc:contains($artifact-outs, 'bed_difference_height_year')"> + <dc:macro name="bed-difference"> <fix_longitudinal_section_curve> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT a.gid as aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description as facet_description @@ -1932,28 +2108,21 @@ </dc:elements> </fix_longitudinal_section_curve> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </fix_longitudinal_section_curve> - </dc:if> + </dc:macro> <dc:comment> MINFO bedheight middle </dc:comment> - <dc:if test="dc:contains($artifact-outs, 'bedheight_middle')"> + <dc:macro name="bed-height"> <fix_vollmer_wq_curve> <dc:elements> <dc:context> - <dc:statement> - SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation - FROM master_artifacts m - WHERE m.collection_id = ${collection_id} AND m.gid <> CAST(${artifact-id} AS uuid) - AND EXISTS ( - SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river}) - </dc:statement> - <dc:elements> + <dc:call-macro name="range-filter"> <dc:context> <dc:statement> SELECT a.gid as aid, f.id AS fid, f.name AS facet_name, f.num AS facet_num, f.description as facet_description @@ -1974,13 +2143,90 @@ </dc:elements> </fix_vollmer_wq_curve> </dc:context> - </dc:elements> + </dc:call-macro> </dc:context> </dc:elements> </fix_vollmer_wq_curve> + </dc:macro> + + <dc:macro name="floodmap-hws-user"> + <dc:context> + <dc:statement> + SELECT id AS out_id + FROM outs + WHERE artifact_id = ${a_id} AND name = 'floodmap' + </dc:statement> + <dc:elements> + <dc:context> + <dc:statement> + SELECT name AS facet_name, num as facet_num, description AS facet_description + FROM facets + WHERE out_id = ${out_id} and name = 'floodmap.usershape' + ORDER BY num ASC, name DESC + </dc:statement> + <own-hws> + <dc:elements> + <dc:element name="${facet_name}"> + <dc:attribute name="description" value="${facet_description}"/> + <dc:attribute name="ids" value="${facet_num}"/> + <dc:attribute name="factory" value="winfo"/> + <dc:attribute name="artifact-id" value="${a_gid}"/> + <dc:attribute name="out" value="floodmap"/> + </dc:element> + </dc:elements> + </own-hws> + </dc:context> + </dc:elements> + </dc:context> + </dc:macro> + <dc:if test="dc:contains($artifact-outs, 'longitudinal_section') or (dc:contains($artifact-outs, 'discharge_longitudinal_section') or (dc:contains($artifact-outs, 'w_differences')))"> + <dc:call-macro name="longitudinal"/> </dc:if> + <dc:if test="dc:contains($artifact-outs, 'fix_deltawt_curve')"> + <dc:call-macro name="delta-wt"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'longitudinal_section') or (dc:contains($artifact-outs, 'w_differences') or (dc:contains($artifact-outs, 'discharge_longitudinal_section')))"> + <dc:call-macro name="differences"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'reference_curve')"> + <dc:call-macro name="reference-curves"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve')"> + <dc:call-macro name="computed-discharge-curve"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'cross_section')"> + <dc:call-macro name="waterlevels"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'fix_longitudinal_section_curve')"> + <dc:call-macro name="longitudinal-section"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'fix_derivate_curve')"> + <dc:call-macro name="fix-derivate-curve"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'fix_wq_curve')"> + <dc:call-macro name="fix-wq-curve"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'duration_curve')"> + <dc:call-macro name="duration-curve"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'waterlevels') or (dc:contains($artifact-outs, 'fix_wq_curve'))"> + <dc:call-macro name="waterlevels-fix"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'floodmap') or dc:contains($artifact-outs, 'map')"> + <dc:call-macro name="flood-map"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'bed_difference_year') or dc:contains($artifact-outs, 'bed_difference_height_year')"> + <dc:call-macro name="bed-difference"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'bedheight_middle')"> + <dc:call-macro name="bed-height"/> + </dc:if> + <dc:if test="dc:contains($artifact-outs, 'floodmap-hws')"> + <dc:call-macro name="floodmap-hws-user"/> + </dc:if> + </dc:context> + </dc:call-macro> - </dc:context> </old_calculations>