Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSFloodplainArtifact.java @ 5496:23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 28 Mar 2013 12:39:14 +0100 |
parents | a2735a4bf75e |
children |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSFloodplainArtifact.java Thu Mar 28 12:38:06 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSFloodplainArtifact.java Thu Mar 28 12:39:14 2013 +0100 @@ -84,21 +84,6 @@ riverId = 0; } - 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; - } - protected River getRiver() { return RiverFactory.getRiver(getRiverId()); } @@ -121,19 +106,46 @@ @Override protected Envelope getExtent(boolean reproject) { - River river = getRiver(); - Floodplain plain = Floodplain.getFloodplain(river.getName()); + River river = getRiver(); + List<Floodplain> fps; - Envelope e = plain.getGeom().getEnvelopeInternal(); + String kind = getIdPart(2); - return e != null && reproject - ? GeometryUtils.transform(e, getSrid()) - : e; + if (kind != null && ! kind.equals("1")) { + fps = Floodplain.getFloodplains(river.getName(), + getName(), Integer.parseInt(kind)); + } else { + fps = Floodplain.getFloodplains(river.getName(), 1); + } + + Envelope max = null; + + for (Floodplain fp: fps) { + Envelope env = fp.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 + + " AND name='" + getName() + "'"; + } + return "river_id=" + String.valueOf(getRiverId()) + + " AND kind_id=1"; } @Override