# HG changeset patch # User Ingo Weinzierl # Date 1325760392 0 # Node ID cbeeaaad10561c8472127729547a627ed077f63d # Parent 29459ddb6f304a34c96e9f10905d8cca08c400ca #440 Support river axes that consist of more than a single geometry. flys-artifacts/trunk@3593 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 29459ddb6f30 -r cbeeaaad1056 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Jan 05 08:34:47 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Jan 05 10:46:32 2012 +0000 @@ -1,3 +1,21 @@ +2012-01-05 Ingo Weinzierl + + flys/issue440 (Karte: WSPLGEN Berechnungen für Mosel schlagen fehl) + + * src/main/java/de/intevation/flys/utils/GeometryUtils.java: Modified the + getRiverBoundary() method because the signature of + RiverAxis.getRiverAxis() has changed. This method will now take each + geometry into account, that is retrieved by + RiverAxis.getRiverBoundary(). + + * src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java: + Use GeometryUtils.getRiverBoundary() to determine the boundary of a + river. + + * src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java: + Create the riveraxis shapefile with all geometries returned by + RiverAxis.getRiverAxis(). + 2012-01-05 Ingo Weinzierl * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Repaired diff -r 29459ddb6f30 -r cbeeaaad1056 flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java Thu Jan 05 08:34:47 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java Thu Jan 05 10:46:32 2012 +0000 @@ -77,12 +77,11 @@ cr.addAttr(root, "name", river); mapinfo.appendChild(root); - RiverAxis axis = RiverAxis.getRiverAxis(river); - if (axis != null) { - Envelope env = axis.getGeom().getEnvelopeInternal(); - String bounds = GeometryUtils.jtsBoundsToOLBounds(env); + Envelope env = GeometryUtils.getRiverBoundary(river); + if (env != null) { + String bounds = GeometryUtils.jtsBoundsToOLBounds(env); + logger.debug("River '" + river + "' bounds: " + bounds); - logger.debug("River '" + river + "' bounds: " + bounds); Element bbox = cr.create("bbox"); cr.addAttr(bbox, "value", bounds); root.appendChild(bbox); diff -r 29459ddb6f30 -r cbeeaaad1056 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java Thu Jan 05 08:34:47 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java Thu Jan 05 10:46:32 2012 +0000 @@ -510,22 +510,26 @@ String srid = FLYSUtils.getRiverSrid(artifact); String srs = "EPSG:" + srid; - RiverAxis axis = RiverAxis.getRiverAxis(river); - if (axis == null) { + List axes = RiverAxis.getRiverAxis(river); + if (axes == null || axes.size() == 0) { logger.warn("Could not find river axis for: '" + river + "'"); return; } - Geometry geom = axis.getGeom(); - SimpleFeatureType ft = GeometryUtils.buildFeatureType( "axis", srs, LineString.class); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft); - builder.add(geom); + FeatureCollection collection = FeatureCollections.newCollection(); - FeatureCollection collection = FeatureCollections.newCollection(); - collection.add(builder.buildFeature("0")); + for (int i = 0, n = axes.size(); i < n; i++) { + RiverAxis axis = axes.get(i); + + builder.add(axis.getGeom()); + collection.add(builder.buildFeature(String.valueOf(i))); + + builder.reset(); + } File axisShape = new File(dir, WSPLGEN_AXIS); diff -r 29459ddb6f30 -r cbeeaaad1056 flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Thu Jan 05 08:34:47 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Thu Jan 05 10:46:32 2012 +0000 @@ -46,11 +46,24 @@ public static Envelope getRiverBoundary(String rivername) { - RiverAxis axis = RiverAxis.getRiverAxis(rivername); - if (axis != null) { - // TODO Take the correct EPSG into account. Maybe, we need to - // reproject the geometry. - return axis.getGeom().getEnvelopeInternal(); + List axes = RiverAxis.getRiverAxis(rivername); + if (axes != null && axes.size() > 0) { + Envelope max = null; + + for (RiverAxis axis: axes) { + // TODO Take the correct EPSG into account. Maybe, we need to + // reproject the geometry. + Envelope env = axis.getGeom().getEnvelopeInternal(); + + if (max == null) { + max = env; + } + else { + max.expandToInclude(env); + } + } + + return max; } return null;