diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.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 7ef59d7e113d
children 3952429cc41b
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Tue May 08 15:37:21 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Wed May 09 11:18:24 2012 +0000
@@ -15,6 +15,7 @@
 import com.smartgwt.client.widgets.events.ResizedEvent;
 import com.smartgwt.client.widgets.events.ResizedHandler;
 
+import org.gwtopenmaps.openlayers.client.Bounds;
 import org.gwtopenmaps.openlayers.client.Map;
 import org.gwtopenmaps.openlayers.client.control.DragPan;
 import org.gwtopenmaps.openlayers.client.control.SelectFeature;
@@ -29,6 +30,7 @@
 import de.intevation.flys.client.client.ui.ImgLink;
 import de.intevation.flys.client.client.utils.EnableDisableCmd;
 import de.intevation.flys.client.shared.model.ThemeList;
+import de.intevation.flys.client.shared.model.Collection;
 
 
 /**
@@ -280,8 +282,8 @@
         return new ImgLink(
             baseUrl + MSG.downloadPDF(),
             getPrintUrl(),
-            20,
-            20);
+            20, 20,
+            true);
     }
 
 
@@ -609,8 +611,38 @@
     }
 
     public String getPrintUrl() {
-        String url = GWT.getModuleBaseURL();
-        GWT.log("TODO: Generate real print link.");
+        MapOutputTab ot = (MapOutputTab)getOutputTab();
+        Collection collection = ot.getCollection();
+        String uuid = collection.identifier();
+
+        String mapType = collection.getOutputModes().containsKey("floodmap")
+            ? "floodmap"
+            : "map";
+
+        String url = GWT.getModuleBaseURL() + "map-print?";
+
+        Map map = getMap();
+        Bounds bounds = map.getExtent();
+
+        if (bounds != null) {
+            try {
+                double minX = bounds.getLowerLeftX();
+                double maxX = bounds.getUpperRightX();
+                double minY = bounds.getLowerLeftY();
+                double maxY = bounds.getUpperRightY();
+                url += "minx=" + minX + "&";
+                url += "maxx=" + maxX + "&";
+                url += "miny=" + minY + "&";
+                url += "maxy=" + maxY + "&";
+            }
+            catch (Exception e) {
+                // XXX: Ignore it. bounds.getXXX() throw 
+                // exceptions when bound is invalid. :-/
+            }
+        }
+
+        url += "uuid=" + uuid + "&maptype=" + mapType;
+
         return url;
     }
 }

http://dive4elements.wald.intevation.org