[Webflysuesk-commits] r40 - in webflysuesk/branches/openlayers-integration: . webflys/src/main/java/de/intevation/webflys/servlets webflys/src/main/webapp/WEB-INF

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Mar 26 12:02:00 CET 2009


Author: iweinzierl
Date: 2009-03-26 12:01:47 +0100 (Thu, 26 Mar 2009)
New Revision: 40

Added:
   webflysuesk/branches/openlayers-integration/webflys/src/main/java/de/intevation/webflys/servlets/BoundingBox.java
Modified:
   webflysuesk/branches/openlayers-integration/ChangeLog.txt
   webflysuesk/branches/openlayers-integration/webflys/src/main/webapp/WEB-INF/web.xml
Log:
New Service webflys/bbox available to fetch the BoundingBox of a river. See the ChangeLog.txt for notes.

Modified: webflysuesk/branches/openlayers-integration/ChangeLog.txt
===================================================================
--- webflysuesk/branches/openlayers-integration/ChangeLog.txt	2009-03-26 10:50:26 UTC (rev 39)
+++ webflysuesk/branches/openlayers-integration/ChangeLog.txt	2009-03-26 11:01:47 UTC (rev 40)
@@ -1,5 +1,16 @@
 2009-03-26  Ingo Weinzierl <ingo.weinzierl at intevation.de>
+	
+	* webflys/src/main/java/de/intevation/webflys/servlets/BoundingBox.java,
+	  webflys/src/main/webapp/WEB-INF/web.xml: New service /bbox available. It
+	  returns the BoundingBox of a special river as XML.
+	  
+	  Note: If there is a river in the parameter list of the URI (e.g.
+	  webflys/box?river=Saar) the BoundingBox of this River will be returned. 
+	  If the URI does not contain a river, the BoundingBox of the river in the 
+	  ServletContext will be returned.
 
+2009-03-26  Ingo Weinzierl <ingo.weinzierl at intevation.de>
+
 	* webflys/src/main/java/de/intevation/webflys/model/River.java,
 	  webflys/src/main/java/de/intevation/webflys/model/BBox.java: Now, we are
 	  able to ask the River for it's BoundingBox.

Added: webflysuesk/branches/openlayers-integration/webflys/src/main/java/de/intevation/webflys/servlets/BoundingBox.java
===================================================================
--- webflysuesk/branches/openlayers-integration/webflys/src/main/java/de/intevation/webflys/servlets/BoundingBox.java	2009-03-26 10:50:26 UTC (rev 39)
+++ webflysuesk/branches/openlayers-integration/webflys/src/main/java/de/intevation/webflys/servlets/BoundingBox.java	2009-03-26 11:01:47 UTC (rev 40)
@@ -0,0 +1,85 @@
+/*
+ * BoundingBox.java
+ * -------------
+ * (c) 2009 by Intevation GmbH
+ *
+ * This file is part of WebFLYS/UeSK.
+ *
+ * WebFLYS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * WebFLYS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with WebFLYS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package de.intevation.webflys.servlets;
+
+/**
+ * HttpServlet to get information about the BoundingBox of a river.
+ * If no argument river (e.g. ?river=Saar) is passed in the request, we will
+ * fetch the BoundingBox of the river in the ServletContext.
+ *
+ * @author Ingo Weinzierl <ingo.weinzierl at intevation.de>
+ */
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpSession;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletException;
+import javax.servlet.ServletContext;
+
+import de.intevation.webflys.model.Parameters;
+import de.intevation.webflys.model.Rivers;
+import de.intevation.webflys.model.River;
+import de.intevation.webflys.model.BBox;
+
+public class BoundingBox extends HttpServlet {
+
+    public static final String MIME_TYPE   = "text/xml";
+    public static final String RIVER_PARAM = "river";
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+    throws IOException, ServletException
+    {
+        HttpSession session   = request.getSession();
+        ServletContext sc     = getServletContext();
+
+        // fetch the river from request
+        String river_session = request.getParameter(RIVER_PARAM);
+
+        // if no river name was sent in the request, fetch river from session
+        if( river_session == null ) {
+            Parameters parameters =
+                (Parameters)session.getAttribute("parameters");
+
+            river_session = parameters.getRiver();
+        }
+    
+        Rivers rivers = (Rivers)sc.getAttribute(Rivers.RIVERS_KEY);
+        River  river  = rivers.getRiverByName(river_session);
+
+        response.setContentType(MIME_TYPE);
+        ServletOutputStream out = response.getOutputStream();
+
+        // if no river or no boundingbox is existing, return an error
+        if( river == null || river.getBBox() == null ) {
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            return;
+        }
+        // return the boundingbox of the given river in the ServletContext
+        else
+            out.println("<boundingbox>"+river.getBBox().toString()+"</boundingbox>");
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

Modified: webflysuesk/branches/openlayers-integration/webflys/src/main/webapp/WEB-INF/web.xml
===================================================================
--- webflysuesk/branches/openlayers-integration/webflys/src/main/webapp/WEB-INF/web.xml	2009-03-26 10:50:26 UTC (rev 39)
+++ webflysuesk/branches/openlayers-integration/webflys/src/main/webapp/WEB-INF/web.xml	2009-03-26 11:01:47 UTC (rev 40)
@@ -27,7 +27,17 @@
         <url-pattern>/wmc</url-pattern>
     </servlet-mapping>
 
+    <servlet>
+        <servlet-name>boundingbox</servlet-name>
+        <servlet-class>de.intevation.webflys.servlets.BoundingBox</servlet-class>
+    </servlet>
 
+    <servlet-mapping>
+        <servlet-name>boundingbox</servlet-name>
+        <url-pattern>/bbox</url-pattern>
+    </servlet-mapping>
+
+
     <filter>
         <filter-name>encoding-filter</filter-name>
         <filter-class>de.intevation.webflys.filters.EncodingFilter</filter-class>



More information about the Webflysuesk-commits mailing list