changeset 5676:f8409fbe3b88

Request maps from osm.intevation.de by another url and fix dpi handling
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 12 Apr 2013 12:57:57 +0200
parents 10aac4ec2d76
children 413798463dfe
files flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/shared/MapUtils.java
diffstat 2 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Fri Apr 12 12:56:25 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Fri Apr 12 12:57:57 2013 +0200
@@ -11,7 +11,6 @@
 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
 import de.intevation.flys.client.shared.MapUtils;
 import de.intevation.flys.client.shared.model.MapConfig;
-import de.intevation.flys.client.client.FLYSConstants;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -107,7 +106,10 @@
             List<Object> subLayers = new ArrayList<Object>(1);
             subLayers.add(layers);
             layer.put("layers", subLayers);
-            layer.put("baseURL", url);
+            // XXX: osm.intevation.de mapache only offers low dpi maps
+            // so we need to use the uncached service
+            layer.put("baseURL", url.replace("http://osm.intevation.de/mapcache/?",
+                        "http://osm.intevation.de/cgi-bin/germany.fcgi?"));
             layer.put("format", "image/png"); // TODO: Make configurable.
 
             return layer;
@@ -129,12 +131,12 @@
         Map<String, Object> pageSpecs
     ) {
         Map<String, Object> spec = new LinkedHashMap<String, Object>();
+        int dpi = 254;
         spec.put("layout",       "A4 landscape");
         spec.put("pageSize",     "A4");
-        spec.put("landscape",    "false");
-        spec.put("title",        "FLYS Druck");
+        spec.put("landscape",    "true");
         spec.put("srs",          "EPSG:" + mapConfig.getSrid());
-        spec.put("dpi",          Integer.valueOf(254));
+        spec.put("dpi",          dpi);
         spec.put("units",        "m");
         spec.put("geodaetic",    "true");
         spec.put("outputFormat", "pdf");
@@ -202,7 +204,7 @@
             Map<String, Object> legend = new LinkedHashMap<String, Object>();
             List<Object> classes = new ArrayList<Object>(1);
             Map<String, Object> clazz = new LinkedHashMap<String, Object>();
-            String lgu = MapUtils.getLegendGraphicUrl(layer.url, layer.layers);
+            String lgu = MapUtils.getLegendGraphicUrl(layer.url, layer.layers, dpi);
             clazz.put("icon", lgu);
             clazz.put("name", layer.description);
             classes.add(clazz);
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/MapUtils.java	Fri Apr 12 12:56:25 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/MapUtils.java	Fri Apr 12 12:57:57 2013 +0200
@@ -13,18 +13,29 @@
     private MapUtils() {
     }
 
+    public static String getLegendGraphicUrl(String server, String layer) {
+        return getLegendGraphicUrl(server, layer, -1);
+    }
 
-    public static String getLegendGraphicUrl(String server, String layer) {
+    public static String getLegendGraphicUrl(String server, String layer, int dpi) {
         if (server == null || layer == null) {
             return null;
         }
 
+        if (server.contains("osm.intevation.de")) {
+            // GetLegend is not implemented at osm.intevation.de
+            // This avoids an error in the print log
+            return null;
+        }
         server = server.indexOf("?") >= 0 ? server : server + "?";
 
         String url = GET_LEGEND_GRAPHIC_TEMPLATE;
         url = url.replace("${SERVER}", server);
         url = url.replace("${LAYER}", layer);
         url = url + "&timestamp=" + new Date().getTime();
+        if (dpi != -1) {
+            url+="&legend_options=dpi:" + dpi;
+        }
 
         return url;
     }

http://dive4elements.wald.intevation.org