Mercurial > dive4elements > river
changeset 823:407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
flys-client/trunk@2515 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 19 Aug 2011 15:57:23 +0000 |
parents | ffb98b228b3c |
children | 3fe265b47675 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java |
diffstat | 3 files changed, 94 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Fri Aug 12 15:51:51 2011 +0000 +++ b/flys-client/ChangeLog Fri Aug 19 15:57:23 2011 +0000 @@ -1,3 +1,11 @@ +2011-08-19 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java: + Determine the max extent of all layers contained in the collection. + + * src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java: Set + the map projection and its max extent determined by MapOutputTab. + 2011-08-12 Sascha L. Teichmann <sascha.teichmann@intevation.de> Extract selected data from datacage panel
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java Fri Aug 12 15:51:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java Fri Aug 19 15:57:23 2011 +0000 @@ -1,9 +1,11 @@ package de.intevation.flys.client.client.ui.map; +import org.gwtopenmaps.openlayers.client.Bounds; import org.gwtopenmaps.openlayers.client.Map; import org.gwtopenmaps.openlayers.client.MapOptions; import org.gwtopenmaps.openlayers.client.MapWidget; import org.gwtopenmaps.openlayers.client.layer.Vector; +import org.gwtopenmaps.openlayers.client.layer.VectorOptions; import org.gwtopenmaps.openlayers.client.util.JObjectArray; import org.gwtopenmaps.openlayers.client.util.JSObject; @@ -15,13 +17,20 @@ protected MapWidget mapWidget; protected Map map; protected Vector barrierLayer; + protected String srid; + protected Bounds maxExtent; - public FloodMap() { + public FloodMap(String srid, Bounds maxExtent) { + this.srid = srid; + this.maxExtent = maxExtent; + MapOptions opts = new MapOptions(); opts.setControls(new JObjectArray(new JSObject[] {})); opts.setNumZoomLevels(16); opts.setProjection(getRiverProjection()); + opts.setMaxExtent(maxExtent); + opts.setMaxResolution(500); // TODO DO THIS ON THE FLY mapWidget = new MapWidget("510px", "635px", opts); map = mapWidget.getMap(); @@ -41,14 +50,19 @@ public String getRiverProjection() { - return "EPSG:4326"; + return "EPSG:" + srid; } public Vector getBarrierLayer() { if (barrierLayer == null) { - barrierLayer = new Vector(LAYER_BARRIERS); + VectorOptions opts = new VectorOptions(); + opts.setProjection(getRiverProjection()); + opts.setMaxExtent(maxExtent); + + barrierLayer = new Vector(LAYER_BARRIERS, opts); barrierLayer.setIsBaseLayer(true); + map.addLayer(barrierLayer); }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Fri Aug 12 15:51:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Fri Aug 19 15:57:23 2011 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.client.client.ui.map; +import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Widget; @@ -14,6 +15,7 @@ import org.gwtopenmaps.openlayers.client.layer.Layer; import org.gwtopenmaps.openlayers.client.layer.WMS; import org.gwtopenmaps.openlayers.client.layer.WMSParams; +import org.gwtopenmaps.openlayers.client.layer.WMSOptions; import de.intevation.flys.client.shared.model.AttributedTheme; import de.intevation.flys.client.shared.model.Collection; @@ -28,6 +30,9 @@ public class MapOutputTab extends OutputTab { + public static final String DEFAULT_SRID = "4326"; + + protected CollectionView parent; protected Canvas controlPanel; @@ -46,7 +51,7 @@ super(title, collection, mode); this.parent = collectionView; - floodMap = new FloodMap(); + floodMap = new FloodMap(getSrid(), getMaxExtent()); initLayout(); initLayers(); @@ -139,12 +144,66 @@ } } - map.zoomToExtent(extent != null + GWT.log("Maps initial extent = " + extent); + + map.zoomToExtent(extent != null ? extent : new Bounds(-90, -180, 90, 180)); } + public ThemeList getThemeList() { + return collection.getThemeList(mode.getName()); + } + + + public String getSrid() { + ThemeList themeList = getThemeList(); + + int num = themeList.getThemeCount(); + + for (int i = 1; i <= num; i++) { + AttributedTheme theme = (AttributedTheme) themeList.getThemeAt(i); + String srid = theme.getAttr("srid"); + + if (srid != null && srid.length() > 0) { + return srid; + } + } + + return DEFAULT_SRID; + } + + + 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); + 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) { if (bounds == null || bounds.length() == 0) { return null; @@ -159,9 +218,9 @@ try { return new Bounds( Double.valueOf(values[0]), - Double.valueOf(values[3]), + Double.valueOf(values[1]), Double.valueOf(values[2]), - Double.valueOf(values[1])); + Double.valueOf(values[3])); } catch (NumberFormatException nfe) {} @@ -191,9 +250,13 @@ params.setLayers(layers); params.setFormat("image/png"); params.setIsTransparent(true); - params.setMaxExtent(new Bounds(90, 180, -90, -180)); - WMS wms = new WMS(desc, url, params); + WMSOptions opts = new WMSOptions(); + opts.setProjection("EPSG:" + getSrid()); + opts.setSingleTile(true); + opts.setRatio(1); + + WMS wms = new WMS(desc, url, params, opts); wms.setIsVisible(at.getActive() == 1); wms.setIsBaseLayer(false);