Mercurial > dive4elements > river
changeset 5404:08262e0ce57a
Add buildings with kinds to datacage
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 25 Mar 2013 15:02:04 +0100 |
parents | e1cd77ddcbc4 |
children | 5ca06120b918 |
files | flys-artifacts/doc/conf/meta-data.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSBuildingsArtifact.java |
diffstat | 2 files changed, 36 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- 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>
--- 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() + "'"; }