# HG changeset patch # User Andre Heinecke # Date 1364405491 -3600 # Node ID ae60bb7b8085e9cd319e5cf8bc4d7dd552039716 # Parent f9eee1909e6e6ec5bbed3dad7b8ffbefc9777e70 Add proper handling of multiple river_axes for datacage and rivermapfile diff -r f9eee1909e6e -r ae60bb7b8085 flys-artifacts/doc/conf/meta-data.xml --- 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 @@ + + + + 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 + + + + + + + + + + + + + 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 + + + + + + + + + + + + + @@ -1745,10 +1788,9 @@ - - - - + + + diff -r f9eee1909e6e -r ae60bb7b8085 flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java --- 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 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 diff -r f9eee1909e6e -r ae60bb7b8085 flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java --- 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"); diff -r f9eee1909e6e -r ae60bb7b8085 flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java --- 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 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 list = query.list(); + return list.isEmpty() ? null : list; + } + public static List getRiverAxis(String river, int kind) throws HibernateException { Session session = SessionHolder.HOLDER.get(); diff -r f9eee1909e6e -r ae60bb7b8085 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 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 : diff -r f9eee1909e6e -r ae60bb7b8085 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 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 diff -r f9eee1909e6e -r ae60bb7b8085 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 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