[Dive4elements-commits] [PATCH 3 of 5] Request maps from osm.intevation.de by another url and fix dpi handling

Wald Commits scm-commit at wald.intevation.org
Fri Apr 12 13:02:15 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1365764277 -7200
# Node ID f8409fbe3b888b477342faaae48dbbd3e9d8ed75
# Parent  10aac4ec2d769363cce5326c034c8b33d7860614
Request maps from osm.intevation.de by another url and fix dpi handling

diff -r 10aac4ec2d76 -r f8409fbe3b88 flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java
--- 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);
diff -r 10aac4ec2d76 -r f8409fbe3b88 flys-client/src/main/java/de/intevation/flys/client/shared/MapUtils.java
--- 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;
     }


More information about the Dive4elements-commits mailing list