1<%-- $HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/apps/igeoportal-standard/branches/2.5_testing/downloadlayerlist.jsp $ --%> 2<%-- 3 This file is part of deegree, http://deegree.org/ 4 Copyright (C) 2001-2009 by: 5 - Department of Geography, University of Bonn - 6 and 7 - lat/lon GmbH - 8 9 This library is free software; you can redistribute it and/or modify it under 10 the terms of the GNU Lesser General Public License as published by the Free 11 Software Foundation; either version 2.1 of the License, or (at your option) 12 any later version. 13 This library is distributed in the hope that it will be useful, but WITHOUT 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 16 details. 17 You should have received a copy of the GNU Lesser General Public License 18 along with this library; if not, write to the Free Software Foundation, Inc., 19 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 21 Contact information: 22 23 lat/lon GmbH 24 Aennchenstr. 19, 53177 Bonn 25 Germany 26 http://lat-lon.de/ 27 28 Department of Geography, University of Bonn 29 Prof. Dr. Klaus Greve 30 Postfach 1147, 53001 Bonn 31 Germany 32 http://www.geographie.uni-bonn.de/deegree/ 33 34 e-mail: info@deegree.org 35--%> 36<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 37<%@ page import="org.deegree.i18n.Messages" %> 38<%@ page import="org.deegree.portal.context.Layer" %> 39<%@ page import="java.util.List" %> 40<%@ page import="java.util.Locale" %> 41<% 42 Locale loc = request.getLocale(); 43 Layer[] layers = (Layer[])request.getAttribute( "LAYERS" ); 44 String email = (String)request.getAttribute( "EMAIL" ); 45 List<String> formats = (List<String>)request.getAttribute( "FORMATS" ); 46%> 47<html> 48 <head> 49 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 50 <meta name="author" content="lat/lon GmbH"> 51 <meta name="KeyWords" content="deegree iGeoPortal lat/lon" /> 52 <title>deegree iGeoPortal</title> 53 <link href="css/deegree.css" rel="stylesheet" type="text/css"/> 54 <script LANGUAGE="JavaScript1.2" TYPE="text/javascript"> 55 <!-- 56 57 function createMember( name, value, type ) { 58 return "<member><name>"+ name +"</name><value><"+ type +">"+ value +"</"+ type +"></value></member>"; 59 } 60 61 /** 62 * Returns the current bounding box of the map 63 */ 64 function getBBox(){ 65 return opener.parent.controller.mapModel.getBoundingBox(); 66 } 67 68 /** 69 * Return a list of the selected layers (whose checkboxes are checked) 70 */ 71 function getLayerList(){ 72 var layerlist = ''; 73 var b = opener.parent.controller.mapModel.getLayerList(); 74 var lgroup = b.getLayerGroups(); 75 for( var i = 0; i < lgroup.length; i++ ){ 76 var g = lgroup[i].getLayers(); 77 for( var j = 0; j < g.length; j++ ){ 78 var checked = document.getElementById(g[j].getName()); 79 if( g[j].getDSResource() && g[j].getDSGeomType && g[j].getDSFeatureType 80 && checked && checked.checked ) { 81 82 var key = g[j].getName() + "," + g[j].getTitle(); 83 var value = lgroup[i].getServiceURL(); 84 85 layerlist += createMember( key , value, "string" ); 86 } 87 } 88 } 89 return layerlist; 90 } 91 92 function getEmail() { 93 if ( document.getElementById( "email" ) == null ) { 94 return null; 95 } else { 96 return document.getElementById( "email" ).value; 97 } 98 } 99 100 function getFormat() { 101 var checkbox; 102 var selectedFormat = "SHP"; // default value. do not change! 103 <% 104 for ( String f : formats ) { 105 %> 106 checkbox = document.getElementById( "<%=f %>" ); 107 if ( checkbox && checkbox.checked ) { 108 // is radio button. therefore only one can be chosen. 109 selectedFormat = checkbox.value; 110 return selectedFormat; 111 } 112 <% 113 } 114 %> 115 return selectedFormat; 116 } 117 118 /** 119 * Called when clicking the download button. It sends an rpc request to the server with a list of 120 * the layers that should be downloaded 121 */ 122 function download() { 123 var sessionID = null; 124 if ( opener.parent.controller.vSessionKeeper != null ){ 125 sessionID = opener.parent.controller.vSessionKeeper.id; 126 } 127 128 var req= "<?xml version='1.0' encoding='UTF-8'?>"; 129 req += "<methodCall><methodName>mapView:downloadFeatures</methodName>"; 130 req += "<params><param><value><struct>"; 131 req += createMember( "layerList", getLayerList(), "struct" ); 132 req += createMember( "sessionID", sessionID, "string" ); 133 req += createMember( "email", getEmail(), "string" ); 134 req += createMember( "format", getFormat(), "string" ); 135 136 var b = getBBox(); 137 req = req + "<member><name>boundingBox</name><value><struct>"; 138 req += createMember("minx", b.minx, "double"); 139 req += createMember("miny", b.miny, "double"); 140 req += createMember("maxx", b.maxx, "double"); 141 req += createMember("maxy", b.maxy, "double"); 142 req += "</struct></value></member>"; 143 req = req + "</struct></value></param></params></methodCall>"; 144 145 //document.forms[0].action = "control?rpc=" + req; 146 document.getElementById( "RPC" ).value = req; 147 document.forms[0].method = "post"; 148 document.forms[0].action = "control"; 149 document.forms[0].submit(); 150 } 151 152 function invert() { 153 for ( var i = 0; i < document.forms[0].elements.length; i++ ) { 154 if ( document.forms[0].elements[i].type == 'checkbox' ) { 155 document.forms[0].elements[i].checked = !document.forms[0].elements[i].checked; 156 } 157 } 158 } 159 160 // --> 161 </script> 162 </head> 163 <body class="pDownloadLayerList"> 164 <table> 165 <tbody> 166 <tr> 167 <td width="30"> </td> 168 <td colspan="3"><h3><%=Messages.get( loc, "IGEO_STD_DWNLD_HEADER" ) %></h3></td> 169 </tr> 170 171 <% 172 if ( layers.length > 0 ) { 173 // layers available for this user to download 174 %> 175 <tr> 176 <td width="30"> </td> 177 <td colspan="3"><p><%=Messages.get( loc, "IGEO_STD_DWNLD_AVAIL_LAYS" ) %></p></td> 178 </tr> 179 <tr> 180 <td width="30"> </td> 181 <td colspan="3"> 182 <form id="downloadform" method="post" action="javascript:download();"> 183 <input id="RPC" type="hidden" name="rpc" value="" /> 184 <% 185 for ( int i = 0; i < layers.length; i++ ) { 186 out.print( "<input type='checkbox' id='" + layers[i].getName() + "'>" ); 187 out.print( layers[i].getTitle() ); 188 out.println( "<br />" ); 189 } 190 %> 191 <br /><a href="javascript:invert()" class="buttonArea"><%=Messages.get( loc, "IGEO_STD_BTN_INVERT" ) %></a><br /><br /> 192 <% 193 if ( formats.size() > 1 ) { 194 out.println( "<br />" ); 195 out.println( Messages.get( loc, "IGEO_STD_DWNLD_SEL_FORMAT" ) ); 196 for ( String f : formats ) { 197 out.println( "<input type='radio' id='" + f + "' name='format' value='" + f + "'> " + f + "<br />" ); 198 } 199 } 200 if ( email == null ) { 201 out.println( "<br />" ); 202 out.println( Messages.get( loc, "IGEO_STD_DWNLD_EMAIL" ) ); 203 out.println("<input type='text' id='email' size='30' maxlength='50' >"); 204 } 205 %> 206 </form> 207 </td> 208 </tr> 209 <tr> 210 <td colspan="4"> </td> 211 </tr> 212 <tr> 213 <td width="30"> </td> 214 <td><a href="javascript:download();" class="buttonArea"><%=Messages.get( loc, "IGEO_STD_BTN_DWNLD" ) %></a></td> 215 <td width="10"> </td> 216 <td><a href="javascript:window.close()" class="buttonArea"><%=Messages.get( loc, "IGEO_STD_BTN_CANCEL" ) %></a></td> 217 </tr> 218 <% 219 } else { 220 // no layers available for this user and WebMapContext 221 %> 222 <tr> 223 <td width="30"> </td> 224 <td colspan="3"> 225 <p><%=Messages.get( loc, "IGEO_STD_DWNLD_NOT_AVAILABLE" ) %></p> 226 </td> 227 </tr> 228 <tr> 229 <td width="30"> </td> 230 <td colspan="3"><a href="javascript:window.close()" class="buttonArea"><%=Messages.get( loc, "IGEO_STD_BTN_CANCEL" ) %></a></td> 231 </tr> 232 <% 233 } 234 %> 235 </tbody> 236 </table> 237 </body> 238</html> 239