Strabon
changeset 319:7225b65b690f
code beautification in Strabon.java
author | Babis Nikolaou <charnik@di.uoa.gr> |
---|---|
date | Thu Jun 21 20:51:34 2012 +0300 (2012-06-21) |
parents | 48d640f6f1db |
children | e36e63a58d63 |
files | runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java |
line diff
1.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Thu Jun 21 20:50:49 2012 +0300 1.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Thu Jun 21 20:51:34 2012 +0300 1.3 @@ -50,6 +50,7 @@ 1.4 import org.openrdf.query.Update; 1.5 import org.openrdf.query.UpdateExecutionException; 1.6 import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron; 1.7 +import org.openrdf.query.resultio.sparqlxml.stSPARQLResultsKMLWriter; 1.8 import org.openrdf.query.resultio.sparqlxml.stSPARQLResultsXMLWriter; 1.9 import org.openrdf.repository.RepositoryException; 1.10 import org.openrdf.repository.sail.SailRepository; 1.11 @@ -172,22 +173,22 @@ 1.12 } 1.13 1.14 public Object query(String queryString) 1.15 - throws MalformedQueryException, QueryEvaluationException, IOException, TupleQueryResultHandlerException 1.16 - { 1.17 + throws MalformedQueryException, QueryEvaluationException, IOException, TupleQueryResultHandlerException 1.18 + { 1.19 return query(queryString, "", this.getSailRepoConnection()); 1.20 - } 1.21 + } 1.22 1.23 public Object query(String queryString, String resultsFormat) 1.24 - throws MalformedQueryException , QueryEvaluationException, IOException, TupleQueryResultHandlerException 1.25 - { 1.26 + throws MalformedQueryException , QueryEvaluationException, IOException, TupleQueryResultHandlerException 1.27 + { 1.28 return query(queryString, resultsFormat, this.getSailRepoConnection()); 1.29 - } 1.30 + } 1.31 1.32 public Object query(String queryString, SailRepositoryConnection con) 1.33 - throws MalformedQueryException, QueryEvaluationException, IOException, TupleQueryResultHandlerException 1.34 - { 1.35 + throws MalformedQueryException, QueryEvaluationException, IOException, TupleQueryResultHandlerException 1.36 + { 1.37 return query(queryString, "", con); 1.38 - } 1.39 + } 1.40 1.41 public Object queryBindings(String queryString, SailRepositoryConnection con) throws QueryEvaluationException, MalformedQueryException 1.42 { 1.43 @@ -203,8 +204,8 @@ 1.44 } 1.45 1.46 public Object query(String queryString, String resultsFormat, SailRepositoryConnection con) 1.47 - throws MalformedQueryException, QueryEvaluationException, IOException, TupleQueryResultHandlerException 1.48 - { 1.49 + throws MalformedQueryException, QueryEvaluationException, IOException, TupleQueryResultHandlerException 1.50 + { 1.51 logger.info("[Strabon.query] Executing query: " + queryString); 1.52 TupleQuery tupleQuery = null; 1.53 try { 1.54 @@ -436,6 +437,15 @@ 1.55 1.56 } 1.57 else if ( resultsFormat.equalsIgnoreCase("KML") || resultsFormat.equalsIgnoreCase("KMZ")) { 1.58 + if (logger.isDebugEnabled()) { 1.59 + logger.debug("Serializing results (KML/KMZ)"); 1.60 + } 1.61 + tupleQuery.evaluate(new stSPARQLResultsKMLWriter(retStream)); 1.62 + if (true) { 1.63 + System.out.println(retStream); 1.64 + return retStream.toString(); 1.65 + } 1.66 + 1.67 //GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(null); 1.68 GeometryFactory gf = new GeometryFactory(new PrecisionModel(),4326); 1.69 WKTReader reader = new WKTReader(gf); 1.70 @@ -776,13 +786,13 @@ 1.71 } catch (IOException e) { 1.72 logger.error("[Strabon.query]", e); 1.73 } 1.74 - 1.75 + 1.76 // Print results. 1.77 //System.out.println(retStream.toString()); 1.78 1.79 //return ret; 1.80 return retStream.toString(); 1.81 - } 1.82 + } 1.83 1.84 public void update(String updateString, SailRepositoryConnection con) throws MalformedQueryException 1.85 {