# HG changeset patch # User Ingo Weinzierl # Date 1317051346 0 # Node ID eb3ab28d1c210af5fa10fd5362e044a762c01765 # Parent fb296bdf815f40c3a7c3abc73312888d114f7776 The extent of the WSPLGEN facets are now determined by the extent of the start and end CrossSectionTrack of the WSPLGEN calculation. flys-artifacts/trunk@2827 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r fb296bdf815f -r eb3ab28d1c21 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Sep 26 13:37:30 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon Sep 26 15:35:46 2011 +0000 @@ -1,3 +1,13 @@ +2011-09-26 Ingo Weinzierl + + * src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java: + The extent of the WSPLGEN result layer is now specified by the extent of + the CrossSectionTracks that matches the start and end kilometer of the + WSPLGEN calculation. + + * src/main/java/de/intevation/flys/utils/GeometryUtils.java: New function + that creates the OpenLayers bounding box based on two Geometries. + 2011-09-26 Felix Wolfsteller Improved w-differences diagram generation with included "absolute" diff -r fb296bdf815f -r eb3ab28d1c21 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 Mon Sep 26 13:37:30 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java Mon Sep 26 15:35:46 2011 +0000 @@ -126,6 +126,23 @@ return FLYSUtils.getRiverSrid(artifact); } + protected String getWSPLGENBounds() { + String river = getRiver(); + double kms[] = FLYSUtils.getKmRange(artifact); + + CrossSectionTrack a = + CrossSectionTrack.getCrossSectionTrack(river, kms[0]); + + CrossSectionTrack b = + CrossSectionTrack.getCrossSectionTrack(river, kms[1]); + + if (a == null || b == null) { + return null; + } + + return GeometryUtils.createOLBounds(a.getGeom(), b.getGeom()); + } + protected String getBounds() { return GeometryUtils.getRiverBounds(getRiver()); } @@ -147,10 +164,16 @@ hash, getUrl()); + String bounds = getWSPLGENBounds(); + + if (bounds == null || bounds.length() == 0) { + bounds = getBounds(); + } + wsplgen.addLayer( artifact.identifier() + MapfileGenerator.MS_WSPLGEN_POSTFIX); wsplgen.setSrid(getSrid()); - wsplgen.setExtent(getBounds()); + wsplgen.setExtent(bounds); facets.add(wsplgen); } diff -r fb296bdf815f -r eb3ab28d1c21 flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Mon Sep 26 13:37:30 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Mon Sep 26 15:35:46 2011 +0000 @@ -76,6 +76,35 @@ } + public static String createOLBounds(Geometry a, Geometry b) { + Coordinate[] ca = a.getCoordinates(); + Coordinate[] cb = b.getCoordinates(); + + double lowerX = Double.MAX_VALUE; + double lowerY = Double.MAX_VALUE; + double upperX = -Double.MAX_VALUE; + double upperY = -Double.MAX_VALUE; + + for (Coordinate c: ca) { + lowerX = lowerX < c.x ? lowerX : c.x; + lowerY = lowerY < c.y ? lowerY : c.y; + + upperX = upperX > c.x ? upperX : c.x; + upperY = upperY > c.y ? upperY : c.y; + } + + for (Coordinate c: cb) { + lowerX = lowerX < c.x ? lowerX : c.x; + lowerY = lowerY < c.y ? lowerY : c.y; + + upperX = upperX > c.x ? upperX : c.x; + upperY = upperY > c.y ? upperY : c.y; + } + + return "" + lowerX + " " + lowerY + " " + upperX + " " + upperY; + } + + public static SimpleFeatureType buildFeatureType( String name, String srs, Class geometryType) {