changeset 9626:ad852be69900

Nachtrag Pos. 20: improved infrastructure query
author mschaefer
date Mon, 14 Oct 2019 12:55:07 +0200
parents 07f02019065e
children f51e23eb036a
files artifacts/doc/conf/meta-data.xml
diffstat 1 files changed, 37 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Mon Oct 14 08:14:58 2019 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Mon Oct 14 12:55:07 2019 +0200
@@ -1417,24 +1417,30 @@
     <!-- XXXXXXX -->
     <dc:macro name="predefined_infrastructures">
       <infrastructures TODO="i10n">
-        <dc:context connection="system">
-          <!--dc:choose>
-            <dc:when test="dc:contains($riverside, 'left')">
+        <dc:choose>
+          <dc:when test="dc:contains($riverside, 'left')">
+            <dc:context connection="system">
+              <dc:variable name="infra_rs_clause" expr="'AND (lower(rs.value) = ''links'')'" />
+              <!--dc:call-macro name="infrastructures_statement" /-->
               <dc:call-macro name="infrastructures_leftside_statement" />
               <dc:call-macro name="infrastructures_groups_fill" />
-            </dc:when>
-            <dc:when test="dc:contains($riverside, 'right')">
+            </dc:context>
+          </dc:when>
+          <dc:when test="dc:contains($riverside, 'right')">
+            <dc:context connection="system">
+              <dc:variable name="infra_rs_clause" expr="'AND (lower(rs.value) = ''rechts'')'" />
               <dc:call-macro name="infrastructures_rightside_statement" />
               <dc:call-macro name="infrastructures_groups_fill" />
-            </dc:when>
-            <dc:otherwise>
+            </dc:context>
+          </dc:when>
+          <dc:otherwise>
+            <dc:context connection="system">
+              <dc:variable name="infra_rs_clause" expr="" />
               <dc:call-macro name="infrastructures_bothsides_statement" />
               <dc:call-macro name="infrastructures_groups_fill" />
-            </dc:otherwise>
-          </dc:choose-->
-          <dc:call-macro name="infrastructures_bothsides_statement" />
-          <dc:call-macro name="infrastructures_groups_fill" />
-        </dc:context>
+            </dc:context>
+          </dc:otherwise>
+        </dc:choose>
       </infrastructures>
     </dc:macro>
     
@@ -1450,6 +1456,25 @@
       </dc:group>
     </dc:macro>
     
+    <dc:macro name="infrastructures_statement">
+      <dc:comment>die expansion von infra_rs_clause funktioniert nicht richtig, die messages erscheinen leider nicht im log...</dc:comment>
+      <dc:message>infrastructures_statement.infra_rs_clause: $infra_rs_clause</dc:message>
+      <dc:message>infrastructures_statement.infra_rs_clause: ${infra_rs_clause}</dc:message>
+      <dc:statement>
+          SELECT s.id, MIN(s.filename) AS filename, MIN(s.group_id) AS group_id, MIN(g.name) AS group_label, 
+            MIN(s.annotation_type_id) AS type_id, MIN(t.name) AS type_label
+          FROM (((infrastructure AS s INNER JOIN infrastructure_values AS v ON v.infrastructure_id = s.id)
+            INNER JOIN annotation_types AS g ON s.group_id = g.id)
+            INNER JOIN annotation_types AS t ON s.annotation_type_id = t.id)
+            INNER JOIN attributes AS rs ON v.attribute_id = rs.id
+          WHERE (s.river_id = ${river_id})
+            AND (v.station BETWEEN ${fromkm}-0.0001 AND ${tokm}+0.0001)
+            ${infra_rs_clause}
+          GROUP BY s.id
+          ORDER BY MIN(g.name), MIN(t.name)
+      </dc:statement>
+    </dc:macro>
+
     <dc:macro name="infrastructures_leftside_statement">
       <dc:statement>
           SELECT s.id, MIN(s.filename) AS filename, MIN(s.group_id) AS group_id, MIN(g.name) AS group_label, 

http://dive4elements.wald.intevation.org