Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java @ 1376:28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
flys-client/trunk@3096 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 28 Oct 2011 06:12:51 +0000 |
parents | 9085cffbb7c4 |
children | b0fe35d4ce6b |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Wed Oct 26 12:33:48 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Fri Oct 28 06:12:51 2011 +0000 @@ -36,6 +36,7 @@ import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; +import de.intevation.flys.client.shared.model.MapConfig; import de.intevation.flys.client.shared.model.Theme; import de.intevation.flys.client.shared.model.ThemeList; import de.intevation.flys.client.shared.model.OutputMode; @@ -82,22 +83,34 @@ ){ super(title, collection, collectionView, mode); - floodMap = new FloodMap(getSrid(), getMaxExtent()); - - mapService.doOut(collection, new AsyncCallback<Void>() { + mapService.doOut(collection, new AsyncCallback<MapConfig>() { public void onFailure(Throwable caught) { GWT.log("MAP ERROR: " + caught.getMessage()); } - public void onSuccess(Void v) { + public void onSuccess(MapConfig c) { GWT.log("MAP SUCCESS!"); + + Bounds max = boundsFromString(c.getMaxExtent()); + Bounds initial = boundsFromString(c.getInitialExtent()); + + if (initial == null) { + GWT.log("Warning: No initial extent set."); + initial = max; + } + + setFloodmap(new FloodMap(c.getSrid(), max)); + + initLayout(); + initLayers(); + initBarriers(); + + GWT.log("MAX EXTENT: " + max); + GWT.log("ZOOM TO: " + initial); + getMap().zoomToExtent(initial); } } ); - - initLayout(); - initLayers(); - initBarriers(); } @@ -156,10 +169,7 @@ ThemeList themeList = themePanel.getThemeList(); int num = themeList.getThemeCount(); - - Map map = floodMap.getMap(); - Bounds extent = null; - Bounds wsplgenExtent = null; + Map map = floodMap.getMap(); for (int i = num; i >= 0; i--) { Theme theme = themeList.getThemeAt(i); @@ -170,37 +180,7 @@ } map.addLayer(layer); - - AttributedTheme at = (AttributedTheme) theme; - String tmp = at.getAttr("extent"); - - if (WSPLGEN_FACET.equals(at.getFacet())) { - // if there is a wsplgen layer, we want to zoom to - // that place initially - wsplgenExtent = boundsFromString(tmp); - } - - if (theme.getActive() == 1) { - if (extent == null) { - extent = boundsFromString(tmp); - } - else { - Bounds b = boundsFromString(tmp); - - if (b != null) { - extent.extend(b); - } - } - } } - - extent = wsplgenExtent != null ? wsplgenExtent : extent; - - GWT.log("Maps initial extent = " + extent); - - map.zoomToExtent(extent != null - ? extent - : new Bounds(-90, -180, 90, 180)); } @@ -253,6 +233,11 @@ } + protected void setFloodmap(FloodMap floodMap) { + this.floodMap = floodMap; + } + + protected Map getMap() { return floodMap.getMap(); } @@ -317,41 +302,8 @@ } - public Bounds getMaxExtent() { - ThemeList themeList = getThemeList(); - - int num = themeList.getThemeCount(); - - Bounds extent = null; - - for (int i = 1; i <= num; i++) { - AttributedTheme theme = (AttributedTheme) themeList.getThemeAt(i); - - if (theme == null) { - continue; - } - - String tmp = theme.getAttr("extent"); - - if (theme.getActive() == 1) { - if (extent == null) { - extent = boundsFromString(tmp); - } - else { - Bounds b = boundsFromString(tmp); - - if (b != null) { - extent.extend(b); - } - } - } - } - - return extent; - } - - protected Bounds boundsFromString(String bounds) { + GWT.log("Create Bounds from String: '" + bounds + "'"); if (bounds == null || bounds.length() == 0) { return null; }