Project

General

Profile

1
<!--
2
  *   '$RCSfile$'
3
  *   '$Author: harris $'
4
  *   '$Date: 2006-02-19 21:15:50 -0800 (Sun, 19 Feb 2006) $'
5
  *   '$Revision: 2911 $'
6
  *
7
  *
8
  * This program is free software; you can redistribute it and/or modify
9
  * it under the terms of the GNU General Public License as published by
10
  * the Free Software Foundation; either version 2 of the License, or
11
  * (at your option) any later version.
12
  *
13
  * This program is distributed in the hope that it will be useful,
14
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
  * GNU General Public License for more details.
17
  *
18
  * You should have received a copy of the GNU General Public License
19
  * along with this program; if not, write to the Free Software
20
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
-->
22

    
23
<%@ page import="org.apache.tools.mail.MailMessage" %>
24
<%@ page import="java.io.PrintStream" %>
25
<%@ page import="java.io.BufferedReader" %>
26
<%@ page import="java.util.StringTokenizer" %>
27
<%@ page import="java.io.InputStreamReader" %>
28
<%@ page import="java.net.URLConnection" %>
29
<%@ page import="java.net.URL" %>
30

    
31

    
32
<%
33
	System.out.println("********************************************************");
34
	System.out.println("********************************************************");
35
	System.out.println("**************** metacat_spatialresolver.jsp*****************\n");
36

    
37

    
38
	String _request = request.getParameter("REQUEST");
39
	_request = (_request!=null)? _request.trim() : "";
40

    
41
	System.out.println("request param: >>" + _request);
42
	System.out.println("uri: >>" + request.getRequestURI());
43
	System.out.println("request string: >>" + request.getQueryString()+" \n");
44
					   
45
	// connect to the metacat spatial option, request the info using the wms getFeatureId call
46
	// parse the response for the url to the metacat document and then redirect there. The query 
47
	// should look like
48
	// VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS=EPSG:4326&BBOX=-143.09099999999998,19.856,-96.79899999999999,43.002&WIDTH=600&HEIGHT=300&LAYERS=topp:RIVERS&FORMAT=text/html&FEATURE_COUNT=1&QUERY_LAYERS=topp:RIVERS&X=328&Y=218
49

    
50
	if (_request.toLowerCase().equals("aoimetacatquery")) {
51
		// bounded box
52
		System.out.println("forwarding AoiMetacatQuery");
53
		String _url = "http://nebulous.msi.ucsb.edu:9999/knp/metacat?action=spatial_query&"+ request.getQueryString();
54

    
55
		System.out.println("redirecting to: " + _url);
56
		response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
57
		response.setHeader("Location",_url);
58
	} else {
59
		// feature info
60
		if ( request.getQueryString().indexOf("metacat_testdata") > -1 ) {
61

    
62
			URL url = new URL("http://nebulous.msi.ucsb.edu:8080/geoserver/wms?"+request.getQueryString());
63
			URLConnection c = url.openConnection();
64
			BufferedReader in = new BufferedReader(
65
			new InputStreamReader(
66
			c.getInputStream()));
67
			String inputLine;
68

    
69
			while ((inputLine = in.readLine()) != null) {
70
				if ( inputLine.startsWith("url") ) {
71

    
72
					StringTokenizer _st = new StringTokenizer(inputLine, " ");
73
					_st.nextToken(); // url string
74
					_st.nextToken(); // equals sign
75
					String _redirectTo = _st.nextToken();
76
					System.out.println("redirecting to: " + _redirectTo); 
77
					response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
78
					String newLocn = _redirectTo;
79
					response.setHeader("Location",newLocn);
80
				}
81
			}
82
			in.close();
83

    
84
		} else {
85
			System.out.println(" -- not a metacat query");
86
			String _url = "/geoserver/wms?"+ request.getQueryString();
87

    
88
			System.out.println("redirecting to: " + _url);
89
			response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
90
			response.setHeader("Location",_url);
91
		}
92
	}
93

    
94
%>
95

    
96
<html>
97
<head>
98
<title>Metacat Spatial Resolver</title>
99
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
100
<link href="styles.css" rel="stylesheet" type="text/css">
101
</head>
102

    
103
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/blue_pixel_bg.jpg">
104
<table width="100%" border="0" cellspacing="0" cellpadding="0">
105
  <!--DWLayoutTable-->
106
  <tr>
107
          <td  width="700" height="20" background="images/blue_pixel_bg.jpg"></td>
108

    
109
  </tr>
110
    
111
 
112
  
113
  
114
  <tr> 
115
    <td bgcolor="#6699CC"> <table width="700" border="0" cellspacing="0" cellpadding="0">
116
        <tr> 
117
          <td>&nbsp;</td>
118
          <td><td>&nbsp;</td>
119
        </tr>
120
      </table>
121
  </tr>
122
</table>
123
</body>
124
</html>
125

    
    (1-1/1)