Mercurial > dive4elements > gnv-client
changeset 984:cfc7bd35ee0b
Set the map to the extent which was sent by the rest-server
gnv/trunk@1167 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Mon, 07 Jun 2010 14:52:45 +0000 |
parents | 45ea5feb94c0 |
children | 95004318d1ce |
files | gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/WMSAction.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/map/DefaultMapService.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/map/MapService.java gnv/src/main/webapp/scripts/viewport.jsp |
diffstat | 5 files changed, 60 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Mon Jun 07 12:35:49 2010 +0000 +++ b/gnv/ChangeLog Mon Jun 07 14:52:45 2010 +0000 @@ -1,3 +1,18 @@ +2010-06-07 Tim Englich <tim.englich@intevation.de> + + * src/main/webapp/scripts/viewport.jsp: + Put the bboxx from the mapservice-object and write it to an + javascript-variable. This variable will be used to center the map to + the extend of the data which should be visualized. + + * src/main/java/de/intevation/gnv/artifactdatabase/objects/map/DefaultMapService.java (getBBoxValue), + src/main/java/de/intevation/gnv/artifactdatabase/objects/map/MapService.java (getBBoxValue): + Added a method for getting the bbox as a string from the mapservice-object. + + * src/main/java/de/intevation/gnv/action/WMSAction.java (execute): + Read the bbox from the retrieved meta-document and out it into the + mapservice-object which is used to represent the WMS in the client. + 2010-06-07 Tim Englich <tim.englich@intevation.de> * src/main/webapp/scripts/viewport.jsp:
--- a/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Mon Jun 07 12:35:49 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Mon Jun 07 14:52:45 2010 +0000 @@ -61,6 +61,9 @@ public static final String XPATH_TTL = "/art:meta/art:mapserver/art:ttl/text()"; + + public static final String XPATH_BBOX = + "/art:meta/art:mapserver/art:Box/art:coordinates/text()"; /** * the logger, used to log exceptions and additonaly information @@ -133,6 +136,8 @@ meta, XPATH_MAPSERVER_MAPFILE); String tmpTTL = XMLUtils.getStringXPath( meta, XPATH_TTL); + + String bbox = XMLUtils.getStringXPath(meta, XPATH_BBOX); String ttl = null; if (tmpTTL != null) { DateFormat df = DateFormat.getDateTimeInstance( @@ -187,7 +192,8 @@ request.setAttribute("wms_published", Boolean.TRUE); MapService mapService = new DefaultMapService("0815", layers, - "UMN", mapserverPath); + "UMN", mapserverPath, + bbox); sm.setLocalMapService(mapService); return super.execute(mapping, form, request, response); }else{
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/map/DefaultMapService.java Mon Jun 07 12:35:49 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/map/DefaultMapService.java Mon Jun 07 14:52:45 2010 +0000 @@ -28,6 +28,11 @@ * The URl of this mapservice. */ private String url = null; + + /** + * The Bbox which surrounds the data of the Mapservice + */ + private String bbox = null; /** * Constructor @@ -45,6 +50,21 @@ this.type = type; this.url = url; } + + /** + * Constructor + * + * @param id the id of this mapservice + * @param layer the layer which are provided by this mapservice + * @param type the type of this mapservice + * @param url the URl of this mapservice + * @param bbox the Bbox which surrounds the data of the Mapservice + */ + public DefaultMapService(String id, Collection<Layer> layer, + String type, String url, String bbox) { + this(id,layer,type,url); + this.bbox = bbox; + } public String getID() { @@ -65,5 +85,9 @@ public String getURL() { return this.url; } + + public String getBBoxValue() { + return this.bbox; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/map/MapService.java Mon Jun 07 12:35:49 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/map/MapService.java Mon Jun 07 14:52:45 2010 +0000 @@ -39,5 +39,11 @@ * @return the layers served by a map service. */ Collection<Layer> getLayer(); + + /** + * Retrieves the bboxvalue served by a map service. + * @return the bboxvalue + */ + String getBBoxValue (); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gnv/src/main/webapp/scripts/viewport.jsp Mon Jun 07 12:35:49 2010 +0000 +++ b/gnv/src/main/webapp/scripts/viewport.jsp Mon Jun 07 14:52:45 2010 +0000 @@ -1,9 +1,11 @@ <%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%> <%@page import="de.intevation.gnv.action.MapClientStandaloneAction"%> +<%@page import="de.intevation.gnv.artifactdatabase.objects.map.MapService"%> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <% boolean standalone = request.getParameter(MapClientStandaloneAction.MAPCLIENTSTANDALONE_KEY) != null && request.getParameter(MapClientStandaloneAction.MAPCLIENTSTANDALONE_KEY).equals("true"); +MapService mapService = SessionModelFactory.getInstance().getSessionModel(request).getLocalMapService(); %> OpenLayers.ProxyHost= "/cgi-bin/proxy.cgi?url="; OpenLayers.Lang.setCode('<%=SessionModelFactory.getInstance().getSessionModel(request).getCurrentLocale().getLanguage() %>'); @@ -15,9 +17,10 @@ * settings inline the code! */ PROJECTION = "EPSG:4326"; -MAX_EXTENT = new OpenLayers.Bounds(-17.44,29.41,40.04,77.66); +MAX_EXTENT = new OpenLayers.Bounds(-90,-180,90,180); +CURRENT_EXTENT = new OpenLayers.Bounds(<%=mapService.getBBoxValue().replace(' ',',')%>); INITIAL_CENTER = new OpenLayers.LonLat(5, 55); -GETFEATUREINFO_URL = "<%=SessionModelFactory.getInstance().getSessionModel(request).getLocalMapService().getURL()%>"; +GETFEATUREINFO_URL = "<%=mapService.getURL()%>"; Ext.onReady(function() { @@ -31,7 +34,6 @@ var options = { maxExtent: MAX_EXTENT, projection: PROJECTION, - zoom: 5, controls: [], units: 'm' }; @@ -110,7 +112,8 @@ }); - map.setCenter(INITIAL_CENTER); + //map.setCenter(INITIAL_CENTER); + store = new GeoExt.data.WMSCapabilitiesStore({ }); @@ -284,4 +287,5 @@ ] }); <%}%> + map.zoomToExtent(CURRENT_EXTENT); });