[Dive4elements-commits] [PATCH 4 of 5] Add buildings with kinds to datacage

Wald Commits scm-commit at wald.intevation.org
Mon Mar 25 15:39:19 CET 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1364220124 -3600
# Node ID 08262e0ce57a94242c8cd5e89679c085f3657a18
# Parent  e1cd77ddcbc44ff4132a305e5bcee67f245da95b
Add buildings with kinds to datacage

diff -r e1cd77ddcbc4 -r 08262e0ce57a flys-artifacts/doc/conf/meta-data.xml
--- a/flys-artifacts/doc/conf/meta-data.xml	Mon Mar 25 15:01:16 2013 +0100
+++ b/flys-artifacts/doc/conf/meta-data.xml	Mon Mar 25 15:02:04 2013 +0100
@@ -1521,23 +1521,25 @@
             </dc:macro>
 
 
-              <dc:macro name="flood-map-buildings">
-                <dc:context>
-                  <dc:statement>
-                    SELECT count(*) as km_exists, name as name
-                    FROM buildings WHERE river_id = ${river_id} GROUP BY name
-                  </dc:statement>
-                   <dc:elements>
-                    <dc:if test="$km_exists>0">
-                      <building>
-                        <dc:attribute name="factory" value="wmsbuildingsfactory"/>
-                        <dc:attribute name="ids" value="${river_id};${name}"/>
-                        <dc:attribute name="name" value="${name}"/>
-                      </building>
-                    </dc:if>
-                  </dc:elements>
-                </dc:context>
-              </dc:macro>
+            <dc:macro name="flood-map-buildings">
+              <dc:context>
+                <dc:statement>
+                  SELECT DISTINCT
+                  b.kind_id AS building_kind_id,
+                  bk.name AS building_kind
+                  FROM buildings b
+                  JOIN building_kinds bk ON b.kind_id = bk.id
+                  WHERE river_id = ${river_id}
+                </dc:statement>
+                <dc:elements>
+                  <buildings>
+                    <dc:attribute name="description" value="${building_kind}"/>
+                    <dc:attribute name="factory" value="wmsbuildingsfactory"/>
+                    <dc:attribute name="ids" value="${river_id};${building_kind};${building_kind_id}"/>
+                  </buildings>
+                </dc:elements>
+              </dc:context>
+            </dc:macro>
               <dc:macro name="flood-map-fixpoints">
                 <dc:context>
                   <dc:statement>
diff -r e1cd77ddcbc4 -r 08262e0ce57a flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSBuildingsArtifact.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSBuildingsArtifact.java	Mon Mar 25 15:01:16 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSBuildingsArtifact.java	Mon Mar 25 15:02:04 2013 +0100
@@ -102,8 +102,14 @@
 
         @Override
         protected Envelope getExtent(boolean reproject) {
-            List<Building> buildings =
-                Building.getBuildings(getRiverId(), getName());
+            List<Building> buildings;
+            String kind = getIdPart(2);
+
+            if (kind != null) {
+                buildings = Building.getBuildings(getRiverId(), Integer.parseInt(kind));
+            } else {
+                buildings = Building.getBuildings(getRiverId(), name);
+            }
 
             Envelope max = null;
 
@@ -125,6 +131,15 @@
 
         @Override
         protected String getFilter() {
+            // The expected id string is:
+            // river_id;layer-name;kind
+
+            String kind = getIdPart(2);
+            if (kind != null) {
+                // If kind is provided we filter by kind
+                return "river_id=" + String.valueOf(getRiverId()) +
+                    " AND kind_id=" + kind;
+            }
             return "river_id=" + String.valueOf(getRiverId()) +
                 " AND name='" + getName() + "'";
         }


More information about the Dive4elements-commits mailing list