Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java @ 2508:4aa70825bde1
map print: generate valid url to access service.
flys-client/trunk@4363 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 09 May 2012 11:18:24 +0000 |
parents | 47d07709ba09 |
children | 4861ab2c28d2 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java Tue May 08 15:37:21 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java Wed May 09 11:18:24 2012 +0000 @@ -121,18 +121,16 @@ protected static String generateSpec( Document descDocument, - Document outDocument, - double minX, double minY, - double maxX, double maxY + MapConfig mapConfig, + Double minX, Double minY, + Double maxX, Double maxY ) { - MapConfig mapConfig = MapHelper.parseConfig(outDocument); - Map<String, Object> spec = new LinkedHashMap<String, Object>(); spec.put("layout", "A4 portrait"); spec.put("title", "FLYS Druck"); spec.put("srs", "EPSG:" + mapConfig.getSrid()); spec.put("dpi", Integer.valueOf(254)); - spec.put("units", "degrees"); + spec.put("units", "m"); spec.put("outputFormat", "pdf"); @@ -203,27 +201,28 @@ String minYS = req.getParameter("miny"); String maxYS = req.getParameter("maxy"); - if (minXS == null || maxXS == null - || minYS == null || maxYS == null) { - throw new ServletException("Missing minX, minY, maxX or maxY"); - } - - double minX, maxX, minY, maxY; + Double minX = null; + Double maxX = null; + Double minY = null; + Double maxY = null; - try { - minX = Double.parseDouble(minXS); - minY = Double.parseDouble(minYS); - maxX = Double.parseDouble(maxXS); - maxY = Double.parseDouble(maxYS); - } - catch (NumberFormatException nfe) { - throw new ServletException("Misspelled minX, minY, maxX or maxY"); + if (minXS != null && maxXS != null + && minYS != null && maxYS == null) { + try { + minX = Double.parseDouble(minXS); + minY = Double.parseDouble(minYS); + maxX = Double.parseDouble(maxXS); + maxY = Double.parseDouble(maxYS); + } + catch (NumberFormatException nfe) { + throw new ServletException("Misspelled minX, minY, maxX or maxY"); + } } String mapType = req.getParameter("maptype"); - if (mapType == null || !mapType.equals("map")) { - mapType = "floodmap"; + if (mapType == null || !mapType.equals("floodmap")) { + mapType = "map"; } String url = getURL(); @@ -240,6 +239,9 @@ try { HttpClient client = new HttpClientImpl(url); + descDocument = (Document)client.doCollectionAction( + requestDesc, uuid, new DocumentResponseHandler()); + InputStream is = client.collectionOut( requestOut, uuid, mapType); @@ -251,17 +253,34 @@ is = null; } - descDocument = (Document)client.doCollectionAction( - requestDesc, uuid, new DocumentResponseHandler()); } catch (ConnectionException ce) { log.error(ce); throw new ServletException(ce); } + MapConfig mapConfig = MapHelper.parseConfig(outDocument); + + if (minX == null) { + String [] parts = mapConfig.getMaxExtent().split("\\s+"); + if (parts.length < 4) { + throw new ServletException( + "Max extent has less than 4 values"); + } + try { + minX = Double.valueOf(parts[0]); + minY = Double.valueOf(parts[1]); + maxX = Double.valueOf(parts[2]); + maxY = Double.valueOf(parts[3]); + } + catch (NumberFormatException nfe) { + throw new ServletException(nfe); + } + } + String spec = generateSpec( descDocument, - outDocument, + mapConfig, minX, minY, maxX, maxY);