# HG changeset patch # User Babis Nikolaou # Date 1411398944 -10800 # Node ID f602e11d476fabc324a7c1b6922d459cc82fe2d3 # Parent a232e330769333d599dca222cb2ffb2ad5a7f42b fixed a test that was using strdf:distance in ORDER BY clause with two arguments (expecting three arguments always) and de-activated evaluation of grounded expressions in SELECT queries in Java (see the respective #72 the reason I did so) diff -r a232e3307693 -r f602e11d476f evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Mon Sep 22 16:35:25 2014 +0300 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Mon Sep 22 18:15:44 2014 +0300 @@ -700,6 +700,14 @@ return poly; } + /** + * Think that this computation is done in meters and there is no way of doing it + * in degrees, except if one calculate the corresponding transformation, which + * depends on the spatial reference system used! + * + * A not so good approximation of meters for degrees: + * double meters = (degrees * 6378137 * Math.PI) / 180; + */ public static StrabonPolyhedron buffer(StrabonPolyhedron A, double B) throws Exception { return new StrabonPolyhedron(A.geometry.buffer(B), A.getGeometry().getSRID(), A.getGeometryDatatype()); } diff -r a232e3307693 -r f602e11d476f generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java Mon Sep 22 16:35:25 2014 +0300 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java Mon Sep 22 18:15:44 2014 +0300 @@ -562,22 +562,22 @@ // check required number of arguments checkArgs(left, right, third, 3); - // TODO implement computation of the buffer in meters + // TODO implement computation of the buffer in degrees // you'll get the type (degrees/meter) from the thirdResult, which // would be a URI. - if (OGCConstants.OGCmetre.equals(third.stringValue())) { - logger.info("[GeneraDBEvaluation] Computation of {} will be done in degrees.", function.getURI()); + if (OGCConstants.OGCdegree.equals(third.stringValue())) { + logger.info("[GeneraDBEvaluation] Computation of {} will be done in meters.", function.getURI()); } if(right instanceof LiteralImpl) { - LiteralImpl radius = (LiteralImpl) right; - return StrabonPolyhedron.buffer(leftArg, radius.doubleValue()); + LiteralImpl meters = (LiteralImpl) right; + return StrabonPolyhedron.buffer(leftArg, meters.doubleValue()); } else if (right instanceof RdbmsLiteral) { - RdbmsLiteral radius = (RdbmsLiteral) right; - return StrabonPolyhedron.buffer(leftArg, radius.doubleValue()); + RdbmsLiteral meters = (RdbmsLiteral) right; + return StrabonPolyhedron.buffer(leftArg, meters.doubleValue()); } } else if(function.getURI().equals(GeoConstants.stSPARQLtransform)) diff -r a232e3307693 -r f602e11d476f generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java Mon Sep 22 16:35:25 2014 +0300 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java Mon Sep 22 18:15:44 2014 +0300 @@ -183,16 +183,15 @@ } @Override - public void meet(Distinct node) - throws RuntimeException - { + public void meet(Distinct node) throws RuntimeException + { super.meet(node); if (node.getArg() instanceof GeneralDBSelectQuery) { GeneralDBSelectQuery query = (GeneralDBSelectQuery)node.getArg(); query.setDistinct(true); node.replaceWith(query); } - } + } @Override public void meet(Union node) throws RuntimeException @@ -238,9 +237,8 @@ } @Override - public void meet(Join node) - throws RuntimeException - { + public void meet(Join node) throws RuntimeException + { super.meet(node); TupleExpr l = node.getLeftArg(); TupleExpr r = node.getRightArg(); @@ -261,12 +259,11 @@ * This change was made before altering the spatial joins operation */ reference = left; - } + } @Override - public void meet(LeftJoin node) - throws RuntimeException - { + public void meet(LeftJoin node) throws RuntimeException + { super.meet(node); TupleExpr l = node.getLeftArg(); TupleExpr r = node.getRightArg(); @@ -297,7 +294,7 @@ } node.replaceWith(left); reference = left; - } + } @Override public void meet(StatementPattern sp) { @@ -484,10 +481,8 @@ } @Override - public void meet(Filter node) - throws RuntimeException - { - + public void meet(Filter node) throws RuntimeException + { /** * XXX 21/09/2011 addition for spatial joins * Ekmetalleyomai to gegonos oti exw 'fytepsei' sta embolima filters twn joins mia statement pattern me to onoma -dummy- diff -r a232e3307693 -r f602e11d476f resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java --- a/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Mon Sep 22 16:35:25 2014 +0300 +++ b/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Mon Sep 22 18:15:44 2014 +0300 @@ -22,8 +22,6 @@ import org.openrdf.model.BNode; import org.openrdf.model.Literal; import org.openrdf.model.Value; -import org.openrdf.model.impl.LiteralImpl; -import org.openrdf.model.impl.URIImpl; import org.openrdf.query.Binding; import org.openrdf.query.BindingSet; import org.openrdf.query.TupleQueryResultHandlerException; diff -r a232e3307693 -r f602e11d476f testsuite/src/test/resources/bugs/SpatialFunctionInOrderBy/Distance_stRDF.rq --- a/testsuite/src/test/resources/bugs/SpatialFunctionInOrderBy/Distance_stRDF.rq Mon Sep 22 16:35:25 2014 +0300 +++ b/testsuite/src/test/resources/bugs/SpatialFunctionInOrderBy/Distance_stRDF.rq Mon Sep 22 18:15:44 2014 +0300 @@ -9,5 +9,5 @@ FILTER(str(?x) < str(?y)) } -ORDER BY DESC(strdf:distance(?g1,?g2)) +ORDER BY DESC(strdf:distance(?g1, ?g2, ogc:degree)) LIMIT 2 \ No newline at end of file