Mercurial > dive4elements > river
changeset 5477:ae60bb7b8085
Add proper handling of multiple river_axes for datacage and rivermapfile
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 27 Mar 2013 18:31:31 +0100 |
parents | f9eee1909e6e |
children | 5bb3610b94f7 |
files | flys-artifacts/doc/conf/meta-data.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties |
diffstat | 7 files changed, 127 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/meta-data.xml Wed Mar 27 17:49:46 2013 +0100 +++ b/flys-artifacts/doc/conf/meta-data.xml Wed Mar 27 18:31:31 2013 +0100 @@ -1195,6 +1195,49 @@ </dc:if> </dc:context> </dc:macro> + <dc:macro name="flood-map-riveraxis"> + <dc:context> + <dc:statement> + SELECT DISTINCT + ax.kind_id as kind_id, + ak.name as kind_name + FROM river_axes ax + JOIN axis_kinds ak on ax.kind_id = ak.id + WHERE river_id = ${river_id} + AND kind_id=1 + </dc:statement> + <dc:if test="dc:has-result()"> + <dc:elements> + <actual factory="riveraxis"> + <dc:attribute name="description" value="${kind_name}"/> + <dc:attribute name="ids" value="${river_id};${kind_name};${kind_id}"/> + </actual> + </dc:elements> + </dc:if> + </dc:context> + <dc:context> + <dc:statement> + SELECT DISTINCT + ak.name as kind_name, + ax.kind_id as kind_id, + ax.name as layer_name + FROM river_axes ax + JOIN axis_kinds ak on ax.kind_id = ak.id + WHERE river_id = ${river_id} + AND kind_id <> 1 + </dc:statement> + <dc:if test="dc:has-result()"> + <other> + <dc:elements> + <misc-axis factory="riveraxis"> + <dc:attribute name="description" value="${layer_name}"/> + <dc:attribute name="ids" value="${river_id};${layer_name};${kind_id}"/> + </misc-axis> + </dc:elements> + </other> + </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"/> @@ -1745,10 +1788,9 @@ </qps> <dc:call-macro name="flood-map-fixpoints"/> <dc:call-macro name="flood-map-km"/> - <riveraxis> - <dc:attribute name="factory" value="riveraxis"/> - <dc:attribute name="ids" value="${river_id}"/> - </riveraxis> + <axis> + <dc:call-macro name="flood-map-riveraxis"/> + </axis> </dc:macro> <dc:macro name="flood-map-complete">
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java Wed Mar 27 17:49:46 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java Wed Mar 27 18:31:31 2013 +0100 @@ -11,6 +11,7 @@ import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.model.River; +import de.intevation.flys.model.RiverAxis; import de.intevation.flys.utils.FLYSUtils; import de.intevation.flys.utils.GeometryUtils; @@ -80,23 +81,6 @@ public RiverAxisState(FLYSArtifact artifact) { super(artifact); - riverId = 0; - } - - @Override - public int getRiverId() { - if (riverId == 0) { - String ids = artifact.getDataAsString("ids"); - - try { - riverId = Integer.parseInt(ids); - } - catch (NumberFormatException nfe) { - logger.error("Cannot parse river id from '" + ids + "'"); - } - } - - return riverId; } @Override @@ -123,23 +107,63 @@ @Override protected Envelope getExtent(boolean reproject) { River river = RiverFactory.getRiver(getRiverId()); + List<RiverAxis> axes; - if (reproject) { - logger.debug("Query extent for RiverAxis with Srid: " + getSrid()); - return GeometryUtils.transform( - GeometryUtils.getRiverBoundary(river.getName()), - getSrid()); + String kind = getIdPart(2); + + if (kind != null && kind.equals("1")) { + axes = RiverAxis.getRiverAxis(river.getName(), + Integer.parseInt(kind)); + } else if (kind != null) { + axes = RiverAxis.getRiverAxis(river.getName(), + getName(), Integer.parseInt(kind)); + } else { + if (reproject) { + logger.debug("Query extent for RiverAxis with Srid: " + getSrid()); + return GeometryUtils.transform( + GeometryUtils.getRiverBoundary(river.getName()), + getSrid()); + } else { + return GeometryUtils.transform( + GeometryUtils.getRiverBoundary(river.getName()), + "31467"); + } } - else { - return GeometryUtils.transform( - GeometryUtils.getRiverBoundary(river.getName()), - "31467"); + + Envelope max = null; + + for (RiverAxis ax: axes) { + Envelope env = ax.getGeom().getEnvelopeInternal(); + + if (max == null) { + max = env; + continue; + } + + max.expandToInclude(env); } + + return max != null && reproject + ? GeometryUtils.transform(max, getSrid()) + : max; } @Override protected String getFilter() { - return "river_id=" + String.valueOf(getRiverId()); + String kind = getIdPart(2); + if (kind != null && kind.equals("1")) { + return "river_id=" + String.valueOf(getRiverId()) + + " AND kind_id=" + kind; + } else if (kind != null) { + return "river_id=" + String.valueOf(getRiverId()) + + " AND kind_id=" + kind + + " AND name='" + getName() + "'"; + } else if (getIdPart(1) != null) { + return "river_id=" + String.valueOf(getRiverId()) + + " AND name='" + getName() + "'"; + } + return "river_id=" + String.valueOf(getRiverId()) + + " AND kind_id=" + kind; } @Override
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java Wed Mar 27 17:49:46 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java Wed Mar 27 18:31:31 2013 +0100 @@ -116,7 +116,7 @@ } else { layerInfo.setData("geom FROM river_axes"); } - layerInfo.setFilter("river_id = " + riverID); + layerInfo.setFilter("river_id = " + riverID + " and kind_id = 1"); layerInfo.setTitle(riverName + " RiverAxis"); File layerFile = new File("river-" + riverName + ".map");
--- a/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java Wed Mar 27 17:49:46 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java Wed Mar 27 18:31:31 2013 +0100 @@ -34,6 +34,7 @@ private Integer id; private AxisKind kind; private River river; + private String name; private MultiLineString geom; public static final int KIND_UNKOWN = 0; @@ -67,6 +68,15 @@ this.river = river; } + @Column(name = "name") + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } /** * Get kind. @@ -106,6 +116,21 @@ return getRiverAxis(river, KIND_CURRENT); } + public static List<RiverAxis> getRiverAxis(String river, String name, int kind) + throws HibernateException { + Session session = SessionHolder.HOLDER.get(); + Query query = session.createQuery( + "from RiverAxis as ax where river.name =:river" + + " and kind.id =:kind" + + " and ax.name=:name"); + query.setParameter("river", river); + query.setParameter("kind", kind); + query.setParameter("name", name); + + List<RiverAxis> list = query.list(); + return list.isEmpty() ? null : list; + } + public static List<RiverAxis> getRiverAxis(String river, int kind) throws HibernateException { Session session = SessionHolder.HOLDER.get();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed Mar 27 17:49:46 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed Mar 27 18:31:31 2013 +0100 @@ -1170,5 +1170,7 @@ String other(); + String axis(); + } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed Mar 27 17:49:46 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed Mar 27 18:31:31 2013 +0100 @@ -464,6 +464,7 @@ jetties = Jetties route_data = Route Data other = Other +axis = Axis startcolor = Colorrange start color endcolor = Colorrange end color
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed Mar 27 17:49:46 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed Mar 27 18:31:31 2013 +0100 @@ -465,6 +465,7 @@ jetties = Buhnen route_data = Streckendaten other = Sonstige +axis = Achse startcolor = Farbverlauf Startfarbe endcolor = Farbverlauf Endfarbe