Strabon
changeset 1241:08dfd00b8324
finalized timemap support
author | Konstantina Bereta <Konstantina.Bereta@di.uoa.gr> |
---|---|
date | Wed Jul 31 16:36:01 2013 +0300 (2013-07-31) |
parents | 89d7b54da9b1 |
children | 48d719bebfac |
files | endpoint/WebContent/query.jsp endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java |
line diff
1.1 --- a/endpoint/WebContent/query.jsp Mon Jul 29 23:13:43 2013 +0300 1.2 +++ b/endpoint/WebContent/query.jsp Wed Jul 31 16:36:01 2013 +0300 1.3 @@ -120,7 +120,7 @@ 1.4 } 1.5 1.6 if (request.getAttribute("pathToKML") != null) { 1.7 - if ("map_local".equals(request.getAttribute("handle")) || ("timemap_local".equals(request.getAttribute("handle")))) { 1.8 + if (request.getAttribute("handle").toString().contains("map")) { 1.9 %> 1.10 <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /> 1.11 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> 1.12 @@ -163,7 +163,8 @@ 1.13 function initialize() { 1.14 var myOptions = { 1.15 zoom: 11, 1.16 - //mapTypeId: google.maps.MapTypeId.ROADMAP 1.17 + mapTypeId: google.maps.MapTypeId.ROADMAP, 1.18 + zoomControl: true 1.19 }; 1.20 1.21 // get KML filename 1.22 @@ -171,12 +172,13 @@ 1.23 var map; 1.24 // create map 1.25 <%if(request.getAttribute("handle").toString().contains("timemap")){ %> 1.26 - map = tm.map; 1.27 + map = tm.getNativeMap(); 1.28 + map.setOptions(myOptions); 1.29 <%} else {%> 1.30 var map = new google.maps.Map(document.getElementById("map"), myOptions); 1.31 <%}%> 1.32 <% if (request.getAttribute("pathToKML") == null) {%> 1.33 - center at Brahames 1.34 + // center at Brahames 1.35 map.setCenter(new google.maps.LatLng(37.92253, 23.72275)); 1.36 <%}%> 1.37 1.38 @@ -253,11 +255,21 @@ 1.39 1.40 var tm; 1.41 $(function() { 1.42 + var myOptions = { 1.43 + zoom: 11, 1.44 + mapTypeId: google.maps.MapTypeId.ROADMAP, 1.45 + zoomControl: true, 1.46 + scrollwheel : true 1.47 + 1.48 + }; 1.49 + 1.50 + var map = new google.maps.Map(document.getElementById("map"), myOptions); 1.51 tm = TimeMap.init({ 1.52 - mapId: "map", // Id of map div element (required) 1.53 + // Id of map div element (required) 1.54 + mapId: "map", 1.55 timelineId: "timeline", // Id of timeline div element (required) 1.56 options: { 1.57 - eventIconPath: "../images/" 1.58 + eventIconPath: "images/" 1.59 }, 1.60 datasets: [ 1.61 { 1.62 @@ -287,8 +299,10 @@ 1.63 } 1.64 ] 1.65 }); 1.66 + 1.67 + 1.68 }); 1.69 - 1.70 + 1.71 1.72 </script> 1.73 1.74 @@ -502,8 +516,9 @@ 1.75 <div id="map"></div> 1.76 </div> 1.77 </div> 1.78 -<%}%> 1.79 +<%} else {%> 1.80 <div id="map"></div> 1.81 + <%} %> 1.82 <div id="divResultsEnd" style="height: 1px; width 1px"></div> 1.83 <div id="chart_div"></div> 1.84 </body>
2.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java Mon Jul 29 23:13:43 2013 +0300 2.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java Wed Jul 31 16:36:01 2013 +0300 2.3 @@ -115,12 +115,9 @@ 2.4 // get the name of this web application 2.5 appName = context.getContextPath().replace("/", ""); 2.6 2.7 - // fix the temporary directory for this web application 2.8 - tempDirectory = "js/timemap"; 2.9 + 2.10 2.11 - // get the absolute path of the temporary directory 2.12 - //basePath = context.getRealPath("/") + "/../ROOT/" + tempDirectory + "/"; 2.13 - basePath = context.getRealPath("/") + tempDirectory + "/"; 2.14 + 2.15 } 2.16 2.17 public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 2.18 @@ -290,17 +287,32 @@ 2.19 2.20 try{ 2.21 Date date = new Date(); 2.22 + 2.23 + // get the absolute path of the temporary directory 2.24 + if(!request.getParameter("handle").toString().contains("timemap")){ 2.25 + tempDirectory = appName + "-temp"; 2.26 + 2.27 + basePath = context.getRealPath("/") + "/../ROOT/" + tempDirectory + "/"; 2.28 + // fix the temporary directory for this web application 2.29 + 2.30 + FileUtils.forceMkdir(new File(basePath)); 2.31 2.32 - //FileUtils.forceMkdir(new File(basePath)); 2.33 + @SuppressWarnings("unchecked") 2.34 + Iterator<File> it = FileUtils.iterateFiles(new File(basePath), null, false); 2.35 + while(it.hasNext()){ 2.36 + File tbd = new File((it.next()).getAbsolutePath()); 2.37 + if (FileUtils.isFileOlder(new File(tbd.getAbsolutePath()), date.getTime())){ 2.38 + FileUtils.forceDelete(new File(tbd.getAbsolutePath())); 2.39 + } 2.40 + } 2.41 + } else{ //timemap case 2.42 + tempDirectory = "js/timemap"; 2.43 + basePath = context.getRealPath("/") + tempDirectory + "/"; 2.44 + // fix the temporary directory for this web application 2.45 + } 2.46 2.47 - @SuppressWarnings("unchecked") 2.48 - /* Iterator<File> it = FileUtils.iterateFiles(new File(basePath), null, false); 2.49 - while(it.hasNext()){ 2.50 - File tbd = new File((it.next()).getAbsolutePath()); 2.51 - if (FileUtils.isFileOlder(new File(tbd.getAbsolutePath()), date.getTime())){ 2.52 - FileUtils.forceDelete(new File(tbd.getAbsolutePath())); 2.53 - } 2.54 - }*/ 2.55 + 2.56 + // fix the temporary directory for this web application 2.57 2.58 // create temporary KML/KMZ file 2.59 File file = new File(basePath + tempKMLFile); 2.60 @@ -318,11 +330,14 @@ 2.61 strabonWrapper.query(query, format, fos); 2.62 fos.close(); 2.63 2.64 - /*request.setAttribute("pathToKML", 2.65 - request.getScheme() + "://" + 2.66 - request.getServerName() + ":" + request.getServerPort() + 2.67 - "/" + tempDirectory + "/" + tempKMLFile);*/ 2.68 - request.setAttribute("pathToKML", tempDirectory+"/"+ tempKMLFile); 2.69 + if(request.getParameter("handle").toString().contains("timemap")){ 2.70 + request.setAttribute("pathToKML", tempDirectory+"/"+ tempKMLFile); 2.71 + }else { 2.72 + request.setAttribute("pathToKML", 2.73 + request.getScheme() + "://" + 2.74 + request.getServerName() + ":" + request.getServerPort() + 2.75 + "/" + tempDirectory + "/" + tempKMLFile); 2.76 + } 2.77 2.78 } catch (MalformedQueryException e) { 2.79 logger.error("[StrabonEndpoint.QueryBean] Error during querying. {}", e.getMessage());
3.1 --- a/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Mon Jul 29 23:13:43 2013 +0300 3.2 +++ b/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Wed Jul 31 16:36:01 2013 +0300 3.3 @@ -25,6 +25,7 @@ 3.4 import org.openrdf.query.Binding; 3.5 import org.openrdf.query.BindingSet; 3.6 import org.openrdf.query.TupleQueryResultHandlerException; 3.7 +import org.openrdf.query.algebra.IsLiteral; 3.8 import org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT; 3.9 import org.openrdf.query.algebra.evaluation.util.JTSWrapper; 3.10 import org.openrdf.query.resultio.TupleQueryResultFormat; 3.11 @@ -196,7 +197,7 @@ 3.12 // write placemark tag 3.13 xmlWriter.startTag(PLACEMARK_TAG); 3.14 for (Binding binding : bindingSet) { 3.15 - 3.16 + 3.17 Literal literal = (Literal) binding.getValue(); 3.18 if(XMLGSDatatypeUtil.isCalendarDatatype(literal.getDatatype())){ 3.19 hasTimestamp = true;