[Dive4elements-commits] [PATCH 5 of 8] Properly handle hydr_boundaries and hydr_boundaries_poly in datacage
Wald Commits
scm-commit at wald.intevation.org
Thu Mar 28 17:15:25 CET 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1364487233 -3600
# Node ID 87dab419b924486b0c8c951043846b42edd7fd6f
# Parent 4c4fed23693f237945893286edb1183caed6539d
Properly handle hydr_boundaries and hydr_boundaries_poly in datacage
This also fixes hydr_boundaries_poly which refered to the wrong
table
diff -r 4c4fed23693f -r 87dab419b924 flys-artifacts/doc/conf/meta-data.xml
--- 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>
diff -r 4c4fed23693f -r 87dab419b924 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSHydrBoundaryArtifact.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSHydrBoundaryArtifact.java Thu Mar 28 15:56:24 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSHydrBoundaryArtifact.java Thu Mar 28 17:13:53 2013 +0100
@@ -102,8 +102,14 @@
@Override
protected Envelope getExtent(boolean reproject) {
- List<HydrBoundary> boundaries = HydrBoundary.getHydrBoundaries(
- getRiverId(), getName());
+ List<HydrBoundary> boundaries;
+ String kind = getIdPart(2);
+ if (kind != null) {
+ boundaries = HydrBoundary.getHydrBoundaries(getRiverId(),
+ getName(), Integer.parseInt(kind));
+ } else {
+ boundaries = HydrBoundary.getHydrBoundaries(getRiverId(), getName());
+ }
Envelope max = null;
@@ -125,6 +131,12 @@
@Override
protected String getFilter() {
+ String kind = getIdPart(2);
+ if (kind != null) {
+ return "river_id=" + String.valueOf(getRiverId())
+ + " AND name='" + getName() + "'"
+ + " AND kind = " + kind;
+ }
return "river_id=" + String.valueOf(getRiverId())
+ " AND name='" + getName() + "'";
}
diff -r 4c4fed23693f -r 87dab419b924 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSHydrBoundaryPolyArtifact.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSHydrBoundaryPolyArtifact.java Thu Mar 28 15:56:24 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSHydrBoundaryPolyArtifact.java Thu Mar 28 17:13:53 2013 +0100
@@ -102,8 +102,31 @@
@Override
protected Envelope getExtent(boolean reproject) {
- List<HydrBoundaryPoly> boundaries = HydrBoundaryPoly.getHydrBoundaries(
- getRiverId(), getName());
+ String kind = getIdPart(2);
+ String sectie = getIdPart(3);
+ String sobek = getIdPart(4);
+ int kindId = -1;
+ int sectieId = -1;
+ int sobekId = -1;
+
+ if (kind != null) {
+ kindId = Integer.parseInt(kind);
+ }
+ if (sectie != null && !sectie.equals("-1")) {
+ sectieId = Integer.parseInt(sectie);
+ }
+ if (sobek != null && !sobek.equals("-1")) {
+ sobekId = Integer.parseInt(sobek);
+ }
+
+ List<HydrBoundaryPoly> boundaries;
+ if (kindId == -1 && sobekId == -1 && sectieId == -1) {
+ boundaries = HydrBoundaryPoly.getHydrBoundaries(
+ getRiverId(), getName());
+ } else {
+ boundaries = HydrBoundaryPoly.getHydrBoundaries(
+ getRiverId(), kindId, sectieId, sobekId);
+ }
Envelope max = null;
@@ -125,8 +148,29 @@
@Override
protected String getFilter() {
+ // Expected id string:
+ // river_id;layer_name;kind;sectie;sobek
+ String kind = getIdPart(2);
+ String sectie = getIdPart(3);
+ String sobek = getIdPart(4);
+
+ String filter = "";
+ if (kind != null && !kind.equals("-1")) {
+ filter += " AND kind = " + kind;
+ }
+ if (sectie != null && !sectie.equals("-1")) {
+ filter += " AND sectie = " + sectie;
+ }
+ if (sobek != null && !sobek.equals("-1")) {
+ filter += " AND sobek = " + sobek;
+ }
+
+ if (filter.isEmpty()) {
+ filter = " AND name='" + getName() + "'";
+ }
+
return "river_id=" + String.valueOf(getRiverId())
- + " AND name='" + getName() + "'";
+ + filter;
}
@Override
@@ -134,10 +178,10 @@
String srid = getSrid();
if (FLYSUtils.isUsingOracle()) {
- return "geom FROM hydr_boundaries USING SRID " + srid;
+ return "geom FROM hydr_boundaries_poly USING SRID " + srid;
}
else {
- return "geom FROM hydr_boundaries USING UNIQUE id USING SRID " + srid;
+ return "geom FROM hydr_boundaries_poly USING UNIQUE id USING SRID " + srid;
}
}
diff -r 4c4fed23693f -r 87dab419b924 flys-backend/src/main/java/de/intevation/flys/model/HydrBoundary.java
--- a/flys-backend/src/main/java/de/intevation/flys/model/HydrBoundary.java Thu Mar 28 15:56:24 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/HydrBoundary.java Thu Mar 28 17:13:53 2013 +0100
@@ -91,6 +91,18 @@
this.geom = geom;
}
+ public static List<HydrBoundary> getHydrBoundaries(int riverId, String name, int kindId) {
+ Session session = SessionHolder.HOLDER.get();
+
+ Query query = session.createQuery(
+ "from HydrBoundary where river.id =:river_id and name=:name" +
+ " and kind.id=:kind_id");
+ query.setParameter("river_id", riverId);
+ query.setParameter("name", name);
+ query.setParameter("kind_id", kindId);
+
+ return query.list();
+ }
public static List<HydrBoundary> getHydrBoundaries(int riverId, String name) {
Session session = SessionHolder.HOLDER.get();
diff -r 4c4fed23693f -r 87dab419b924 flys-backend/src/main/java/de/intevation/flys/model/HydrBoundaryPoly.java
--- a/flys-backend/src/main/java/de/intevation/flys/model/HydrBoundaryPoly.java Thu Mar 28 15:56:24 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/HydrBoundaryPoly.java Thu Mar 28 17:13:53 2013 +0100
@@ -104,6 +104,27 @@
return query.list();
}
+ public static List<HydrBoundaryPoly> getHydrBoundaries(int riverId,
+ int kind, int sectie, int sobek) {
+ Session session = SessionHolder.HOLDER.get();
+
+ String filter = " where river.id =:river_id";
+
+ if (kind != -1) {
+ filter += " and kind = " + kind;
+ }
+ if (sectie != -1) {
+ filter += " and sectie = " + sectie;
+ }
+ if (sobek != -1){
+ filter += " and sobek = " + sobek;
+ }
+
+ Query query = session.createQuery("from HydrBoundaryPoly" + filter);
+ query.setParameter("river_id", riverId);
+ return query.list();
+ }
+
/**
* Get sectie.
*
diff -r 4c4fed23693f -r 87dab419b924 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Mar 28 15:56:24 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Mar 28 17:13:53 2013 +0100
@@ -1174,5 +1174,15 @@
String axis();
+ String bfg_model();
+
+ String federal();
+
+ String areas();
+
+ String sobek_areas();
+
+ String sobek_flooded();
+
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 4c4fed23693f -r 87dab419b924 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Mar 28 15:56:24 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Mar 28 17:13:53 2013 +0100
@@ -466,6 +466,11 @@
route_data = Route Data
other = Other
axis = Axis
+bfg_model = BfG-Model
+federal = Federal States
+areas = Areas
+sobek_flooded = SOBEK-Boundary flooded / not flooded
+sobek_areas = SOBEK-Areas
startcolor = Colorrange start color
endcolor = Colorrange end color
diff -r 4c4fed23693f -r 87dab419b924 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Mar 28 15:56:24 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Mar 28 17:13:53 2013 +0100
@@ -467,6 +467,11 @@
route_data = Streckendaten
other = Sonstige
axis = Achse
+bfg_model = BfG-Modell
+federal = Bundesländer
+areas = Flächen
+sobek_flooded = SOBEK-Grenzlinie durchflutet / nicht durchflutet
+sobek_areas = SOBEK-Bereiche
startcolor = Farbverlauf Startfarbe
endcolor = Farbverlauf Endfarbe
More information about the Dive4elements-commits
mailing list