teichmann@5523: <?xml version="1.0" encoding="UTF-8"?>
sascha@1046: <dc:template xmlns:dc="http://www.intevation.org/2011/Datacage">
aheinecke@6053:   <datacage>
rrenkert@5015: 
gernotbelger@9127:     <dc:call-macro name="load-user" />
aheinecke@6053: 
gernotbelger@9127:     <dc:call-macro name="load-system" />
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="load-system">
aheinecke@6053:       <dc:context connection="system">
rrenkert@5015:         <dc:statement>
aheinecke@6053:           SELECT id AS river_id, name AS river_name
aheinecke@6053:           FROM rivers
aheinecke@6053:           WHERE lower(name) LIKE lower(${river})
rrenkert@5015:         </dc:statement>
teichmann@5522:         <dc:for-each>
gernotbelger@9127:           <dc:call-macro name="generate-system-content" />
teichmann@5522:         </dc:for-each>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
felix@3283: 
aheinecke@6053:     <dc:macro name="load-user">
aheinecke@6053:       <old_calculations>
gernotbelger@9127:         <dc:call-macro name="generate-user-content" />
aheinecke@6053:       </old_calculations>
aheinecke@6053:     </dc:macro>
felix@4014: 
aheinecke@6053:     <dc:macro name="generate-system-content">
aheinecke@6653:       <dc:message>Generate system content with variables: {dc:dump-variables()}</dc:message>
aheinecke@6183:       <dc:call-macro name="artifact-range">
aheinecke@6053:         <dc:call-macro name="km-filtered-wsts">
aheinecke@6053:           <dc:choose>
aheinecke@6053:             <dc:when test="dc:contains($parameters, 'recommended')">
aheinecke@6053:               <dc:comment>
aheinecke@6053:                 Recommendations (client shall load immediately).
aheinecke@6053:               </dc:comment>
aheinecke@6053:               <dc:iterate var="out" container="artifact-outs">
aheinecke@6653:                 <dc:message>Rec out iteration for: {$out}</dc:message>
aheinecke@6053:                 <dc:choose>
tom@8299:                   <dc:comment> Longitudinal sections </dc:comment>
tom@6638:                   <dc:when test="$out = 'w_differences'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
tom@6638:                   </dc:when>
tom@6638:                   <dc:when test="$out = 'discharge_longitudinal_section'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@9127:                     <dc:call-macro name="officiallines_user" />
aheinecke@6053:                   </dc:when>
aheinecke@6053:                   <dc:when test="$out = 'longitudinal_section'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@9127:                     <dc:call-macro name="officiallines_user" />
aheinecke@6053:                   </dc:when>
aheinecke@6053:                   <dc:when test="$out = 'fix_longitudinal_section_curve'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
aheinecke@6053:                   </dc:when>
felix@6743:                   <dc:when test="$out = 'bedheight_middle'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
felix@6743:                   </dc:when>
aheinecke@6053:                   <dc:when test="$out = 'bed_difference_year'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@9127:                     <dc:call-macro name="basedata_6_delta_w" />
gernotbelger@9127:                     <dc:call-macro name="sounding-width-recommendations" />
aheinecke@6053:                   </dc:when>
aheinecke@6053:                   <dc:when test="$out = 'bed_difference_height_year'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@9127:                     <dc:call-macro name="basedata_6_delta_w" />
aheinecke@6053:                   </dc:when>
tom@6638:                   <dc:when test="$out = 'sedimentload_ls'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@9127:                     <dc:call-macro name="sedimentload_off_epochs" />
tom@6638:                   </dc:when>
tom@7664:                   <dc:when test="$out = 'bed_longitudinal_section'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
tom@7664:                   </dc:when>
tom@7664:                   <dc:when test="$out = 'flow_velocity'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
tom@7664:                   </dc:when>
tom@8299:                   <dc:comment> Discharge curves </dc:comment>
tom@8299:                   <dc:when test="$out = 'historical_discharge_wq'">
gernotbelger@9127:                     <dc:call-macro name="hist_discharge_rec" />
gernotbelger@9127:                     <dc:call-macro name="mainvalues" />
tom@8299:                   </dc:when>
tom@8299:                   <dc:when test="$out = 'discharge_curve'">
gernotbelger@9127:                     <dc:call-macro name="mainvalues" />
gernotbelger@9127:                     <dc:call-macro name="basedata_3_officials_wq" />
tom@8299:                   </dc:when>
tom@8299:                   <dc:when test="$out = 'computed_discharge_curve'">
gernotbelger@9127:                     <dc:call-macro name="mainvalues" />
gernotbelger@9127:                     <dc:call-macro name="basedata_3_officials_wq" />
gernotbelger@9127:                     <dc:call-macro name="basedata_2_fixations_wq" />
tom@8299:                   </dc:when>
tom@8299:                   <dc:when test="$out = 'fix_wq_curve'">
gernotbelger@9127:                     <dc:call-macro name="mainvalues" />
gernotbelger@9127:                     <dc:call-macro name="qsectors" />
tom@8299:                   </dc:when>
tom@8336:                   <dc:when test="$out = 'fix_derivate_curve'">
gernotbelger@9127:                     <dc:call-macro name="qmainvalues" />
tom@8336:                   </dc:when>
tom@8334:                   <dc:when test="starts-with($out, 'sq_') and
tom@8334:                                  not($out = 'sq_relation_export')">
gernotbelger@9127:                     <dc:call-macro name="qmainvalues" />
tom@8334:                   </dc:when>
tom@8299:                   <dc:comment> Cross sections </dc:comment>
tom@8299:                   <dc:when test="$out = 'cross_section'">
gernotbelger@9127:                     <dc:call-macro name="cross_sections" />
gernotbelger@9127:                     <dc:call-macro name="hyks" />
gernotbelger@9127:                     <dc:call-macro name="officiallines_user" />
tom@8299:                   </dc:when>
tom@8299:                   <dc:comment> Duration curve </dc:comment>
tom@8299:                   <dc:when test="$out = 'duration_curve'">
gernotbelger@9127:                     <dc:call-macro name="mainvalues" />
tom@8299:                   </dc:when>
tom@8299:                   <dc:comment> Reference curve </dc:comment>
tom@8299:                   <dc:when test="$out = 'reference_curve'">
gernotbelger@9127:                     <dc:call-macro name="mainvalues" />
tom@8299:                   </dc:when>
tom@8299:                   <dc:comment> Maps </dc:comment>
tom@8299:                   <dc:when test="$out = 'floodmap'">
gernotbelger@9127:                     <dc:call-macro name="flood-map-recommended" />
tom@8299:                   </dc:when>
gernotbelger@8941: 
gernotbelger@8897:                   <dc:when test="$out = 'sinfo_flow_depth'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@8897:                   </dc:when>
gernotbelger@8950:                   <dc:when test="$out = 'sinfo_flow_depth_minmax'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@8950:                   </dc:when>
gernotbelger@8956:                   <dc:when test="$out = 'sinfo_flow_depth_development'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@8956:                   </dc:when>
gernotbelger@8956:                   <dc:when test="$out = 'sinfo_flow_depth_development_peryear'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@8956:                   </dc:when>
gernotbelger@8916:                   <dc:when test="$out = 'sinfo_tkk'">
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@8916:                   </dc:when>
mschaefer@9156:                   <dc:when test="$out = 'sinfo_collision'">
mschaefer@9156:                     <dc:call-macro name="annotations" />
mschaefer@9156:                   </dc:when>
mschaefer@9176:                   <dc:when test="$out = 'sinfo_flood_duration'">
mschaefer@9176:                     <dc:call-macro name="annotations" />
mschaefer@9176:                   </dc:when>
mschaefer@9176:                   <dc:when test="$out = 'sinfo_flood_height'">
mschaefer@9176:                     <dc:call-macro name="annotations" />
mschaefer@9176:                   </dc:when>
gernotbelger@9495:                   <!--TODO sinfo_floodduration_curve: mainvalues wie in winfo-duration_curve unterstuetzen -->
mschaefer@9344:                   <!--dc:when test="$out = 'sinfo_floodduration_curve'">
mschaefer@9344:                     <dc:call-macro name="mainvalues" />
gernotbelger@9495:                     </dc:when -->
mschaefer@9296:                   <dc:when test="$out = 'uinfo_salix_line'">
mschaefer@9296:                     <dc:call-macro name="annotations" />
mschaefer@9296:                   </dc:when>
mschaefer@9438:                   <dc:when test="$out = 'bundu_wspl_longitudinal_section'">
mschaefer@9438:                     <dc:call-macro name="annotations" />
mschaefer@9438:                   </dc:when>
mschaefer@9438:                   <dc:when test="$out = 'bundu_depth_longitudinal_section'">
mschaefer@9438:                     <dc:call-macro name="annotations" />
mschaefer@9438:                   </dc:when>
aheinecke@6053:                 </dc:choose>
aheinecke@6053:               </dc:iterate>
aheinecke@6053:             </dc:when>
aheinecke@6053:             <dc:otherwise>
aheinecke@6053:               <dc:comment>
felix@7303:                 Non - Recommendations (offered to user to choose additional data from).
aheinecke@6053:               </dc:comment>
aheinecke@6053:               <dc:iterate var="out" container="artifact-outs">
aheinecke@6653:                 <dc:message>Non Rec out iteration for: {$out}</dc:message>
aheinecke@6053:                 <dc:choose>
tom@8300:                   <dc:comment> Inline datacage panels </dc:comment>
tom@8298:                   <dc:when test="$out = 'minfo_diff_panel'">
gernotbelger@9127:                     <dc:call-macro name="minfo-heights-diff" />
rrenkert@7961:                   </dc:when>
tom@8300:                   <dc:when test="$out = 'floodmap_dem_panel'">
gernotbelger@9127:                     <dc:call-macro name="flood-map-dem" />
tom@8300:                   </dc:when>
tom@8300:                   <dc:when test="$out = 'floodmap_hws_panel'">
tom@8300:                     <hws>
gernotbelger@9127:                       <dc:call-macro name="flood-map-hws-lines" />
gernotbelger@9127:                       <dc:call-macro name="flood-map-hws-points" />
tom@8300:                     </hws>
tom@8300:                   </dc:when>
tom@8300:                   <dc:when test="$out = 'winfo_diff_twin_panel'">
tom@8300:                     <dc:if test="$current-state-id != 'state.winfo.uesk.wsp'">
gernotbelger@9127:                       <dc:call-macro name="basedata_0" />
gernotbelger@9127:                       <dc:call-macro name="basedata_1_additionals" />
gernotbelger@9127:                       <dc:call-macro name="basedata_2_fixations" />
gernotbelger@9127:                       <dc:call-macro name="basedata_4_heightmarks-points" />
gernotbelger@9127:                       <dc:call-macro name="basedata_5_flood-protections" />
tom@8300:                     </dc:if>
tom@8300:                   </dc:when>
tom@8300:                   <dc:when test="$out = 'waterlevels_panel'">
gernotbelger@9127:                     <dc:call-macro name="basedata_0" />
gernotbelger@9127:                     <dc:call-macro name="basedata_1_additionals" />
gernotbelger@9127:                     <dc:call-macro name="basedata_2_fixations" />
gernotbelger@9127:                     <dc:call-macro name="basedata_3_officials" />
gernotbelger@9127:                     <dc:call-macro name="basedata_4_heightmarks-points" />
gernotbelger@9127:                     <dc:call-macro name="basedata_5_flood-protections" />
aheinecke@6053:                   </dc:when>
tom@8300:                   <dc:comment> Longitudinal sections </dc:comment>
aheinecke@6053:                   <dc:when test="$out = 'longitudinal_section'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6053:                   </dc:when>
tom@6638:                   <dc:when test="$out = 'w_differences'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6053:                   </dc:when>
aheinecke@6053:                   <dc:when test="$out = 'discharge_longitudinal_section'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6053:                   </dc:when>
aheinecke@6053:                   <dc:when test="$out = 'fix_longitudinal_section_curve'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6053:                   </dc:when>
tom@6638:                   <dc:when test="$out = 'flow_velocity'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6053:                   </dc:when>
aheinecke@6053:                   <dc:when test="$out = 'bed_longitudinal_section'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6053:                   </dc:when>
tom@6638:                   <dc:when test="$out = 'sedimentload_ls'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6053:                   </dc:when>
tom@6638:                   <dc:when test="$out = 'bedheight_middle'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6053:                   </dc:when>
tom@6638:                   <dc:when test="$out = 'bed_difference_height_year'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6277:                   </dc:when>
tom@6638:                   <dc:when test="$out = 'bed_difference_year'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
aheinecke@6053:                   </dc:when>
tom@8300:                   <dc:comment> Discharge curves </dc:comment>
tom@8300:                   <dc:when test="$out = 'historical_discharge_wq'">
gernotbelger@9127:                     <dc:call-macro name="discharge-curve-prototype" />
tom@8298:                   </dc:when>
tom@8300:                   <dc:when test="$out = 'discharge_curve'">
gernotbelger@9127:                     <dc:call-macro name="discharge-curve-prototype" />
aheinecke@6053:                   </dc:when>
tom@8300:                   <dc:when test="$out = 'fix_wq_curve'">
gernotbelger@9127:                     <dc:call-macro name="discharge-curve-prototype" />
aheinecke@6053:                   </dc:when>
tom@8336:                   <dc:when test="$out = 'fix_derivate_curve'">
gernotbelger@9127:                     <dc:call-macro name="discharge-curve-prototype" />
tom@8336:                   </dc:when>
aheinecke@6053:                   <dc:when test="$out = 'computed_discharge_curve'">
gernotbelger@9127:                     <dc:call-macro name="discharge-curve-prototype" />
aheinecke@6053:                   </dc:when>
tom@8300:                   <dc:when test="starts-with($out, 'sq_relation') or
tom@8300:                                  $out = 'sq_overview'">
gernotbelger@9127:                     <dc:call-macro name="discharge-curve-prototype" />
felix@6581:                   </dc:when>
tom@8300:                   <dc:comment> Cross sections </dc:comment>
tom@8300:                   <dc:when test="$out = 'cross_section'">
gernotbelger@9127:                     <dc:call-macro name="basedata_0" />
gernotbelger@9127:                     <dc:call-macro name="basedata_1_additionals" />
gernotbelger@9127:                     <dc:call-macro name="basedata_2_fixations" />
gernotbelger@9127:                     <dc:call-macro name="basedata_3_officials" />
gernotbelger@9127:                     <dc:call-macro name="basedata_4_heightmarks-points" />
gernotbelger@9127:                     <dc:call-macro name="cross_sections" />
gernotbelger@9127:                     <dc:call-macro name="basedata_5_flood-protections" />
gernotbelger@9127:                     <dc:call-macro name="hyks" />
gernotbelger@9506:                     <dc:call-macro name="predefined_vegetation_zones" />
aheinecke@6081:                   </dc:when>
tom@8300:                   <dc:comment> Duration curve </dc:comment>
tom@8300:                   <dc:when test="$out = 'duration_curve'">
gernotbelger@9127:                     <dc:call-macro name="mainvalues" />
gernotbelger@9127:                     <dc:call-macro name="basedata_2_fixations_relative_point" />
gernotbelger@9127:                     <dc:call-macro name="basedata_4_heightmarks-points-relative_points" />
gernotbelger@9127:                     <dc:call-macro name="basedata_5_flood-protections_relative_points" />
tom@8300:                   </dc:when>
tom@8300:                   <dc:comment> Reference curve </dc:comment>
tom@8300:                   <dc:when test="$out = 'reference_curve'">
gernotbelger@9127:                     <dc:call-macro name="mainvalues" />
gernotbelger@9127:                     <dc:call-macro name="annotations" />
gernotbelger@9127:                     <dc:call-macro name="basedata_1_additionals-relative_point" />
gernotbelger@9127:                     <dc:call-macro name="basedata_2_fixations_relative_point" />
gernotbelger@9127:                     <dc:call-macro name="basedata_4_heightmarks-points-relative_points" />
gernotbelger@9127:                     <dc:call-macro name="basedata_5_flood-protections_relative_points" />
tom@8300:                   </dc:when>
tom@8300:                   <dc:comment> Maps </dc:comment>
tom@8300:                   <dc:when test="$out = 'map'">
gernotbelger@9127:                     <dc:call-macro name="flood-map-complete" />
tom@8300:                   </dc:when>
tom@8300:                   <dc:when test="$out = 'floodmap'">
gernotbelger@9127:                     <dc:call-macro name="flood-map-complete" />
aheinecke@7236:                   </dc:when>
gernotbelger@8854: 
gernotbelger@8854:                   <dc:comment> S-INFO </dc:comment>
gernotbelger@8854:                   <dc:when test="$out = 'sinfo_flowdepth_minfo_heights'">
gernotbelger@9127:                     <dc:call-macro name="bed-heights-single-MW" />
gernotbelger@8854:                   </dc:when>
gernotbelger@8993:                   <dc:when test="$out = 'sinfo_flowdepthminmax_heights'">
gernotbelger@9127:                     <dc:call-macro name="bed-heights-single-KL_TW" />
gernotbelger@8993:                   </dc:when>
gernotbelger@8854:                   <dc:when test="$out = 'sinfo_flowdepth_waterlevels'">
gernotbelger@8958:                     <minfo>
gernotbelger@8958:                       <fixanalysis>
gernotbelger@9127:                         <dc:call-macro name="basedata_7_waterlevels" />
gernotbelger@8958:                       </fixanalysis>
gernotbelger@8958:                     </minfo>
gernotbelger@9127:                     <dc:call-macro name="basedata_3_officials" />
gernotbelger@9127:                     <dc:call-macro name="basedata_2_fixations" />
gernotbelger@8963:                     <sinfo>
gernotbelger@8963:                       <sinfo_additional_ls>
gernotbelger@9127:                         <dc:call-macro name="basedata_1_additionals-sinfo-with-q" />
gernotbelger@9127:                         <dc:call-macro name="basedata_1_additionals-sinfo-without-q" />
mschaefer@9016:                       </sinfo_additional_ls>
mschaefer@9016:                     </sinfo>
gernotbelger@8854:                   </dc:when>
gernotbelger@8941: 
gernotbelger@8897:                   <dc:when test="$out = 'sinfo_flow_depth'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
gernotbelger@8941:                   </dc:when>
gernotbelger@8950:                   <dc:when test="$out = 'sinfo_flow_depth_minmax'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
gernotbelger@8950:                   </dc:when>
gernotbelger@8956:                   <dc:when test="$out = 'sinfo_flow_depth_development'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
gernotbelger@8956:                   </dc:when>
gernotbelger@8956:                   <dc:when test="$out = 'sinfo_flow_depth_development_peryear'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
gernotbelger@8956:                   </dc:when>
gernotbelger@8941:                   <dc:when test="$out = 'sinfo_tkk'">
gernotbelger@9127:                     <dc:call-macro name="longitudinal-section-prototype" />
gernotbelger@8941:                   </dc:when>
mschaefer@9156:                   <dc:when test="$out = 'sinfo_collision'">
mschaefer@9156:                     <dc:call-macro name="longitudinal-section-prototype" />
mschaefer@9156:                   </dc:when>
mschaefer@9176:                   <dc:when test="$out = 'sinfo_flood_duration'">
mschaefer@9176:                     <dc:call-macro name="longitudinal-section-prototype" />
mschaefer@9176:                   </dc:when>
mschaefer@9176:                   <dc:when test="$out = 'sinfo_flood_height'">
mschaefer@9176:                     <dc:call-macro name="longitudinal-section-prototype" />
mschaefer@9176:                   </dc:when>
gernotbelger@9495:                   <!--TODO sinfo_floodduration_curve: mainvalues wie in winfo-duration_curve unterstuetzen -->
mschaefer@9344:                   <!--dc:when test="$out = 'sinfo_floodduration_curve'">
mschaefer@9344:                     <dc:call-macro name="mainvalues" />
mschaefer@9344:                     <dc:call-macro name="basedata_2_fixations_relative_point" />
mschaefer@9344:                     <dc:call-macro name="basedata_4_heightmarks-points-relative_points" />
mschaefer@9344:                     <dc:call-macro name="basedata_5_flood-protections_relative_points" />
gernotbelger@9495:                     </dc:when -->
gernotbelger@9299: 
mschaefer@9296:                   <dc:when test="$out = 'uinfo_salix_line'">
mschaefer@9296:                     <dc:call-macro name="longitudinal-section-prototype" />
mschaefer@9296:                   </dc:when>
gernotbelger@9299:                   <dc:when test="$out = 'uinfo.inundation_duration.vegzoneselect'">
gernotbelger@9506:                     <dc:call-macro name="predefined_vegetation_zones" />
gernotbelger@9299:                   </dc:when>
mschaefer@9438:                   <dc:when test="$out = 'bundu_wspl_longitudinal_section'">
mschaefer@9438:                     <dc:call-macro name="longitudinal-section-prototype" />
mschaefer@9438:                   </dc:when>
mschaefer@9438:                   <dc:when test="$out = 'bundu_depth_longitudinal_section'">
mschaefer@9438:                     <dc:call-macro name="longitudinal-section-prototype" />
gernotbelger@9495:                   </dc:when> 
gernotbelger@9495:                 </dc:choose> 
aheinecke@6053:               </dc:iterate>
aheinecke@6053:             </dc:otherwise>
aheinecke@6053:           </dc:choose>
aheinecke@6053:         </dc:call-macro>
aheinecke@6053:       </dc:call-macro>
aheinecke@6053:     </dc:macro>
rrenkert@5015: 
aheinecke@6053:     <dc:macro name="generate-user-content">
aheinecke@7347:       <dc:message>Generate user content with variables: {dc:dump-variables()}</dc:message>
aheinecke@6183:       <dc:call-macro name="artifact-range">
aheinecke@6095:         <dc:call-macro name="all-user-artifacts">
aheinecke@6095:           <dc:call-macro name="km-filtered-user-artifacts">
aheinecke@6095:             <dc:choose>
aheinecke@6095:               <dc:when test="dc:contains($parameters, 'recommended')">
aheinecke@6095:                 <dc:comment>
aheinecke@6095:                   Recommendations (user)
aheinecke@6095:                 </dc:comment>
aheinecke@6095:                 <dc:iterate var="out" container="artifact-outs">
aheinecke@6095:                   <dc:choose>
aheinecke@6095:                     <dc:when test="$out = 'longitudinal_section'">
gernotbelger@9127:                       <dc:call-macro name="officiallines_user" />
aheinecke@6095:                     </dc:when>
aheinecke@6095:                   </dc:choose>
aheinecke@6095:                 </dc:iterate>
aheinecke@6095:               </dc:when>
aheinecke@6095:               <dc:otherwise>
aheinecke@6095:                 <dc:comment>
felix@7303:                   Non Recommendations (user) - offer to load other projects
aheinecke@6095:                 </dc:comment>
aheinecke@6095:                 <dc:iterate var="out" container="artifact-outs">
aheinecke@6095:                   <dc:choose>
tom@8301:                     <dc:comment> Inline datacage panels </dc:comment>
tom@8298:                     <dc:when test="$out = 'winfo_diff_twin_panel'">
gernotbelger@9127:                       <dc:call-macro name="differences-fix" />
gernotbelger@9127:                       <dc:call-macro name="differences" />
felix@7435:                       <dc:comment comment="Candidate for:">
gernotbelger@9127:                         <dc:call-macro name="longitudinal-section-user-prototype" />
felix@7435:                       </dc:comment>
felix@6581:                     </dc:when>
tom@8298:                     <dc:when test="$out = 'waterlevels_panel'">
gernotbelger@9127:                       <dc:call-macro name="waterlevels-user" />
felix@7435:                       <dc:comment comment="Candidate for:">
gernotbelger@9127:                         <dc:call-macro name="longitudinal-section-user-prototype" />
felix@7435:                       </dc:comment>
aheinecke@6095:                     </dc:when>
tom@8301:                     <dc:when test="$out = 'floodmap_hws_panel'">
gernotbelger@9127:                       <dc:call-macro name="floodmap-hws-user" />
aheinecke@6095:                     </dc:when>
tom@8301:                     <dc:comment> Longitudinal sections </dc:comment>
tom@8301:                     <dc:when test="$out = 'longitudinal_section'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:when test="$out = 'discharge_longitudinal_section'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:when test="$out = 'w_differences'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:when test="$out = 'fix_longitudinal_section_curve'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
aheinecke@6095:                     </dc:when>
tom@6638:                     <dc:when test="$out = 'bedheight_middle'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
aheinecke@6095:                     </dc:when>
tom@6638:                     <dc:when test="$out = 'flow_velocity'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
aheinecke@6095:                     </dc:when>
aheinecke@6095:                     <dc:when test="$out = 'bed_longitudinal_section'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
aheinecke@6095:                     </dc:when>
tom@6638:                     <dc:when test="$out = 'sedimentload_ls'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
aheinecke@6095:                     </dc:when>
tom@6638:                     <dc:when test="$out = 'bed_difference_year'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
aheinecke@6095:                     </dc:when>
felix@7467:                     <dc:when test="$out = 'bed_difference_height_year'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
felix@7467:                     </dc:when>
gernotbelger@8909:                     <dc:when test="$out = 'sinfo_flow_depth'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
gernotbelger@8909:                     </dc:when>
gernotbelger@8950:                     <dc:when test="$out = 'sinfo_flow_depth_minmax'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
gernotbelger@8950:                     </dc:when>
gernotbelger@8956:                     <dc:when test="$out = 'sinfo_flow_depth_development'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
gernotbelger@8956:                     </dc:when>
gernotbelger@8956:                     <dc:when test="$out = 'sinfo_flow_depth_development_peryear'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
gernotbelger@8956:                     </dc:when>
gernotbelger@8941:                     <dc:when test="$out = 'sinfo_tkk'">
gernotbelger@9127:                       <dc:call-macro name="longitudinal-section-user-prototype" />
gernotbelger@8941:                     </dc:when>
mschaefer@9378:                     <dc:when test="$out = 'sinfo_collision'">
mschaefer@9378:                       <dc:call-macro name="longitudinal-section-user-prototype" />
mschaefer@9378:                     </dc:when>
mschaefer@9344:                     <dc:when test="$out = 'sinfo_flood_duration'">
mschaefer@9344:                       <dc:call-macro name="longitudinal-section-user-prototype" />
mschaefer@9344:                     </dc:when>
mschaefer@9344:                     <dc:when test="$out = 'sinfo_flood_height'">
mschaefer@9344:                       <dc:call-macro name="longitudinal-section-user-prototype" />
mschaefer@9344:                     </dc:when>
mschaefer@9378:                     <dc:when test="$out = 'uinfo_salix_line'">
mschaefer@9378:                       <dc:call-macro name="longitudinal-section-user-prototype" />
mschaefer@9378:                     </dc:when>
gernotbelger@9299:                     <dc:when test="$out = 'uinfo.inundation_duration.vegzoneselect'">
gernotbelger@9299:                       <dc:call-macro name="vegetationzones" />
gernotbelger@9299:                     </dc:when>
mschaefer@9438:                     <dc:when test="$out = 'bundu_wspl_longitudinal_section'">
mschaefer@9438:                       <dc:call-macro name="longitudinal-section-user-prototype" />
mschaefer@9438:                     </dc:when>
mschaefer@9438:                     <dc:when test="$out = 'bundu_depth_longitudinal_section'">
mschaefer@9438:                       <dc:call-macro name="longitudinal-section-user-prototype" />
mschaefer@9438:                     </dc:when>
gernotbelger@9495: 
gernotbelger@9495: 
tom@8301:                     <dc:comment> Discharge curves </dc:comment>
tom@8301:                     <dc:when test="$out = 'computed_discharge_curve'">
gernotbelger@9127:                       <dc:call-macro name="discharge-curve-user-prototype" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:when test="$out = 'fix_derivate_curve'">
gernotbelger@9127:                       <dc:call-macro name="discharge-curve-user-prototype" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:when test="$out = 'fix_wq_curve'">
gernotbelger@9127:                       <dc:call-macro name="discharge-curve-user-prototype" />
felix@7575:                     </dc:when>
felix@7576:                     <dc:when test="$out = 'historical_discharge_wq'">
gernotbelger@9127:                       <dc:call-macro name="discharge-curve-user-prototype" />
felix@7576:                     </dc:when>
gernotbelger@8958:                     <dc:when test="starts-with($out, 'sq_relation') or $out = 'sq_overview'">
gernotbelger@9127:                       <dc:call-macro name="discharge-curve-user-prototype" />
aheinecke@7348:                     </dc:when>
tom@8301:                     <dc:comment> Time series </dc:comment>
tom@8301:                     <dc:when test="$out = 'fix_deltawt_curve'">
gernotbelger@9127:                       <dc:call-macro name="delta-wt" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:when test="$out = 'historical_discharge'">
gernotbelger@9127:                       <dc:call-macro name="historical-discharge-user" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:comment> Cross sections </dc:comment>
tom@8301:                     <dc:when test="$out = 'cross_section'">
gernotbelger@9499:                       <dc:call-macro name="cross_section_user_content" />
gernotbelger@9499:                     </dc:when>                    
tom@8301:                     <dc:comment> Duration curve </dc:comment>
tom@8301:                     <dc:when test="$out = 'duration_curve'">
gernotbelger@9127:                       <dc:call-macro name="duration-curve" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:comment> Reference curve </dc:comment>
tom@8301:                     <dc:when test="$out = 'reference_curve'">
gernotbelger@9127:                       <dc:call-macro name="reference-curves" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:comment> Maps </dc:comment>
tom@8301:                     <dc:when test="$out = 'floodmap'">
gernotbelger@9127:                       <dc:call-macro name="flood-map" />
tom@8301:                     </dc:when>
tom@8301:                     <dc:when test="$out = 'map'">
gernotbelger@9127:                       <dc:call-macro name="flood-map" />
tom@8301:                     </dc:when>
gernotbelger@8961: 
gernotbelger@8958:                     <dc:when test="$out = 'sinfo_flowdepth_waterlevels'">
gernotbelger@9340:                       <dc:call-macro name="longitudinal-section-fix-vollmer_w" />
gernotbelger@8958:                     </dc:when>
aheinecke@6095:                   </dc:choose>
aheinecke@6095:                 </dc:iterate>
aheinecke@6095:               </dc:otherwise>
aheinecke@6095:             </dc:choose>
aheinecke@6095:           </dc:call-macro>
aheinecke@6081:         </dc:call-macro>
aheinecke@6053:       </dc:call-macro>
aheinecke@6053:     </dc:macro>
felix@4455: 
aheinecke@6053:     <!-- Macros to load user data -->
rrenkert@5631: 
felix@7575:     <dc:macro name="historical-discharge-user">
felix@7576:       <dc:filter expr="$out = 'historical_discharge' and starts-with($facet_name, 'historical_discharge.historical')">
felix@7576:         <dc:if test="dc:has-result()">
felix@7576:           <historical_discharges>
felix@7576:             <dc:call-macro name="collection-group">
felix@7576:               <discharges description="{dc:group-key()}">
felix@7576:                 <dc:for-each>
felix@7576:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="out" value="historical_discharge" />
felix@7576:                   </dc:element>
felix@7576:                 </dc:for-each>
felix@7576:               </discharges>
felix@7576:             </dc:call-macro>
felix@7576:           </historical_discharges>
felix@7576:         </dc:if>
felix@7576:       </dc:filter>
felix@7576:     </dc:macro>
felix@7576: 
aheinecke@6110:     <dc:macro name="differences">
rrenkert@7795:       <dc:filter expr="$facet_name = 'w_differences' or $facet_name = 'w_differences.filtered'">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6110:           <differences>
felix@7418:             <dc:call-macro name="collection-group">
felix@7408:               <differences description="{dc:group-key()}">
felix@7408:                 <dc:for-each>
rrenkert@7795:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="out" value="${out_name}" />
rrenkert@7795:                   </dc:element>
felix@7408:                 </dc:for-each>
felix@7408:               </differences>
felix@7418:             </dc:call-macro>
aheinecke@6110:           </differences>
aheinecke@6053:         </dc:if>
aheinecke@6110:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@5976: 
aheinecke@6053:     <dc:macro name="reference-curves">
felix@7457:       <dc:filter expr="$out = 'reference_curve' and $facet_name = 'reference_curve'">
aheinecke@6111:         <dc:if test="dc:has-result()">
aheinecke@6111:           <reference_curves>
felix@7457:             <dc:call-macro name="collection-group">
felix@7457:               <ref_curve description="{dc:group-key()}">
felix@7457:                 <dc:for-each>
felix@7457:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="out" value="reference_curve" />
felix@7457:                   </dc:element>
felix@7457:                 </dc:for-each>
felix@7457:               </ref_curve>
felix@7457:             </dc:call-macro>
aheinecke@6111:           </reference_curves>
aheinecke@6111:         </dc:if>
aheinecke@6111:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6691: 
aheinecke@6053:     <dc:macro name="flood-map">
aheinecke@6111:       <dc:filter expr="$facet_name = 'floodmap.wsplgen'">
aheinecke@6111:         <dc:if test="dc:has-result()">
aheinecke@6111:           <floodmap>
aheinecke@6111:             <dc:for-each>
gernotbelger@9127:               <dc:variable name="combined_desc" expr="concat($facet_description, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)" />
aheinecke@6111:               <dc:element name="${facet_name}">
gernotbelger@9127:                 <dc:attribute name="description" value="${combined_desc}" />
gernotbelger@9127:                 <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                 <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                 <dc:attribute name="artifact-id" value="${a_id}" />
gernotbelger@9127:                 <dc:attribute name="ids" value="${a_id}" />
gernotbelger@9127:                 <dc:attribute name="out" value="floodmap" />
aheinecke@6111:               </dc:element>
aheinecke@6111:             </dc:for-each>
aheinecke@6111:           </floodmap>
aheinecke@6111:         </dc:if>
aheinecke@6111:       </dc:filter>
aheinecke@6053:     </dc:macro>
gernotbelger@9499:     
gernotbelger@9499:     <dc:macro name="cross_section_user_content">
gernotbelger@9499:       <dc:call-macro name="waterlevels" />                    
gernotbelger@9499:       <dc:call-macro name="vegetationzones" />
gernotbelger@9499:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="waterlevels">
aheinecke@6095:       <dc:filter expr="$out_name = 'cross_section'">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <waterlevels>
aheinecke@6654:             <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation))">
aheinecke@6111:               <dc:comment>Aheinecke: Why is this grouping different from the rest?</dc:comment>
aheinecke@6111:               <longitudinal_section_columns description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
aheinecke@6111:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="cross_section" />
aheinecke@6111:                   </dc:element>
aheinecke@6111:                 </dc:for-each>
aheinecke@6111:               </longitudinal_section_columns>
aheinecke@6111:             </dc:group>
aheinecke@6053:           </waterlevels>
aheinecke@6053:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
gernotbelger@9499: 
gernotbelger@9499: 
felix@7418:     <dc:macro name="collection-group">
felix@7418:       <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)">
gernotbelger@9127:         <dc:macro-body />
felix@7418:       </dc:group>
felix@7418:     </dc:macro>
felix@7418: 
aheinecke@6053:     <dc:macro name="longitudinal">
felix@7492:       <dc:filter expr="$out_name = 'longitudinal_section' and $a_state != 'state.fix.vollmer.compute'">
aheinecke@6053:         <dc:if test="dc:has-result()">
felix@7332:           <waterlevels_ls>
felix@7418:             <dc:call-macro name="collection-group">
aheinecke@6111:               <dc:comment>Aheinecke: Why is this grouping different from the rest?</dc:comment>
aheinecke@6111:               <longitudinal_section_columns description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
aheinecke@6111:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="longitudinal_section" />
aheinecke@6111:                   </dc:element>
aheinecke@6111:                 </dc:for-each>
aheinecke@6111:               </longitudinal_section_columns>
felix@7418:             </dc:call-macro>
felix@7332:           </waterlevels_ls>
aheinecke@6053:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
felix@7491:     <dc:macro name="longitudinal-section-fix-vollmer">
felix@7491:       <dc:filter expr="$a_state = 'state.fix.vollmer.compute' and
felix@7491:           ($facet_name = 'longitudinal_section.w' or
felix@7491:            $facet_name = 'longitudinal_section.q')
felix@7491:         ">
gernotbelger@9127:         <dc:call-macro name="longitudinal-section-fix-vollmer_macro" />
gernotbelger@8958:       </dc:filter>
gernotbelger@8958:     </dc:macro>
gernotbelger@8958: 
gernotbelger@9340:     <dc:macro name="longitudinal-section-fix-vollmer_w">
gernotbelger@9340:       <dc:filter expr="$a_state = 'state.fix.vollmer.compute' and $facet_name = 'longitudinal_section.w'">
gernotbelger@9127:         <dc:call-macro name="longitudinal-section-fix-vollmer_macro" />
gernotbelger@8958:       </dc:filter>
gernotbelger@8958:     </dc:macro>
gernotbelger@8958: 
gernotbelger@8958:     <dc:macro name="longitudinal-section-fix-vollmer_macro">
gernotbelger@8961:       <dc:if test="dc:has-result()">
gernotbelger@8961:         <waterlevels_fix_vollmer>
gernotbelger@8961:           <dc:call-macro name="collection-group">
gernotbelger@8961:             <waterlevels description="{dc:group-key()}">
gernotbelger@8961:               <dc:for-each>
gernotbelger@8961:                 <dc:element name="${facet_name}">
gernotbelger@9127:                   <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                   <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                   <dc:attribute name="factory" value="fixanalysis" />
gernotbelger@9127:                   <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                   <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                   <dc:attribute name="out" value="longitudinal_section" />
gernotbelger@9233: 
gernotbelger@9233:                   <dc:variable name="fixAnalysisYear" expr="dc:fix_analysis_year($a_gid)" />
gernotbelger@9233:                   <dc:attribute name="year" value="${fixAnalysisYear}" />
gernotbelger@8961:                 </dc:element>
gernotbelger@8961:               </dc:for-each>
gernotbelger@8961:             </waterlevels>
gernotbelger@8961:           </dc:call-macro>
gernotbelger@8961:         </waterlevels_fix_vollmer>
gernotbelger@8961:       </dc:if>
felix@7491:     </dc:macro>
felix@7491: 
felix@7332:     <dc:macro name="longitudinal-section-fix">
aheinecke@6111:       <dc:filter expr="$out_name = 'fix_longitudinal_section_curve' and
aheinecke@6111:         (starts-with($facet_name, 'fix_deviation_ls') or
aheinecke@6111:         starts-with($facet_name, 'fix_sector_average_ls') or
aheinecke@6111:         starts-with($facet_name, 'fix_analysis_events_ls') or
felix@7491:         starts-with($facet_name, 'fix_reference_events_ls'))
felix@7365:         ">
aheinecke@6053:         <dc:if test="dc:has-result()">
felix@7332:           <waterlevels_fix>
felix@7418:             <dc:call-macro name="collection-group">
aheinecke@6111:               <waterlevels description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
aheinecke@6111:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="fixanalysis" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="fix_longitudinal_section_curve" />
aheinecke@6111:                   </dc:element>
aheinecke@6111:                 </dc:for-each>
aheinecke@6111:               </waterlevels>
felix@7418:             </dc:call-macro>
felix@7332:           </waterlevels_fix>
aheinecke@6053:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="delta-wt">
aheinecke@6111:       <dc:filter expr="$out_name = 'fix_deltawt_curve' and
aheinecke@6111:         ($facet_name = 'fix_analysis_events_dwt' or
aheinecke@6111:         $facet_name = 'fix_analysis_periods_dwt' or
aheinecke@6111:         $facet_name = 'fix_reference_events_dwt' or
aheinecke@6111:         starts-with($facet_name, 'fix_deviation_dwt') or
aheinecke@6111:         starts-with($facet_name, 'fix_sector_average_dwt'))">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <waterlevels>
felix@7418:             <dc:call-macro name="collection-group">
aheinecke@6111:               <waterlevels description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
aheinecke@6111:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="fixanalysis" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="fix_deltawt_curve" />
aheinecke@6111:                   </dc:element>
aheinecke@6111:                 </dc:for-each>
aheinecke@6111:               </waterlevels>
felix@7418:             </dc:call-macro>
aheinecke@6053:           </waterlevels>
aheinecke@6053:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8377:     <dc:macro name="fix-wq-curve">
gernotbelger@9127:       <dc:filter
gernotbelger@9127:         expr="($out_name = 'fix_wq_curve' and
tom@8377:                        (starts-with($facet_name, 'fix_analysis_events_wq') or
tom@8377:                        starts-with($facet_name, 'fix_reference_events_wq') or
tom@8377:                        starts-with($facet_name, 'fix_sector_average_wq') or
tom@8377:                        $facet_name = 'fix_wq_curve')) or
tom@8377:                        ($out_name = 'fix_derivate_curve' and
tom@8377:                        $facet_name = 'fix_derivate_curve')">
aheinecke@6053:         <dc:if test="dc:has-result()">
tom@8377:           <waterlevels_fix>
felix@7418:             <dc:call-macro name="collection-group">
tom@8377:               <projects description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
tom@8377:                   <dc:choose>
tom@8377:                     <dc:when test="$out_name = 'fix_wq_curve'">
tom@8377:                       <dc:element name="${facet_name}">
gernotbelger@9127:                         <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                         <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                         <dc:attribute name="factory" value="fixanalysis" />
gernotbelger@9127:                         <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                         <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                         <dc:attribute name="out" value="fix_wq_curve" />
tom@8377:                       </dc:element>
tom@8377:                     </dc:when>
tom@8377:                     <dc:when test="$out_name = 'fix_derivate_curve'">
tom@8377:                       <dc:element name="${facet_name}">
gernotbelger@9127:                         <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                         <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                         <dc:attribute name="factory" value="fixanalysis" />
gernotbelger@9127:                         <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                         <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                         <dc:attribute name="out" value="fix_derivate_curve" />
tom@8377:                       </dc:element>
tom@8377:                     </dc:when>
tom@8377:                   </dc:choose>
aheinecke@6111:                 </dc:for-each>
tom@8377:               </projects>
felix@7418:             </dc:call-macro>
tom@8377:           </waterlevels_fix>
felix@7267:         </dc:if>
felix@7267:       </dc:filter>
felix@7267:     </dc:macro>
felix@7267: 
felix@7267:     <dc:macro name="extreme-wq-curve">
felix@7424:       <dc:filter expr="$facet_name = 'extreme_wq_curve' or $facet_name = 'extreme_wq_curve_base'">
felix@7267:         <dc:if test="dc:has-result()">
felix@7267:           <computed_discharge_curves>
felix@7267:             <dc:for-each>
felix@7267:               <dc:element name="${facet_name}">
gernotbelger@9127:                 <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                 <dc:attribute name="factory" value="fixanalysis" />
gernotbelger@9127:                 <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                 <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                 <dc:attribute name="ids" value="${a_gid}" />
gernotbelger@9127:                 <dc:attribute name="out" value="computed_discharge_curve" />
felix@7267:               </dc:element>
felix@7267:             </dc:for-each>
felix@7267:           </computed_discharge_curves>
felix@7267:         </dc:if>
felix@7267:       </dc:filter>
felix@7267:     </dc:macro>
felix@7267: 
felix@7264:     <dc:macro name="computed-discharge-curve">
felix@7264:       <dc:filter expr="$facet_name = 'computed_discharge_curve.q'">
felix@7264:         <dc:if test="dc:has-result()">
felix@7264:           <computed_discharge_curves>
tom@8377:             <dc:call-macro name="collection-group">
tom@8377:               <projects description="{dc:group-key()}">
tom@8377:                 <dc:for-each>
tom@8377:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="computed_discharge_curve" />
tom@8377:                   </dc:element>
tom@8377:                 </dc:for-each>
tom@8377:               </projects>
tom@8377:             </dc:call-macro>
felix@7264:           </computed_discharge_curves>
felix@7264:         </dc:if>
felix@7264:       </dc:filter>
felix@7264:     </dc:macro>
felix@7264: 
aheinecke@6053:     <dc:macro name="duration-curve">
aheinecke@6111:       <dc:filter expr="$facet_name = 'duration_curve.q' or $facet_name = 'duration_curve.w'">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <computed_discharge_curves>
aheinecke@6053:             <dc:for-each>
aheinecke@6053:               <dc:element name="${facet_name}">
gernotbelger@9127:                 <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                 <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                 <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                 <dc:attribute name="artifact-id" value="${a_id}" />
gernotbelger@9127:                 <dc:attribute name="ids" value="${a_id}" />
gernotbelger@9127:                 <dc:attribute name="out" value="duration_curve" />
aheinecke@6053:               </dc:element>
aheinecke@6053:             </dc:for-each>
aheinecke@6053:           </computed_discharge_curves>
aheinecke@6053:         </dc:if>
aheinecke@6111:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8377: 
tom@8377:     <dc:macro name="waterlevels-user">
tom@8377:       <dc:filter expr="($out_name = 'longitudinal_section'
tom@8377:                        and $facet_name = 'longitudinal_section.w') and
tom@8377:                        (not ($current-state-id = 'state.winfo.uesk.wsp'
tom@8377:                        and $ld_m = 'location'))">
aheinecke@6111:         <dc:if test="dc:has-result()">
aheinecke@6111:           <waterlevels>
felix@7420:             <dc:call-macro name="collection-group">
aheinecke@6111:               <waterlevels description="{dc:group-key()}">
aheinecke@6095:                 <dc:for-each>
aheinecke@6324:                   <dc:choose>
aheinecke@6324:                     <dc:when test="$ld_m = 'location'">
gernotbelger@8941:                       <dc:variable name="combined_desc" expr="concat($facet_description,
gernotbelger@9127:                                          ' an KM ', $deffrom)" />
aheinecke@6324:                     </dc:when>
aheinecke@6324:                     <dc:otherwise>
gernotbelger@8941:                       <dc:variable name="combined_desc" expr="concat($facet_description, ' von KM ',
gernotbelger@9127:                                          $deffrom, ' bis KM ', $defto)" />
aheinecke@6324:                     </dc:otherwise>
aheinecke@6324:                   </dc:choose>
aheinecke@6095:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${combined_desc}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="longitudinal_section" />
aheinecke@6095:                   </dc:element>
aheinecke@6095:                 </dc:for-each>
aheinecke@6095:               </waterlevels>
felix@7420:             </dc:call-macro>
aheinecke@6111:           </waterlevels>
aheinecke@6111:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
gernotbelger@9127:     <dc:comment comment="For building differences." />
tom@8298:     <dc:macro name="differences-fix">
gernotbelger@9127:       <dc:comment comment="Vollmer curves need own factory" />
felix@6649:       <dc:filter expr="$a_state = 'state.fix.vollmer.compute' and $facet_name = 'longitudinal_section.w'">
felix@6581:         <dc:if test="dc:has-result()">
felix@6587:           <vollmer_waterlevels>
felix@7420:             <dc:call-macro name="collection-group">
felix@6581:               <waterlevels description="{dc:group-key()}">
felix@6581:                 <dc:for-each>
felix@6581:                   <dc:choose>
felix@6581:                     <dc:when test="$ld_m = 'location'">
gernotbelger@9127:                       <dc:variable name="combined_desc" expr="concat($facet_description, ' an KM ', $deffrom)" />
felix@6581:                     </dc:when>
felix@6581:                     <dc:otherwise>
felix@6581:                       <dc:variable name="combined_desc" expr="concat($facet_description, ' von KM ',
gernotbelger@9127:                         $deffrom, ' bis KM ', $defto)" />
felix@6581:                     </dc:otherwise>
gernotbelger@8941:                   </dc:choose>
felix@6587:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${combined_desc}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="fixanalysis" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="longitudinal_section" />
felix@6587:                   </dc:element>
felix@6581:                 </dc:for-each>
felix@6581:               </waterlevels>
felix@7420:             </dc:call-macro>
felix@6587:           </vollmer_waterlevels>
felix@6587:         </dc:if>
felix@6587:       </dc:filter>
felix@6587:       <dc:filter expr="not($a_state = 'state.fix.vollmer.compute') and (($out_name = 'longitudinal_section' and $facet_name = 'longitudinal_section.w') and
felix@6587:         (not ($current-state-id = 'state.winfo.uesk.wsp' and $ld_m = 'location')))">
felix@6587:         <dc:if test="dc:has-result()">
felix@6581:           <waterlevels>
felix@7420:             <dc:call-macro name="collection-group">
gernotbelger@8941:               <waterlevels description="{dc:group-key()}">
gernotbelger@8941:                 <dc:for-each>
gernotbelger@8941:                   <dc:choose>
gernotbelger@8941:                     <dc:when test="$ld_m = 'location'">
gernotbelger@9127:                       <dc:variable name="combined_desc" expr="concat($facet_description, ' an KM ', $deffrom)" />
gernotbelger@8941:                     </dc:when>
gernotbelger@8941:                     <dc:otherwise>
gernotbelger@8941:                       <dc:variable name="combined_desc" expr="concat($facet_description, ' von KM ',
gernotbelger@9127:                           $deffrom, ' bis KM ', $defto)" />
gernotbelger@8941:                     </dc:otherwise>
gernotbelger@8941:                   </dc:choose>
gernotbelger@8941:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="description" value="${combined_desc}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="longitudinal_section" />
gernotbelger@8941:                   </dc:element>
gernotbelger@8941:                 </dc:for-each>
gernotbelger@8941:               </waterlevels>
felix@7420:             </dc:call-macro>
felix@6581:           </waterlevels>
felix@6581:         </dc:if>
felix@6581:       </dc:filter>
felix@6581:     </dc:macro>
felix@6581: 
felix@6581: 
aheinecke@6053:     <dc:macro name="floodmap-hws-user">
aheinecke@6111:       <dc:comment>No grouping in this?</dc:comment>
aheinecke@6111:       <dc:filter expr="$out_name = 'floodmap' and $facet_name = 'floodmap.usershape'">
aheinecke@6111:         <own-hws>
aheinecke@6111:           <dc:for-each>
aheinecke@6111:             <dc:element name="${facet_name}">
gernotbelger@9127:               <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:               <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:               <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:               <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:               <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:               <dc:attribute name="out" value="floodmap" />
aheinecke@6111:             </dc:element>
aheinecke@6111:           </dc:for-each>
aheinecke@6111:         </own-hws>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
felix@7443:     <dc:macro name="bedquality">
aheinecke@6111:       <dc:filter expr="$out_name = 'bed_longitudinal_section' and
andre@8592:         starts-with($facet_name, 'bed_longitudinal_section')">
aheinecke@6053:         <dc:if test="dc:has-result()">
felix@7443:           <bed_quality>
felix@7420:             <dc:call-macro name="collection-group">
aheinecke@6111:               <quality-bed description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
aheinecke@6111:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="minfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="bed_longitudinal_section" />
aheinecke@6111:                   </dc:element>
aheinecke@6111:                 </dc:for-each>
aheinecke@6053:               </quality-bed>
felix@7420:             </dc:call-macro>
felix@7443:           </bed_quality>
aheinecke@6053:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="flow-velocity">
tom@6638:       <dc:filter expr="$out_name = 'flow_velocity' and
felix@7469:               starts-with($facet_name, 'flow_velocity')">
aheinecke@6053:         <dc:if test="dc:has-result()">
felix@7441:           <flow_velocity>
felix@7418:             <dc:call-macro name="collection-group">
aheinecke@6111:               <flow description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
aheinecke@6111:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="minfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="flow_velocity" />
aheinecke@6111:                   </dc:element>
aheinecke@6111:                 </dc:for-each>
aheinecke@6053:               </flow>
felix@7418:             </dc:call-macro>
felix@7441:           </flow_velocity>
aheinecke@6053:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="sediment-load">
tom@6638:       <dc:filter expr="$out_name = 'sedimentload_ls' and starts-with($facet_name, 'sedimentload')">
aheinecke@6053:         <dc:if test="dc:has-result()">
felix@7441:           <sediment_load>
felix@7418:             <dc:call-macro name="collection-group">
aheinecke@6111:               <load description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
aheinecke@6111:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="minfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="${out_name}" />
aheinecke@6111:                   </dc:element>
aheinecke@6111:                 </dc:for-each>
aheinecke@6053:               </load>
felix@7418:             </dc:call-macro>
felix@7441:           </sediment_load>
aheinecke@6053:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
rrenkert@8004:     <dc:macro name="middle_bedheights">
rrenkert@8004:       <dc:filter expr="($out_name = 'bedheight_middle') and
rrenkert@8004:           (starts-with($facet_name, 'bedheight_middle.single'))">
rrenkert@8004:         <dc:if test="dc:has-result()">
rrenkert@8004:           <middle_bedheights>
rrenkert@8004:             <dc:call-macro name="collection-group">
rrenkert@8004:               <middle_bedheight description="{dc:group-key()}">
rrenkert@8004:                 <dc:for-each>
rrenkert@8004:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="minfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="${out_name}" />
rrenkert@8004:                   </dc:element>
rrenkert@8004:                 </dc:for-each>
rrenkert@8004:               </middle_bedheight>
rrenkert@8004:             </dc:call-macro>
rrenkert@8004:           </middle_bedheights>
rrenkert@8004:         </dc:if>
rrenkert@8004:       </dc:filter>
rrenkert@8004:     </dc:macro>
rrenkert@8004: 
felix@6595:     <dc:macro name="bedheight_differences">
rrenkert@7923:       <dc:filter expr="($out_name = 'bed_difference_year' or $out_name = 'bed_difference_height_year') and
rrenkert@7923:           (starts-with($facet_name, 'bedheight_difference.year') or starts-with($facet_name, 'bedheight_difference.height'))">
aheinecke@6053:         <dc:if test="dc:has-result()">
felix@6595:           <bedheight_differences>
felix@7418:             <dc:call-macro name="collection-group">
aheinecke@6111:               <difference description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
aheinecke@6111:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="minfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="${out_name}" />
aheinecke@6111:                   </dc:element>
aheinecke@6111:                 </dc:for-each>
aheinecke@6053:               </difference>
felix@7418:             </dc:call-macro>
felix@6595:           </bedheight_differences>
aheinecke@6053:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@7348:     <dc:macro name="sqrelations_user">
gernotbelger@8941:       <dc:filter
gernotbelger@8941:         expr="not(dc:contains($facet_name, 'overview')) and (
aheinecke@7362:         ($out = 'sq_relation_a' and starts-with($facet_name, 'sq_a_')) or
aheinecke@7362:         ($out = 'sq_relation_b' and starts-with($facet_name, 'sq_b_')) or
aheinecke@7362:         ($out = 'sq_relation_c' and starts-with($facet_name, 'sq_c_')) or
aheinecke@7362:         ($out = 'sq_relation_d' and starts-with($facet_name, 'sq_d_')) or
aheinecke@7362:         ($out = 'sq_relation_e' and starts-with($facet_name, 'sq_e_')) or
tom@8289:         ($out = 'sq_relation_f' and starts-with($facet_name, 'sq_f_')) or
tom@8289:         ($out = 'sq_relation_g' and starts-with($facet_name, 'sq_g_'))) or
tom@8377:         dc:contains($facet_name, 'overview')">
aheinecke@7348:         <dc:if test="dc:has-result()">
aheinecke@7348:           <sq_relations>
felix@7418:             <dc:call-macro name="collection-group">
aheinecke@7348:               <sqrel description="{dc:group-key()}">
aheinecke@7348:                 <dc:for-each>
aheinecke@7348:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="minfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="${out_name}" />
aheinecke@7348:                   </dc:element>
aheinecke@7348:                 </dc:for-each>
aheinecke@7348:               </sqrel>
felix@7418:             </dc:call-macro>
aheinecke@7348:           </sq_relations>
aheinecke@7348:         </dc:if>
aheinecke@7348:       </dc:filter>
aheinecke@7348:     </dc:macro>
aheinecke@7348: 
aheinecke@6053:     <dc:macro name="waterlevels-discharge">
felix@7426:       <dc:filter expr="$out_name = 'discharge_longitudinal_section'">
aheinecke@6053:         <dc:if test="dc:has-result()">
felix@7332:           <waterlevels_discharge>
felix@7418:             <dc:call-macro name="collection-group">
aheinecke@6111:               <discharge description="{dc:group-key()}">
aheinecke@6111:                 <dc:for-each>
aheinecke@6111:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="winfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}-${facet_name}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="discharge_longitudinal_section" />
aheinecke@6111:                   </dc:element>
aheinecke@6111:                 </dc:for-each>
aheinecke@6053:               </discharge>
felix@7418:             </dc:call-macro>
felix@7332:           </waterlevels_discharge>
aheinecke@6053:         </dc:if>
aheinecke@6095:       </dc:filter>
aheinecke@6053:     </dc:macro>
tom@8307: 
tom@8307: 
aheinecke@6053:     <!-- Macros to load system data -->
aheinecke@6053: 
tom@8334:     <dc:macro name="qmainvalues">
gernotbelger@9127:       <qmainvalue factory="mainvalue" ids="{$river_id}:q" target_out="{$out}" />
tom@8334:     </dc:macro>
tom@8334: 
aheinecke@6053:     <dc:macro name="mainvalues">
gernotbelger@9127:       <wmainvalue factory="mainvalue" ids="{$river_id}:w" target_out="{$out}" />
gernotbelger@9127:       <dc:call-macro name="qmainvalues" />
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8461:     <!-- discharge curves -->
tom@8461:     <dc:macro name="hist_discharge_factory">
tom@8461:       <dc:for-each>
gernotbelger@8941:         <dc:variable name="validity" expr="concat(
tom@8461:                            dc:date-format('dd.MM.yyyy', $start_time),
tom@8461:                            ' - ',
gernotbelger@9127:                            dc:date-format('dd.MM.yyyy', $stop_time))" />
gernotbelger@8941:         <histdis name="{concat($bfg_id, ' ', $validity)}" description="{concat($bfg_id, ' ', $validity)}" factory="gaugedischarge" target_out="{$out}" ids="{$gauge_name};{$dt_id};{concat($bfg_id, ' ',
gernotbelger@9127:                       $gauge_name, ' ', $validity)}" />
tom@8461:       </dc:for-each>
tom@8461:     </dc:macro>
tom@8461: 
tom@8461:     <dc:macro name="hist_discharge_rec">
gernotbelger@8941:       <dc:variable name="start" type="number" expr="dc:date-format('yyyyMMdd',
gernotbelger@9127:                            number(substring-before($year_range, ';')))" />
gernotbelger@8941:       <dc:variable name="stop" type="number" expr="dc:date-format('yyyyMMdd',
gernotbelger@9127:                            number(substring-after($year_range, ';')))" />
tom@8487:       <dc:call-macro name="discharge_curve_choose_context">
tom@8461:         <dc:filter expr="$kind = 1 and
tom@8461:                          number(dc:date-format('yyyyMMdd', $start_time))
tom@8461:                            &lt; $stop and
tom@8496:                          number(dc:coalesce(
tom@8496:                              dc:date-format('yyyyMMdd', $stop_time),
tom@8496:                              '99999999'))
tom@8461:                            &gt; $start">
gernotbelger@9127:           <dc:call-macro name="hist_discharge_factory" />
tom@8461:         </dc:filter>
tom@8487:       </dc:call-macro>
tom@8461:     </dc:macro>
tom@8461: 
tom@8389:     <dc:macro name="discharge_table_gauge">
tom@8487:       <dc:call-macro name="discharge_curve_choose_context">
tom@8389:         <dc:filter expr="$kind = 0">
tom@8434:           <dc:group expr="$gauge_name">
tom@8434:             <gauge name="{dc:group-key()}">
tom@8434:               <dc:for-each>
gernotbelger@9127:                 <current_gauge factory="gaugedischarge" target_out="{$out}" ids="{$gauge_name}" />
tom@8434:               </dc:for-each>
tom@8434:             </gauge>
tom@8434:           </dc:group>
tom@8389:         </dc:filter>
tom@8487:       </dc:call-macro>
tom@8389:     </dc:macro>
tom@8389: 
tom@8389:     <dc:macro name="historical_discharge_curve">
tom@8487:       <dc:call-macro name="discharge_curve_choose_context">
tom@8389:         <dc:filter expr="$kind = 1">
tom@8389:           <historical_discharge_curves>
tom@8434:             <dc:group expr="$gauge_name">
tom@8434:               <gauge name="{dc:group-key()}">
gernotbelger@9127:                 <dc:call-macro name="hist_discharge_factory" />
tom@8434:               </gauge>
tom@8434:             </dc:group>
tom@8389:           </historical_discharge_curves>
tom@8389:         </dc:filter>
tom@8487:       </dc:call-macro>
tom@8389:     </dc:macro>
tom@8389: 
tom@8487:     <dc:macro name="discharge_curve_choose_context">
tom@8487:       <dc:choose>
tom@8487:         <dc:when test="$fromkm &gt; -99999 and $tokm &lt; 99999">
tom@8487:           <dc:context>
gernotbelger@9127:             <dc:call-macro name="discharge_curves_km" />
gernotbelger@9127:             <dc:macro-body />
tom@8487:           </dc:context>
tom@8487:         </dc:when>
tom@8487:         <dc:otherwise>
gernotbelger@9127:           <dc:variable name="refgauge" type="number" expr="dc:get('reference_gauge')" />
tom@8487:           <dc:context>
gernotbelger@9127:             <dc:call-macro name="discharge_curves_refgauge" />
gernotbelger@9127:             <dc:macro-body />
tom@8487:           </dc:context>
tom@8487:         </dc:otherwise>
tom@8487:       </dc:choose>
tom@8487:     </dc:macro>
tom@8487: 
tom@8487:     <dc:macro name="discharge_curves_km">
tom@8389:       <dc:statement>
gernotbelger@8941:         SELECT g.name AS gauge_name,
gernotbelger@8941:         dt.id AS dt_id,
gernotbelger@8941:         t.start_time AS start_time,
gernotbelger@8941:         t.stop_time AS stop_time,
gernotbelger@8941:         dt.bfg_id AS bfg_id,
gernotbelger@8941:         dt.kind AS kind
gernotbelger@8941:         FROM gauges g
gernotbelger@8941:         JOIN discharge_tables dt ON g.id = dt.gauge_id
gernotbelger@8941:         LEFT JOIN time_intervals t ON dt.time_interval_id = t.id
gernotbelger@8941:         WHERE g.river_id = ${river_id}
gernotbelger@8941:         AND g.station BETWEEN ${fromkm} AND ${tokm}
gernotbelger@8941:         ORDER BY start_time
tom@8389:       </dc:statement>
tom@8389:     </dc:macro>
tom@8389: 
tom@8487:     <dc:macro name="discharge_curves_refgauge">
tom@8487:       <dc:statement>
gernotbelger@8941:         SELECT g.name AS gauge_name,
gernotbelger@8941:         dt.id AS dt_id,
gernotbelger@8941:         t.start_time AS start_time,
gernotbelger@8941:         t.stop_time AS stop_time,
gernotbelger@8941:         dt.bfg_id AS bfg_id,
gernotbelger@8941:         dt.kind AS kind
gernotbelger@8941:         FROM gauges g
gernotbelger@8941:         JOIN discharge_tables dt ON g.id = dt.gauge_id
gernotbelger@8941:         LEFT JOIN time_intervals t ON dt.time_interval_id = t.id
gernotbelger@8941:         WHERE g.river_id = ${river_id}
gernotbelger@8941:         AND g.official_number = ${refgauge}
gernotbelger@8941:         ORDER BY start_time
tom@8487:       </dc:statement>
tom@8487:     </dc:macro>
tom@8487: 
tom@8487:     <!-- Cross sections -->
aheinecke@6053:     <dc:macro name="cross_sections">
aheinecke@6053:       <cross_sections id="flood-protections-{$river_id}">
aheinecke@6053:         <dc:context connection="system">
aheinecke@6053:           <dc:statement>
aheinecke@6053:             SELECT DISTINCT
gernotbelger@8941:             cs.id AS prot_id,
gernotbelger@8941:             cs.description AS prot_description
aheinecke@6053:             FROM cross_sections cs
gernotbelger@8941:             JOIN cross_section_lines csl ON csl.cross_section_id = cs.id
aheinecke@6053:             WHERE cs.river_id = ${river_id}
gernotbelger@8941:             AND csl.km BETWEEN ${fromkm} AND ${tokm}
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:for-each>
gernotbelger@9127:             <cross_section name="{$prot_description}" ids="{$prot_id}" factory="crosssections" target_out="{$out}" />
aheinecke@6053:           </dc:for-each>
aheinecke@6053:         </dc:context>
aheinecke@6053:       </cross_sections>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="hyks">
aheinecke@6053:       <hyks id="hyk-{$river_id}">
aheinecke@6053:         <dc:context connection="system">
aheinecke@6053:           <dc:statement>
aheinecke@6053:             SELECT DISTINCT
gernotbelger@8941:             h.id AS hyk_id,
gernotbelger@8941:             h.description AS hyk_description
aheinecke@6053:             FROM hyks h
gernotbelger@8941:             JOIN hyk_entries he ON he.hyk_id = h.id
aheinecke@6053:             WHERE river_id = ${river_id}
gernotbelger@8941:             AND he.km BETWEEN ${fromkm} AND ${tokm}
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:for-each>
gernotbelger@9127:             <hyk name="{$hyk_description}" ids="{$hyk_id}" factory="hyk" target_out="{$out}" />
aheinecke@6053:           </dc:for-each>
aheinecke@6053:         </dc:context>
aheinecke@6053:       </hyks>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
gernotbelger@9506:     <!-- Default Vegetation Zones -->
gernotbelger@9506:     <dc:macro name="predefined_vegetation_zones">
gernotbelger@9506:       <uinfo>
gernotbelger@9506:         <vegetation_zones>
gernotbelger@9506:           <dc:variable name="vegzonedata" expr="dc:defaultvegetationzone($river)"/>
gernotbelger@9506: 
gernotbelger@9506:           <defaultVegetationZone factory="predefined_vegetation_zonesf" target_out="{$out}" ids="{$vegzonedata}"/>         
gernotbelger@9499:         </vegetation_zones>
gernotbelger@9506:       </uinfo>
gernotbelger@9499:     </dc:macro>
tom@8307: 
tom@8307:     <!-- wst-data -->
tom@8307: 
tom@8307:     <!-- model-waterlevels -->
tom@8307:     <dc:macro name="basedata_0_macro">
tom@8307:       <dc:filter expr="$kind = 0">
tom@8307:         <dc:if test="dc:has-result()">
tom@8307:           <basedata>
tom@8307:             <dc:group expr="$wst_description">
tom@8307:               <basedata name="{dc:group-key()}">
tom@8307:                 <dc:for-each>
gernotbelger@9127:                   <dc:macro-body />
tom@8307:                 </dc:for-each>
tom@8307:               </basedata>
tom@8307:             </dc:group>
tom@8307:           </basedata>
tom@8307:         </dc:if>
tom@8307:       </dc:filter>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_0">
tom@8307:       <dc:call-macro name="basedata_0_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="base_data-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_0_wq">
tom@8307:       <dc:call-macro name="basedata_0_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="base_data-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <!-- additional longitudinal sections -->
tom@8307:     <dc:macro name="basedata_1_additionals_macro">
tom@8307:       <dc:filter expr="$kind=1">
tom@8307:         <dc:if test="dc:has-result()">
tom@8307:           <additionals>
tom@8307:             <dc:group expr="dc:replace($wst_description, 'Zus.Längsschnitte/', '')">
gernotbelger@9233:               <additional name="{dc:group-key()}" description="{dc:group-key()}">
tom@8307:                 <dc:for-each>
gernotbelger@9127:                   <dc:macro-body />
tom@8307:                 </dc:for-each>
tom@8307:               </additional>
tom@8307:             </dc:group>
tom@8307:           </additionals>
tom@8307:         </dc:if>
tom@8307:       </dc:filter>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_1_additionals">
tom@8307:       <dc:call-macro name="basedata_1_additionals_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
mschaefer@9016:     <dc:macro name="basedata_1_additionals-sinfo-with-q_macro">
mschaefer@9016:       <dc:filter expr="$kind=1 and $sinfo_selection='Q'">
mschaefer@9016:         <dc:if test="dc:has-result()">
mschaefer@9016:           <sinfo_additional_ls_withQ>
mschaefer@9016:             <dc:group expr="dc:replace($wst_description, 'Zus.Längsschnitte/', '')">
gernotbelger@9233:               <additional name="{dc:group-key()}" description="{dc:group-key()}">
mschaefer@9016:                 <dc:for-each>
gernotbelger@9127:                   <dc:macro-body />
mschaefer@9016:                 </dc:for-each>
mschaefer@9016:               </additional>
mschaefer@9016:             </dc:group>
mschaefer@9016:           </sinfo_additional_ls_withQ>
mschaefer@9016:         </dc:if>
mschaefer@9016:       </dc:filter>
mschaefer@9016:     </dc:macro>
mschaefer@9016: 
mschaefer@9016:     <dc:macro name="basedata_1_additionals-sinfo-with-q">
mschaefer@9016:       <dc:call-macro name="basedata_1_additionals-sinfo-with-q_macro">
gernotbelger@9233:         <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" year="{dc:date-format('yyyy', $start_time)}" />
mschaefer@9016:       </dc:call-macro>
mschaefer@9016:     </dc:macro>
mschaefer@9016: 
mschaefer@9016:     <dc:macro name="basedata_1_additionals-sinfo-without-q_macro">
mschaefer@9016:       <dc:filter expr="$kind=1 and $sinfo_selection='W'">
mschaefer@9016:         <dc:if test="dc:has-result()">
mschaefer@9016:           <sinfo_additional_ls_withoutQ>
mschaefer@9016:             <dc:group expr="dc:replace($wst_description, 'Zus.Längsschnitte/', '')">
gernotbelger@9233:               <additional name="{dc:group-key()}" description="{dc:group-key()}">
mschaefer@9016:                 <dc:for-each>
gernotbelger@9127:                   <dc:macro-body />
mschaefer@9016:                 </dc:for-each>
mschaefer@9016:               </additional>
mschaefer@9016:             </dc:group>
mschaefer@9016:           </sinfo_additional_ls_withoutQ>
mschaefer@9016:         </dc:if>
mschaefer@9016:       </dc:filter>
mschaefer@9016:     </dc:macro>
mschaefer@9016: 
mschaefer@9016:     <dc:macro name="basedata_1_additionals-sinfo-without-q">
mschaefer@9016:       <dc:call-macro name="basedata_1_additionals-sinfo-without-q_macro">
gernotbelger@9233:         <dc:variable name="start_year" expr="dc:date-format('yyyy', $start_time)" />
gernotbelger@9233:         <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" year="{dc:date-format('yyyy', $start_time)}" />
mschaefer@9016:       </dc:call-macro>
mschaefer@9016:     </dc:macro>
mschaefer@9016: 
tom@8307:     <dc:macro name="basedata_1_additionals_wq">
tom@8307:       <dc:call-macro name="basedata_1_additionals_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="base_data-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_1_additionals-relative_point">
tom@8307:       <dc:call-macro name="basedata_1_additionals_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <!-- fixations -->
aheinecke@6053:     <dc:macro name="fixings-macro">
aheinecke@6053:       <dc:filter expr="$kind=2">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <fixations>
aheinecke@6053:             <dc:group expr="dc:replace($wst_description, 'Fixierungen/', '')">
aheinecke@6053:               <fixation name="{dc:group-key()}">
aheinecke@6053:                 <dc:for-each>
gernotbelger@9127:                   <dc:macro-body />
aheinecke@6053:                 </dc:for-each>
aheinecke@6053:               </fixation>
aheinecke@6053:             </dc:group>
aheinecke@6053:           </fixations>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="basedata_2_fixations">
aheinecke@6053:       <dc:call-macro name="fixings-macro">
gernotbelger@9233:         <dc:variable name="start_year" expr="dc:date-format('yyyy', $start_time)" />
gernotbelger@9233:         <column name="{$wst_column_name}" ids="fixations-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" year="{dc:date-format('yyyy', $start_time)}" />
aheinecke@6053:       </dc:call-macro>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8307:     <dc:macro name="basedata_2_fixations_wq">
tom@8307:       <dc:call-macro name="fixings-macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="fixations-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_2_fixations_relative_point">
tom@8307:       <dc:call-macro name="fixings-macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="fixations-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <!-- official lines -->
tom@8307:     <dc:macro name="basedata_3_macro">
aheinecke@6053:       <dc:filter expr="$kind=3">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <officiallines>
aheinecke@6053:             <dc:group expr="$wst_description">
aheinecke@6053:               <official name="{dc:group-key()}">
aheinecke@6053:                 <dc:for-each>
gernotbelger@9127:                   <dc:macro-body />
felix@7621:                 </dc:for-each>
felix@7621:               </official>
felix@7621:             </dc:group>
felix@7621:           </officiallines>
felix@7621:         </dc:if>
felix@7621:       </dc:filter>
felix@7621:     </dc:macro>
felix@7621: 
tom@8307:     <dc:macro name="basedata_3_officials">
tom@8307:       <dc:call-macro name="basedata_3_macro">
gernotbelger@9299:         <dc:variable name="start_year" expr="dc:date-format('yyyy', $start_time)" />
gernotbelger@9233:         <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" year="{dc:date-format('yyyy', $start_time)}" />
tom@8307:       </dc:call-macro>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8307:     <dc:macro name="basedata_3_officials_wq">
tom@8307:       <dc:call-macro name="basedata_3_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="officials_wq-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <!-- flood marks -->
tom@8307:     <dc:macro name="basedata_4_macro">
aheinecke@6053:       <dc:filter expr="$kind=4">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <heightmarks>
aheinecke@6081:             <dc:group expr="dc:replace($wst_description, 'HW-Marken/', '')">
gernotbelger@9282:               <heightmark name="{dc:group-key()}" description="{dc:group-key()}">
aheinecke@6053:                 <dc:for-each>
gernotbelger@9127:                   <dc:macro-body />
aheinecke@6053:                 </dc:for-each>
aheinecke@6053:               </heightmark>
aheinecke@6053:             </dc:group>
aheinecke@6053:           </heightmarks>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8307:     <dc:macro name="basedata_4_heightmarks-points">
tom@8307:       <dc:call-macro name="basedata_4_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_4_heightmarks-points_wq">
tom@8307:       <dc:call-macro name="basedata_4_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
aheinecke@6053:     <dc:macro name="basedata_4_heightmarks-points-relative_points">
tom@8307:       <dc:call-macro name="basedata_4_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="heightmarks_points-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <!-- flood protection structures -->
tom@8307:     <dc:macro name="basedata_5_macro">
tom@8307:       <dc:filter expr="$kind=5">
aheinecke@6053:         <dc:if test="dc:has-result()">
tom@8307:           <flood_protections>
tom@8307:             <dc:group expr="dc:replace($wst_description, 'HW-Schutzanlagen/', '')">
gernotbelger@9282:               <flood_protection name="{dc:group-key()}" description="{dc:group-key()}">
aheinecke@6053:                 <dc:for-each>
gernotbelger@9127:                   <dc:macro-body />
aheinecke@6053:                 </dc:for-each>
tom@8307:               </flood_protection>
aheinecke@6053:             </dc:group>
tom@8307:           </flood_protections>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8307:     <dc:macro name="basedata_5_flood-protections">
tom@8307:       <dc:call-macro name="basedata_5_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_5_flood-protections_wq">
tom@8307:       <dc:call-macro name="basedata_5_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_5_flood-protections_relative_points">
tom@8307:       <dc:call-macro name="basedata_5_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="flood_protection-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <!-- waterlevel differences imported from CSV-files for M-INFO -->
tom@8307:     <dc:macro name="basedata_6_delta_w">
tom@8307:       <dc:filter expr="$kind=6">
tom@8307:         <dc:if test="dc:has-result()">
tom@8307:           <delta_w>
tom@8307:             <delta_w_cm>
tom@8307:               <dc:filter expr="contains($wst_description, 'cm.csv')">
tom@8307:                 <dc:group expr="dc:replace($wst_description, 'CSV/', '')">
gernotbelger@9233:                   <relativepoint name="{dc:group-key()}" description="{dc:group-key()}">
tom@8307:                     <dc:for-each>
gernotbelger@9127:                       <column name="{$wst_column_name}" ids="delta_w-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:                     </dc:for-each>
tom@8307:                   </relativepoint>
tom@8307:                 </dc:group>
tom@8307:               </dc:filter>
tom@8307:             </delta_w_cm>
tom@8307:             <delta_w_cma>
tom@8307:               <dc:filter expr="contains($wst_description, 'cm-a.csv')">
tom@8307:                 <dc:group expr="dc:replace($wst_description, 'CSV/', '')">
gernotbelger@9233:                   <relativepoint name="{dc:group-key()}" description="{dc:group-key()}">
tom@8307:                     <dc:for-each>
gernotbelger@9127:                       <column name="{$wst_column_name}" ids="delta_w_cma-wstv-{$wst_column_position}-{$wst_id}" factory="staticwkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:                     </dc:for-each>
tom@8307:                   </relativepoint>
tom@8307:                 </dc:group>
tom@8307:               </dc:filter>
tom@8307:             </delta_w_cma>
tom@8307:           </delta_w>
tom@8307:         </dc:if>
tom@8307:       </dc:filter>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <!-- waterlevels imported from CSV-files for M-INFO -->
tom@8307:     <dc:macro name="basedata_7_macro">
tom@8307:       <dc:filter expr="$kind=7">
tom@8307:         <dc:if test="dc:has-result()">
tom@8307:           <wlevel>
tom@8307:             <dc:group expr="dc:replace($wst_description, 'CSV/', '')">
gernotbelger@9233:               <relativepoint name="{dc:group-key()}" description="{dc:group-key()}">
tom@8307:                 <dc:for-each>
gernotbelger@9127:                   <dc:macro-body />
tom@8307:                 </dc:for-each>
tom@8307:               </relativepoint>
tom@8307:             </dc:group>
tom@8307:           </wlevel>
tom@8307:         </dc:if>
tom@8307:       </dc:filter>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_7_waterlevels">
tom@8307:       <dc:call-macro name="basedata_7_macro">
gernotbelger@9299:         <dc:variable name="start_year" expr="dc:date-format('yyyy', $start_time)" />
gernotbelger@9233:         <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="staticwqkms" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" year="{dc:date-format('yyyy', $start_time)}" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307:     <dc:macro name="basedata_7_waterlevels_wq">
tom@8307:       <dc:call-macro name="basedata_7_macro">
gernotbelger@9127:         <column name="{$wst_column_name}" ids="additionals-wstv-{$wst_column_position}-{$wst_id}" factory="wqinterpol" target_out="{$out}" info="{$info} [km {$deffrom} - {$defto}]" />
tom@8307:       </dc:call-macro>
tom@8307:     </dc:macro>
tom@8307: 
tom@8307: 
tom@8307:     <!-- prototypes -->
tom@8306: 
felix@7265:     <dc:macro name="discharge-curve-prototype">
gernotbelger@8941:       <computed_discharge_curve>
gernotbelger@9127:         <dc:call-macro name="discharge_table_gauge" />
gernotbelger@9127:         <dc:call-macro name="mainvalues" />
gernotbelger@8941:       </computed_discharge_curve>
gernotbelger@9127:       <dc:call-macro name="historical_discharge_curve" />
gernotbelger@9127:       <dc:call-macro name="basedata_0_wq" />
gernotbelger@9127:       <dc:call-macro name="basedata_1_additionals_wq" />
gernotbelger@9127:       <dc:call-macro name="basedata_2_fixations_wq" />
gernotbelger@9127:       <dc:call-macro name="basedata_3_officials_wq" />
gernotbelger@9127:       <dc:call-macro name="basedata_4_heightmarks-points_wq" />
gernotbelger@9127:       <dc:call-macro name="basedata_5_flood-protections_wq" />
gernotbelger@8941:       <minfo>
gernotbelger@9127:         <dc:call-macro name="sqrelations" />
gernotbelger@9127:         <dc:call-macro name="basedata_7_waterlevels_wq" />
gernotbelger@8941:       </minfo>
felix@7265:     </dc:macro>
felix@7265: 
tom@8377:     <dc:macro name="discharge-curve-user-prototype">
gernotbelger@9127:       <dc:call-macro name="waterlevels-user" />
gernotbelger@9127:       <dc:call-macro name="computed-discharge-curve" />
tom@8377:       <!-- TODO: macro for discharge longitudinal section -->
gernotbelger@9127:       <dc:call-macro name="fix-wq-curve" />
tom@8377:       <!-- TODO: own macro for Vollmer-curve (extract from fix-wq-curve and waterlevels-user) -->
gernotbelger@9127:       <dc:call-macro name="extreme-wq-curve" />
tom@8377:       <minfo>
gernotbelger@9127:         <dc:call-macro name="sqrelations_user" />
tom@8377:       </minfo>
tom@8377:     </dc:macro>
tom@8377: 
aheinecke@6053:     <dc:macro name="longitudinal-section-prototype">
gernotbelger@9127:       <dc:call-macro name="basedata_0" />
gernotbelger@9127:       <dc:call-macro name="basedata_1_additionals" />
gernotbelger@9127:       <dc:call-macro name="basedata_2_fixations" />
gernotbelger@9127:       <dc:call-macro name="basedata_3_officials" />
gernotbelger@9127:       <dc:call-macro name="basedata_4_heightmarks-points" />
gernotbelger@9127:       <dc:call-macro name="basedata_5_flood-protections" />
gernotbelger@9127:       <dc:call-macro name="annotations_per_type" />
felix@7171:       <minfo>
gernotbelger@8941:         <fixanalysis>
gernotbelger@9127:           <dc:call-macro name="basedata_6_delta_w" />
gernotbelger@9127:           <dc:call-macro name="basedata_7_waterlevels" />
gernotbelger@8941:         </fixanalysis>
gernotbelger@9127:         <dc:call-macro name="sedimentloads" />
gernotbelger@9127:         <dc:call-macro name="densities" />
gernotbelger@9127:         <dc:call-macro name="minfo-heights" />
gernotbelger@9127:         <dc:call-macro name="sounding-width" />
gernotbelger@9127:         <dc:call-macro name="morph_width" />
gernotbelger@9127:         <dc:call-macro name="porosities" />
gernotbelger@8941:         <flow_velocities>
gernotbelger@9127:           <dc:call-macro name="flow_velocity_measurements" />
gernotbelger@9127:           <dc:call-macro name="flow_velocity_models" />
gernotbelger@8941:         </flow_velocities>
felix@7171:       </minfo>
gernotbelger@8961: 
gernotbelger@8961:       <sinfo>
gernotbelger@9088:         <sinfo_predefined_flowdepths>
gernotbelger@9127:           <dc:call-macro name="sinfo_predefined_flowdepth-m" />
gernotbelger@9088:         </sinfo_predefined_flowdepths>
gernotbelger@9088: 
mschaefer@9341:         <sinfo_predefined_collision>
mschaefer@9341:           <dc:call-macro name="sinfo_predefined_collision" />
mschaefer@9341:         </sinfo_predefined_collision>
mschaefer@9117: 
mschaefer@9112:         <sinfo_predefined_channel>
gernotbelger@9127:           <dc:call-macro name="sinfo_predefined_channel" />
mschaefer@9112:         </sinfo_predefined_channel>
mschaefer@9112: 
mschaefer@9341:         <sinfo_predefined_infrastructure>
mschaefer@9341:           <dc:call-macro name="sinfo_predefined_infrastructure" />
mschaefer@9341:         </sinfo_predefined_infrastructure>
mschaefer@9116: 
mschaefer@9016:         <sinfo_predefined_tkh>
gernotbelger@9127:           <dc:call-macro name="sinfo_predefined_tkh-berechnung" />
gernotbelger@9127:           <dc:call-macro name="sinfo_predefined_tkh-messung" />
mschaefer@9016:         </sinfo_predefined_tkh>
gernotbelger@9088: 
mschaefer@9033:         <sinfo_predefined_depthevol>
gernotbelger@9127:           <dc:call-macro name="sinfo_predefined_depthevol-aktuell" />
gernotbelger@9127:           <dc:call-macro name="sinfo_predefined_depthevol-etappe" />
mschaefer@9033:         </sinfo_predefined_depthevol>
gernotbelger@9088: 
gernotbelger@8961:       </sinfo>
gernotbelger@9495:     
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
felix@7333:     <dc:macro name="longitudinal-section-user-prototype">
gernotbelger@9088:       <dc:comment> SINFO </dc:comment>
gernotbelger@9127:       <dc:call-macro name="sinfo_flowdepths" />
gernotbelger@9127:       <dc:call-macro name="sinfo_flowdepths_minmax" />
gernotbelger@9127:       <dc:call-macro name="sinfo_flow_depth_development" />
gernotbelger@9127:       <dc:call-macro name="sinfo_tkh" />
mschaefer@9156:       <dc:call-macro name="sinfo_collision" />
mschaefer@9176:       <dc:call-macro name="sinfo_flood_duration" />
gernotbelger@9088: 
teichmann@7419:       <dc:comment> WINFO/DIFF/FIX </dc:comment>
gernotbelger@9127:       <dc:call-macro name="longitudinal" />
gernotbelger@9127:       <dc:call-macro name="differences" />
gernotbelger@9127:       <dc:call-macro name="waterlevels-discharge" />
gernotbelger@9127:       <dc:call-macro name="longitudinal-section-fix" />
gernotbelger@9127:       <dc:call-macro name="longitudinal-section-fix-vollmer" />
gernotbelger@9088: 
teichmann@7419:       <dc:comment> MINFO </dc:comment>
gernotbelger@9127:       <dc:call-macro name="middle_bedheights" />
gernotbelger@9127:       <dc:call-macro name="bedheight_differences" />
gernotbelger@9127:       <dc:call-macro name="bedquality" />
gernotbelger@9127:       <dc:call-macro name="flow-velocity" />
gernotbelger@9127:       <dc:call-macro name="sediment-load" />
gernotbelger@9495: 
mschaefer@9341:       <dc:comment> UINFO </dc:comment>
mschaefer@9341:       <dc:call-macro name="uinfo_salix_line" />
gernotbelger@9495: 
gernotbelger@9495:       <dc:comment> BUNDU </dc:comment>
gernotbelger@9495:       <dc:call-macro name="bundu_bezugswst" />
felix@7333:     </dc:macro>
felix@7333: 
tom@8307:     <!-- porosities -->
rrenkert@7851:     <dc:macro name="porosities">
rrenkert@7851:       <porosities>
gernotbelger@8941:         <dc:context>
gernotbelger@8941:           <dc:statement>
rrenkert@7851:             SELECT DISTINCT
gernotbelger@8941:             p.id AS pid,
gernotbelger@8941:             p.description AS description,
gernotbelger@8941:             d.lower AS depth_lower,
gernotbelger@8941:             d.upper AS depth_upper,
gernotbelger@8941:             p.description || '&lt;BR&gt;' ||
gernotbelger@8941:             'Tiefe: ' || d.lower || ' - ' || d.upper
gernotbelger@8941:             || ' cm &lt;BR&gt;' ||
gernotbelger@8941:             'Zeitraum: ' AS info,
gernotbelger@8941:             t.start_time AS syear,
gernotbelger@8941:             t.stop_time AS eyear
gernotbelger@8941:             FROM porosity p
gernotbelger@8941:             JOIN depths d ON p.depth_id = d.id
gernotbelger@8941:             JOIN time_intervals t ON p.time_interval_id=t.id
gernotbelger@9127:             WHERE p.river_id =
gernotbelger@9127:             ${river_id}
rrenkert@7851:             ORDER BY depth_lower, depth_upper
gernotbelger@8941:           </dc:statement>
gernotbelger@8941:           <dc:if test="dc:has-result()">
gernotbelger@8941:             <dc:for-each>
gernotbelger@8941:               <porosity description="{$depth_lower}-{$depth_upper} cm" factory="porosity" target_out="{$out}" info="{concat($info, dc:date-format('yyyy', $syear),
gernotbelger@9127:                              ' - ', dc:date-format('yyyy', $eyear))}" ids="{$pid};{$description}" />
gernotbelger@8941:             </dc:for-each>
gernotbelger@8941:           </dc:if>
gernotbelger@8941:         </dc:context>
rrenkert@7851:       </porosities>
rrenkert@7851:     </dc:macro>
felix@7333: 
felix@7208:     <dc:macro name="densities">
felix@7208:       <densities>
gernotbelger@8941:         <dc:context>
gernotbelger@8941:           <dc:statement>
felix@7208:             SELECT DISTINCT
gernotbelger@8941:             sd.id AS sdid,
gernotbelger@8941:             d.lower AS depth_lower,
gernotbelger@8941:             d.upper AS depth_upper,
gernotbelger@8941:             min(sdv.year) AS year,
gernotbelger@8941:             sd.description || '&lt;BR&gt;Jahr: ' || min(sdv.year) AS info
gernotbelger@8941:             FROM sediment_density sd
gernotbelger@8941:             JOIN depths d ON sd.depth_id = d.id
gernotbelger@8941:             JOIN sediment_density_values sdv on sdv.sediment_density_id = sd.id
gernotbelger@8941:             WHERE sd.river_id = ${river_id}
felix@7451:             GROUP BY sd.id, sd.description, d.upper, d.lower
gernotbelger@9127:             ORDER BY
gernotbelger@9127:             year, depth_lower, depth_upper
gernotbelger@8941:           </dc:statement>
gernotbelger@8941:           <dc:if test="dc:has-result()">
gernotbelger@8941:             <dc:for-each>
gernotbelger@9127:               <density description="{$depth_lower}-{$depth_upper} cm" factory="sedimentdensity" target_out="{$out}" info="{$info}" ids="{$sdid}" />
gernotbelger@8941:             </dc:for-each>
gernotbelger@8941:           </dc:if>
gernotbelger@8941:         </dc:context>
felix@7208:       </densities>
felix@7208:     </dc:macro>
felix@7208: 
tom@8307:     <!-- sediment load -->
tom@8120:     <dc:macro name="load">
gernotbelger@9127:       <year description="{$timespan}" factory="sedimentload" target_out="{$out}" info="{$info}" ids="{$slid};{$fraction};{$timespan};{$kind}" />
andre@8096:     </dc:macro>
andre@8096: 
tom@8120:     <dc:macro name="load_ls">
gernotbelger@9127:       <year description="{$timespan}" factory="sedimentload_ls" target_out="{$out}" info="{$info}" ids="{$slid};{$timespan};{$kind}" />
felix@7279:     </dc:macro>
felix@7279: 
felix@7278:     <dc:macro name="loads">
tom@8297:       <dc:if test="dc:has-result()">
tom@8297:         <dc:group expr="concat('SQ ', dc:date-format('yyyy', $sqstart), '-',
tom@8297:                         dc:date-format('yyyy', $sqstop))">
tom@8297:           <sq_time description="{dc:group-key()}">
tom@8297:             <dc:group expr="$fraction">
gernotbelger@9127:               <dc:variable name="fraction_name" expr="concat('${', dc:group-key(), '}')" />
tom@8297:               <fraction description="{$fraction_name}">
tom@8297:                 <dc:for-each>
tom@8297:                   <dc:choose>
tom@8297:                     <dc:when test="string-length(dc:get('endyear')) = 0">
gernotbelger@9127:                       <dc:variable name="timespan" type="string" expr="dc:date-format('yyyy', $startyear)" />
tom@8297:                     </dc:when>
tom@8297:                     <dc:otherwise>
gernotbelger@8941:                       <dc:variable name="timespan" type="string" expr="concat(dc:date-format('yyyy',
tom@8297:                                          $startyear), '-',
gernotbelger@9127:                                          dc:date-format('yyyy', $endyear))" />
tom@8297:                     </dc:otherwise>
tom@8297:                   </dc:choose>
tom@8297:                   <dc:if test="$kind = 'official'">
gernotbelger@8941:                     <dc:variable name="info" type="string" expr="concat('Amtliche Epoche&lt;BR&gt;',
gernotbelger@9127:                                        dc:get('info'))" />
tom@8297:                   </dc:if>
gernotbelger@9127:                   <dc:macro-body />
tom@8297:                 </dc:for-each>
tom@8297:               </fraction>
tom@8297:             </dc:group>
tom@8297:           </sq_time>
tom@8297:         </dc:group>
tom@8297:       </dc:if>
felix@7278:     </dc:macro>
tom@8079: 
tom@8120:     <dc:macro name="sedimentloads-filter">
tom@8297:       <years>
tom@8297:         <dc:filter expr="string-length(dc:get('endyear')) = 0 and
gernotbelger@8941:                          $kind != 'official'">
gernotbelger@9127:           <dc:macro-body />
tom@8297:         </dc:filter>
tom@8297:       </years>
tom@8297:       <epochs>
tom@8297:         <dc:filter expr="string-length(dc:get('endyear')) &gt; 0 and
gernotbelger@8941:                          $kind != 'official'">
gernotbelger@9127:           <dc:macro-body />
tom@8297:         </dc:filter>
tom@8297:       </epochs>
tom@8297:       <off_epochs>
gernotbelger@8941:         <dc:filter expr="$kind = 'official'">
gernotbelger@9127:           <dc:macro-body />
tom@8297:         </dc:filter>
tom@8297:       </off_epochs>
tom@8120:     </dc:macro>
tom@8120: 
andre@8096:     <dc:macro name="sedimentloads">
andre@8096:       <sedimentloads>
gernotbelger@9127:         <dc:call-macro name="annotations_sediment_load_ls" />
tom@8079:         <measurement_stations>
tom@8120:           <dc:context>
gernotbelger@9127:             <dc:call-macro name="sedimentload_stations_statement" />
tom@8120:             <dc:call-macro name="sedimentloads-filter">
tom@8079:               <dc:call-macro name="loads">
gernotbelger@9127:                 <dc:call-macro name="load" />
tom@8079:               </dc:call-macro>
tom@8120:             </dc:call-macro>
tom@8120:           </dc:context>
tom@8079:         </measurement_stations>
tom@8079:         <sediment_load_ls>
tom@8120:           <dc:context>
gernotbelger@9127:             <dc:call-macro name="sedimentload_ls_statement" />
tom@8120:             <dc:call-macro name="sedimentloads-filter">
tom@8079:               <dc:call-macro name="loads">
gernotbelger@9127:                 <dc:call-macro name="load_ls" />
tom@8079:               </dc:call-macro>
tom@8120:             </dc:call-macro>
tom@8120:           </dc:context>
tom@8079:         </sediment_load_ls>
andre@8096:       </sedimentloads>
felix@7190:     </dc:macro>
felix@7190: 
tom@8416:     <dc:macro name="sedimentload_stations_statement">
tom@8416:       <dc:statement>
tom@8416:         SELECT DISTINCT
gernotbelger@8941:         sl.id AS slid,
gernotbelger@8941:         slk.kind AS kind,
gernotbelger@8941:         ti.start_time AS startyear,
gernotbelger@8941:         ti.stop_time AS endyear,
gernotbelger@8941:         sq.start_time AS sqstart,
gernotbelger@8941:         sq.stop_time AS sqstop,
gernotbelger@8941:         sq.id AS sqid,
gernotbelger@8941:         gf.name AS fraction,
gernotbelger@8941:         sl.description || '&lt;BR&gt;' ||
gernotbelger@8941:         'Fraktion: ' || gf.lower || ' bis ' || gf.upper ||
gernotbelger@8941:         ' mm&lt;BR&gt;Einheit: t/a' AS info
gernotbelger@8941:         FROM sediment_load sl
gernotbelger@8941:         JOIN sediment_load_kinds slk ON slk.id = sl.kind
gernotbelger@9127:         JOIN
gernotbelger@9127:         sediment_load_values slv
gernotbelger@8941:         ON sl.id = slv.sediment_load_id
gernotbelger@8941:         JOIN measurement_station ms
gernotbelger@8941:         ON ms.id =
gernotbelger@8941:         slv.measurement_station_id
gernotbelger@8941:         JOIN ranges ra ON ms.range_id = ra.id
gernotbelger@8941:         JOIN rivers r ON ra.river_id = r.id
gernotbelger@8941:         JOIN time_intervals ti ON sl.time_interval_id = ti.id
gernotbelger@8941:         LEFT JOIN time_intervals sq ON sl.sq_time_interval_id = sq.id
gernotbelger@8941:         JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
tom@8416:         WHERE r.id = ${river_id}
gernotbelger@9127:         AND CASE
gernotbelger@9127:         WHEN r.km_up = 1 AND ra.b IS NOT NULL
gernotbelger@8941:         THEN ra.b ELSE ra.a END BETWEEN ${fromkm} AND ${tokm}
gernotbelger@8941:         ORDER BY sqstart DESC, sqstop DESC,
gernotbelger@8941:         fraction, startyear DESC, endyear DESC
tom@8416:       </dc:statement>
tom@8416:     </dc:macro>
tom@8416: 
tom@8416:     <dc:macro name="sedimentload_ls_statement">
tom@8416:       <dc:statement>
tom@8416:         SELECT DISTINCT
gernotbelger@8941:         sl.id AS slid,
gernotbelger@8941:         slk.kind AS kind,
gernotbelger@8941:         ti.start_time AS startyear,
gernotbelger@8941:         ti.stop_time AS endyear,
gernotbelger@8941:         sq.start_time AS sqstart,
gernotbelger@8941:         sq.stop_time AS sqstop,
gernotbelger@8941:         sq.id AS sqid,
gernotbelger@8941:         gf.name AS fraction,
gernotbelger@8941:         sl.description || '&lt;BR&gt;' ||
gernotbelger@8941:         'Fraktion: ' || gf.lower || ' bis ' || gf.upper ||
gernotbelger@8941:         ' mm&lt;BR&gt;Einheit: ' || u.name AS info
gernotbelger@8941:         FROM sediment_load_ls sl
gernotbelger@8941:         JOIN sediment_load_kinds slk ON slk.id = sl.kind
gernotbelger@8941:         JOIN rivers r ON sl.river_id = r.id
gernotbelger@8941:         JOIN sediment_load_ls_values slv
gernotbelger@8941:         ON sl.id = slv.sediment_load_ls_id
gernotbelger@8941:         JOIN time_intervals ti ON sl.time_interval_id = ti.id
gernotbelger@8941:         LEFT JOIN time_intervals sq ON sl.sq_time_interval_id = sq.id
gernotbelger@8941:         JOIN grain_fraction gf ON gf.id = sl.grain_fraction_id
gernotbelger@8941:         JOIN units u ON sl.unit_id = u.id
gernotbelger@8941:         WHERE r.id = ${river_id}
gernotbelger@8941:         AND slv.station BETWEEN ${fromkm} AND ${tokm}
gernotbelger@9127:         ORDER BY sqstart
gernotbelger@9127:         DESC, sqstop DESC,
gernotbelger@8941:         fraction, startyear DESC, endyear DESC
tom@8416:       </dc:statement>
tom@8416:     </dc:macro>
tom@8416: 
tom@8307:     <!-- annotations -->
tom@8389:     <dc:macro name="annotations">
gernotbelger@9127:       <annotation factory="annotations" ids="{$river_id}" target_out="{$out}" />
tom@8389:     </dc:macro>
tom@8389: 
aheinecke@6053:     <dc:macro name="annotations_per_type">
aheinecke@6053:       <annotations>
aheinecke@6053:         <dc:context>
gernotbelger@9127:           <all_annotations factory="annotations" ids="{$river_id}" target_out="{$out}" />
aheinecke@6053:           <dc:statement>
gernotbelger@8941:             SELECT id AS anno_id,
gernotbelger@8941:             name AS anno_description
aheinecke@6053:             FROM annotation_types
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:for-each>
gernotbelger@9127:             <annotation name="{$anno_description}" factory="annotations" target_out="{$out}" ids="{$river_id}:{$anno_description}" />
aheinecke@6053:           </dc:for-each>
aheinecke@6053:         </dc:context>
aheinecke@6053:       </annotations>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8072:     <dc:macro name="annotations_sediment_load_ls">
tom@7665:       <sources_sinks>
tom@7665:         <dc:context>
tom@7665:           <dc:statement>
gernotbelger@8941:             SELECT id AS anno_id,
gernotbelger@8941:             name AS anno_description
tom@7665:             FROM annotation_types
gernotbelger@8941:             WHERE name LIKE 'Quelle %' OR name LIKE 'Senke %'
tom@7665:           </dc:statement>
tom@7665:           <dc:for-each>
gernotbelger@9127:             <annotation name="{$anno_description}" factory="annotations" target_out="{$out}" ids="{$river_id}:{$anno_description}" />
tom@7665:           </dc:for-each>
tom@7665:         </dc:context>
tom@7665:       </sources_sinks>
tom@7665:     </dc:macro>
tom@7665: 
aheinecke@6053:     <dc:macro name="qsectors">
gernotbelger@9127:       <qsector factory="qsectors" ids="{$river_id}" target_out="{$out}" />
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="flood-map-recommended">
aheinecke@6053:       <kilometrage>
gernotbelger@9127:         <riveraxis factory="riveraxis" ids="{$river_id}" target_out="{$out}" />
aheinecke@6053:       </kilometrage>
aheinecke@6053:       <rastermap>
gernotbelger@9127:         <background factory="wmsbackground" ids="{$river_id}" target_out="{$out}" />
aheinecke@6053:       </rastermap>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8419:     <!-- bed heights -->
rrenkert@7961:     <dc:macro name="minfo-heights-diff">
tom@8431:       <dc:context>
tom@8431:         <dc:statement>
gernotbelger@8941:           WITH sta
gernotbelger@8941:           AS (SELECT bhs.id,
gernotbelger@8941:           bhs.description,
gernotbelger@8941:           bhsv.station,
gernotbelger@8941:           bhs.year
gernotbelger@8941:           FROM bed_height bhs
gernotbelger@8941:           JOIN bed_height_values bhsv
gernotbelger@8941:           ON bhsv.bed_height_id = bhs.id
gernotbelger@8941:           WHERE bhs.river_id = ${river_id}
gernotbelger@8941:           AND bhsv.station BETWEEN ${fromkm} AND ${tokm}),
gernotbelger@8941:           csta
gernotbelger@8941:           AS (SELECT b1.id AS b1id,
gernotbelger@8941:           b1.description AS b1desc,
gernotbelger@8941:           b1.year AS b1year,
gernotbelger@8941:           b2.id AS b2id,
gernotbelger@8941:           b2.description AS b2desc,
gernotbelger@8941:           b2.year AS b2year
gernotbelger@8941:           FROM sta b1
gernotbelger@8941:           JOIN sta b2
gernotbelger@9127:           ON
gernotbelger@9127:           b1.station = b2.station
gernotbelger@8941:           AND b1.id &lt;&gt; b2.id
gernotbelger@8941:           AND (b1.year &gt; b2.year OR b1.year IS NULL))
gernotbelger@8941:           SELECT
gernotbelger@8941:           DISTINCT b1id, b1desc, b1year,
gernotbelger@8941:           b2id, b2desc, b2year
gernotbelger@8941:           FROM csta
gernotbelger@8941:           ORDER BY b1desc, b2desc
tom@8431:         </dc:statement>
tom@8431:         <dc:if test="dc:has-result()">
tom@8431:           <bedheights>
gernotbelger@9127:             <dc:call-macro name="bed-heights-single-diff" />
gernotbelger@9127:             <dc:call-macro name="bed-heights-epoch-diff" />
tom@8431:           </bedheights>
tom@8431:         </dc:if>
tom@8431:       </dc:context>
rrenkert@7961:     </dc:macro>
rrenkert@7961: 
rrenkert@7961:     <dc:macro name="bed-heights-single-diff">
tom@8009:       <dc:filter expr="not(contains(dc:lowercase($b1desc), 'epoche'))">
rrenkert@7961:         <years>
gernotbelger@9127:           <dc:call-macro name="minfo-heights-diff-tree" />
rrenkert@7961:         </years>
rrenkert@7961:       </dc:filter>
rrenkert@7961:     </dc:macro>
rrenkert@7961: 
rrenkert@7961:     <dc:macro name="bed-heights-epoch-diff">
tom@8009:       <dc:filter expr="contains(dc:lowercase($b1desc), 'epoche')">
rrenkert@7961:         <epochs>
gernotbelger@9127:           <dc:call-macro name="minfo-heights-diff-tree" />
rrenkert@7961:         </epochs>
rrenkert@7961:       </dc:filter>
rrenkert@7961:     </dc:macro>
rrenkert@7961: 
rrenkert@7961:     <dc:macro name="minfo-heights-diff-tree">
rrenkert@7975:       <dc:group expr="dc:coalesce($b1year, 'sonstige')">
rrenkert@7970:         <minfo-diff name="{dc:group-key()}">
rrenkert@7961:           <dc:for-each>
rrenkert@7970:             <dc:choose>
rrenkert@7970:               <dc:when test="dc:group-key() = $b1year">
gernotbelger@9127:                 <height factory="bedheight" target_out="{$out}" ids="bedheight-single-{$b1id}-{$b1desc}#bedheight-single-{$b2id}-{$b2desc}" info="{$b1desc}#{$b2desc}" description="{$b1desc} - {$b2desc}" />
rrenkert@7970:               </dc:when>
rrenkert@7970:               <dc:when test="dc:group-key() = 'sonstige'">
gernotbelger@9127:                 <height factory="bedheight" target_out="{$out}" ids="bedheight-single-{$b1id}-{$b1desc}#bedheight-single-{$b2id}-{$b2desc}" info="{$b1desc}#{$b2desc}" description="{$b1desc} - {$b2desc}" />
gernotbelger@9127:                 <height factory="bedheight" target_out="{$out}" ids="bedheight-single-{$b2id}-{$b1desc}#bedheight-single-{$b1id}-{$b2desc}" info="{$b2desc}#{$b1desc}" description="{$b2desc} - {$b1desc}" />
rrenkert@7970:               </dc:when>
rrenkert@7970:             </dc:choose>
rrenkert@7961:           </dc:for-each>
rrenkert@7970:         </minfo-diff>
rrenkert@7961:       </dc:group>
rrenkert@7961:     </dc:macro>
rrenkert@7961: 
tom@8419:     <dc:macro name="minfo-heights">
tom@8419:       <bedheights>
gernotbelger@9127:         <dc:call-macro name="bed-heights-single" />
gernotbelger@9127:         <dc:call-macro name="bed-heights-epoch" />
tom@8419:       </bedheights>
tom@8141:     </dc:macro>
tom@8141: 
gernotbelger@9103:     <!-- Show all three MW, TL, and KL bedheights -->
gernotbelger@9103:     <dc:macro name="bed-heights-factory_MW_TW_KL">
gernotbelger@9103:       <dc:for-each>
gernotbelger@9103:         <dc:if test="$bedh_height_count > 0">
gernotbelger@9127:           <height factory="bedheight" target_out="{$out}" ids="bedheight-single-{$bedh_id}-{$bedh_year}-MW-{$bedh_descr}" info="{$info}" description="MW-{$bedh_descr}" />
gernotbelger@9103:         </dc:if>
gernotbelger@9103:         <dc:if test="$bedh_min_count > 0">
gernotbelger@9127:           <height factory="bedheight" target_out="{$out}" ids="bedheight-singleMin-{$bedh_id}-{$bedh_year}-TW-{$bedh_descr}" info="{$info}" description="TW-{$bedh_descr}" />
gernotbelger@9103:         </dc:if>
gernotbelger@9103:         <dc:if test="$bedh_max_count > 0">
gernotbelger@9127:           <height factory="bedheight" target_out="{$out}" ids="bedheight-singleMax-{$bedh_id}-{$bedh_year}-KL-{$bedh_descr}" info="{$info}" description="KL-{$bedh_descr}" />
gernotbelger@9103:         </dc:if>
gernotbelger@9103:       </dc:for-each>
gernotbelger@8961:     </dc:macro>
gernotbelger@8961: 
gernotbelger@9103:     <!-- Show only MW bed height and name it in a neutral way -->
gernotbelger@9103:     <dc:macro name="bed-heights-factory_MW">
tom@8141:       <dc:for-each>
gernotbelger@9103:         <dc:if test="$bedh_height_count > 0">
gernotbelger@9233:           <!-- REMARK: addition 'yaer' attribute is used by intelligent datacage filter of SINFO -->
gernotbelger@9233:           <height factory="bedheight" target_out="{$out}" ids="bedheight-single-{$bedh_id}-{$bedh_year}-{$bedh_descr}" info="{$info}" description="{$bedh_descr}" year="{$bedh_year}" />
gernotbelger@9103:         </dc:if>
tom@8141:       </dc:for-each>
tom@8141:     </dc:macro>
tom@8141: 
aheinecke@6053:     <dc:macro name="bed-heights-single">
aheinecke@6053:       <single>
aheinecke@6053:         <dc:context>
gernotbelger@9299:           <dc:call-macro name="bed-heights-statement" />
gernotbelger@9127:           <dc:if test="dc:has-result()">
gernotbelger@9127:             <dc:group expr="dc:coalesce($bedh_year, 'sonstige')">
gernotbelger@9233:               <heights name="{dc:group-key()}" description="{dc:group-key()}">
gernotbelger@9127:                 <dc:call-macro name="bed-heights-factory_MW_TW_KL" />
gernotbelger@9127:               </heights>
gernotbelger@9127:             </dc:group>
gernotbelger@9127:           </dc:if>
gernotbelger@9103:         </dc:context>
gernotbelger@9103:       </single>
gernotbelger@9103:     </dc:macro>
gernotbelger@9103: 
gernotbelger@9103:     <!-- Show bed heights that have MW values with a neutral name -->
gernotbelger@9103:     <dc:macro name="bed-heights-single-MW">
gernotbelger@9103:       <single>
gernotbelger@9103:         <dc:context>
gernotbelger@9127:           <dc:call-macro name="bed-heights-statement" />
gernotbelger@9127:           <dc:filter expr="$bedh_height_count">
gernotbelger@9127:             <dc:if test="dc:has-result()">
gernotbelger@9127:               <dc:group expr="dc:coalesce($bedh_year, 'sonstige')">
gernotbelger@9233:                 <heights name="{dc:group-key()}" description="{dc:group-key()}">
gernotbelger@9127:                   <dc:call-macro name="bed-heights-factory_MW" />
gernotbelger@9127:                 </heights>
gernotbelger@9127:               </dc:group>
gernotbelger@9127:             </dc:if>
gernotbelger@9127:           </dc:filter>
gernotbelger@9103:         </dc:context>
gernotbelger@9103:       </single>
gernotbelger@9103:     </dc:macro>
gernotbelger@9103: 
gernotbelger@9103:     <!-- Show bed heights that have KL and TW values with a neutral name -->
gernotbelger@9103:     <dc:macro name="bed-heights-single-KL_TW">
gernotbelger@9103:       <single>
gernotbelger@9103:         <dc:context>
gernotbelger@9127:           <dc:call-macro name="bed-heights-statement" />
gernotbelger@9127:           <dc:filter expr="$bedh_max_count > 0 and $bedh_min_count > 0">
gernotbelger@9127:             <dc:if test="dc:has-result()">
gernotbelger@9127:               <dc:group expr="dc:coalesce($bedh_year, 'sonstige')">
gernotbelger@9233:                 <heights name="{dc:group-key()}" description="{dc:group-key()}">
gernotbelger@9127:                   <dc:call-macro name="bed-heights-factory_MW" />
gernotbelger@9127:                 </heights>
gernotbelger@9127:               </dc:group>
gernotbelger@9127:             </dc:if>
gernotbelger@9127:           </dc:filter>
aheinecke@6053:         </dc:context>
aheinecke@6053:       </single>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="bed-heights-epoch">
aheinecke@6053:       <epoch>
aheinecke@6053:         <dc:context>
gernotbelger@9127:           <dc:call-macro name="bed-heights-statement" />
tom@8141:           <dc:filter expr="contains($bedh_descr, 'Epoche')">
gernotbelger@9127:             <dc:call-macro name="bed-heights-factory_MW_TW_KL" />
tom@8141:           </dc:filter>
aheinecke@6053:         </dc:context>
aheinecke@6053:       </epoch>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
tom@8431:     <dc:macro name="sounding-width-factory">
tom@8431:       <dc:for-each>
gernotbelger@9127:         <height factory="bedheight" target_out="{$out}" ids="bedheight-soundings-{$bedh_id}-{$bedh_year}-{$bedh_descr}" info="{$info}" description="{$bedh_descr}" />
tom@8431:       </dc:for-each>
tom@8431:     </dc:macro>
tom@8431: 
tom@8431:     <dc:macro name="sounding-width">
tom@8431:       <dc:context>
gernotbelger@9127:         <dc:call-macro name="bed-heights-statement" />
tom@8431:         <dc:if test="dc:has-result()">
tom@8431:           <soundings_width>
gernotbelger@9127:             <dc:call-macro name="sounding-width-factory" />
tom@8431:           </soundings_width>
tom@8431:         </dc:if>
tom@8431:       </dc:context>
tom@8431:     </dc:macro>
tom@8431: 
tom@8431:     <dc:macro name="sounding-width-recommendations">
tom@8431:       <dc:context>
gernotbelger@9127:         <dc:call-macro name="bed-heights-statement" />
tom@8431:         <dc:filter expr="dc:contains($diffids, concat(';', $bedh_descr, ']'))">
gernotbelger@9127:           <dc:call-macro name="sounding-width-factory" />
tom@8431:         </dc:filter>
tom@8431:       </dc:context>
tom@8431:     </dc:macro>
tom@8431: 
tom@8419:     <dc:macro name="bed-heights-statement">
tom@8419:       <dc:statement>
gernotbelger@8963:         SELECT bhs.id AS bedh_id,
gernotbelger@8963:         bhs.year AS bedh_year,
gernotbelger@8963:         bhs.description AS bedh_descr,
gernotbelger@8963:         bhs.description || '&lt;BR&gt;Jahr: ' || bhs.year ||
gernotbelger@8963:         '&lt;BR&gt;Aufnahmeart: ' || bht.name ||
gernotbelger@8963:         '&lt;BR&gt;Lagesystem: ' || ls.name ||
gernotbelger@8963:         '&lt;BR&gt;Höhensystem: ' || cur_em.name ||
gernotbelger@8963:         '&lt;BR&gt;ursprüngliches Höhensystem: ' || old_em.name ||
gernotbelger@8963:         '&lt;BR&gt;Strecke: ' || round(r.a, 1) || '-' || round(r.b, 1) ||
gernotbelger@8963:         '&lt;BR&gt;Auswerter: ' || bhs.evaluation_by AS info,
mschaefer@9111:         COALESCE(bhv.height_count,0) AS bedh_height_count,
mschaefer@9111:         COALESCE(bhv.min_count,0) AS bedh_min_count,
mschaefer@9111:         COALESCE(bhv.max_count,0) AS bedh_max_count
gernotbelger@8963:         FROM bed_height bhs
gernotbelger@8963:         JOIN bed_height_type bht ON bht.id = bhs.type_id
gernotbelger@8963:         JOIN location_system ls ON ls.id = location_system_id
gernotbelger@8963:         JOIN elevation_model cur_em ON cur_em.id = cur_elevation_model_id
gernotbelger@9127:         LEFT JOIN
gernotbelger@9127:         elevation_model old_em
gernotbelger@8963:         ON old_em.id = old_elevation_model_id
gernotbelger@8963:         LEFT JOIN ranges r ON r.id = range_id
gernotbelger@8963:         LEFT JOIN (SELECT bed_height_id, COUNT(height) AS height_count, COUNT(min_height) AS min_count, COUNT(max_height) AS max_count
mschaefer@9111:         FROM bed_height_values
mschaefer@9111:         WHERE (station BETWEEN (${fromkm}-0.0001) AND (${tokm}+0.0001))
mschaefer@9111:         GROUP BY bed_height_id
gernotbelger@8963:         ) bhv ON bhs.id = bhv.bed_height_id
gernotbelger@9127:         WHERE bhs.river_id =
gernotbelger@9127:         ${river_id}
tom@8419:       </dc:statement>
tom@8419:     </dc:macro>
tom@8419: 
tom@8419:     <!-- flow velocity -->
felix@7292:     <dc:macro name="flow_velocity_models">
felix@7292:       <dc:context>
felix@7292:         <dc:statement>
gernotbelger@8941:           SELECT fvm.id AS fvmid,
gernotbelger@8941:           fvm.description AS fvmd,
gernotbelger@8941:           dz.gauge_name AS gauge,
gernotbelger@8941:           dz.value AS q,
gernotbelger@8941:           dz.upper_discharge AS upperQ,
gernotbelger@8941:           dz.lower_discharge AS lowerQ
felix@7292:           FROM flow_velocity_model fvm
tom@8502:           JOIN discharge_zone dz ON dz.id = fvm.discharge_zone_id
felix@7292:           WHERE dz.river_id = ${river_id}
felix@7409:           ORDER BY dz.value
felix@7292:         </dc:statement>
felix@7292:         <dc:if test="dc:has-result()">
felix@7292:           <flowvelocitymodel>
felix@7292:             <dc:for-each>
gernotbelger@9282:               <measurement_value name="{$fvmd}" description="{$fvmd}" ids="{$fvmid}" factory="flowvelocitymodel" info="{$lowerQ} - {$upperQ}&lt;BR&gt;
tom@8141:                                        Pegel {$gauge}&lt;BR&gt;
gernotbelger@9127:                                        Q = {$q} m3/s" target_out="{$out}" />
felix@7292:             </dc:for-each>
felix@7292:           </flowvelocitymodel>
felix@7292:         </dc:if>
felix@7292:       </dc:context>
felix@7292:     </dc:macro>
felix@7292: 
felix@7292: 
aheinecke@6053:     <dc:macro name="flow_velocity_measurements">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
gernotbelger@8941:           SELECT id AS fvmid,
gernotbelger@8941:           description AS fvmd
aheinecke@6053:           FROM flow_velocity_measurements WHERE river_id = ${river_id}
aheinecke@6053:         </dc:statement>
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <flowvelocitymeasurement>
aheinecke@6053:             <dc:for-each>
gernotbelger@9282:               <flow_velocity_measurement name="{$fvmd}" description="{$fvmd}">
aheinecke@6053:                 <dc:context>
aheinecke@6053:                   <dc:statement>
aheinecke@6053:                     SELECT id, description, station, datetime, v, w, q
aheinecke@6053:                     FROM flow_velocity_measure_values
aheinecke@6053:                     WHERE measurements_id = ${fvmid}
gernotbelger@8941:                     AND station BETWEEN ${fromkm} AND ${tokm}
aheinecke@6053:                   </dc:statement>
aheinecke@6053:                   <dc:for-each>
gernotbelger@9282:                     <measurement_value name="{$description} - {$station} - {$datetime}" description="{$description} - {$station} - {$datetime}" ids="{$id}" factory="flowvelocity" target_out="{$out}" />
aheinecke@6053:                   </dc:for-each>
aheinecke@6053:                 </dc:context>
aheinecke@6053:               </flow_velocity_measurement>
aheinecke@6053:             </dc:for-each>
aheinecke@6053:           </flowvelocitymeasurement>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="morph_width">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
gernotbelger@8941:           SELECT id AS width_id
aheinecke@6053:           FROM morphologic_width
aheinecke@6053:           WHERE river_id = ${river_id}
aheinecke@6053:         </dc:statement>
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <morph_width>
aheinecke@6053:             <dc:for-each>
aheinecke@6053:               <dc:context>
aheinecke@6053:                 <dc:statement>
aheinecke@6053:                   SELECT min(station) AS from_station,
gernotbelger@8941:                   max(station) AS to_station
aheinecke@6053:                   FROM morphologic_width_values
aheinecke@6053:                   WHERE morphologic_width_id = ${width_id}
aheinecke@5976:                 </dc:statement>
aheinecke@5976:                 <dc:for-each>
gernotbelger@9282:                   <morphologic-width name="{$from_station} - {$to_station}" description="{$from_station} - {$to_station}" ids="{$width_id}" factory="morph-width" target_out="{$out}" />
teichmann@5523:                 </dc:for-each>
teichmann@5523:               </dc:context>
aheinecke@6053:             </dc:for-each>
aheinecke@6053:           </morph_width>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
aheinecke@5405: 
aheinecke@7236:     <dc:macro name="sqrelations">
aheinecke@7236:       <dc:context>
aheinecke@7236:         <dc:statement>
tom@8308:           SELECT
gernotbelger@8941:           ti.start_time AS start_time,
gernotbelger@8941:           ti.stop_time AS stop_time,
gernotbelger@8941:           ms.name AS station_name,
gernotbelger@8941:           lower(sqv.parameter) AS parameter,
gernotbelger@8941:           sqv.id AS sqvid,
gernotbelger@8941:           ra.a AS station_km
aheinecke@7236:           FROM sq_relation sq
tom@8308:           JOIN time_intervals ti ON ti.id = sq.time_interval_id
aheinecke@7236:           JOIN sq_relation_value sqv ON sqv.sq_relation_id = sq.id
aheinecke@7236:           JOIN measurement_station ms ON sqv.measurement_station_id = ms.id
gernotbelger@9127:           JOIN ranges ra ON ms.range_id =
gernotbelger@9127:           ra.id
tom@8308:           JOIN rivers r ON r.id = ra.river_id
aheinecke@7236:           WHERE r.id = ${river_id}
tom@8308:           ORDER BY start_time, stop_time
aheinecke@7236:         </dc:statement>
aheinecke@7236:         <dc:if test="dc:has-result()">
aheinecke@7236:           <sq_relations>
tom@8308:             <dc:group expr="concat('Parameter ', dc:uppercase($parameter))">
tom@8308:               <parameter description="{dc:group-key()}">
tom@8308:                 <dc:group expr="$station_km" type="number">
tom@8308:                   <dc:group expr="concat('km ', $station_km, ': ',
tom@8308:                                   $station_name)">
tom@8308:                     <station description="{dc:group-key()}">
tom@8308:                       <dc:for-each>
gernotbelger@8941:                         <dc:variable name="combined_desc" expr="concat(dc:date-format('yyyy',
tom@8308:                                            $start_time), ' bis ',
tom@8308:                                            dc:date-format('yyyy',
gernotbelger@9127:                                            $stop_time))" />
gernotbelger@9127:                         <sqvalue factory="sqrelationdatacage" target_out="{$out}" ids="{$sqvid};{dc:uppercase($parameter)} - {$station_name}: {$combined_desc}" description="{$combined_desc}" />
tom@8308:                       </dc:for-each>
tom@8308:                     </station>
tom@8308:                   </dc:group>
tom@8308:                 </dc:group>
tom@8308:               </parameter>
tom@8308:             </dc:group>
aheinecke@7236:           </sq_relations>
aheinecke@7236:         </dc:if>
aheinecke@7236:       </dc:context>
aheinecke@7236:     </dc:macro>
aheinecke@7236: 
aheinecke@6053:     <!-- Floodmap part -->
aheinecke@6053:     <dc:macro name="flood-map-complete">
gernotbelger@9127:       <dc:call-macro name="flood-map-buildings" />
gernotbelger@9127:       <dc:call-macro name="flood-map-gaugelocations" />
gernotbelger@9127:       <dc:call-macro name="floodmarks" />
aheinecke@6053:       <hws>
gernotbelger@9127:         <dc:call-macro name="hwslines" />
gernotbelger@9127:         <dc:call-macro name="hwspoints" />
aheinecke@6053:       </hws>
gernotbelger@9127:       <dc:call-macro name="flood-map-routing" />
aheinecke@6053:       <hydrboundaries>
gernotbelger@9127:         <dc:call-macro name="flood-map-floodplain" />
gernotbelger@9127:         <dc:call-macro name="flood-map-hydr-boundaries" />
aheinecke@6053:       </hydrboundaries>
gernotbelger@9127:       <dc:call-macro name="flood-map-uesk" />
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="flood-map-routing">
aheinecke@6053:       <route_data>
gernotbelger@9127:         <dc:call-macro name="flood-map-qps" />
gernotbelger@9127:         <dc:call-macro name="flood-map-fixpoints" />
gernotbelger@9127:         <dc:call-macro name="flood-map-km" />
gernotbelger@9127:         <dc:call-macro name="flood-map-riveraxis" />
aheinecke@6053:       </route_data>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="flood-map-hydr-boundaries">
aheinecke@6053:       <bfg_model>
gernotbelger@9127:         <dc:call-macro name="flood-map-hydr-boundaries-poly" />
gernotbelger@9127:         <dc:call-macro name="flood-map-hydr-boundaries-lines" />
aheinecke@6053:       </bfg_model>
gernotbelger@9127:       <dc:call-macro name="flood-map-hydr-boundaries-state" />
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="flood-map-dem">
aheinecke@6053:       <dems>
aheinecke@6053:         <dc:context>
aheinecke@6053:           <dc:statement>
gernotbelger@8941:             SELECT d.id AS dem_id,
gernotbelger@8941:             r.a AS dem_lower,
gernotbelger@8941:             r.b AS dem_upper,
gernotbelger@8941:             d.name AS name,
gernotbelger@8941:             t.start_time AS start_time,
gernotbelger@8941:             t.stop_time AS stop_time,
gernotbelger@8941:             'Projektion: ' || d.projection || '&lt;BR&gt;' ||
gernotbelger@8941:             'Rasterweite: ' || d.resolution || 'm&lt;BR&gt;' ||
gernotbelger@8941:             'Format: ' || d.format || '&lt;BR&gt;' ||
gernotbelger@8941:             'Zeitraum: '
gernotbelger@8941:             AS info
aheinecke@6053:             FROM dem d
gernotbelger@8941:             JOIN ranges r ON d.range_id = r.id
gernotbelger@9127:             LEFT JOIN time_intervals t ON d.time_interval_id
gernotbelger@9127:             = t.id
gernotbelger@8941:             WHERE d.river_id = ${river_id}
gernotbelger@8941:             AND NOT((${tokm} &lt; r.a) or (${fromkm} &gt; r.b))
gernotbelger@8941:           </dc:statement>
gernotbelger@8941:           <dc:for-each>
gernotbelger@9127:             <dem factory="demfactory" target_out="{$out}" ids="{$dem_id}" name="{$name}" info="{$info}{dc:date-format('yyyy', $start_time)} - {dc:date-format('yyyy', $stop_time)}" />
aheinecke@6053:           </dc:for-each>
aheinecke@6053:         </dc:context>
aheinecke@6053:       </dems>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="filter_hws_ddg">
aheinecke@6053:       <dc:macro name="durchlass_damm_graben">
aheinecke@6053:         <dc:macro name="ddg_factory">
aheinecke@6053:           <dc:for-each>
gernotbelger@9127:             <hws factory="hwsfactory" name="{$hws_name}" target_out="{$out}" />
aheinecke@6053:           </dc:for-each>
aheinecke@5976:         </dc:macro>
aheinecke@5976: 
aheinecke@6053:         <dc:filter expr="$hws_kind=1">
aheinecke@6053:           <dc:if test="dc:has-result()">
gernotbelger@8941:             <Durchlass>
gernotbelger@9127:               <dc:call-macro name="ddg_factory" />
gernotbelger@8941:             </Durchlass>
aheinecke@6053:           </dc:if>
aheinecke@6053:         </dc:filter>
aheinecke@5976: 
aheinecke@6053:         <dc:filter expr="$hws_kind=2">
aheinecke@6053:           <dc:if test="dc:has-result()">
gernotbelger@8941:             <Damm>
gernotbelger@9127:               <dc:call-macro name="ddg_factory" />
gernotbelger@8941:             </Damm>
aheinecke@6053:           </dc:if>
aheinecke@6053:         </dc:filter>
teichmann@5523: 
aheinecke@6053:         <dc:filter expr="$hws_kind=3">
aheinecke@6053:           <dc:if test="dc:has-result()">
gernotbelger@8941:             <Graben>
gernotbelger@9127:               <dc:call-macro name="ddg_factory" />
gernotbelger@8941:             </Graben>
aheinecke@6053:           </dc:if>
aheinecke@6053:         </dc:filter>
aheinecke@6053:       </dc:macro>
teichmann@5523: 
aheinecke@6053:       <dc:filter expr="$hws_official=1">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <official>
gernotbelger@9127:             <dc:call-macro name="durchlass_damm_graben" />
aheinecke@6053:           </official>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
teichmann@5524: 
aheinecke@6053:       <dc:filter expr="$hws_official=0">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <inofficial>
gernotbelger@9127:             <dc:call-macro name="durchlass_damm_graben" />
aheinecke@6053:           </inofficial>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
aheinecke@6053:     </dc:macro>
teichmann@5524: 
aheinecke@6054:     <dc:macro name="flood-map-hws-lines">
aheinecke@6054:       <dc:context>
aheinecke@6054:         <dc:statement>
aheinecke@6054:           SELECT DISTINCT
gernotbelger@8941:           name AS hws_name,
aheinecke@6054:           official AS hws_official,
gernotbelger@8941:           kind_id AS hws_kind
aheinecke@6054:           FROM hws_lines
aheinecke@6054:           WHERE river_id = ${river_id}
aheinecke@6054:         </dc:statement>
aheinecke@6054:         <dc:if test="dc:has-result()">
aheinecke@6054:           <lines>
gernotbelger@9127:             <dc:call-macro name="filter_hws_ddg" />
aheinecke@6054:           </lines>
aheinecke@6054:         </dc:if>
aheinecke@6054:       </dc:context>
aheinecke@6054:     </dc:macro>
aheinecke@6054: 
aheinecke@6054:     <dc:macro name="flood-map-hws-points">
aheinecke@6054:       <dc:context>
aheinecke@6054:         <dc:statement>
aheinecke@6054:           SELECT DISTINCT
gernotbelger@8941:           name AS hws_name,
aheinecke@6054:           official AS hws_official,
gernotbelger@8941:           kind_id AS hws_kind
aheinecke@6054:           FROM hws_points
aheinecke@6054:           WHERE river_id = ${river_id}
aheinecke@6054:         </dc:statement>
aheinecke@6054:         <dc:if test="dc:has-result()">
aheinecke@6054:           <points>
gernotbelger@9127:             <dc:call-macro name="filter_hws_ddg" />
aheinecke@6054:           </points>
aheinecke@6054:         </dc:if>
aheinecke@6054:       </dc:context>
aheinecke@6054:     </dc:macro>
aheinecke@6054: 
aheinecke@6053:     <dc:macro name="flood-map-hydr-boundaries-state">
aheinecke@6053:       <federal>
aheinecke@6053:         <dc:context>
aheinecke@6053:           <dc:statement>
aheinecke@6053:             SELECT DISTINCT
gernotbelger@8941:             name
aheinecke@6053:             FROM hydr_boundaries
aheinecke@6053:             WHERE river_id = ${river_id}
gernotbelger@8941:             AND kind = 2
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:for-each>
gernotbelger@9127:             <line factory="wmshydrboundariesfactory" target_out="{$out}" ids="{$river_id};{$name};2" name="{$name}" />
aheinecke@6053:           </dc:for-each>
aheinecke@6053:         </dc:context>
aheinecke@6053:         <dc:context>
aheinecke@6053:           <dc:statement>
aheinecke@6053:             SELECT DISTINCT
gernotbelger@8941:             name
aheinecke@6053:             FROM hydr_boundaries_poly
aheinecke@6053:             WHERE river_id = ${river_id}
gernotbelger@8941:             AND kind = 2
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:for-each>
gernotbelger@9127:             <line factory="wmshydrboundariespolyfactory" target_out="{$out}" ids="{$river_id};{$name};2" name="{$name}" />
aheinecke@6053:           </dc:for-each>
aheinecke@6053:         </dc:context>
aheinecke@6053:       </federal>
aheinecke@6053:     </dc:macro>
teichmann@5524: 
aheinecke@6053:     <dc:macro name="flood-map-hydr-boundaries-lines">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
aheinecke@6053:           SELECT DISTINCT
gernotbelger@8941:           name
aheinecke@6053:           FROM hydr_boundaries
aheinecke@6053:           WHERE river_id = ${river_id}
gernotbelger@8941:           AND kind = 1
aheinecke@6053:         </dc:statement>
aheinecke@6053:         <dc:comment> What about all other line kinds?</dc:comment>
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <lines>
aheinecke@6053:             <dc:for-each>
gernotbelger@9127:               <line factory="wmshydrboundariesfactory" target_out="{$out}" ids="{$river_id};{$name};1" name="{$name}" />
aheinecke@6053:             </dc:for-each>
aheinecke@6053:           </lines>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
teichmann@5524: 
aheinecke@6053:     <dc:macro name="flood-map-hydr-boundaries-poly">
aheinecke@6053:       <areas>
aheinecke@6053:         <dc:context>
aheinecke@6053:           <dc:statement>
aheinecke@6053:             SELECT DISTINCT
gernotbelger@8941:             b.sectie AS sectie_id,
gernotbelger@8941:             sk.name AS sectie
aheinecke@6053:             FROM hydr_boundaries_poly b
gernotbelger@8941:             JOIN sectie_kinds sk ON b.sectie = sk.id
aheinecke@6053:             WHERE b.river_id = ${river_id}
gernotbelger@8941:             AND b.kind = 1
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:if test="dc:has-result()">
aheinecke@6053:             <sobek_areas>
aheinecke@6053:               <dc:for-each>
gernotbelger@9127:                 <boundary name="{$sectie}" factory="wmshydrboundariespolyfactory" target_out="{$out}" ids="{$river_id};{$sectie};1;{$sectie_id};-1" />
aheinecke@6053:               </dc:for-each>
aheinecke@6053:             </sobek_areas>
aheinecke@6053:           </dc:if>
aheinecke@6053:         </dc:context>
aheinecke@6053:         <dc:context>
aheinecke@6053:           <dc:statement>
aheinecke@6053:             SELECT DISTINCT
gernotbelger@8941:             b.sobek AS sobek_id,
gernotbelger@8941:             sk.name AS sobek
aheinecke@6053:             FROM hydr_boundaries_poly b
gernotbelger@8941:             JOIN sobek_kinds sk ON b.sobek = sk.id
aheinecke@6053:             WHERE b.river_id = ${river_id}
gernotbelger@8941:             AND b.kind = 1
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:if test="dc:has-result()">
aheinecke@6053:             <sobek_flooded>
aheinecke@6053:               <dc:for-each>
gernotbelger@9127:                 <boundary name="{$sobek}" factory="wmshydrboundariespolyfactory" target_out="{$out}" ids="{$river_id};{$sobek};1;-1;{$sobek_id}" />
aheinecke@6053:               </dc:for-each>
aheinecke@6053:             </sobek_flooded>
aheinecke@6053:           </dc:if>
aheinecke@6053:         </dc:context>
aheinecke@6053:         <dc:context>
aheinecke@6053:           <dc:statement>
aheinecke@6053:             SELECT DISTINCT
gernotbelger@8941:             b.name AS name
aheinecke@6053:             FROM hydr_boundaries_poly b
aheinecke@6053:             WHERE b.river_id = ${river_id}
gernotbelger@8941:             AND b.kind = 1
gernotbelger@8941:             AND b.sobek IS NULL
gernotbelger@8941:             AND b.sectie is NULL
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:for-each>
gernotbelger@9127:             <boundary name="{$name}" factory="wmshydrboundariespolyfactory" target_out="{$out}" ids="{$river_id};{$name}" />
aheinecke@6053:           </dc:for-each>
aheinecke@6053:         </dc:context>
aheinecke@6053:       </areas>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="flood-map-uesk">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
aheinecke@6053:           SELECT DISTINCT 1 FROM floodmaps WHERE river_id = ${river_id}
aheinecke@6053:         </dc:statement>
aheinecke@6053:         <dc:if test="dc:has-result()">
gernotbelger@8941:           <uesk>
gernotbelger@8941:             <calculations>
gernotbelger@8941:               <dc:context>
gernotbelger@8941:                 <dc:statement>
gernotbelger@8941:                   SELECT DISTINCT 1 FROM floodmaps WHERE river_id = ${river_id}
gernotbelger@8941:                   AND (kind = 112 OR kind = 111)
gernotbelger@8941:                 </dc:statement>
gernotbelger@8941:                 <dc:if test="dc:has-result()">
gernotbelger@8941:                   <current>
gernotbelger@8941:                     <dc:context>
gernotbelger@8941:                       <dc:statement>
gernotbelger@8941:                         SELECT DISTINCT name AS name
gernotbelger@8941:                         FROM floodmaps
gernotbelger@8941:                         WHERE river_id = ${river_id} AND kind = 111
gernotbelger@8941:                       </dc:statement>
gernotbelger@8941:                       <dc:if test="dc:has-result()">
gernotbelger@8941:                         <bfg>
gernotbelger@8941:                           <dc:for-each>
gernotbelger@9127:                             <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}" />
gernotbelger@8941:                           </dc:for-each>
gernotbelger@8941:                         </bfg>
gernotbelger@8941:                       </dc:if>
gernotbelger@8941:                     </dc:context>
gernotbelger@8941:                     <dc:context>
gernotbelger@8941:                       <dc:statement>
gernotbelger@8941:                         SELECT DISTINCT name AS name
gernotbelger@8941:                         FROM floodmaps
gernotbelger@8941:                         WHERE river_id = ${river_id} AND kind = 112
gernotbelger@8941:                       </dc:statement>
gernotbelger@8941:                       <dc:if test="dc:has-result()">
gernotbelger@8941:                         <federal>
gernotbelger@8941:                           <dc:for-each>
gernotbelger@9127:                             <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}" />
gernotbelger@8941:                           </dc:for-each>
gernotbelger@8941:                         </federal>
gernotbelger@8941:                       </dc:if>
gernotbelger@8941:                     </dc:context>
gernotbelger@8941:                   </current>
gernotbelger@8941:                 </dc:if>
gernotbelger@8941:               </dc:context>
gernotbelger@8941:               <dc:context>
gernotbelger@8941:                 <dc:statement>
gernotbelger@8941:                   SELECT DISTINCT 1 from floodmaps where river_id = ${river_id}
gernotbelger@8941:                   AND (kind = 122 OR kind = 121)
gernotbelger@8941:                 </dc:statement>
gernotbelger@8941:                 <dc:if test="dc:has-result()">
gernotbelger@8941:                   <potential>
gernotbelger@8941:                     <dc:context>
gernotbelger@8941:                       <dc:statement>
gernotbelger@8941:                         SELECT DISTINCT name AS name
gernotbelger@8941:                         FROM floodmaps
gernotbelger@8941:                         WHERE river_id = ${river_id} AND kind = 121
gernotbelger@8941:                       </dc:statement>
gernotbelger@8941:                       <dc:if test="dc:has-result()">
gernotbelger@8941:                         <bfg>
gernotbelger@8941:                           <dc:for-each>
gernotbelger@9127:                             <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}" />
gernotbelger@8941:                           </dc:for-each>
gernotbelger@8941:                         </bfg>
gernotbelger@8941:                       </dc:if>
gernotbelger@8941:                     </dc:context>
aheinecke@6053:                     <dc:context>
aheinecke@6053:                       <dc:statement>
aheinecke@6053:                         SELECT DISTINCT
gernotbelger@8941:                         name AS name
aheinecke@6053:                         FROM floodmaps
gernotbelger@8941:                         WHERE river_id = ${river_id} AND kind = 122
aheinecke@6053:                       </dc:statement>
gernotbelger@8941:                       <dc:if test="dc:has-result()">
gernotbelger@8941:                         <federal>
gernotbelger@8941:                           <dc:for-each>
gernotbelger@9127:                             <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}" />
gernotbelger@8941:                           </dc:for-each>
gernotbelger@8941:                         </federal>
gernotbelger@8941:                       </dc:if>
aheinecke@6053:                     </dc:context>
gernotbelger@8941:                   </potential>
gernotbelger@8941:                 </dc:if>
gernotbelger@8941:               </dc:context>
gernotbelger@8941:             </calculations>
gernotbelger@8941:             <dc:context>
gernotbelger@8941:               <dc:statement>
gernotbelger@8941:                 SELECT DISTINCT
gernotbelger@8941:                 source AS source
gernotbelger@8941:                 FROM floodmaps
gernotbelger@8941:                 WHERE river_id = ${river_id} AND kind = 200
gernotbelger@8941:               </dc:statement>
gernotbelger@8941:               <dc:if test="dc:has-result()">
gernotbelger@8941:                 <measurements>
gernotbelger@8941:                   <dc:for-each>
gernotbelger@8941:                     <year name="{$source}">
gernotbelger@8941:                       <dc:context>
gernotbelger@8941:                         <dc:statement>
gernotbelger@8941:                           SELECT DISTINCT
gernotbelger@8941:                           name AS name
gernotbelger@8941:                           FROM floodmaps
gernotbelger@8941:                           WHERE river_id = ${river_id} AND kind = 200 AND source =
gernotbelger@8941:                           ${source}
gernotbelger@8941:                         </dc:statement>
gernotbelger@8941:                         <dc:for-each>
gernotbelger@9127:                           <floodmaps factory="wmsfloodmapsfactory" target_out="{$out}" ids="{$river_id};{$name}" name="{$name}" />
gernotbelger@8941:                         </dc:for-each>
gernotbelger@8941:                       </dc:context>
gernotbelger@8941:                     </year>
gernotbelger@8941:                   </dc:for-each>
gernotbelger@8941:                 </measurements>
gernotbelger@8941:               </dc:if>
gernotbelger@8941:             </dc:context>
gernotbelger@8941:           </uesk>
gernotbelger@8941:         </dc:if>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
teichmann@5523: 
aheinecke@6053:     <dc:macro name="flood-map-floodplain">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
aheinecke@6053:           SELECT DISTINCT
gernotbelger@8941:           fp.kind_id AS kind_id,
gernotbelger@8941:           flk.name AS kind_name
aheinecke@6053:           FROM floodplain fp
gernotbelger@8941:           JOIN floodplain_kinds flk on fp.kind_id = flk.id
aheinecke@6053:           WHERE river_id = ${river_id}
aheinecke@6053:         </dc:statement>
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <floodplain>
aheinecke@6053:             <dc:filter expr="$kind_id=1">
aheinecke@6053:               <dc:for-each>
gernotbelger@9127:                 <floody factory="wmsfloodplainfactory" target_out="{$out}" description="{$kind_name}" ids="{$river_id};{$kind_name};{$kind_id}" />
aheinecke@6053:               </dc:for-each>
aheinecke@6053:             </dc:filter>
teichmann@6098:             <dc:filter expr="$kind_id != 1">
teichmann@6098:               <dc:if test="dc:has-result()">
teichmann@6098:                 <other>
teichmann@6098:                   <dc:for-each>
gernotbelger@9127:                     <floody factory="wmsfloodplainfactory" target_out="{$out}" description="{$layer_name}" ids="{$river_id};{$layer_name};{$kind_id}" />
teichmann@6098:                   </dc:for-each>
teichmann@6098:                 </other>
teichmann@6098:               </dc:if>
aheinecke@6053:             </dc:filter>
aheinecke@6053:           </floodplain>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
rrenkert@5015: 
aheinecke@6053:     <dc:macro name="hwspoints_by_kind">
aheinecke@6053:       <dc:comment>
aheinecke@6053:         Call from a context where fed_name hws_kind hws_name and river_id is
aheinecke@6053:         availble
aheinecke@6053:       </dc:comment>
rrenkert@5015: 
aheinecke@6053:       <dc:macro name="hwspoints_by_kind_factory">
aheinecke@6053:         <dc:for-each>
gernotbelger@9127:           <hws factory="wmshwspointsfactory" target_out="{$out}" ids="{$river_id};{$hws_name}" name="{$hws_name}" />
aheinecke@6053:         </dc:for-each>
aheinecke@6053:       </dc:macro>
teichmann@5523: 
aheinecke@6053:       <dc:filter expr="$hws_kind=1">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <Durchlass>
gernotbelger@9127:             <dc:call-macro name="hwspoints_by_kind_factory" />
aheinecke@6053:           </Durchlass>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
teichmann@5523: 
aheinecke@6053:       <dc:filter expr="$hws_kind=2">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <Damm>
gernotbelger@9127:             <dc:call-macro name="hwspoints_by_kind_factory" />
aheinecke@6053:           </Damm>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
ingo@2096: 
aheinecke@6053:       <dc:filter expr="$hws_kind=3">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <Graben>
gernotbelger@9127:             <dc:call-macro name="hwspoints_by_kind_factory" />
aheinecke@6053:           </Graben>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
aheinecke@6053:     </dc:macro>
teichmann@5523: 
aheinecke@6053:     <dc:macro name="hwspoints">
aheinecke@6053:       <hws_points>
aheinecke@6053:         <official>
aheinecke@6053:           <dc:context>
aheinecke@6053:             <dc:statement>
aheinecke@6053:               SELECT DISTINCT
gernotbelger@8941:               fs.name AS fed_name,
gernotbelger@8941:               fs.id AS fed_id
aheinecke@6053:               FROM hws_points hws
gernotbelger@8941:               JOIN fed_states fs ON hws.fed_state_id = fs.id
aheinecke@6053:               WHERE river_id = ${river_id}
gernotbelger@8941:               AND hws.official=1
aheinecke@6053:             </dc:statement>
aheinecke@6053:             <dc:for-each>
teichmann@5523:               <dc:context>
teichmann@5523:                 <dc:statement>
aheinecke@6053:                   SELECT DISTINCT
gernotbelger@8941:                   name AS hws_name,
gernotbelger@8941:                   kind_id AS hws_kind
aheinecke@6053:                   FROM hws_points
aheinecke@6053:                   WHERE river_id = ${river_id}
gernotbelger@8941:                   AND official=1
gernotbelger@8941:                   AND fed_state_id = ${fed_id} ORDER BY name
teichmann@5523:                 </dc:statement>
aheinecke@6053:                 <fedstate description="{$fed_name}">
gernotbelger@9127:                   <dc:call-macro name="hwspoints_by_kind" />
aheinecke@6053:                 </fedstate>
teichmann@5523:               </dc:context>
aheinecke@6053:             </dc:for-each>
aheinecke@6053:           </dc:context>
aheinecke@6053:           <dc:context>
aheinecke@6053:             <dc:statement>
aheinecke@6053:               SELECT distinct
gernotbelger@8941:               name AS hws_name,
gernotbelger@8941:               kind_id AS hws_kind
aheinecke@6053:               FROM hws_points
aheinecke@6053:               WHERE river_id = ${river_id}
gernotbelger@8941:               AND official=1
gernotbelger@8941:               AND fed_state_id IS NULL
gernotbelger@8941:               ORDER BY name
aheinecke@6053:             </dc:statement>
aheinecke@6053:             <hws_fed_unknown>
gernotbelger@9127:               <dc:call-macro name="hwspoints_by_kind" />
aheinecke@6053:             </hws_fed_unknown>
aheinecke@6053:           </dc:context>
aheinecke@6053:         </official>
aheinecke@6053:         <inofficial>
aheinecke@6053:           <dc:context>
aheinecke@6053:             <dc:statement>
aheinecke@6053:               SELECT DISTINCT
gernotbelger@8941:               fs.name AS fed_name,
gernotbelger@8941:               fs.id AS fed_id
aheinecke@6053:               FROM hws_points hws
gernotbelger@8941:               JOIN fed_states fs ON hws.fed_state_id = fs.id
aheinecke@6053:               WHERE river_id = ${river_id}
gernotbelger@8941:               AND hws.official=0
aheinecke@6053:             </dc:statement>
aheinecke@6053:             <dc:for-each>
aheinecke@6053:               <dc:context>
aheinecke@6053:                 <dc:statement>
aheinecke@6053:                   SELECT DISTINCT
gernotbelger@8941:                   name AS hws_name,
gernotbelger@8941:                   kind_id AS hws_kind
aheinecke@6053:                   FROM hws_points
aheinecke@6053:                   WHERE river_id = ${river_id}
gernotbelger@8941:                   AND official=0
gernotbelger@8941:                   AND fed_state_id = ${fed_id} ORDER BY name
aheinecke@6053:                 </dc:statement>
aheinecke@6053:                 <fedstate description="{$fed_name}">
gernotbelger@9127:                   <dc:call-macro name="hwspoints_by_kind" />
aheinecke@6053:                 </fedstate>
aheinecke@6053:               </dc:context>
aheinecke@6053:             </dc:for-each>
aheinecke@6053:           </dc:context>
aheinecke@6053:           <dc:context>
aheinecke@6053:             <dc:statement>
aheinecke@6053:               SELECT distinct
gernotbelger@8941:               name AS hws_name,
gernotbelger@8941:               kind_id AS hws_kind
aheinecke@6053:               FROM hws_points
aheinecke@6053:               WHERE river_id = ${river_id}
gernotbelger@8941:               AND official=0
gernotbelger@8941:               AND fed_state_id IS NULL ORDER BY name
aheinecke@6053:             </dc:statement>
aheinecke@6053:             <hws_fed_unknown>
gernotbelger@9127:               <dc:call-macro name="hwspoints_by_kind" />
aheinecke@6053:             </hws_fed_unknown>
aheinecke@6053:           </dc:context>
aheinecke@6053:         </inofficial>
aheinecke@6053:       </hws_points>
aheinecke@6053:     </dc:macro>
teichmann@5523: 
aheinecke@6053:     <dc:macro name="hwslines_by_kind">
aheinecke@6053:       <dc:comment>
aheinecke@6053:         Call from a context where fed_name hws_kind hws_name and river_id is
aheinecke@6053:         availble
aheinecke@6053:       </dc:comment>
rrenkert@5549: 
aheinecke@6053:       <dc:macro name="hwslines_by_kind_factory">
aheinecke@6053:         <dc:for-each>
gernotbelger@9127:           <hws factory="wmshwslinesfactory" target_out="{$out}" ids="{$river_id};{$hws_name}" name="{$hws_name}" />
aheinecke@6053:         </dc:for-each>
aheinecke@6053:       </dc:macro>
rrenkert@5549: 
aheinecke@6053:       <dc:filter expr="$hws_kind=1">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <Durchlass>
gernotbelger@9127:             <dc:call-macro name="hwslines_by_kind_factory" />
aheinecke@6053:           </Durchlass>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
aheinecke@6053: 
aheinecke@6053:       <dc:filter expr="$hws_kind=2">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <Damm>
gernotbelger@9127:             <dc:call-macro name="hwslines_by_kind_factory" />
aheinecke@6053:           </Damm>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
aheinecke@6053: 
aheinecke@6053:       <dc:filter expr="$hws_kind=3">
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <Graben>
gernotbelger@9127:             <dc:call-macro name="hwslines_by_kind_factory" />
aheinecke@6053:           </Graben>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:filter>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="hwslines">
aheinecke@6053:       <hws_lines>
aheinecke@6053:         <official>
aheinecke@6053:           <dc:context>
aheinecke@6053:             <dc:statement>
aheinecke@6053:               SELECT DISTINCT
gernotbelger@8941:               fs.name AS fed_name,
gernotbelger@8941:               fs.id AS fed_id
aheinecke@6053:               FROM hws_lines hws
gernotbelger@8941:               JOIN fed_states fs ON hws.fed_state_id = fs.id
aheinecke@6053:               WHERE river_id = ${river_id}
gernotbelger@8941:               AND hws.official=1
aheinecke@6053:             </dc:statement>
aheinecke@6053:             <dc:for-each>
aheinecke@6053:               <dc:context>
aheinecke@6053:                 <dc:statement>
aheinecke@6053:                   SELECT DISTINCT
gernotbelger@8941:                   name AS hws_name,
gernotbelger@8941:                   kind_id AS hws_kind
aheinecke@6053:                   FROM hws_lines
aheinecke@6053:                   WHERE river_id = ${river_id}
gernotbelger@8941:                   AND official=1
gernotbelger@8941:                   AND fed_state_id = ${fed_id} ORDER BY name
aheinecke@6053:                 </dc:statement>
aheinecke@6053:                 <fedstate description="{$fed_name}">
gernotbelger@9127:                   <dc:call-macro name="hwslines_by_kind" />
aheinecke@6053:                 </fedstate>
aheinecke@6053:               </dc:context>
aheinecke@6053:             </dc:for-each>
aheinecke@6053:           </dc:context>
aheinecke@6053:           <dc:context>
aheinecke@6053:             <dc:statement>
aheinecke@6053:               SELECT distinct
gernotbelger@8941:               name AS hws_name,
gernotbelger@8941:               kind_id AS hws_kind
aheinecke@6053:               FROM hws_lines
aheinecke@6053:               WHERE river_id = ${river_id}
gernotbelger@8941:               AND official=1
gernotbelger@8941:               AND fed_state_id IS NULL
gernotbelger@8941:               ORDER BY name
aheinecke@6053:             </dc:statement>
aheinecke@6053:             <hws_fed_unknown>
gernotbelger@9127:               <dc:call-macro name="hwslines_by_kind" />
aheinecke@6053:             </hws_fed_unknown>
aheinecke@6053:           </dc:context>
aheinecke@6053:         </official>
aheinecke@6053:         <inofficial>
aheinecke@6053:           <dc:context>
aheinecke@6053:             <dc:statement>
aheinecke@6053:               SELECT DISTINCT
gernotbelger@8941:               fs.name AS fed_name,
gernotbelger@8941:               fs.id AS fed_id
aheinecke@6053:               FROM hws_lines hws
gernotbelger@8941:               JOIN fed_states fs ON hws.fed_state_id = fs.id
aheinecke@6053:               WHERE river_id = ${river_id}
gernotbelger@8941:               AND hws.official=0
aheinecke@6053:             </dc:statement>
aheinecke@6053:             <dc:for-each>
aheinecke@6053:               <dc:context>
aheinecke@6053:                 <dc:statement>
aheinecke@6053:                   SELECT DISTINCT
gernotbelger@8941:                   name AS hws_name,
gernotbelger@8941:                   kind_id AS hws_kind
aheinecke@6053:                   FROM hws_lines
aheinecke@6053:                   WHERE river_id = ${river_id}
gernotbelger@8941:                   AND official=0
gernotbelger@8941:                   AND fed_state_id = ${fed_id} ORDER BY name
aheinecke@6053:                 </dc:statement>
aheinecke@6053:                 <fedstate description="{$fed_name}">
gernotbelger@9127:                   <dc:call-macro name="hwslines_by_kind" />
aheinecke@6053:                 </fedstate>
aheinecke@6053:               </dc:context>
aheinecke@6053:             </dc:for-each>
aheinecke@6053:           </dc:context>
aheinecke@6053:           <dc:context>
aheinecke@6053:             <dc:statement>
aheinecke@6053:               SELECT distinct
gernotbelger@8941:               name AS hws_name,
gernotbelger@8941:               kind_id AS hws_kind
aheinecke@6053:               FROM hws_lines
aheinecke@6053:               WHERE river_id = ${river_id}
gernotbelger@8941:               AND official=0
gernotbelger@8941:               AND fed_state_id IS NULL ORDER BY name
aheinecke@6053:             </dc:statement>
aheinecke@6053:             <hws_fed_unknown>
gernotbelger@9127:               <dc:call-macro name="hwslines_by_kind" />
aheinecke@6053:             </hws_fed_unknown>
aheinecke@6053:           </dc:context>
aheinecke@6053:         </inofficial>
aheinecke@6053:       </hws_lines>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="floodmarks">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
aheinecke@6053:           SELECT DISTINCT
gernotbelger@8941:           COALESCE(CAST (year AS VARCHAR(64)), 'Unbekanntes Jahr') AS year
aheinecke@6053:           FROM flood_marks
aheinecke@6053:           WHERE river_id = ${river_id}
aheinecke@6053:         </dc:statement>
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <floodmarks>
aheinecke@6053:             <dc:for-each>
gernotbelger@9127:               <floodmark name="{$year}" factory="wmsfloodmarkfactory" target_out="{$out}" ids="{$river_id};{$year};{$year}" />
aheinecke@6053:             </dc:for-each>
aheinecke@6053:           </floodmarks>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="flood-map-gaugelocations">
aheinecke@6053:       <gaugelocations>
gernotbelger@9127:         <gauge_points factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelpunkte;Pegelpunkte (WSV)" target_out="{$out}" />
gernotbelger@9127:         <gauge_names factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelnamen;Pegelnamen (WSV)" target_out="{$out}" />
gernotbelger@9127:         <gauge_level factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;Pegelwasserstand;Aktueller Wasserstand (WSV)" target_out="{$out}" />
gernotbelger@9127:         <gauge_tendency factory="externalwmsfactory" ids="http://www.pegelonline.wsv.de/webservices/gis/wms;TendenzWasserstand;Tendenz des Wasserstands (WSV)" target_out="{$out}" />
aheinecke@6053:       </gaugelocations>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="flood-map-riveraxis">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
aheinecke@6053:           SELECT DISTINCT
gernotbelger@8941:           ak.name AS kind_name,
gernotbelger@8941:           ax.kind_id AS kind_id,
gernotbelger@8941:           ax.name AS layer_name
aheinecke@6053:           FROM river_axes ax
gernotbelger@8941:           JOIN axis_kinds ak on ax.kind_id = ak.id
aheinecke@6053:           WHERE river_id = ${river_id}
aheinecke@6053:         </dc:statement>
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <axis>
aheinecke@6053:             <dc:filter expr="$kind_id=1">
aheinecke@6053:               <dc:for-each>
gernotbelger@9127:                 <actual description="{$kind_name}" ids="{$river_id};{$kind_name};{$kind_id}" factory="riveraxis" target_out="{$out}" />
aheinecke@6053:               </dc:for-each>
aheinecke@6053:             </dc:filter>
aheinecke@6053:             <dc:filter expr="$kind_id!=1">
aheinecke@6053:               <other>
rrenkert@5591:                 <dc:for-each>
gernotbelger@9127:                   <misc-axis description="{$layer_name}" ids="{$river_id};{$layer_name};{$kind_id}" factory="riveraxis" target_out="{$out}" />
rrenkert@5591:                 </dc:for-each>
aheinecke@6053:               </other>
aheinecke@6053:             </dc:filter>
aheinecke@6053:           </axis>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
rrenkert@5631: 
aheinecke@6053:     <dc:macro name="flood-map-km">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
aheinecke@6053:           SELECT DISTINCT 1 FROM river_axes_km WHERE river_id = ${river_id}
aheinecke@6053:         </dc:statement>
gernotbelger@8941:         <dc:for-each>
gernotbelger@9127:           <kilometrage factory="wmskmfactory" ids="{$river_id}" target_out="{$out}" />
aheinecke@6053:         </dc:for-each>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
rrenkert@5631: 
aheinecke@6053:     <dc:macro name="flood-map-fixpoints">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
aheinecke@6053:           SELECT name AS name
aheinecke@6053:           FROM fixpoints
aheinecke@6053:           WHERE river_id = ${river_id}
gernotbelger@8941:           GROUP BY name
aheinecke@6053:         </dc:statement>
aheinecke@6053:         <dc:for-each>
gernotbelger@9127:           <fixpoints factory="wmsfixpointsfactory" target_out="{$out}" ids="{$river_id};{$name}" />
aheinecke@6053:         </dc:for-each>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6053:     <dc:macro name="flood-map-qps">
aheinecke@6053:       <dc:context>
aheinecke@6053:         <dc:statement>
aheinecke@6053:           SELECT DISTINCT
gernotbelger@8941:           cs.kind_id AS kind_id,
gernotbelger@8941:           cs.name AS layer_name,
gernotbelger@8941:           ck.name AS kind_name
aheinecke@6053:           FROM cross_section_tracks cs
gernotbelger@8941:           JOIN cross_section_track_kinds ck ON cs.kind_id = ck.id
aheinecke@6053:           WHERE river_id = ${river_id}
aheinecke@6053:         </dc:statement>
aheinecke@6053:         <dc:if test="dc:has-result()">
aheinecke@6053:           <qps>
aheinecke@6053:             <dc:filter expr="$kind_id=1">
aheinecke@6053:               <dc:for-each>
gernotbelger@9127:                 <actual description="{$kind_name}" factory="wmsqpsfactory" target_out="{$out}" ids="{$river_id};{$kind_name};{$kind_id}" />
aheinecke@6053:               </dc:for-each>
aheinecke@6053:             </dc:filter>
teichmann@6098:             <dc:filter expr="$kind_id = 0">
teichmann@6098:               <dc:if test="dc:has-result()">
teichmann@6098:                 <other>
teichmann@6098:                   <dc:for-each>
gernotbelger@9127:                     <misc-qps description="{$layer_name}" factory="wmsqpsfactory" target_out="{$out}" ids="{$river_id};{$layer_name};{$kind_id}" />
teichmann@6098:                   </dc:for-each>
teichmann@6098:                 </other>
teichmann@6098:               </dc:if>
aheinecke@6053:             </dc:filter>
aheinecke@6053:           </qps>
aheinecke@6053:         </dc:if>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
rrenkert@5549: 
aheinecke@6053:     <dc:macro name="flood-map-buildings">
aheinecke@6053:       <buildings>
aheinecke@6053:         <dc:context>
aheinecke@6053:           <dc:statement>
aheinecke@6053:             SELECT DISTINCT
gernotbelger@8941:             b.name AS building_name,
gernotbelger@8941:             bk.name AS building_kind,
gernotbelger@8941:             b.kind_id AS building_kind_id
aheinecke@6053:             FROM buildings b
gernotbelger@8941:             JOIN building_kinds bk ON b.kind_id = bk.id
aheinecke@6053:             WHERE river_id = ${river_id}
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:if test="dc:has-result()">
aheinecke@6053:             <dc:filter expr="$building_kind_id!=0">
aheinecke@6053:               <dc:for-each>
gernotbelger@9127:                 <buildings description="{$building_kind}" factory="wmsbuildingsfactory" target_out="{$out}" ids="{$river_id};{$building_kind};{$building_kind_id}" />
aheinecke@6053:               </dc:for-each>
aheinecke@6053:             </dc:filter>
aheinecke@6053:             <dc:filter expr="$building_kind_id=0">
aheinecke@6053:               <other>
aheinecke@6053:                 <dc:for-each>
gernotbelger@9127:                   <buildings description="{$building_name}" factory="wmsbuildingsfactory" target_out="{$out}" ids="{$river_id};{$building_name}" />
aheinecke@6053:                 </dc:for-each>
aheinecke@6053:               </other>
aheinecke@6053:             </dc:filter>
aheinecke@6053:           </dc:if>
aheinecke@6053:         </dc:context>
aheinecke@6053:         <dc:context>
aheinecke@6053:           <dc:statement>
aheinecke@6053:             SELECT DISTINCT
gernotbelger@8941:             j.kind_id AS jetty_kind_id,
gernotbelger@8941:             jk.name AS jetty_kind
aheinecke@6053:             FROM jetties j
gernotbelger@8941:             JOIN jetty_kinds jk ON j.kind_id = jk.id
aheinecke@6053:             WHERE river_id = ${river_id}
aheinecke@6053:           </dc:statement>
aheinecke@6053:           <dc:if test="dc:has-result()">
aheinecke@6053:             <jetties>
aheinecke@6053:               <dc:for-each>
gernotbelger@9127:                 <jetty description="{$jetty_kind}" factory="wmsjettiesfactory" target_out="{$out}" ids="{$river_id};{$jetty_kind};{$jetty_kind_id}" />
aheinecke@6053:               </dc:for-each>
aheinecke@6053:             </jetties>
aheinecke@6053:           </dc:if>
aheinecke@6053:         </dc:context>
aheinecke@6053:       </buildings>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6054:     <dc:macro name="officiallines_user">
teichmann@6401:       <dc:if test="dc:contains($parameters, 'official-lines')">
teichmann@6401:         <dc:container-context container="official-lines">
teichmann@6401:           <dc:properties>
gernotbelger@9127:             <dc:property name="name" alias="olname" />
gernotbelger@9127:             <dc:property name="wstId" alias="wstid" />
gernotbelger@9127:             <dc:property name="columnPos" alias="wstcolpos" />
teichmann@6401:           </dc:properties>
teichmann@6401:           <dc:if test="dc:has-result()">
teichmann@6401:             <officiallines>
teichmann@6401:               <dc:for-each>
gernotbelger@9127:                 <column name="{$olname}" ids="official-wstv-{$wstcolpos}-{$wstid}" factory="staticwqkms" target_out="{$out}" />
teichmann@6401:               </dc:for-each>
teichmann@6401:             </officiallines>
teichmann@6401:           </dc:if>
teichmann@6401:         </dc:container-context>
teichmann@6401:       </dc:if>
aheinecke@6054:     </dc:macro>
aheinecke@6054: 
tom@8416:     <!-- sediment loads -->
tom@8241:     <dc:macro name="sedimentload_off_epoch_filter">
tom@8416:       <dc:if test="dc:has-result()">
gernotbelger@9127:         <dc:variable name="sq_time_id" type="number" expr="number($sq_ti_id)" />
tom@8416:         <dc:if test="string-length(dc:get('epochs')) &gt; 0">
gernotbelger@9127:           <dc:variable name="start" type="number" expr="dc:min-number(dc:find-all('\d{4}', $epochs))" />
gernotbelger@9127:           <dc:variable name="end" type="number" expr="dc:max-number(dc:find-all('\d{4}', $epochs))" />
tom@8241:         </dc:if>
andre@8598:         <dc:if test="string-length(dc:get('years')) &gt; 0">
gernotbelger@9127:           <dc:variable name="start" type="number" expr="dc:min-number(dc:find-all('\d{4}', $years))" />
gernotbelger@9127:           <dc:variable name="end" type="number" expr="dc:max-number(dc:find-all('\d{4}', $years))" />
andre@8598:         </dc:if>
tom@8416:         <dc:filter expr="$kind = 'official' and
tom@8416:                          $sqid = $sq_time_id and
tom@8416:                          not(number($end) &lt;
tom@8416:                              number(dc:date-format('yyyy', $startyear))
tom@8416:                            or number($start) &gt;
tom@8416:                              number(dc:date-format('yyyy', $endyear)))">
gernotbelger@9127:           <dc:macro-body />
tom@8416:         </dc:filter>
tom@8416:       </dc:if>
tom@8241:     </dc:macro>
tom@8241: 
tom@8241:     <dc:macro name="sedimentload_off_epochs">
tom@8241:       <dc:context>
gernotbelger@9127:         <dc:call-macro name="sedimentload_stations_statement" />
tom@8241:         <dc:call-macro name="sedimentload_off_epoch_filter">
tom@8241:           <dc:call-macro name="loads">
gernotbelger@9127:             <dc:call-macro name="load" />
tom@8241:           </dc:call-macro>
tom@8241:         </dc:call-macro>
tom@8241:       </dc:context>
tom@8241:       <dc:context>
gernotbelger@9127:         <dc:call-macro name="sedimentload_ls_statement" />
tom@8241:         <dc:call-macro name="sedimentload_off_epoch_filter">
tom@8241:           <dc:call-macro name="loads">
gernotbelger@9127:             <dc:call-macro name="load_ls" />
tom@8241:           </dc:call-macro>
tom@8241:         </dc:call-macro>
tom@8241:       </dc:context>
tom@8241:     </dc:macro>
tom@8241: 
tom@8416: 
aheinecke@6053:     <!-- Common stuff -->
aheinecke@6053:     <dc:macro name="km-filtered-wsts">
aheinecke@6053:       <dc:context connection="system">
aheinecke@6053:         <dc:statement>
gernotbelger@8941:           SELECT w.kind AS kind,
gernotbelger@8941:           w.id AS wst_id,
gernotbelger@8941:           wc.id AS wst_column_id,
gernotbelger@8941:           wc.position AS wst_column_position,
gernotbelger@8941:           wc.description AS info,
gernotbelger@8941:           w.description AS wst_description,
gernotbelger@9233:           ti.start_time AS start_time,
gernotbelger@9233:           ti.stop_time AS stop_time,
gernotbelger@8941:           COALESCE(wc.name, '') AS wst_column_name,
gernotbelger@8941:           wr.a AS deffrom,
gernotbelger@8961:           wr.b AS defto,
gernotbelger@8961:           w.sinfo_selection
aheinecke@6053:           FROM wst_columns wc
gernotbelger@8941:           JOIN wsts w ON wc.wst_id = w.id
gernotbelger@9299:           JOIN wst_ranges wr ON wc.id =
gernotbelger@9299:           wr.wst_column_id
gernotbelger@9299:           LEFT JOIN time_intervals ti ON wc.time_interval_id = ti.id
aheinecke@6053:           WHERE w.river_id = ${river_id} AND
gernotbelger@8941:           NOT((${tokm} &lt; wr.a) or (${fromkm} &gt; wr.b))
gernotbelger@8941:           ORDER BY wst_column_position
aheinecke@6053:         </dc:statement>
gernotbelger@9127:         <dc:macro-body />
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6095:     <dc:macro name="all-user-artifacts">
gernotbelger@8941:       <dc:context connection="user">
gernotbelger@8941:         <dc:comment>Select collections and masterartifacts.
gernotbelger@8941:           XXX: The cast is a quick hack because the ld_* values are
gernotbelger@8941:           now TEXT fields. To properly fix / asses the problems here
gernotbelger@8941:           an SLT evaluation is needed.
gernotbelger@8941:         </dc:comment>
aheinecke@6053:         <dc:statement>
gernotbelger@8941:           SELECT c.name AS collection_name,
gernotbelger@9499:           c.gid AS collection_gid,
gernotbelger@8941:           ma.id AS a_id,
gernotbelger@8941:           ma.state AS a_state,
gernotbelger@8941:           ma.gid AS a_gid,
gernotbelger@8941:           ma.creation AS a_creation,
gernotbelger@8941:           CAST(COALESCE(ma.ld_mode, '') AS VARCHAR(255)) AS ld_m,
gernotbelger@8941:           CAST(COALESCE(ma.ld_locations, '') AS VARCHAR(255)) AS ld_l,
gernotbelger@8941:           CAST(COALESCE(ma.ld_from, '') AS VARCHAR(255)) AS ld_f,
gernotbelger@8941:           CAST(COALESCE(ma.ld_to, '') AS VARCHAR(255)) AS ld_t,
gernotbelger@8941:           o.name AS out_name,
gernotbelger@8941:           o.id AS out_id,
gernotbelger@9127:           f.name AS
gernotbelger@9127:           facet_name,
gernotbelger@8941:           f.num AS facet_num,
gernotbelger@8941:           f.description AS facet_description,
gernotbelger@8941:           f.id AS fid
aheinecke@6053:           FROM users u
gernotbelger@8941:           JOIN
gernotbelger@8941:           collections c ON c.user_id = u.id
gernotbelger@8941:           JOIN master_artifacts_range ma ON ma.collection_id = c.id
gernotbelger@8941:           JOIN outs o ON o.artifact_id = ma.id
gernotbelger@8941:           JOIN facets f ON f.out_id = o.id
gernotbelger@8941:           WHERE u.gid = CAST(${user-id} AS UUID)
gernotbelger@8941:           AND ma.gid &lt;&gt; CAST(${artifact-id} AS uuid)
gernotbelger@8941:           AND f.name NOT LIKE '%empty.facet%'
gernotbelger@8941:           AND EXISTS (
gernotbelger@9127:           SELECT
gernotbelger@9127:           id
gernotbelger@8941:           FROM artifact_data ad
gernotbelger@8941:           WHERE ad.artifact_id = ma.id
gernotbelger@8941:           AND k = 'river'
gernotbelger@8941:           AND v = ${river})
aheinecke@6053:         </dc:statement>
aheinecke@6095:         <dc:virtual-column name="deffrom" type="number" expr="dc:fromValue($ld_m, $ld_l, $ld_f)">
aheinecke@6095:           <dc:virtual-column name="defto" type="number" expr="dc:toValue($ld_m, $ld_l, $ld_t)">
gernotbelger@9127:             <dc:macro-body />
aheinecke@6095:           </dc:virtual-column>
aheinecke@6095:         </dc:virtual-column>
aheinecke@6053:       </dc:context>
aheinecke@6053:     </dc:macro>
aheinecke@6053: 
aheinecke@6095:     <dc:macro name="km-filtered-user-artifacts">
aheinecke@7348:       <dc:comment>
aheinecke@7348:         Apply KM Filtering but pass
aheinecke@7348:         sq_ facets with no regard about their location.
aheinecke@7348:       </dc:comment>
aheinecke@7348:       <dc:filter expr="not($deffrom &gt; $tokm or $defto &lt; $fromkm) or
aheinecke@7348:         starts-with($facet_name, 'sq_')">
gernotbelger@9127:         <dc:macro-body />
aheinecke@6095:       </dc:filter>
aheinecke@6095:     </dc:macro>
aheinecke@6095: 
aheinecke@6183:     <dc:macro name="artifact-range">
tom@8773:       <dc:choose>
tom@8773:         <dc:when test="dc:coalesce(dc:get('ld_locations'), ' ') != ' '">
gernotbelger@8941:           <dc:variable name="fromkm" type="number" expr="dc:min-number(dc:find-all('\d*\.?\d*',
gernotbelger@9127:                              dc:get('ld_locations')))" />
gernotbelger@8941:           <dc:variable name="tokm" type="number" expr="dc:max-number(dc:find-all('\d*\.?\d*',
gernotbelger@9127:                              dc:get('ld_locations')))" />
tom@8773:         </dc:when>
tom@8773:         <dc:otherwise>
gernotbelger@8941:           <dc:variable name="fromkm" type="number" expr="dc:fromValue(dc:get('ld_mode'),
gernotbelger@9127:                              dc:get('ld_locations'), dc:get('ld_from'))" />
gernotbelger@8941:           <dc:variable name="tokm" type="number" expr="dc:toValue(dc:get('ld_mode'),
gernotbelger@9127:                              dc:get('ld_locations'), dc:get('ld_to'))" />
tom@8773:           <dc:if test="$fromkm > $tokm">
tom@8773:             <dc:message>Inverting KM filter.</dc:message>
gernotbelger@8941:             <dc:variable name="fromkm" type="number" expr="dc:toValue(dc:get('ld_mode'),
gernotbelger@9127:                                dc:get('ld_locations'), dc:get('ld_to'))" />
gernotbelger@8941:             <dc:variable name="tokm" type="number" expr="dc:fromValue(dc:get('ld_mode'),
gernotbelger@9127:                                dc:get('ld_locations'), dc:get('ld_from'))" />
tom@8773:           </dc:if>
tom@8773:         </dc:otherwise>
tom@8773:       </dc:choose>
gernotbelger@9127:       <dc:macro-body />
aheinecke@6053:     </dc:macro>
ingo@1657: 
mschaefer@9341:     <!-- S-INFO -->
gernotbelger@8909:     <dc:macro name="sinfo_flowdepths">
gernotbelger@9088:       <dc:filter expr="$a_state = 'state.sinfo.flow_depth' and 
gernotbelger@9088:                        ( $facet_name = 'sinfo_facet_flow_depth' or $facet_name = 'sinfo_facet_flow_depth.filtered' or 
gernotbelger@9088:                          $facet_name = 'sinfo_facet_flow_depth_with_tkh' or $facet_name = 'sinfo_facet_flow_depth_with_tkh.filtered' or 
gernotbelger@9088:                          $facet_name = 'sinfo_facet_tkh' )">
gernotbelger@8909:         <dc:if test="dc:has-result()">
gernotbelger@8909:           <sinfo_flow_depths>
gernotbelger@8909:             <dc:call-macro name="collection-group">
gernotbelger@8909:               <sinfo_flow_depth description="{dc:group-key()}">
gernotbelger@8909:                 <dc:for-each>
gernotbelger@8909:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="sinfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="${out_name}" />
gernotbelger@8909:                   </dc:element>
gernotbelger@8909:                 </dc:for-each>
gernotbelger@8909:               </sinfo_flow_depth>
gernotbelger@8909:             </dc:call-macro>
gernotbelger@8909:           </sinfo_flow_depths>
gernotbelger@8909:         </dc:if>
gernotbelger@8909:       </dc:filter>
gernotbelger@8909:     </dc:macro>
gernotbelger@8909: 
gernotbelger@8950:     <dc:macro name="sinfo_flowdepths_minmax">
gernotbelger@9088:       <dc:filter expr="$a_state = 'state.sinfo.flow_depth_minmax' and 
gernotbelger@9088:                      ( $facet_name = 'sinfo_facet_flow_depth_min' or $facet_name = 'sinfo_facet_flow_depth_min.filtered' or 
gernotbelger@9088:                        $facet_name = 'sinfo_facet_flow_depth_max' or $facet_name = 'sinfo_facet_flow_depth_max.filtered' )">
gernotbelger@8950:         <dc:if test="dc:has-result()">
gernotbelger@8950:           <sinfo_flow_depths_minmax>
gernotbelger@8950:             <dc:call-macro name="collection-group">
gernotbelger@8950:               <sinfo_flow_depth_minmax description="{dc:group-key()}">
gernotbelger@8950:                 <dc:for-each>
gernotbelger@8950:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="sinfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="${out_name}" />
gernotbelger@8950:                   </dc:element>
gernotbelger@8950:                 </dc:for-each>
gernotbelger@8950:               </sinfo_flow_depth_minmax>
gernotbelger@8950:             </dc:call-macro>
gernotbelger@8950:           </sinfo_flow_depths_minmax>
gernotbelger@8950:         </dc:if>
gernotbelger@8950:       </dc:filter>
gernotbelger@8950:     </dc:macro>
gernotbelger@8950: 
gernotbelger@8956:     <dc:macro name="sinfo_flow_depth_development">
gernotbelger@9127:       <dc:filter
gernotbelger@9127:         expr="$a_state = 'state.sinfo.flow_depth_development' and
gernotbelger@9088:                      ( $facet_name = 'sinfo_facet_flow_depth_development' or $facet_name = 'sinfo_facet_flow_depth_development.filtered' or
gernotbelger@9088:                        $facet_name = 'sinfo_facet_flow_depth_development_per_year' or $facet_name = 'sinfo_facet_flow_depth_development_per_year.filtered' or
gernotbelger@9088:                        $facet_name = 'sinfo_facet_flow_depth_current' or $facet_name = 'sinfo_facet_flow_depth_current.filtered' or 
gernotbelger@9088:                        $facet_name = 'sinfo_facet_flow_depth_historical' or $facet_name = 'sinfo_facet_flow_depth_historical.filtered' or                       
gernotbelger@9088:                        $facet_name = 'sinfo_facet_waterlevel_difference' or $facet_name = 'sinfo_facet_waterlevel_difference.filtered' or
gernotbelger@9088:                        $facet_name = 'sinfo_facet_bedheight_difference' or $facet_name = 'sinfo_facet_bedheight_difference.filtered' )">
gernotbelger@8956:         <dc:if test="dc:has-result()">
gernotbelger@8956:           <sinfo_flow_depth_developments>
gernotbelger@8956:             <dc:call-macro name="collection-group">
gernotbelger@8956:               <sinfo_flow_depth_development description="{dc:group-key()}">
gernotbelger@8956:                 <dc:for-each>
gernotbelger@8956:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="sinfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="${out_name}" />
gernotbelger@8956:                   </dc:element>
gernotbelger@8956:                 </dc:for-each>
gernotbelger@8956:               </sinfo_flow_depth_development>
gernotbelger@8956:             </dc:call-macro>
gernotbelger@8956:           </sinfo_flow_depth_developments>
gernotbelger@8956:         </dc:if>
gernotbelger@8956:       </dc:filter>
gernotbelger@8956:     </dc:macro>
gernotbelger@8956: 
gernotbelger@8909:     <dc:macro name="sinfo_tkh">
gernotbelger@9127:       <dc:filter
gernotbelger@9127:         expr="$a_state = 'state.sinfo.transport_bodies_heights' and
gernotbelger@9088:                     ( $facet_name = 'sinfo_facet_tkh' or
gernotbelger@9088:                       $facet_name = 'sinfo_facet_flow_depth' or $facet_name = 'sinfo_facet_flow_depth.filtered' or
gernotbelger@9088:                       $facet_name = 'sinfo_facet_velocity' or $facet_name = 'sinfo_facet_velocity.filtered' or
gernotbelger@9088:                       $facet_name = 'sinfo_facet_tau' or $facet_name = 'sinfo_facet_tau.filtered' or
gernotbelger@9088:                       $facet_name = 'sinfo_facet_d50' or $facet_name = 'sinfo_facet_d50.filtered' )">
gernotbelger@8909:         <dc:if test="dc:has-result()">
gernotbelger@8909:           <sinfo_tkhs>
gernotbelger@8909:             <dc:call-macro name="collection-group">
gernotbelger@8909:               <sinfo_tkh description="{dc:group-key()}">
gernotbelger@8909:                 <dc:for-each>
gernotbelger@8909:                   <dc:element name="${facet_name}">
gernotbelger@9127:                     <dc:attribute name="factory" value="sinfo" />
gernotbelger@9127:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9127:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9127:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9127:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9127:                     <dc:attribute name="out" value="${out_name}" />
gernotbelger@8909:                   </dc:element>
gernotbelger@8909:                 </dc:for-each>
gernotbelger@8909:               </sinfo_tkh>
gernotbelger@8909:             </dc:call-macro>
gernotbelger@8909:           </sinfo_tkhs>
gernotbelger@8909:         </dc:if>
gernotbelger@8909:       </dc:filter>
gernotbelger@8909:     </dc:macro>
gernotbelger@8909: 
mschaefer@9156:     <dc:macro name="sinfo_collision">
mschaefer@9341:       <dc:filter expr="$a_state = 'state.sinfo.collision' and ($facet_name = 'sinfo_facet_collision_calc_count'
mschaefer@9341:           or $facet_name = 'sinfo_facet_collision_calc_count.2' or $facet_name = 'sinfo_facet_collision_calc_count.3')">
mschaefer@9156:         <dc:if test="dc:has-result()">
mschaefer@9378:           <sinfo_collisions>
mschaefer@9378:             <dc:call-macro name="collection-group">
mschaefer@9378:               <sinfo_collision description="{dc:group-key()}">
mschaefer@9378:                 <dc:for-each>
mschaefer@9378:                   <dc:element name="${facet_name}">
mschaefer@9378:                     <dc:attribute name="factory" value="sinfo" />
mschaefer@9378:                     <dc:attribute name="target_out" value="${out}" />
mschaefer@9378:                     <dc:attribute name="description" value="${facet_description}" />
mschaefer@9378:                     <dc:attribute name="ids" value="${facet_num}" />
mschaefer@9378:                     <dc:attribute name="artifact-id" value="${a_gid}" />
mschaefer@9378:                     <dc:attribute name="out" value="${out_name}" />
mschaefer@9378:                   </dc:element>
mschaefer@9378:                 </dc:for-each>
mschaefer@9378:               </sinfo_collision>
mschaefer@9378:             </dc:call-macro>
mschaefer@9378:           </sinfo_collisions>
mschaefer@9156:         </dc:if>
mschaefer@9156:       </dc:filter>
mschaefer@9156:     </dc:macro>
mschaefer@9156: 
mschaefer@9176:     <dc:macro name="sinfo_flood_duration">
mschaefer@9341:       <dc:filter expr="$a_state = 'state.sinfo.flood_duration'
mschaefer@9341:           and ($facet_name = 'sinfo_facet_flood_duration.left' or $facet_name = 'sinfo_facet_flood_duration.right'
mschaefer@9341:           or $facet_name = 'mainvalue.duration' or $facet_name = 'sinfo_facet_flood_height.left'
mschaefer@9341:           or $facet_name = 'sinfo_facet_flood_height.right' or $facet_name = 'mainvalue.w')">
mschaefer@9176:         <dc:if test="dc:has-result()">
mschaefer@9378:           <sinfo_flood_durations>
mschaefer@9378:             <dc:call-macro name="collection-group">
mschaefer@9378:               <sinfo_flood_duration description="{dc:group-key()}">
mschaefer@9378:                 <dc:for-each>
mschaefer@9378:                   <dc:element name="${facet_name}">
mschaefer@9378:                     <dc:attribute name="factory" value="sinfo" />
mschaefer@9378:                     <dc:attribute name="target_out" value="${out}" />
mschaefer@9378:                     <dc:attribute name="description" value="${facet_description}" />
mschaefer@9378:                     <dc:attribute name="ids" value="${facet_num}" />
mschaefer@9378:                     <dc:attribute name="artifact-id" value="${a_gid}" />
mschaefer@9378:                     <dc:attribute name="out" value="${out_name}" />
mschaefer@9378:                   </dc:element>
mschaefer@9378:                 </dc:for-each>
mschaefer@9378:               </sinfo_flood_duration>
mschaefer@9378:             </dc:call-macro>
mschaefer@9378:           </sinfo_flood_durations>
mschaefer@9176:         </dc:if>
mschaefer@9176:       </dc:filter>
mschaefer@9176:     </dc:macro>
gernotbelger@9495: 
mschaefer@9112:     <!-- channel size imported from CSV-files for S-INFO -->
mschaefer@9112:     <dc:macro name="sinfo_predefined_channel">
mschaefer@9112:       <dc:context>
mschaefer@9112:         <dc:statement>
mschaefer@9112:           SELECT s.id AS id, MIN(s.filename) AS seriesname, MIN(v.station) AS km_min, MAX(v.station) AS km_max,
mschaefer@9112:           MIN(s.filename) || '&lt;br /&gt;'
mschaefer@9116:           || MIN(s.kmrange_info) || ']&lt;br /&gt;'
mschaefer@9112:           || MIN(s.year_from) || ' - ' || MIN(s.year_to) || '&lt;br /&gt;' AS info
mschaefer@9144:           FROM channel s
mschaefer@9144:           INNER JOIN channel_values v ON s.id=v.channel_id
mschaefer@9112:           WHERE (s.river_id=${river_id})
gernotbelger@9299:           AND (v.station BETWEEN ${fromkm}-0.0001
gernotbelger@9299:           AND ${tokm}+0.0001)
mschaefer@9112:           GROUP BY s.id
mschaefer@9144:           ORDER BY MIN(s.year_to) DESC
mschaefer@9112:         </dc:statement>
mschaefer@9112:         <dc:if test="dc:has-result()">
mschaefer@9112:           <dc:for-each>
gernotbelger@9282:             <channelseries name="{$seriesname}" description="{$seriesname}" ids="channelx-{$id}-{$seriesname}" factory="channelf" target_out="{$out}" info="{$info}" />
mschaefer@9112:           </dc:for-each>
mschaefer@9112:         </dc:if>
mschaefer@9112:       </dc:context>
mschaefer@9112:     </dc:macro>
mschaefer@9112: 
mschaefer@9033:     <!-- tkh imported from CSV-files for S-INFO -->
mschaefer@9033:     <dc:macro name="sinfo_predefined_tkh-berechnung">
mschaefer@9033:       <predefined_tkh_berechnung>
gernotbelger@9127:         <dc:variable name="tkh_groupname" expr="'berechnung'" />
gernotbelger@9127:         <dc:call-macro name="sinfo_predefined_tkh" />
mschaefer@9033:       </predefined_tkh_berechnung>
mschaefer@9033:     </dc:macro>
gernotbelger@9088: 
mschaefer@9033:     <dc:macro name="sinfo_predefined_tkh-messung">
mschaefer@9033:       <predefined_tkh_messung>
gernotbelger@9127:         <dc:variable name="tkh_groupname" expr="'messung'" />
gernotbelger@9127:         <dc:call-macro name="sinfo_predefined_tkh" />
mschaefer@9033:       </predefined_tkh_messung>
mschaefer@9033:     </dc:macro>
gernotbelger@9088: 
mschaefer@9016:     <dc:macro name="sinfo_predefined_tkh">
mschaefer@9016:       <dc:context>
mschaefer@9016:         <dc:statement>
mschaefer@9059:           SELECT sc.tkh_id AS tkh_id, sc.id AS tkh_col_id, MIN(sc.name) AS tkh_col_name,
gernotbelger@9088:           MIN(s.filename) AS tkh_name, MIN(v.station) AS km_min, MAX(v.station) AS km_max,
gernotbelger@9088:           MIN(s.filename) || '&lt;br /&gt;'
mschaefer@9116:           || MIN(s.kmrange_info) || ']&lt;br /&gt;'
gernotbelger@9088:           || MIN(s.sounding_info) || '&lt;br /&gt;'
gernotbelger@9088:           || MIN(s.evaluation_by) AS info
mschaefer@9144:           FROM tkh_column sc
mschaefer@9144:           INNER JOIN tkh s ON sc.tkh_id=s.id
gernotbelger@9299:           INNER JOIN tkh_values
gernotbelger@9299:           v ON sc.id=v.tkh_column_id
mschaefer@9035:           WHERE (s.river_id=${river_id})
mschaefer@9035:           AND (lower(s.groupname)=${tkh_groupname})
mschaefer@9113:           AND (v.station BETWEEN ${fromkm}-0.0001 AND ${tokm}+0.0001)
mschaefer@9035:           GROUP BY sc.tkh_id, sc.id
mschaefer@9035:           ORDER BY sc.id
mschaefer@9016:         </dc:statement>
mschaefer@9016:         <dc:if test="dc:has-result()">
mschaefer@9016:           <dc:group expr="$tkh_name">
gernotbelger@9282:             <tkhx name="{dc:group-key()}" description="{dc:group-key()}">
mschaefer@9016:               <dc:for-each>
gernotbelger@9282:                 <tkhcolumn name="{$tkh_col_name}" description="{$tkh_col_name}" ids="tkhx-{$tkh_col_id}-{$tkh_id}" factory="tkhxf" target_out="{$out}" info="{$info}" />
mschaefer@9016:               </dc:for-each>
mschaefer@9016:             </tkhx>
mschaefer@9016:           </dc:group>
mschaefer@9016:         </dc:if>
mschaefer@9016:       </dc:context>
mschaefer@9016:     </dc:macro>
mschaefer@9016: 
mschaefer@9033:     <!-- depth_evolution imported from CSV-files for S-INFO -->
mschaefer@9033:     <dc:macro name="sinfo_predefined_depthevol-aktuell">
mschaefer@9033:       <predefined_depthevol_aktuell>
gernotbelger@9127:         <dc:variable name="depthevol_groupname" expr="'aktuell'" />
gernotbelger@9127:         <dc:call-macro name="sinfo_predefined_depthevol" />
mschaefer@9033:       </predefined_depthevol_aktuell>
mschaefer@9033:     </dc:macro>
gernotbelger@9088: 
mschaefer@9033:     <dc:macro name="sinfo_predefined_depthevol-etappe">
mschaefer@9033:       <predefined_depthevol_etappe>
gernotbelger@9127:         <dc:variable name="depthevol_groupname" expr="'etappe'" />
gernotbelger@9127:         <dc:call-macro name="sinfo_predefined_depthevol" />
mschaefer@9033:       </predefined_depthevol_etappe>
mschaefer@9033:     </dc:macro>
gernotbelger@9088: 
mschaefer@9033:     <dc:macro name="sinfo_predefined_depthevol">
mschaefer@9033:       <dc:context>
mschaefer@9033:         <dc:statement>
mschaefer@9059:           SELECT s.id AS depthevol_id, MIN(s.filename) AS depthevol_name, MIN(v.station) AS km_min, MAX(v.station) AS km_max,
gernotbelger@9088:           MIN(s.filename) || '&lt;br /&gt;'
mschaefer@9116:           || MIN(s.kmrange_info) || ']&lt;br /&gt;'
gernotbelger@9088:           || MIN(s.start_year) || ' - ' || MIN(s.reference_year) || '&lt;br /&gt;'
gernotbelger@9088:           || MIN(s.old_sounding) || ' - ' || MIN(s.curr_sounding) || '&lt;br /&gt;'
gernotbelger@9127:           || MIN(s.old_glw) || ' - ' ||
gernotbelger@9127:           MIN(s.curr_glw) AS info
mschaefer@9144:           FROM depth_evolution s
mschaefer@9144:           INNER JOIN depth_evolution_values v ON s.id=v.depth_evolution_id
mschaefer@9033:           WHERE (s.river_id=${river_id})
mschaefer@9033:           AND (lower(s.groupname)=${depthevol_groupname})
mschaefer@9113:           AND (v.station BETWEEN ${fromkm}-0.0001 AND ${tokm}+0.0001)
mschaefer@9033:           GROUP BY s.id
mschaefer@9033:           ORDER BY s.id
mschaefer@9033:         </dc:statement>
mschaefer@9033:         <dc:for-each>
gernotbelger@9282:           <depth_evol name="{$depthevol_name}" description="{$depthevol_name}" ids="depthevolx-{$depthevol_id}-{$depthevol_name}" factory="depthevolxf" target_out="{$out}" info="{$info}" />
mschaefer@9033:         </dc:for-each>
mschaefer@9033:       </dc:context>
mschaefer@9033:     </dc:macro>
mschaefer@9033: 
mschaefer@9035:     <!-- flow depth imported from CSV-files for S-INFO -->
mschaefer@9035:     <dc:macro name="sinfo_predefined_flowdepth-m">
gernotbelger@9127:       <dc:call-macro name="sinfo_predefined_flowdepth-m1" />
mschaefer@9035:     </dc:macro>
gernotbelger@9088: 
mschaefer@9035:     <dc:macro name="sinfo_predefined_flowdepth-m1">
mschaefer@9035:       <dc:context>
mschaefer@9035:         <dc:statement>
mschaefer@9059:           SELECT sc.flow_depth_id AS flowdepth_id, sc.id AS flowdepth_col_id, MIN(sc.name) AS flowdepth_col_name,
gernotbelger@9088:           MIN(s.filename) AS flowdepth_name, MIN(v.station) AS km_min, MAX(v.station) AS km_max,
gernotbelger@9088:           MIN(s.filename) || '&lt;br /&gt;'
mschaefer@9116:           || MIN(s.kmrange_info) || ']&lt;br /&gt;'
gernotbelger@9088:           || MIN(s.sounding_info) || '&lt;br /&gt;'
gernotbelger@9088:           || MIN(s.evaluation_by) AS info
mschaefer@9144:           FROM flow_depth_column sc
gernotbelger@9299:           INNER JOIN
gernotbelger@9299:           flow_depth s ON sc.flow_depth_id=s.id
gernotbelger@9088:           INNER JOIN flow_depth_values v ON sc.id=v.flow_depth_column_id
mschaefer@9035:           WHERE (s.river_id=${river_id})
mschaefer@9113:           AND (v.station BETWEEN ${fromkm}-0.0001 AND ${tokm}+0.0001)
mschaefer@9035:           GROUP BY sc.flow_depth_id, sc.id
mschaefer@9035:           ORDER BY sc.id
mschaefer@9035:         </dc:statement>
mschaefer@9035:         <dc:if test="dc:has-result()">
mschaefer@9035:           <dc:group expr="$flowdepth_name">
gernotbelger@9088:             <sinfo_predefined_flowdepth>
mschaefer@9035:               <dc:for-each>
gernotbelger@9282:                 <flowdepthcolumn name="{$flowdepth_col_name}" description="{$flowdepth_col_name}" ids="flowdepthx-{$flowdepth_col_id}-{$flowdepth_id}" factory="flowdepthxf" target_out="{$out}" info="{$info}" />
mschaefer@9035:               </dc:for-each>
gernotbelger@9088:             </sinfo_predefined_flowdepth>
mschaefer@9035:           </dc:group>
mschaefer@9035:         </dc:if>
mschaefer@9035:       </dc:context>
mschaefer@9035:     </dc:macro>
mschaefer@9035: 
mschaefer@9116:     <!-- infrastructure height imported from CSV-files for S-INFO -->
mschaefer@9341:     <dc:macro name="sinfo_predefined_infrastructure">
mschaefer@9116:       <dc:context>
mschaefer@9116:         <dc:statement>
mschaefer@9116:           SELECT s.id AS id, MIN(s.filename) AS seriesname, MIN(v.station) AS km_min, MAX(v.station) AS km_max,
mschaefer@9116:           MIN(x.name) AS typename,
mschaefer@9116:           MIN(s.filename) || '&lt;br /&gt;'
mschaefer@9116:           || MIN(s.kmrange_info) || '&lt;br /&gt;'
mschaefer@9116:           || MIN(s.year) || '&lt;br /&gt;' AS info
mschaefer@9144:           FROM infrastructure s
mschaefer@9144:           INNER JOIN infrastructure_values v ON s.id=v.infrastructure_id
gernotbelger@9127:           INNER JOIN annotation_types x ON
gernotbelger@9127:           s.annotation_type_id=x.id
mschaefer@9116:           WHERE (s.river_id=${river_id})
mschaefer@9116:           AND (v.station BETWEEN ${fromkm}-0.0001 AND ${tokm}+0.0001)
mschaefer@9116:           GROUP BY s.id
mschaefer@9144:           ORDER BY MIN(s.filename) DESC
mschaefer@9116:         </dc:statement>
mschaefer@9116:         <dc:if test="dc:has-result()">
mschaefer@9116:           <dc:for-each>
gernotbelger@9282:             <infrastructureseries name="{$seriesname}" description="{$seriesname}" ids="infrastructurex-{$id}-{$seriesname}" factory="infrastructuref" target_out="{$out}" info="{$info}" />
mschaefer@9116:           </dc:for-each>
mschaefer@9116:         </dc:if>
mschaefer@9116:       </dc:context>
mschaefer@9116:     </dc:macro>
mschaefer@9116: 
mschaefer@9117:     <!-- collisions imported from CSV-files for S-INFO -->
mschaefer@9341:     <dc:macro name="sinfo_predefined_collision">
mschaefer@9117:       <dc:context>
mschaefer@9117:         <dc:statement>
mschaefer@9117:           SELECT s.id AS id, MIN(s.filename) AS seriesname, MIN(v.station) AS km_min, MAX(v.station) AS km_max, MIN(s.year) AS year,
mschaefer@9117:           MIN(s.filename) || '&lt;br /&gt;'
mschaefer@9117:           || MIN(s.kmrange_info) || '&lt;br /&gt;'
mschaefer@9117:           || MIN(s.year) || '&lt;br /&gt;' AS info
mschaefer@9144:           FROM collision s
mschaefer@9144:           INNER JOIN collision_values v ON s.id=v.collision_id
mschaefer@9117:           WHERE (s.river_id=${river_id})
gernotbelger@9299:           AND (v.station BETWEEN ${fromkm}-0.0001 AND
gernotbelger@9299:           ${tokm}+0.0001)
mschaefer@9117:           GROUP BY s.id
mschaefer@9144:           ORDER BY MIN(s.year)
mschaefer@9117:         </dc:statement>
mschaefer@9117:         <dc:if test="dc:has-result()">
mschaefer@9117:           <dc:for-each>
gernotbelger@9282:             <collisionseries name="{$seriesname}" description="{$seriesname}" ids="collisionx-{$id}-{$year}-{$seriesname}" factory="collisionf" target_out="{$out}" info="{$info}" />
mschaefer@9117:           </dc:for-each>
mschaefer@9117:         </dc:if>
mschaefer@9117:       </dc:context>
mschaefer@9117:     </dc:macro>
gernotbelger@9127: 
mschaefer@9341:     <!-- U-INFO -->
mschaefer@9341:     <dc:macro name="uinfo_salix_line">
mschaefer@9341:       <dc:filter expr="$a_state = 'state.uinfo.salix_line'
mschaefer@9341:           and ($facet_name = 'uinfo_facet_salix_line' or $facet_name = 'uinfo_facet_salix_line.filtered'
mschaefer@9341:           or $facet_name = 'uinfo_facet_salix_mnwmw' or $facet_name = 'uinfo_facet_salix_mnwmw.filtered'
mschaefer@9341:           or $facet_name = 'uinfo_facet_salix_scenario' or $facet_name = 'uinfo_facet_salix_scenario.filtered')">
mschaefer@9341:         <dc:if test="dc:has-result()">
mschaefer@9378:           <uinfo_salix_lines>
mschaefer@9378:             <dc:call-macro name="collection-group">
mschaefer@9378:               <uinfo_salix_line description="{dc:group-key()}">
mschaefer@9378:                 <dc:for-each>
mschaefer@9378:                   <dc:element name="${facet_name}">
mschaefer@9378:                     <dc:attribute name="factory" value="uinfo" />
mschaefer@9378:                     <dc:attribute name="target_out" value="${out}" />
mschaefer@9378:                     <dc:attribute name="description" value="${facet_description}" />
mschaefer@9378:                     <dc:attribute name="ids" value="${facet_num}" />
mschaefer@9378:                     <dc:attribute name="artifact-id" value="${a_gid}" />
mschaefer@9378:                     <dc:attribute name="out" value="${out_name}" />
mschaefer@9378:                   </dc:element>
mschaefer@9378:                 </dc:for-each>
mschaefer@9378:               </uinfo_salix_line>
mschaefer@9378:             </dc:call-macro>
mschaefer@9378:           </uinfo_salix_lines>
mschaefer@9341:         </dc:if>
mschaefer@9341:       </dc:filter>
mschaefer@9341:     </dc:macro>
mschaefer@9341: 
gernotbelger@9299:     <!-- Vegetation zones, edited by the user -->
gernotbelger@9299:     <dc:macro name="vegetationzones">
gernotbelger@9499:       <dc:filter expr="$a_state = 'state.uinfo.vegetation_zones' and $facet_name = 'uinfo_facet_vegetation_zones_cross_section'"> <!--'uinfo_facet_vegetation_zones_cross_section'" >  and $facet_name = 'csv'"> we misuse the csv-facet -->
gernotbelger@9299:         <dc:if test="dc:has-result()">
gernotbelger@9499:           <vegetation_zones>
gernotbelger@9499:             <dc:for-each>
gernotbelger@9499:               <dc:variable name="vegzonedata" expr="dc:data_from_artifact($a_gid,'vegzones')" />
gernotbelger@9506:               <dc:variable name="label_temp" type="string" expr="concat(dc:get('ld_f'), ' km - ', dc:get('ld_t'), ' km')" />
gernotbelger@9499: 
gernotbelger@9499:               <dc:element name="${facet_name}">
gernotbelger@9499:                 <dc:attribute name="factory" value="uinfo" />
gernotbelger@9499:                 <dc:attribute name="target_out" value="${out}" />
gernotbelger@9499:                 <dc:attribute name="description" value="${label_temp}" />
gernotbelger@9499:                 <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9499:                 <dc:attribute name="out" value="${out_name}" />
gernotbelger@9499:                 <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9499:                 <!-- veg zones string as attribute -->
gernotbelger@9499:                 <dc:attribute name="data" value="${vegzonedata}" />
gernotbelger@9499:               </dc:element>
gernotbelger@9499:             </dc:for-each>
gernotbelger@9499:           </vegetation_zones>
gernotbelger@9299:         </dc:if>
gernotbelger@9299:       </dc:filter>
gernotbelger@9299:     </dc:macro>
gernotbelger@9299: 
gernotbelger@9495:     <!-- U-INFO -->
gernotbelger@9495:     <dc:macro name="bundu_bezugswst">
gernotbelger@9495:       <dc:filter
gernotbelger@9495:         expr="$a_state = 'state.bundu.wst' 
gernotbelger@9495:        
gernotbelger@9495:           and ($facet_name = 'longitudinal_section.w' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_channelmin' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_01' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_02' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_03' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_04' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_05' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_06' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_07' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_08' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_09' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_10' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_01' 
gernotbelger@9495:           or $facet_name = 'bundu_facet_bedheight_01' 
gernotbelger@9495:           or $facet_name = 'longitudinal_section.q' 
gernotbelger@9495:           or $facet_name = 'longitudinal_section.area' 
gernotbelger@9495:           or $facet_name = 'longitudinal_section.manualpoints' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_flowdepth.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_channeldepth' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_01.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_02.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_03.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_04.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_05.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_06.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_07.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_08.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_09.filtered' 
gernotbelger@9495:             or $facet_name = 'bundu_facet_depth_10.filtered'  
gernotbelger@9495:             or $facet_name = 'longitudinal_section.area' 
gernotbelger@9495:             or $facet_name = 'longitudinal_section.manualpoints' 
gernotbelger@9495:             )" > 
gernotbelger@9495:             
gernotbelger@9495:         <dc:if test="dc:has-result()">
gernotbelger@9495:           <bundu_bezugswsts>
gernotbelger@9495:             <dc:call-macro name="collection-group">
gernotbelger@9495:               <bundu_bezugswst description="{dc:group-key()}">
gernotbelger@9495:                 <dc:for-each>
gernotbelger@9495:                   <dc:element name="${facet_name}">
gernotbelger@9495:                     <dc:attribute name="factory" value="bundu" />
gernotbelger@9495:                     <dc:attribute name="target_out" value="${out}" />
gernotbelger@9495:                     <dc:attribute name="description" value="${facet_description}" />
gernotbelger@9495:                     <dc:attribute name="ids" value="${facet_num}" />
gernotbelger@9495:                     <dc:attribute name="artifact-id" value="${a_gid}" />
gernotbelger@9495:                     <dc:attribute name="out" value="${out_name}" />
gernotbelger@9495:                   </dc:element>
gernotbelger@9495:                 </dc:for-each>
gernotbelger@9495:               </bundu_bezugswst>
gernotbelger@9495:             </dc:call-macro>
gernotbelger@9495:           </bundu_bezugswsts>
gernotbelger@9495:         </dc:if>
gernotbelger@9495:       </dc:filter>
gernotbelger@9495:     </dc:macro>
gernotbelger@9495: 
gernotbelger@9495: 
gernotbelger@9495: 
aheinecke@6053:   </datacage>
gernotbelger@8941: </dc:template>