1
|
<%
|
2
|
/**
|
3
|
<!--
|
4
|
* '$RCSfile$'
|
5
|
* '$Author$'
|
6
|
* '$Date$'
|
7
|
* '$Revision$'
|
8
|
*
|
9
|
*
|
10
|
* This program is free software; you can redistribute it and/or modify
|
11
|
* it under the terms of the GNU General Public License as published by
|
12
|
* the Free Software Foundation; either version 2 of the License, or
|
13
|
* (at your option) any later version.
|
14
|
*
|
15
|
* This program is distributed in the hope that it will be useful,
|
16
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
* GNU General Public License for more details.
|
19
|
*
|
20
|
* You should have received a copy of the GNU General Public License
|
21
|
* along with this program; if not, write to the Free Software
|
22
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
-->
|
24
|
*/
|
25
|
%>
|
26
|
<%@ page import="org.apache.tools.mail.MailMessage" %>
|
27
|
<%@ page import="java.io.PrintStream" %>
|
28
|
<%@ page import="java.io.BufferedReader" %>
|
29
|
<%@ page import="java.util.StringTokenizer" %>
|
30
|
<%@ page import="java.io.InputStreamReader" %>
|
31
|
<%@ page import="java.io.PrintWriter" %>
|
32
|
<%@ page import="java.net.URLConnection" %>
|
33
|
<%@ page import="java.net.URL" %>
|
34
|
<%@ page import="edu.ucsb.nceas.metacat.spatial.XSLTransform" %>
|
35
|
<%
|
36
|
System.out.println("********************************************************");
|
37
|
System.out.println("********************************************************");
|
38
|
System.out.println("**************** metacat_spatialresolver.jsp*****************\n");
|
39
|
|
40
|
|
41
|
String _request = request.getParameter("REQUEST");
|
42
|
_request = (_request!=null)? _request.trim() : "";
|
43
|
|
44
|
System.out.println("request param: >>" + _request);
|
45
|
System.out.println("uri: >>" + request.getRequestURI());
|
46
|
System.out.println("request string: >>" + request.getQueryString()+" \n");
|
47
|
|
48
|
// connect to the metacat spatial option, request the info using the wms getFeatureId call
|
49
|
// parse the response for the url to the metacat document and then redirect there. The query
|
50
|
// should look like
|
51
|
// 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
|
52
|
|
53
|
if (_request.toLowerCase().equals("aoimetacatquery")) {
|
54
|
// bounded box
|
55
|
System.out.println("handling AoiMetacatQuery");
|
56
|
String urlString = "http://dataknp.sanparks.org:8080/knp/metacat?action=spatial_query&"+ request.getQueryString();
|
57
|
|
58
|
System.out.println("redirecting to: " + urlString);
|
59
|
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
|
60
|
response.setHeader("Location",urlString);
|
61
|
|
62
|
|
63
|
/***********
|
64
|
URL url = new URL(urlString);
|
65
|
URLConnection c = url.openConnection();
|
66
|
BufferedReader in = new BufferedReader(
|
67
|
new InputStreamReader(c.getInputStream()));
|
68
|
String inputLine;
|
69
|
//StringBuffer xmlResults = new StringBuffer(4096);
|
70
|
try {
|
71
|
PrintWriter _out = response.getWriter();
|
72
|
while ((inputLine = in.readLine()) != null) {
|
73
|
// xmlResults.append(inputLine);
|
74
|
//System.out.println(inputLine);
|
75
|
out.println(inputLine);
|
76
|
}
|
77
|
} catch (Exception e) { e.printStackTrace(); }
|
78
|
|
79
|
***/
|
80
|
|
81
|
|
82
|
// transform xml into html
|
83
|
//String xslPath = "/tmp/spatial_results.xsl";
|
84
|
//XSLTransform.transform(xmlResults.toString(), xslPath, response.getWriter(), null);
|
85
|
|
86
|
|
87
|
/*
|
88
|
System.out.println("redirecting to: " + urlString);
|
89
|
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
|
90
|
response.setHeader("Location",urlString);
|
91
|
*/
|
92
|
} else {
|
93
|
// feature info
|
94
|
if ( request.getQueryString().indexOf("metacat_testdata") > -1 ) {
|
95
|
|
96
|
URL url = new URL("http://dataknp.sanparks.org:8080/geoserver/wms?"+request.getQueryString());
|
97
|
URLConnection c = url.openConnection();
|
98
|
BufferedReader in = new BufferedReader(
|
99
|
new InputStreamReader(
|
100
|
c.getInputStream()));
|
101
|
String inputLine;
|
102
|
|
103
|
while ((inputLine = in.readLine()) != null) {
|
104
|
if ( inputLine.startsWith("url") ) {
|
105
|
|
106
|
StringTokenizer _st = new StringTokenizer(inputLine, " ");
|
107
|
_st.nextToken(); // url string
|
108
|
_st.nextToken(); // equals sign
|
109
|
String _redirectTo = _st.nextToken();
|
110
|
System.out.println("redirecting to: " + _redirectTo);
|
111
|
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
|
112
|
String newLocn = _redirectTo;
|
113
|
response.setHeader("Location",newLocn);
|
114
|
}
|
115
|
}
|
116
|
in.close();
|
117
|
|
118
|
} else {
|
119
|
System.out.println(" -- not a metacat query");
|
120
|
String urlString = "/geoserver/wms?"+ request.getQueryString();
|
121
|
|
122
|
System.out.println("redirecting to: " + urlString);
|
123
|
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
|
124
|
response.setHeader("Location",urlString);
|
125
|
}
|
126
|
}
|
127
|
|
128
|
if (false) {
|
129
|
%><!--html>
|
130
|
<head>
|
131
|
<title>Metacat Spatial Resolver</title>
|
132
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
133
|
<link href="styles.css" rel="stylesheet" type="text/css">
|
134
|
</head>
|
135
|
|
136
|
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/blue_pixel_bg.jpg">
|
137
|
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
138
|
<!--DWLayoutTable-->
|
139
|
<tr>
|
140
|
<td width="700" height="20" background="images/blue_pixel_bg.jpg"></td>
|
141
|
|
142
|
</tr>
|
143
|
|
144
|
|
145
|
|
146
|
|
147
|
<tr>
|
148
|
<td bgcolor="#6699CC"> <table width="700" border="0" cellspacing="0" cellpadding="0">
|
149
|
<tr>
|
150
|
<td> </td>
|
151
|
<td><td> </td>
|
152
|
</tr>
|
153
|
</table>
|
154
|
</tr>
|
155
|
</table>
|
156
|
</body>
|
157
|
</html-->
|
158
|
<% } %>
|