diff flys-artifacts/doc/conf/meta-data.xml @ 5515:87dab419b924

Properly handle hydr_boundaries and hydr_boundaries_poly in datacage This also fixes hydr_boundaries_poly which refered to the wrong table
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 28 Mar 2013 17:13:53 +0100
parents 23d8f2700b38
children 56d18ecc7d41
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/meta-data.xml	Thu Mar 28 15:56:24 2013 +0100
+++ b/flys-artifacts/doc/conf/meta-data.xml	Thu Mar 28 17:13:53 2013 +0100
@@ -1238,85 +1238,109 @@
                 </dc:if>
               </dc:context>
             </dc:macro>
-            <dc:macro name="flood-map-hydr-boundaries">
-              <hydr_boundaries_lines>
-                <dc:call-macro name="flood-map-hydr-boundaries-lines"/>
-              </hydr_boundaries_lines>
-              <hydr_boundaries_polygons>
-                <dc:call-macro name="flood-map-hydr-boundaries-poly"/>
-              </hydr_boundaries_polygons>
+            <dc:macro name="flood-map-hydr-boundaries-state">
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                  name
+                  FROM hydr_boundaries
+                  WHERE river_id = ${river_id}
+                  AND kind = 2
+                </dc:statement>
+                <dc:elements>
+                  <line factory="wmshydrboundariesfactory"
+                    ids="{$river_id};{$name};2"
+                    name="{$name}"/>
+                </dc:elements>
+              </dc:context>
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                  name
+                  FROM hydr_boundaries_poly
+                  WHERE river_id = ${river_id}
+                  AND kind = 2
+                </dc:statement>
+                <dc:elements>
+                  <line factory="wmshydrboundariespolyfactory"
+                    ids="{$river_id};{$name};2"
+                    name="{$name}"/>
+                </dc:elements>
+              </dc:context>
             </dc:macro>
             <dc:macro name="flood-map-hydr-boundaries-lines">
-              <bfg>
-                <dc:context>
-                  <dc:statement>
-                    SELECT count(*) as km_exists, name as name
-                    FROM hydr_boundaries WHERE river_id = ${river_id} AND kind = 1 GROUP BY name
-                  </dc:statement>
-                   <dc:elements>
-                    <dc:if test="$km_exists>0">
-                      <hydrboundary>
-                        <dc:attribute name="factory" value="wmshydrboundariesfactory"/>
-                        <dc:attribute name="ids" value="${river_id};${name}"/>
-                        <dc:attribute name="name" value="${name}"/>
-                      </hydrboundary>
-                    </dc:if>
-                  </dc:elements>
-                </dc:context>
-              </bfg>
-              <land>
-                <dc:context>
-                  <dc:statement>
-                    SELECT count(*) as km_exists, name as name
-                    FROM hydr_boundaries WHERE river_id = ${river_id} AND kind = 2 GROUP BY name
-                  </dc:statement>
-                   <dc:elements>
-                    <dc:if test="$km_exists>0">
-                      <hydrboundary>
-                        <dc:attribute name="factory" value="wmshydrboundariesfactory"/>
-                        <dc:attribute name="ids" value="${river_id};${name}"/>
-                        <dc:attribute name="name" value="${name}"/>
-                      </hydrboundary>
-                    </dc:if>
-                  </dc:elements>
-                </dc:context>
-              </land>
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                  name
+                  FROM hydr_boundaries
+                  WHERE river_id = ${river_id}
+                  AND kind = 1
+                </dc:statement>
+                <dc:comment> What about all other line kinds?</dc:comment>
+                <dc:if test="dc:has-result()">
+                  <lines>
+                    <dc:elements>
+                      <line factory="wmshydrboundariesfactory"
+                        ids="{$river_id};{$name};1"
+                        name="{$name}"/>
+                    </dc:elements>
+                  </lines>
+                </dc:if>
+              </dc:context>
             </dc:macro>
             <dc:macro name="flood-map-hydr-boundaries-poly">
-              <bfg>
-                <dc:context>
-                  <dc:statement>
-                    SELECT count(*) as km_exists, name as name
-                    FROM hydr_boundaries_poly WHERE river_id = ${river_id} AND kind = 1 GROUP BY name
-                  </dc:statement>
-                   <dc:elements>
-                    <dc:if test="$km_exists>0">
-                      <hws>
-                        <dc:attribute name="factory" value="wmshydrboundariespolyfactory"/>
-                        <dc:attribute name="ids" value="${river_id};${name}"/>
-                        <dc:attribute name="name" value="${name}"/>
-                      </hws>
-                    </dc:if>
-                  </dc:elements>
-                </dc:context>
-              </bfg>
-              <land>
-                <dc:context>
-                  <dc:statement>
-                    SELECT count(*) as km_exists, name as name
-                    FROM hydr_boundaries_poly WHERE river_id = ${river_id} AND kind = 2 GROUP BY name
-                  </dc:statement>
-                   <dc:elements>
-                    <dc:if test="$km_exists>0">
-                      <hws>
-                        <dc:attribute name="factory" value="wmshydrboundariespolyfactory"/>
-                        <dc:attribute name="ids" value="${river_id};${name}"/>
-                        <dc:attribute name="name" value="${name}"/>
-                      </hws>
-                    </dc:if>
-                  </dc:elements>
-                </dc:context>
-              </land>
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                  b.sectie AS sectie_id,
+                  sk.name AS sectie
+                  FROM hydr_boundaries_poly b
+                  JOIN sectie_kinds sk ON b.sectie = sk.id
+                  WHERE b.river_id = ${river_id}
+                  AND b.kind = 1
+                </dc:statement>
+                <dc:if test="dc:has-result()">
+                  <sobek_areas>
+                    <dc:elements>
+                      <boundary name="{$sectie}"
+                        factory="wmshydrboundariespolyfactory"
+                        ids="{$river_id};{$sectie};1;{$sectie_id};-1"/>
+                    </dc:elements>
+                  </sobek_areas>
+                </dc:if>
+              </dc:context>
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                  b.sobek AS sobek_id,
+                  sk.name AS sobek
+                  FROM hydr_boundaries_poly b
+                  JOIN sobek_kinds sk ON b.sobek = sk.id
+                  WHERE b.river_id = ${river_id}
+                  AND b.kind = 1
+                </dc:statement>
+                <dc:if test="dc:has-result()">
+                  <sobek_flooded>
+                    <dc:elements>
+                      <boundary name="{$sobek}"
+                        factory="wmshydrboundariespolyfactory"
+                        ids="{$river_id};{$sobek};1;-1;{$sobek_id}"/>
+                    </dc:elements>
+                  </sobek_flooded>
+                </dc:if>
+              </dc:context>
+            </dc:macro>
+            <dc:macro name="flood-map-hydr-boundaries">
+              <bfg_model>
+                <areas>
+                  <dc:call-macro name="flood-map-hydr-boundaries-poly"/>
+                </areas>
+                <dc:call-macro name="flood-map-hydr-boundaries-lines"/>
+              </bfg_model>
+              <federal>
+                <dc:call-macro name="flood-map-hydr-boundaries-state"/>
+              </federal>
             </dc:macro>
             <dc:macro name="flood-map-floodplain">
               <dc:context>

http://dive4elements.wald.intevation.org