comparison 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
comparison
equal deleted inserted replaced
2507:7ef59d7e113d 2508:4aa70825bde1
13 import com.smartgwt.client.widgets.events.ClickHandler; 13 import com.smartgwt.client.widgets.events.ClickHandler;
14 import com.smartgwt.client.widgets.layout.HLayout; 14 import com.smartgwt.client.widgets.layout.HLayout;
15 import com.smartgwt.client.widgets.events.ResizedEvent; 15 import com.smartgwt.client.widgets.events.ResizedEvent;
16 import com.smartgwt.client.widgets.events.ResizedHandler; 16 import com.smartgwt.client.widgets.events.ResizedHandler;
17 17
18 import org.gwtopenmaps.openlayers.client.Bounds;
18 import org.gwtopenmaps.openlayers.client.Map; 19 import org.gwtopenmaps.openlayers.client.Map;
19 import org.gwtopenmaps.openlayers.client.control.DragPan; 20 import org.gwtopenmaps.openlayers.client.control.DragPan;
20 import org.gwtopenmaps.openlayers.client.control.SelectFeature; 21 import org.gwtopenmaps.openlayers.client.control.SelectFeature;
21 import org.gwtopenmaps.openlayers.client.control.SelectFeatureOptions; 22 import org.gwtopenmaps.openlayers.client.control.SelectFeatureOptions;
22 import org.gwtopenmaps.openlayers.client.control.ZoomBox; 23 import org.gwtopenmaps.openlayers.client.control.ZoomBox;
27 import de.intevation.flys.client.client.FLYSConstants; 28 import de.intevation.flys.client.client.FLYSConstants;
28 import de.intevation.flys.client.client.ui.Toolbar; 29 import de.intevation.flys.client.client.ui.Toolbar;
29 import de.intevation.flys.client.client.ui.ImgLink; 30 import de.intevation.flys.client.client.ui.ImgLink;
30 import de.intevation.flys.client.client.utils.EnableDisableCmd; 31 import de.intevation.flys.client.client.utils.EnableDisableCmd;
31 import de.intevation.flys.client.shared.model.ThemeList; 32 import de.intevation.flys.client.shared.model.ThemeList;
33 import de.intevation.flys.client.shared.model.Collection;
32 34
33 35
34 /** 36 /**
35 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 37 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
36 */ 38 */
278 String baseUrl = GWT.getHostPageBaseURL(); 280 String baseUrl = GWT.getHostPageBaseURL();
279 281
280 return new ImgLink( 282 return new ImgLink(
281 baseUrl + MSG.downloadPDF(), 283 baseUrl + MSG.downloadPDF(),
282 getPrintUrl(), 284 getPrintUrl(),
283 20, 285 20, 20,
284 20); 286 true);
285 } 287 }
286 288
287 289
288 protected ImgButton createMaxExtentControl() { 290 protected ImgButton createMaxExtentControl() {
289 ImgButton zoomToMax = createButton(MSG.zoom_all(), new ClickHandler() { 291 ImgButton zoomToMax = createButton(MSG.zoom_all(), new ClickHandler() {
607 609
608 return epsgLabel; 610 return epsgLabel;
609 } 611 }
610 612
611 public String getPrintUrl() { 613 public String getPrintUrl() {
612 String url = GWT.getModuleBaseURL(); 614 MapOutputTab ot = (MapOutputTab)getOutputTab();
613 GWT.log("TODO: Generate real print link."); 615 Collection collection = ot.getCollection();
616 String uuid = collection.identifier();
617
618 String mapType = collection.getOutputModes().containsKey("floodmap")
619 ? "floodmap"
620 : "map";
621
622 String url = GWT.getModuleBaseURL() + "map-print?";
623
624 Map map = getMap();
625 Bounds bounds = map.getExtent();
626
627 if (bounds != null) {
628 try {
629 double minX = bounds.getLowerLeftX();
630 double maxX = bounds.getUpperRightX();
631 double minY = bounds.getLowerLeftY();
632 double maxY = bounds.getUpperRightY();
633 url += "minx=" + minX + "&";
634 url += "maxx=" + maxX + "&";
635 url += "miny=" + minY + "&";
636 url += "maxy=" + maxY + "&";
637 }
638 catch (Exception e) {
639 // XXX: Ignore it. bounds.getXXX() throw
640 // exceptions when bound is invalid. :-/
641 }
642 }
643
644 url += "uuid=" + uuid + "&maptype=" + mapType;
645
614 return url; 646 return url;
615 } 647 }
616 } 648 }
617 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 649 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org