Strabon

changeset 137:9088d826b017

GeoJSON support added in endpoint too
author Manos Karpathiotakis <mk@di.uoa.gr>
date Wed May 09 12:32:15 2012 +0300 (2012-05-09)
parents de305c240be4
children 1de6a3e4670f
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java
line diff
     1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Tue May 08 20:29:23 2012 +0300
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Wed May 09 12:32:15 2012 +0300
     1.3 @@ -145,6 +145,9 @@
     1.4  		} else if (reqFormat.equalsIgnoreCase("KMZMAP"))  {
     1.5  			response.setContentType("text/html; charset=UTF-8");
     1.6  			hive.setFormat("KMZMAP");
     1.7 +		} else if (reqFormat.equalsIgnoreCase("GEOJSON"))  {
     1.8 +			response.setContentType("application/json; charset=UTF-8");
     1.9 +			hive.setFormat("GEOJSON");
    1.10  		} else {
    1.11  			response.setContentType("text/html; charset=UTF-8");
    1.12  			hive.setFormat("HTML");
    1.13 @@ -337,7 +340,7 @@
    1.14  			if (answer!="")
    1.15  				out.append("<div id=\"map_canvas\"></div>");
    1.16  			appendHTML5(out);
    1.17 -		} else if ((hive.getFormat().equalsIgnoreCase("XML"))) {
    1.18 +		} else if ((hive.getFormat().equalsIgnoreCase("XML"))||(hive.getFormat().equalsIgnoreCase("GEOJSON"))) {
    1.19  			int status_code = HttpServletResponse.SC_OK;
    1.20  			String answer = "";
    1.21  
    1.22 @@ -367,7 +370,14 @@
    1.23  			}
    1.24  
    1.25  			// write response to client
    1.26 -			response.setContentType("text/xml; charset=UTF-8");
    1.27 +			if(hive.getFormat().equalsIgnoreCase("XML"))
    1.28 +			{
    1.29 +				response.setContentType("text/xml; charset=UTF-8");
    1.30 +			}
    1.31 +			else //GeoJSON
    1.32 +			{
    1.33 +				response.setContentType("application/json; charset=UTF-8");
    1.34 +			}
    1.35  			response.setStatus(status_code);
    1.36  			if (status_code == HttpServletResponse.SC_OK) {
    1.37  				response.getWriter().append(answer);
    1.38 @@ -378,7 +388,8 @@
    1.39  				response.getWriter().append(ResponseMessages.getXMLFooter());
    1.40  			}
    1.41  
    1.42 -		} else { // HTML
    1.43 +		} 
    1.44 +		else { // HTML
    1.45  
    1.46  			appendHTML1a(out,"");
    1.47  
    1.48 @@ -556,6 +567,7 @@
    1.49  		out.println("	<option value=\"HTML\">HTML</option>");
    1.50  		out.println("	<option value=\"KML\">KML</option>");
    1.51  		out.println("	<option value=\"XML\">XML</option>");
    1.52 +		out.println("	<option value=\"GEOJSON\">GeoJSON</option>");
    1.53  		out.println("</select></center></td>");
    1.54  		out.println("</tr>");
    1.55  		out.println("<tr>");